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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +13 -12
- data/Makefile +10 -0
- data/README.md +144 -15
- data/lib/patch_ruby.rb +2 -0
- data/lib/patch_ruby/models/allocation.rb +15 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +41 -4
- data/lib/patch_ruby/models/create_order_request.rb +68 -7
- data/lib/patch_ruby/models/estimate.rb +15 -0
- data/lib/patch_ruby/models/order.rb +85 -4
- data/lib/patch_ruby/models/photo.rb +216 -0
- data/lib/patch_ruby/models/preference.rb +15 -0
- data/lib/patch_ruby/models/project.rb +119 -25
- data/lib/patch_ruby/models/standard.rb +244 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/api/estimates_api_spec.rb +6 -7
- data/spec/api/orders_api_spec.rb +10 -11
- data/spec/api/preferences_api_spec.rb +8 -9
- data/spec/api/projects_api_spec.rb +4 -5
- data/spec/api_client_spec.rb +12 -33
- data/spec/constants.rb +3 -0
- data/spec/integration/estimates_spec.rb +30 -23
- data/spec/integration/orders_spec.rb +85 -38
- data/spec/integration/preferences_spec.rb +24 -30
- data/spec/integration/projects_spec.rb +38 -27
- data/spec/models/allocation_spec.rb +0 -1
- data/spec/models/create_mass_estimate_request_spec.rb +0 -1
- data/spec/models/create_order_request_spec.rb +0 -1
- data/spec/models/create_preference_request_spec.rb +0 -1
- data/spec/models/error_response_spec.rb +0 -1
- data/spec/models/estimate_list_response_spec.rb +0 -1
- data/spec/models/estimate_response_spec.rb +0 -1
- data/spec/models/estimate_spec.rb +0 -1
- data/spec/models/meta_index_object_spec.rb +0 -1
- data/spec/models/order_list_response_spec.rb +0 -1
- data/spec/models/order_response_spec.rb +0 -1
- data/spec/models/order_spec.rb +0 -1
- data/spec/models/preference_list_response_spec.rb +0 -1
- data/spec/models/preference_response_spec.rb +0 -1
- data/spec/models/preference_spec.rb +0 -1
- data/spec/models/project_list_response_spec.rb +0 -1
- data/spec/models/project_response_spec.rb +0 -1
- data/spec/models/project_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -11
- metadata +26 -30
- data/spec/fixtures/vcr_cassettes/estimate_orders.yml +0 -276
- data/spec/fixtures/vcr_cassettes/estimates.yml +0 -211
- data/spec/fixtures/vcr_cassettes/orders.yml +0 -229
- data/spec/fixtures/vcr_cassettes/preferences.yml +0 -352
- data/spec/fixtures/vcr_cassettes/projects.yml +0 -143
data/lib/patch_ruby/version.rb
CHANGED
@@ -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
|
data/spec/api/orders_api_spec.rb
CHANGED
@@ -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
|
data/spec/api_client_spec.rb
CHANGED
@@ -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 '
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
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
|
data/spec/constants.rb
ADDED
@@ -1,31 +1,38 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
RSpec.describe 'Estimates Integration' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
16
|
-
|
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
|
-
|
19
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
estimates += retrieve_estimates_response.data
|
26
|
-
end
|
15
|
+
page_limit = 1
|
16
|
+
next_page = 1
|
17
|
+
estimates = []
|
27
18
|
|
28
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
12
|
+
retrieve_order_response = Patch::Order.retrieve_order(order_id)
|
13
|
+
expect(retrieve_order_response.data.id).to eq order_id
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
page_limit = 1
|
16
|
+
next_page = 1
|
17
|
+
orders = []
|
20
18
|
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
26
|
-
orders = []
|
25
|
+
expect(orders.length).not_to be_zero
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
35
|
-
|
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
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
44
|
-
|
55
|
+
project_id = retrieve_project_response.data.id
|
56
|
+
total_price_cents_usd = 5_00
|
45
57
|
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
13
|
+
create_preference_response = Patch::Preference.create_preference(project_id: project_id)
|
14
|
+
preference_id = create_preference_response.data.id
|
18
15
|
|
19
|
-
|
20
|
-
|
16
|
+
retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
|
17
|
+
expect(retrieve_preference_response.data.id).to eq preference_id
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
preferences = []
|
19
|
+
page_limit = 1
|
20
|
+
next_page = 1
|
21
|
+
preferences = []
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
# END receive_preferences
|
29
|
+
expect(preferences.length).not_to be_zero
|
35
30
|
|
36
|
-
|
37
|
-
|
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
|