patch_ruby 1.0.0.pre → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -0
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +13 -12
  5. data/Makefile +10 -0
  6. data/README.md +144 -15
  7. data/lib/patch_ruby.rb +2 -0
  8. data/lib/patch_ruby/models/allocation.rb +15 -0
  9. data/lib/patch_ruby/models/create_mass_estimate_request.rb +41 -4
  10. data/lib/patch_ruby/models/create_order_request.rb +68 -7
  11. data/lib/patch_ruby/models/estimate.rb +15 -0
  12. data/lib/patch_ruby/models/order.rb +85 -4
  13. data/lib/patch_ruby/models/photo.rb +216 -0
  14. data/lib/patch_ruby/models/preference.rb +15 -0
  15. data/lib/patch_ruby/models/project.rb +119 -25
  16. data/lib/patch_ruby/models/standard.rb +244 -0
  17. data/lib/patch_ruby/version.rb +1 -1
  18. data/spec/api/estimates_api_spec.rb +6 -7
  19. data/spec/api/orders_api_spec.rb +10 -11
  20. data/spec/api/preferences_api_spec.rb +8 -9
  21. data/spec/api/projects_api_spec.rb +4 -5
  22. data/spec/api_client_spec.rb +12 -33
  23. data/spec/constants.rb +3 -0
  24. data/spec/integration/estimates_spec.rb +30 -23
  25. data/spec/integration/orders_spec.rb +85 -38
  26. data/spec/integration/preferences_spec.rb +24 -30
  27. data/spec/integration/projects_spec.rb +38 -27
  28. data/spec/models/allocation_spec.rb +0 -1
  29. data/spec/models/create_mass_estimate_request_spec.rb +0 -1
  30. data/spec/models/create_order_request_spec.rb +0 -1
  31. data/spec/models/create_preference_request_spec.rb +0 -1
  32. data/spec/models/error_response_spec.rb +0 -1
  33. data/spec/models/estimate_list_response_spec.rb +0 -1
  34. data/spec/models/estimate_response_spec.rb +0 -1
  35. data/spec/models/estimate_spec.rb +0 -1
  36. data/spec/models/meta_index_object_spec.rb +0 -1
  37. data/spec/models/order_list_response_spec.rb +0 -1
  38. data/spec/models/order_response_spec.rb +0 -1
  39. data/spec/models/order_spec.rb +0 -1
  40. data/spec/models/preference_list_response_spec.rb +0 -1
  41. data/spec/models/preference_response_spec.rb +0 -1
  42. data/spec/models/preference_spec.rb +0 -1
  43. data/spec/models/project_list_response_spec.rb +0 -1
  44. data/spec/models/project_response_spec.rb +0 -1
  45. data/spec/models/project_spec.rb +0 -1
  46. data/spec/spec_helper.rb +1 -11
  47. metadata +26 -30
  48. data/spec/fixtures/vcr_cassettes/estimate_orders.yml +0 -276
  49. data/spec/fixtures/vcr_cassettes/estimates.yml +0 -211
  50. data/spec/fixtures/vcr_cassettes/orders.yml +0 -229
  51. data/spec/fixtures/vcr_cassettes/preferences.yml +0 -352
  52. data/spec/fixtures/vcr_cassettes/projects.yml +0 -143
@@ -11,5 +11,5 @@ OpenAPI Generator version: 4.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.0.0.pre'
14
+ VERSION = '1.2.4'
15
15
  end
@@ -34,8 +34,8 @@ describe 'EstimatesApi' do
34
34
 
35
35
  # unit tests for create_mass_estimate
36
36
  # Create an estimate based on mass of CO2
37
- # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate.
38
- # @param create_mass_estimate_request
37
+ # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate.
38
+ # @param create_mass_estimate_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [EstimateResponse]
41
41
  describe 'create_mass_estimate test' do
@@ -46,8 +46,8 @@ describe 'EstimatesApi' do
46
46
 
47
47
  # unit tests for retrieve_estimate
48
48
  # Retrieves an estimate
49
- # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
- # @param id
49
+ # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [EstimateResponse]
53
53
  describe 'retrieve_estimate test' do
@@ -58,14 +58,13 @@ describe 'EstimatesApi' do
58
58
 
59
59
  # unit tests for retrieve_estimates
60
60
  # Retrieves a list of estimates
61
- # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
61
+ # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
62
62
  # @param [Hash] opts the optional parameters
63
- # @option opts [Integer] :page
63
+ # @option opts [Integer] :page
64
64
  # @return [EstimateListResponse]
65
65
  describe 'retrieve_estimates test' do
66
66
  it 'should work' do
67
67
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
68
  end
69
69
  end
70
-
71
70
  end
@@ -34,8 +34,8 @@ describe 'OrdersApi' do
34
34
 
35
35
  # unit tests for cancel_order
36
36
  # Cancel an order
37
- # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
38
- # @param id
37
+ # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [OrderResponse]
41
41
  describe 'cancel_order test' do
@@ -46,8 +46,8 @@ describe 'OrdersApi' do
46
46
 
47
47
  # unit tests for create_order
48
48
  # Creates an order
49
- # Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
50
- # @param create_order_request
49
+ # Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
50
+ # @param create_order_request
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [OrderResponse]
53
53
  describe 'create_order test' do
@@ -58,8 +58,8 @@ describe 'OrdersApi' do
58
58
 
59
59
  # unit tests for place_order
60
60
  # Place an order
61
- # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
62
- # @param id
61
+ # Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [OrderResponse]
65
65
  describe 'place_order test' do
@@ -70,8 +70,8 @@ describe 'OrdersApi' do
70
70
 
71
71
  # unit tests for retrieve_order
72
72
  # Retrieves an order
73
- # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
- # @param id
73
+ # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
+ # @param id
75
75
  # @param [Hash] opts the optional parameters
76
76
  # @return [OrderResponse]
77
77
  describe 'retrieve_order test' do
@@ -82,14 +82,13 @@ describe 'OrdersApi' do
82
82
 
83
83
  # unit tests for retrieve_orders
84
84
  # Retrieves a list of orders
85
- # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
85
+ # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
86
86
  # @param [Hash] opts the optional parameters
87
- # @option opts [Integer] :page
87
+ # @option opts [Integer] :page
88
88
  # @return [OrderListResponse]
89
89
  describe 'retrieve_orders test' do
90
90
  it 'should work' do
91
91
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
92
92
  end
93
93
  end
94
-
95
94
  end
@@ -34,8 +34,8 @@ describe 'PreferencesApi' do
34
34
 
35
35
  # unit tests for create_preference
36
36
  # creates a project preference
37
- # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to.
38
- # @param create_preference_request
37
+ # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to.
38
+ # @param create_preference_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [PreferenceResponse]
41
41
  describe 'create_preference test' do
@@ -46,8 +46,8 @@ describe 'PreferencesApi' do
46
46
 
47
47
  # unit tests for delete_preference
48
48
  # Deletes an organization's preference for a project
49
- # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
- # @param id
49
+ # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [PreferenceResponse]
53
53
  describe 'delete_preference test' do
@@ -58,8 +58,8 @@ describe 'PreferencesApi' do
58
58
 
59
59
  # unit tests for retrieve_preference
60
60
  # Retrieve the preference
61
- # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
- # @param id
61
+ # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [PreferenceResponse]
65
65
  describe 'retrieve_preference test' do
@@ -70,14 +70,13 @@ describe 'PreferencesApi' do
70
70
 
71
71
  # unit tests for retrieve_preferences
72
72
  # Retrieves a list of preferences
73
- # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
73
+ # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
74
74
  # @param [Hash] opts the optional parameters
75
- # @option opts [Integer] :page
75
+ # @option opts [Integer] :page
76
76
  # @return [PreferenceListResponse]
77
77
  describe 'retrieve_preferences test' do
78
78
  it 'should work' do
79
79
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
80
80
  end
81
81
  end
82
-
83
82
  end
@@ -34,8 +34,8 @@ describe 'ProjectsApi' do
34
34
 
35
35
  # unit tests for retrieve_project
36
36
  # Retrieves a project
37
- # Retrieves a project available on Patch's platform.
38
- # @param id
37
+ # Retrieves a project available on Patch's platform.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [ProjectResponse]
41
41
  describe 'retrieve_project test' do
@@ -46,14 +46,13 @@ describe 'ProjectsApi' do
46
46
 
47
47
  # unit tests for retrieve_projects
48
48
  # Retrieves a list of projects
49
- # Retrieves a list of projects available for purchase on Patch's platform.
49
+ # Retrieves a list of projects available for purchase on Patch's platform.
50
50
  # @param [Hash] opts the optional parameters
51
- # @option opts [Integer] :page
51
+ # @option opts [Integer] :page
52
52
  # @return [ProjectListResponse]
53
53
  describe 'retrieve_projects test' do
54
54
  it 'should work' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -10,43 +10,22 @@ OpenAPI Generator version: 4.3.1
10
10
 
11
11
  =end
12
12
 
13
- require 'spec_helper'
14
-
15
13
  describe Patch::ApiClient do
16
14
  context 'initialization' do
17
- context 'URL stuff' do
18
- context 'host' do
19
- it 'removes http from host' do
20
- Patch.configure { |c| c.host = 'http://example.com' }
21
- expect(Patch::Configuration.default.host).to eq('example.com')
22
- end
23
-
24
- it 'removes https from host' do
25
- Patch.configure { |c| c.host = 'https://wookiee.com' }
26
- expect(Patch::ApiClient.default.config.host).to eq('wookiee.com')
27
- end
28
-
29
- it 'removes trailing path from host' do
30
- Patch.configure { |c| c.host = 'hobo.com/v4' }
31
- expect(Patch::Configuration.default.host).to eq('hobo.com')
32
- end
15
+ context 'base_path' do
16
+ it "prepends a slash to base_path" do
17
+ Patch.configure { |c| c.base_path = 'v4/dog' }
18
+ expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
19
+ end
20
+
21
+ it "doesn't prepend a slash if one is already there" do
22
+ Patch.configure { |c| c.base_path = '/v4/dog' }
23
+ expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
33
24
  end
34
25
 
35
- context 'base_path' do
36
- it "prepends a slash to base_path" do
37
- Patch.configure { |c| c.base_path = 'v4/dog' }
38
- expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
39
- end
40
-
41
- it "doesn't prepend a slash if one is already there" do
42
- Patch.configure { |c| c.base_path = '/v4/dog' }
43
- expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
44
- end
45
-
46
- it "ends up as a blank string if nil" do
47
- Patch.configure { |c| c.base_path = nil }
48
- expect(Patch::Configuration.default.base_path).to eq('')
49
- end
26
+ it "ends up as a blank string if nil" do
27
+ Patch.configure { |c| c.base_path = nil }
28
+ expect(Patch::Configuration.default.base_path).to eq('')
50
29
  end
51
30
  end
52
31
  end
@@ -0,0 +1,3 @@
1
+ module Constants
2
+ BIOMASS_TEST_PROJECT_ID = "pro_test_c3a9feba769fc7a8806377266ca9ff6a"
3
+ end
@@ -1,31 +1,38 @@
1
- require 'spec_helper'
2
-
3
1
  RSpec.describe 'Estimates Integration' do
4
- it "supports create, retrieve and list" do
5
- VCR.use_cassette('estimates') do
6
- # Configure the Patch gem
7
- Patch.configure do |config|
8
- config.access_token = ENV['PATCH_RUBY_API_KEY']
9
- config.host = ENV['PATCH_RUBY_HOST']
10
- end
11
-
12
- create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
13
- estimate_id = create_estimate_response.data.id
2
+ before do
3
+ Patch.configure do |config|
4
+ config.access_token = ENV['SANDBOX_API_KEY']
5
+ end
6
+ end
14
7
 
15
- retrieve_estimate_response = Patch::Estimate.retrieve_estimate(estimate_id)
16
- expect(retrieve_estimate_response.data.id).to eq estimate_id
8
+ it 'supports create, retrieve and list' do
9
+ create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
10
+ estimate_id = create_estimate_response.data.id
17
11
 
18
- page_limit = 1
19
- next_page = 1
20
- estimates = []
12
+ retrieve_estimate_response = Patch::Estimate.retrieve_estimate(estimate_id)
13
+ expect(retrieve_estimate_response.data.id).to eq estimate_id
21
14
 
22
- while !next_page.nil? && next_page <= page_limit
23
- retrieve_estimates_response = Patch::Estimate.retrieve_estimates(page: next_page)
24
- next_page = retrieve_estimates_response.meta.next_page
25
- estimates += retrieve_estimates_response.data
26
- end
15
+ page_limit = 1
16
+ next_page = 1
17
+ estimates = []
27
18
 
28
- expect(estimates.length).not_to be_zero
19
+ while !next_page.nil? && next_page <= page_limit
20
+ retrieve_estimates_response = Patch::Estimate.retrieve_estimates(page: next_page)
21
+ next_page = retrieve_estimates_response.meta.next_page
22
+ estimates += retrieve_estimates_response.data
29
23
  end
24
+
25
+ expect(estimates.length).not_to be_zero
26
+ end
27
+
28
+ it 'supports create with a project-id' do
29
+ retrieve_projects_response = Patch::Project.retrieve_projects(page: 1)
30
+ project_id = retrieve_projects_response.data.first.id
31
+ create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100, project_id: project_id)
32
+ estimate_id = create_estimate_response.data.id
33
+
34
+ expect(create_estimate_response.success).to eq true
35
+ expect(create_estimate_response.data.order.id).not_to be_nil
36
+ expect(create_estimate_response.data.order.mass_g).to eq(100)
30
37
  end
31
38
  end
@@ -1,53 +1,100 @@
1
- require 'spec_helper'
2
-
3
1
  RSpec.describe 'Orders Integration' do
4
- it "supports create, place, cancel, retrieve and list" do
5
- VCR.use_cassette('orders') do
6
- # Configure the Patch gem
7
- Patch.configure do |config|
8
- config.access_token = ENV['PATCH_RUBY_API_KEY']
9
- config.host = ENV['PATCH_RUBY_HOST']
10
- end
2
+ before do
3
+ Patch.configure do |config|
4
+ config.access_token = ENV['SANDBOX_API_KEY']
5
+ end
6
+ end
11
7
 
12
- create_order_response = Patch::Order.create_order(mass_g: 100)
13
- order_id = create_order_response.data.id
8
+ it 'supports create, place, cancel, retrieve and list' do
9
+ create_order_response = Patch::Order.create_order(mass_g: 100)
10
+ order_id = create_order_response.data.id
14
11
 
15
- retrieve_order_response = Patch::Order.retrieve_order(order_id)
16
- expect(retrieve_order_response.data.id).to eq order_id
12
+ retrieve_order_response = Patch::Order.retrieve_order(order_id)
13
+ expect(retrieve_order_response.data.id).to eq order_id
17
14
 
18
- # place_order_response = Patch::Order.place_order(order_id)
19
- # expect(place_order_response.data.state).to eq 'placed'
15
+ page_limit = 1
16
+ next_page = 1
17
+ orders = []
20
18
 
21
- # place_order_response = Patch::Order.cancel_order(order_id)
22
- # expect(place_order_response.data.state).to eq 'cancelled'
19
+ while !next_page.nil? && next_page <= page_limit
20
+ retrieve_orders_response = Patch::Order.retrieve_orders(page: next_page)
21
+ next_page = retrieve_orders_response.meta.next_page
22
+ orders += retrieve_orders_response.data
23
+ end
23
24
 
24
- page_limit = 1
25
- next_page = 1
26
- orders = []
25
+ expect(orders.length).not_to be_zero
26
+ end
27
27
 
28
- while !next_page.nil? && next_page <= page_limit
29
- retrieve_orders_response = Patch::Order.retrieve_orders(page: next_page)
30
- next_page = retrieve_orders_response.meta.next_page
31
- orders += retrieve_orders_response.data
32
- end
28
+ it 'supports create with a project-id' do
29
+ retrieve_project_response = Patch::Project.retrieve_project(
30
+ Constants::BIOMASS_TEST_PROJECT_ID
31
+ )
33
32
 
34
- expect(orders.length).not_to be_zero
35
- end
33
+ project_id = retrieve_project_response.data.id
34
+ average_price_per_tonne_cents_usd = retrieve_project_response.data.average_price_per_tonne_cents_usd
35
+
36
+ order_mass_g = 100_000
37
+ tonne_per_gram = 1_000_000
38
+
39
+ expected_price = (average_price_per_tonne_cents_usd.to_f / tonne_per_gram) * order_mass_g
40
+
41
+ create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id)
42
+
43
+ expect(create_order_response.success).to eq true
44
+ expect(create_order_response.data.id).not_to be_nil
45
+ expect(create_order_response.data.mass_g).to eq(order_mass_g)
46
+ expect(create_order_response.data.price_cents_usd.to_i).to eq(expected_price)
47
+ expect(create_order_response.data.patch_fee_cents_usd).not_to be_empty
36
48
  end
37
49
 
38
- it "supports place and cancel for order created via an estimate" do
39
- VCR.use_cassette('estimate_orders') do
40
- create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
41
- order_to_place_id = create_estimate_to_place_response.data.order.id
50
+ it 'supports create with a total price' do
51
+ retrieve_project_response = Patch::Project.retrieve_project(
52
+ Constants::BIOMASS_TEST_PROJECT_ID
53
+ )
42
54
 
43
- place_order_response = Patch::Order.place_order(order_to_place_id)
44
- expect(place_order_response.data.state).to eq 'placed'
55
+ project_id = retrieve_project_response.data.id
56
+ total_price_cents_usd = 5_00
45
57
 
46
- create_estimate_to_cancel_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
47
- order_to_cancel_id = create_estimate_to_cancel_response.data.order.id
58
+ create_order_response = Patch::Order.create_order(
59
+ total_price_cents_usd: total_price_cents_usd,
60
+ project_id: project_id
61
+ )
48
62
 
49
- cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id)
50
- expect(cancel_order_response.data.state).to eq 'cancelled'
51
- end
63
+ expect(create_order_response.success).to eq true
64
+
65
+ order = create_order_response.data
66
+
67
+ expect(order.id).not_to be_nil
68
+ expect(order.mass_g).to eq(5_000_000)
69
+ expect(order.price_cents_usd.to_i).to eq(500)
70
+ expect(order.patch_fee_cents_usd).not_to be_empty
71
+ expect(
72
+ order.price_cents_usd.to_i + order.patch_fee_cents_usd.to_i
73
+ ).to eq(total_price_cents_usd)
74
+ end
75
+
76
+ it 'supports create with metadata' do
77
+ metadata = { user: 'john doe' }
78
+
79
+ create_order_response = Patch::Order.create_order(mass_g: 100, metadata: metadata)
80
+
81
+ expect(create_order_response.success).to eq true
82
+ expect(create_order_response.data.id).not_to be_nil
83
+ expect(create_order_response.data.mass_g).to eq(100)
84
+ expect(create_order_response.data.metadata).to eq(metadata)
85
+ end
86
+
87
+ it 'supports place and cancel for orders created via an estimate' do
88
+ create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
89
+ order_to_place_id = create_estimate_to_place_response.data.order.id
90
+
91
+ place_order_response = Patch::Order.place_order(order_to_place_id)
92
+ expect(place_order_response.data.state).to eq 'placed'
93
+
94
+ create_estimate_to_cancel_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
95
+ order_to_cancel_id = create_estimate_to_cancel_response.data.order.id
96
+
97
+ cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id)
98
+ expect(cancel_order_response.data.state).to eq 'cancelled'
52
99
  end
53
100
  end
@@ -1,40 +1,34 @@
1
- require 'spec_helper'
2
-
3
1
  RSpec.describe 'Preferences Integration' do
4
- it "supports create, delete, retrieve and list" do
5
- VCR.use_cassette('preferences') do
6
- # Configure the Patch gem
7
- Patch.configure do |config|
8
- config.access_token = ENV['PATCH_RUBY_API_KEY']
9
- config.host = ENV['PATCH_RUBY_HOST']
10
- end
2
+ before do
3
+ Patch.configure do |config|
4
+ config.access_token = ENV['SANDBOX_API_KEY']
5
+ end
6
+ end
11
7
 
12
- retrieve_projects_response = Patch::Project.retrieve_projects
13
- expect(retrieve_projects_response.data.length).not_to be_zero
14
- project_id = retrieve_projects_response.data.first.id
8
+ it 'supports create, delete, retrieve and list' do
9
+ retrieve_projects_response = Patch::Project.retrieve_projects
10
+ expect(retrieve_projects_response.data.length).not_to be_zero
11
+ project_id = retrieve_projects_response.data.first.id
15
12
 
16
- create_preference_response = Patch::Preference.create_preference(project_id: project_id)
17
- preference_id = create_preference_response.data.id
13
+ create_preference_response = Patch::Preference.create_preference(project_id: project_id)
14
+ preference_id = create_preference_response.data.id
18
15
 
19
- retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
20
- expect(retrieve_preference_response.data.id).to eq preference_id
16
+ retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
17
+ expect(retrieve_preference_response.data.id).to eq preference_id
21
18
 
22
- # START receive_preferences
23
- page_limit = 1
24
- next_page = 1
25
- preferences = []
19
+ page_limit = 1
20
+ next_page = 1
21
+ preferences = []
26
22
 
27
- while !next_page.nil? && next_page <= page_limit
28
- retrieve_preferences_response = Patch::Preference.retrieve_preferences(page: next_page)
29
- next_page = retrieve_preferences_response.meta.next_page
30
- preferences += retrieve_preferences_response.data
31
- end
23
+ while !next_page.nil? && next_page <= page_limit
24
+ retrieve_preferences_response = Patch::Preference.retrieve_preferences(page: next_page)
25
+ next_page = retrieve_preferences_response.meta.next_page
26
+ preferences += retrieve_preferences_response.data
27
+ end
32
28
 
33
- expect(preferences.length).not_to be_zero
34
- # END receive_preferences
29
+ expect(preferences.length).not_to be_zero
35
30
 
36
- delete_preference_response = Patch::Preference.delete_preference(preference_id)
37
- expect(delete_preference_response.data.id).to eq preference_id
38
- end
31
+ delete_preference_response = Patch::Preference.delete_preference(preference_id)
32
+ expect(delete_preference_response.data.id).to eq preference_id
39
33
  end
40
34
  end