diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6785041..b3f9d31 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,3 +10,6 @@ - [ ] Have you added an integration test for the changes? - [ ] Have you built the gem locally and made queries against it successfully? +- [ ] Did you update the changelog? +- [ ] Did you bump the package version? +- [ ] For breaking changes, did you plan for the release of the new SDK versions and deploy the API to production? diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f1b90b..849d492 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,5 +26,5 @@ jobs: - name: Run RSpec env: - PATCH_RUBY_API_KEY: ${{ secrets.SANDBOX_API_KEY }} + SANDBOX_API_KEY: ${{ secrets.SANDBOX_API_KEY }} run: bundle exec rspec diff --git a/.rubocop.yml b/.rubocop.yml index df46058..d32b2b1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -113,7 +113,7 @@ Layout/SpaceInsideParens: # EnforcedStyle: single_quotes # Detect hard tabs, no hard tabs. -Layout/Tab: +Layout/IndentationStyle: Enabled: true # Blank lines should not have any spaces. diff --git a/CHANGELOG.md b/CHANGELOG.md index 53b47b7..bb8e2df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.3] - 2020-09-28 + +### Added + +- `patch_fee_cents_usd` field to `orders` + ## [1.2.2] - 2020-09-18 ### Added diff --git a/Gemfile.lock b/Gemfile.lock index 56dfdcb..1e8c94d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.2.2) + patch_ruby (1.2.3) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9162086 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +SHELL = /bin/bash + +build: + rubocop -a && \ + bundle install + +test: + bundle exec rspec + +.PHONY: build test \ No newline at end of file diff --git a/README.md b/README.md index 56dcfcb..e258cc4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ require 'patch_ruby' Patch.configure do |config| # Configure the Patch gem with your API key here - config.access_token = ENV['PATCH_RUBY_API_KEY'] + config.access_token = ENV['SANDBOX_API_KEY'] end ``` @@ -161,7 +161,7 @@ $ bundle install Set up required environment variables: ``` -$ export PATCH_RUBY_API_KEY= +$ export SANDBOX_API_KEY= ``` Run tests: diff --git a/lib/patch_ruby/models/order.rb b/lib/patch_ruby/models/order.rb index 8f74da2..55b5bb1 100644 --- a/lib/patch_ruby/models/order.rb +++ b/lib/patch_ruby/models/order.rb @@ -26,6 +26,8 @@ class Order attr_accessor :price_cents_usd + attr_accessor :patch_fee_cents_usd + attr_accessor :allocations attr_accessor :metadata @@ -61,6 +63,7 @@ def self.attribute_map :'state' => :'state', :'allocation_state' => :'allocation_state', :'price_cents_usd' => :'price_cents_usd', + :'patch_fee_cents_usd' => :'patch_fee_cents_usd', :'allocations' => :'allocations', :'metadata' => :'metadata' } @@ -75,6 +78,7 @@ def self.openapi_types :'state' => :'String', :'allocation_state' => :'String', :'price_cents_usd' => :'String', + :'patch_fee_cents_usd' => :'String', :'allocations' => :'Array', :'metadata' => :'Object' } @@ -130,6 +134,10 @@ def initialize(attributes = {}) self.price_cents_usd = attributes[:'price_cents_usd'] end + if attributes.key?(:'patch_fee_cents_usd') + self.patch_fee_cents_usd = attributes[:'patch_fee_cents_usd'] + end + if attributes.key?(:'allocations') if (value = attributes[:'allocations']).is_a?(Array) self.allocations = value @@ -252,6 +260,7 @@ def ==(o) state == o.state && allocation_state == o.allocation_state && price_cents_usd == o.price_cents_usd && + patch_fee_cents_usd == o.patch_fee_cents_usd && allocations == o.allocations && metadata == o.metadata end @@ -265,7 +274,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, mass_g, production, state, allocation_state, price_cents_usd, allocations, metadata].hash + [id, mass_g, production, state, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, metadata].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/photo.rb b/lib/patch_ruby/models/photo.rb index 9028c4b..fb9671b 100644 --- a/lib/patch_ruby/models/photo.rb +++ b/lib/patch_ruby/models/photo.rb @@ -65,12 +65,17 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new + if @url.nil? + invalid_properties.push('invalid value for "url", url cannot be nil.') + end + invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? + return false if @url.nil? true end diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index d0708e9..d073ba8 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.2.2' + VERSION = '1.2.3' end diff --git a/spec/constants.rb b/spec/constants.rb new file mode 100644 index 0000000..4e8177e --- /dev/null +++ b/spec/constants.rb @@ -0,0 +1,3 @@ +module Constants + BIOMASS_TEST_PROJECT_ID = "pro_test_c3a9feba769fc7a8806377266ca9ff6a" +end diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb index 523d0c1..caf2b9c 100644 --- a/spec/integration/estimates_spec.rb +++ b/spec/integration/estimates_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'Estimates Integration' do before do Patch.configure do |config| - config.access_token = ENV['PATCH_RUBY_API_KEY'] + config.access_token = ENV['SANDBOX_API_KEY'] end end diff --git a/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index 2c44fef..43a489c 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'Orders Integration' do before do Patch.configure do |config| - config.access_token = ENV['PATCH_RUBY_API_KEY'] + config.access_token = ENV['SANDBOX_API_KEY'] end end @@ -26,14 +26,25 @@ end it 'supports create with a project-id' do - retrieve_projects_response = Patch::Project.retrieve_projects(page: 1) - project_id = retrieve_projects_response.data.first.id + retrieve_project_response = Patch::Project.retrieve_project( + Constants::BIOMASS_TEST_PROJECT_ID + ) - create_order_response = Patch::Order.create_order(mass_g: 100, project_id: project_id) + project_id = retrieve_project_response.data.id + average_price_per_tonne_cents_usd = retrieve_project_response.data.average_price_per_tonne_cents_usd + + order_mass_g = 100_000 + tonne_per_gram = 1_000_000 + + expected_price = (average_price_per_tonne_cents_usd.to_f / tonne_per_gram) * order_mass_g + + create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id) expect(create_order_response.success).to eq true expect(create_order_response.data.id).not_to be_nil - expect(create_order_response.data.mass_g).to eq(100) + expect(create_order_response.data.mass_g).to eq(order_mass_g) + expect(create_order_response.data.price_cents_usd.to_i).to eq(expected_price) + expect(create_order_response.data.patch_fee_cents_usd).not_to be_empty end it 'supports create with metadata' do diff --git a/spec/integration/preferences_spec.rb b/spec/integration/preferences_spec.rb index 8aba7ef..9307033 100644 --- a/spec/integration/preferences_spec.rb +++ b/spec/integration/preferences_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'Preferences Integration' do before do Patch.configure do |config| - config.access_token = ENV['PATCH_RUBY_API_KEY'] + config.access_token = ENV['SANDBOX_API_KEY'] end end diff --git a/spec/integration/projects_spec.rb b/spec/integration/projects_spec.rb index e623b1d..899ae2a 100644 --- a/spec/integration/projects_spec.rb +++ b/spec/integration/projects_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Projects Integration' do Patch.configure do |config| - config.access_token = ENV['PATCH_RUBY_API_KEY'] + config.access_token = ENV['SANDBOX_API_KEY'] end it 'supports retrieve and list' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6c652b6..2ed41b9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,7 @@ # load the gem require 'patch_ruby' +require 'constants' # The following was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.