patch_ruby 1.22.0 → 1.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +32 -2
- data/lib/patch_ruby/api/estimates_api.rb +287 -7
- data/lib/patch_ruby/api/orders_api.rb +11 -4
- data/lib/patch_ruby/api/projects_api.rb +2 -2
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/allocation.rb +1 -1
- data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +374 -0
- data/lib/patch_ruby/models/create_order_request.rb +16 -7
- data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +404 -0
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +507 -0
- data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +461 -0
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/order.rb +20 -7
- data/lib/patch_ruby/models/order_issued_to.rb +242 -0
- data/lib/patch_ruby/models/place_order_request.rb +228 -0
- data/lib/patch_ruby/models/project.rb +2 -2
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +6 -0
- data/spec/integration/estimates_spec.rb +151 -0
- data/spec/integration/orders_spec.rb +34 -0
- data/spec/integration/projects_spec.rb +2 -2
- metadata +31 -25
@@ -42,6 +42,29 @@ RSpec.describe 'Orders Integration' do
|
|
42
42
|
expect(order.registry_url).not_to be_empty
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'supports create with issued_to' do
|
46
|
+
retrieve_project_response = Patch::Project.retrieve_project(
|
47
|
+
Constants::BIOMASS_TEST_PROJECT_ID
|
48
|
+
)
|
49
|
+
|
50
|
+
issued_to = { email: 'envimpact@companyb.com', name: 'Company B' }
|
51
|
+
total_price_cents_usd = 50_00
|
52
|
+
|
53
|
+
create_order_response = Patch::Order.create_order(
|
54
|
+
total_price_cents_usd: total_price_cents_usd,
|
55
|
+
issued_to: issued_to
|
56
|
+
)
|
57
|
+
|
58
|
+
expect(create_order_response.success).to eq true
|
59
|
+
|
60
|
+
order = create_order_response.data
|
61
|
+
|
62
|
+
expect(order.id).not_to be_nil
|
63
|
+
expect(order.price_cents_usd + order.patch_fee_cents_usd).to eq total_price_cents_usd
|
64
|
+
expect(order.issued_to.email).to eq(issued_to[:email])
|
65
|
+
expect(order.issued_to.name).to eq(issued_to[:name])
|
66
|
+
end
|
67
|
+
|
45
68
|
it 'supports create with a total price' do
|
46
69
|
retrieve_project_response = Patch::Project.retrieve_project(
|
47
70
|
Constants::BIOMASS_TEST_PROJECT_ID
|
@@ -108,6 +131,17 @@ RSpec.describe 'Orders Integration' do
|
|
108
131
|
expect(cancel_order_response.data.state).to eq 'cancelled'
|
109
132
|
end
|
110
133
|
|
134
|
+
it 'supports place order with issued_to' do
|
135
|
+
create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true)
|
136
|
+
order_to_place_id = create_estimate_to_place_response.data.order.id
|
137
|
+
|
138
|
+
issued_to = { email: 'envimpact@companya.com', name: 'Company A' }
|
139
|
+
place_order_response = Patch::Order.place_order(order_to_place_id, issued_to: issued_to)
|
140
|
+
expect(place_order_response.data.state).to eq 'placed'
|
141
|
+
expect(place_order_response.data.issued_to.email).to eq(issued_to[:email])
|
142
|
+
expect(place_order_response.data.issued_to.name).to eq(issued_to[:name])
|
143
|
+
end
|
144
|
+
|
111
145
|
it 'supports create with a vintage year' do
|
112
146
|
create_order_response =
|
113
147
|
Patch::Order.create_order(mass_g: 100, vintage_year: 2022)
|
@@ -76,10 +76,10 @@ RSpec.describe 'Projects Integration' do
|
|
76
76
|
it 'retrieves projects in the requested language' do
|
77
77
|
projects_response = Patch::Project.retrieve_projects(accept_language: 'fr')
|
78
78
|
|
79
|
-
expect(projects_response.data.first.name).to include '
|
79
|
+
expect(projects_response.data.first.name).to include 'Démo' # French
|
80
80
|
|
81
81
|
project_id = projects_response.data.first.id
|
82
82
|
project_response = Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
83
|
-
expect(project_response.data.name).to include '
|
83
|
+
expect(project_response.data.name).to include 'Démo' # Frenc
|
84
84
|
end
|
85
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patch_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -101,12 +101,16 @@ files:
|
|
101
101
|
- lib/patch_ruby/api_error.rb
|
102
102
|
- lib/patch_ruby/configuration.rb
|
103
103
|
- lib/patch_ruby/models/allocation.rb
|
104
|
+
- lib/patch_ruby/models/create_air_shipping_estimate_request.rb
|
104
105
|
- lib/patch_ruby/models/create_bitcoin_estimate_request.rb
|
105
106
|
- lib/patch_ruby/models/create_ethereum_estimate_request.rb
|
106
107
|
- lib/patch_ruby/models/create_flight_estimate_request.rb
|
107
108
|
- lib/patch_ruby/models/create_hotel_estimate_request.rb
|
108
109
|
- lib/patch_ruby/models/create_mass_estimate_request.rb
|
109
110
|
- lib/patch_ruby/models/create_order_request.rb
|
111
|
+
- lib/patch_ruby/models/create_rail_shipping_estimate_request.rb
|
112
|
+
- lib/patch_ruby/models/create_road_shipping_estimate_request.rb
|
113
|
+
- lib/patch_ruby/models/create_sea_shipping_estimate_request.rb
|
110
114
|
- lib/patch_ruby/models/create_shipping_estimate_request.rb
|
111
115
|
- lib/patch_ruby/models/create_success_response.rb
|
112
116
|
- lib/patch_ruby/models/create_vehicle_estimate_request.rb
|
@@ -120,10 +124,12 @@ files:
|
|
120
124
|
- lib/patch_ruby/models/order.rb
|
121
125
|
- lib/patch_ruby/models/order_inventory.rb
|
122
126
|
- lib/patch_ruby/models/order_inventory_project.rb
|
127
|
+
- lib/patch_ruby/models/order_issued_to.rb
|
123
128
|
- lib/patch_ruby/models/order_list_response.rb
|
124
129
|
- lib/patch_ruby/models/order_response.rb
|
125
130
|
- lib/patch_ruby/models/parent_technology_type.rb
|
126
131
|
- lib/patch_ruby/models/photo.rb
|
132
|
+
- lib/patch_ruby/models/place_order_request.rb
|
127
133
|
- lib/patch_ruby/models/project.rb
|
128
134
|
- lib/patch_ruby/models/project_list_response.rb
|
129
135
|
- lib/patch_ruby/models/project_response.rb
|
@@ -204,46 +210,46 @@ summary: Ruby wrapper for the Patch API
|
|
204
210
|
test_files:
|
205
211
|
- spec/api/projects_api_spec.rb
|
206
212
|
- spec/api/orders_api_spec.rb
|
207
|
-
- spec/api/estimates_api_spec.rb
|
208
213
|
- spec/api/technology_types_api_spec.rb
|
214
|
+
- spec/api/estimates_api_spec.rb
|
209
215
|
- spec/api_client_spec.rb
|
210
216
|
- spec/configuration_spec.rb
|
211
217
|
- spec/constants.rb
|
212
|
-
- spec/factories/
|
218
|
+
- spec/factories/parent_technology_type.rb
|
219
|
+
- spec/factories/sdgs.rb
|
220
|
+
- spec/factories/project_list_responses.rb
|
221
|
+
- spec/factories/estimate_responses.rb
|
222
|
+
- spec/factories/orders.rb
|
213
223
|
- spec/factories/meta_index_objects.rb
|
224
|
+
- spec/factories/create_order_requests.rb
|
214
225
|
- spec/factories/order_responses.rb
|
215
|
-
- spec/factories/
|
216
|
-
- spec/factories/estimate_responses.rb
|
217
|
-
- spec/factories/project_list_responses.rb
|
218
|
-
- spec/factories/projects.rb
|
226
|
+
- spec/factories/project_responses.rb
|
219
227
|
- spec/factories/allocations.rb
|
228
|
+
- spec/factories/estimates.rb
|
229
|
+
- spec/factories/projects.rb
|
230
|
+
- spec/factories/estimate_list_responses.rb
|
231
|
+
- spec/factories/order_list_responses.rb
|
220
232
|
- spec/factories/error_responses.rb
|
221
|
-
- spec/factories/project_responses.rb
|
222
|
-
- spec/factories/create_order_requests.rb
|
223
233
|
- spec/factories/technology_type.rb
|
224
|
-
- spec/factories/estimate_list_responses.rb
|
225
234
|
- spec/factories/create_mass_estimate_requests.rb
|
226
|
-
- spec/factories/sdgs.rb
|
227
|
-
- spec/factories/parent_technology_type.rb
|
228
|
-
- spec/factories/order_list_responses.rb
|
229
|
-
- spec/integration/estimates_spec.rb
|
230
235
|
- spec/integration/projects/technology_types_spec.rb
|
231
|
-
- spec/integration/projects_spec.rb
|
232
236
|
- spec/integration/orders_spec.rb
|
233
|
-
- spec/
|
234
|
-
- spec/
|
237
|
+
- spec/integration/estimates_spec.rb
|
238
|
+
- spec/integration/projects_spec.rb
|
239
|
+
- spec/models/allocation_spec.rb
|
235
240
|
- spec/models/project_list_response_spec.rb
|
236
|
-
- spec/models/project_response_spec.rb
|
237
|
-
- spec/models/estimate_list_response_spec.rb
|
238
|
-
- spec/models/estimate_response_spec.rb
|
239
|
-
- spec/models/order_list_response_spec.rb
|
240
|
-
- spec/models/estimate_spec.rb
|
241
|
-
- spec/models/create_order_request_spec.rb
|
242
241
|
- spec/models/meta_index_object_spec.rb
|
242
|
+
- spec/models/estimate_response_spec.rb
|
243
|
+
- spec/models/estimate_list_response_spec.rb
|
243
244
|
- spec/models/create_mass_estimate_request_spec.rb
|
245
|
+
- spec/models/project_response_spec.rb
|
244
246
|
- spec/models/error_response_spec.rb
|
247
|
+
- spec/models/estimate_spec.rb
|
248
|
+
- spec/models/order_list_response_spec.rb
|
245
249
|
- spec/models/order_response_spec.rb
|
246
|
-
- spec/models/
|
250
|
+
- spec/models/project_spec.rb
|
251
|
+
- spec/models/order_spec.rb
|
252
|
+
- spec/models/create_order_request_spec.rb
|
247
253
|
- spec/patch_ruby_spec.rb
|
248
254
|
- spec/spec_helper.rb
|
249
255
|
- spec/support/shared/generated_classes.rb
|