patch_ruby 1.22.0 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +32 -2
- data/lib/patch_ruby/api/orders_api.rb +41 -34
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/allocation.rb +1 -1
- data/lib/patch_ruby/models/create_order_request.rb +15 -5
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/issued_to.rb +242 -0
- data/lib/patch_ruby/models/order.rb +14 -5
- data/lib/patch_ruby/models/place_order_request.rb +229 -0
- data/lib/patch_ruby/models/project.rb +1 -1
- data/lib/patch_ruby/models/v1_orders_issued_to.rb +239 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +3 -0
- data/spec/integration/orders_spec.rb +34 -0
- data/spec/models/create_order_request_spec.rb +1 -1
- metadata +26 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 025a65865a5414587e8820d3cb5d236859e543e9047f6695279e1be22d789c52
|
4
|
+
data.tar.gz: bb4cb5ce332b266de2cbe6cc4ca59d41335a1e216a654e3057c9c613622e8eaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0bcea18ad0b42d5f997c2021c5d40925f40158b4eb8c6d8f185162d89d9d956e0a01fe8bd28f8f6741f6144b176cbdd6df2d4034f65371a6aec92e521e60756
|
7
|
+
data.tar.gz: bc4e566299bc9534b41d2339a8d75df40a74398d64a672c17f3560feb0dad65efa0840202aff644ecdbc4c1272c08e621455a5841d7ba1b353c3cd27454a2d55
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.23.0] - 2022-06-03
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Adds support for the `issued_to` parameter on `orders`, to add support for creating and placing orders on behalf of another party.
|
13
|
+
|
8
14
|
## [1.22.0] - 2022-05-16
|
9
15
|
|
10
16
|
### Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,12 @@ total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents
|
|
74
74
|
currency = "USD"
|
75
75
|
Patch::Order.create_order(total_price: total_price, currency: currency)
|
76
76
|
|
77
|
+
# Create an order with issued_to field (optional)
|
78
|
+
total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents for USD).
|
79
|
+
currency = "USD"
|
80
|
+
issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
81
|
+
Patch::Order.create_order(total_price: total_price, currency: currency, issued_to: issued_to)
|
82
|
+
|
77
83
|
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
78
84
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
79
85
|
Patch::Order.create_order(amount: amount, unit: unit, project_id: project_id)
|
@@ -90,6 +96,11 @@ Patch::Order.retrieve_order(order_id)
|
|
90
96
|
order_id = 'ord_test_1234' # Pass in the order's id
|
91
97
|
Patch::Order.place_order(order_id)
|
92
98
|
|
99
|
+
## Placing an order on behalf of another party with the issued_to field (optional)
|
100
|
+
order_id = 'ord_test_1234' # Pass in the order's id
|
101
|
+
issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
102
|
+
Patch::Order.place_order(order_id, issued_to: issued_to)
|
103
|
+
|
93
104
|
# Cancel an order
|
94
105
|
order_id = 'ord_test_1234' # Pass in the order's id
|
95
106
|
Patch::Order.cancel_order(order_id)
|
@@ -191,12 +202,12 @@ minimum_available_mass = 100
|
|
191
202
|
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
192
203
|
|
193
204
|
# Retrieve a project in a different language
|
194
|
-
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
205
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
195
206
|
project_id = 'pro_test_1234'
|
196
207
|
Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
197
208
|
|
198
209
|
# Retrieve a list of projects in a different language
|
199
|
-
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
210
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
200
211
|
Patch::Project.retrieve_projects(accept_language: 'fr')
|
201
212
|
```
|
202
213
|
## Contributing
|
@@ -219,6 +230,25 @@ This will create a .gem file. To install the local gem:
|
|
219
230
|
gem install patch_ruby-1.x.x.gem
|
220
231
|
```
|
221
232
|
|
233
|
+
Once you have installed the gem, you can easily test with `irb`. Here's an example of testing Order creation:
|
234
|
+
```bash
|
235
|
+
brett@Bretts-MacBook-Pro patch-ruby $ irb
|
236
|
+
irb(main):001:0> require 'patch_ruby'
|
237
|
+
=> true
|
238
|
+
irb(main):002:0>
|
239
|
+
irb(main):003:1* Patch.configure do |config|
|
240
|
+
irb(main):004:1* # Configure the Patch gem with your API key here
|
241
|
+
irb(main):005:1* config.access_token = ENV['SANDBOX_API_KEY']
|
242
|
+
irb(main):006:0> end
|
243
|
+
=> "[REDACTED]"
|
244
|
+
irb(main):007:0> total_price = 5_00
|
245
|
+
=> 500
|
246
|
+
irb(main):008:0> currency = "USD"
|
247
|
+
=> "USD"
|
248
|
+
irb(main):009:0> issued_to = {email: "envimpact@companya.com", name: "Company A"}
|
249
|
+
irb(main):010:0> Patch::Order.create_order(total_price: total_price, currency: currency, issued_to: issued_to)
|
250
|
+
```
|
251
|
+
|
222
252
|
### Running tests
|
223
253
|
|
224
254
|
Set up the required environment variable.
|
@@ -28,19 +28,19 @@ module Patch
|
|
28
28
|
@api_client = api_client
|
29
29
|
end
|
30
30
|
# Cancel an order
|
31
|
-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
32
|
-
# @param id [String]
|
31
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
32
|
+
# @param id [String]
|
33
33
|
# @param [Hash] opts the optional parameters
|
34
34
|
# @return [OrderResponse]
|
35
35
|
def cancel_order(id, opts = {})
|
36
|
-
|
36
|
+
|
37
37
|
data, _status_code, _headers = cancel_order_with_http_info(id, opts)
|
38
38
|
data
|
39
39
|
end
|
40
40
|
|
41
41
|
# Cancel an order
|
42
|
-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
43
|
-
# @param id [String]
|
42
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
43
|
+
# @param id [String]
|
44
44
|
# @param [Hash] opts the optional parameters
|
45
45
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
46
46
|
def cancel_order_with_http_info(id, opts = {})
|
@@ -92,19 +92,19 @@ module Patch
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Creates an order
|
95
|
-
# Creates an order in the `placed` or `draft` state.
|
96
|
-
# @param create_order_request [CreateOrderRequest]
|
95
|
+
# Creates an order in the `placed` or `draft` state.
|
96
|
+
# @param create_order_request [CreateOrderRequest]
|
97
97
|
# @param [Hash] opts the optional parameters
|
98
98
|
# @return [OrderResponse]
|
99
99
|
def create_order(create_order_request = {}, opts = {})
|
100
|
-
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
|
100
|
+
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
|
101
101
|
data, _status_code, _headers = create_order_with_http_info(_create_order_request, opts)
|
102
102
|
data
|
103
103
|
end
|
104
104
|
|
105
105
|
# Creates an order
|
106
|
-
# Creates an order in the `placed` or `draft` state.
|
107
|
-
# @param create_order_request [CreateOrderRequest]
|
106
|
+
# Creates an order in the `placed` or `draft` state.
|
107
|
+
# @param create_order_request [CreateOrderRequest]
|
108
108
|
# @param [Hash] opts the optional parameters
|
109
109
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
110
110
|
def create_order_with_http_info(create_order_request, opts = {})
|
@@ -161,20 +161,22 @@ module Patch
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# Place an order
|
164
|
-
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
165
|
-
# @param id [String]
|
164
|
+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
165
|
+
# @param id [String]
|
166
166
|
# @param [Hash] opts the optional parameters
|
167
|
+
# @option opts [PlaceOrderRequest] :place_order_request
|
167
168
|
# @return [OrderResponse]
|
168
|
-
def place_order(id, opts = {})
|
169
|
-
|
170
|
-
data, _status_code, _headers = place_order_with_http_info(id, opts)
|
169
|
+
def place_order(id, place_order_request = {}, opts = {})
|
170
|
+
_place_order_request = Patch::PlaceOrderRequest.new(place_order_request)
|
171
|
+
data, _status_code, _headers = place_order_with_http_info(id, opts.merge!({place_order_request: place_order_request}))
|
171
172
|
data
|
172
173
|
end
|
173
174
|
|
174
175
|
# Place an order
|
175
|
-
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
176
|
-
# @param id [String]
|
176
|
+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
|
177
|
+
# @param id [String]
|
177
178
|
# @param [Hash] opts the optional parameters
|
179
|
+
# @option opts [PlaceOrderRequest] :place_order_request
|
178
180
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
179
181
|
def place_order_with_http_info(id, opts = {})
|
180
182
|
if @api_client.config.debugging
|
@@ -194,12 +196,17 @@ module Patch
|
|
194
196
|
header_params = opts[:header_params] || {}
|
195
197
|
# HTTP header 'Accept' (if needed)
|
196
198
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
199
|
+
# HTTP header 'Content-Type'
|
200
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
201
|
+
if !content_type.nil?
|
202
|
+
header_params['Content-Type'] = content_type
|
203
|
+
end
|
197
204
|
|
198
205
|
# form parameters
|
199
206
|
form_params = opts[:form_params] || {}
|
200
207
|
|
201
208
|
# http body (model)
|
202
|
-
post_body = opts[:debug_body]
|
209
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'place_order_request'])
|
203
210
|
|
204
211
|
# return_type
|
205
212
|
return_type = opts[:debug_return_type] || 'OrderResponse'
|
@@ -225,19 +232,19 @@ module Patch
|
|
225
232
|
end
|
226
233
|
|
227
234
|
# Retrieves an order
|
228
|
-
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
229
|
-
# @param id [String]
|
235
|
+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
236
|
+
# @param id [String]
|
230
237
|
# @param [Hash] opts the optional parameters
|
231
238
|
# @return [OrderResponse]
|
232
239
|
def retrieve_order(id, opts = {})
|
233
|
-
|
240
|
+
|
234
241
|
data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
|
235
242
|
data
|
236
243
|
end
|
237
244
|
|
238
245
|
# Retrieves an order
|
239
|
-
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
240
|
-
# @param id [String]
|
246
|
+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
247
|
+
# @param id [String]
|
241
248
|
# @param [Hash] opts the optional parameters
|
242
249
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
243
250
|
def retrieve_order_with_http_info(id, opts = {})
|
@@ -289,26 +296,26 @@ module Patch
|
|
289
296
|
end
|
290
297
|
|
291
298
|
# Retrieves a list of orders
|
292
|
-
# 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.
|
299
|
+
# 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.
|
293
300
|
# @param [Hash] opts the optional parameters
|
294
|
-
# @option opts [Integer] :page
|
295
|
-
# @option opts [String] :metadata
|
296
|
-
# @option opts [String] :metadata_example1
|
297
|
-
# @option opts [String] :metadata_example2
|
301
|
+
# @option opts [Integer] :page
|
302
|
+
# @option opts [String] :metadata
|
303
|
+
# @option opts [String] :metadata_example1
|
304
|
+
# @option opts [String] :metadata_example2
|
298
305
|
# @return [OrderListResponse]
|
299
306
|
def retrieve_orders(opts = {})
|
300
|
-
|
307
|
+
|
301
308
|
data, _status_code, _headers = retrieve_orders_with_http_info(opts)
|
302
309
|
data
|
303
310
|
end
|
304
311
|
|
305
312
|
# Retrieves a list of orders
|
306
|
-
# 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.
|
313
|
+
# 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.
|
307
314
|
# @param [Hash] opts the optional parameters
|
308
|
-
# @option opts [Integer] :page
|
309
|
-
# @option opts [String] :metadata
|
310
|
-
# @option opts [String] :metadata_example1
|
311
|
-
# @option opts [String] :metadata_example2
|
315
|
+
# @option opts [Integer] :page
|
316
|
+
# @option opts [String] :metadata
|
317
|
+
# @option opts [String] :metadata_example1
|
318
|
+
# @option opts [String] :metadata_example2
|
312
319
|
# @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers
|
313
320
|
def retrieve_orders_with_http_info(opts = {})
|
314
321
|
if @api_client.config.debugging
|
@@ -31,7 +31,7 @@ module Patch
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "patch-ruby/1.
|
34
|
+
@user_agent = "patch-ruby/1.23.0"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
@@ -18,7 +18,7 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# A boolean indicating if this project is a production or
|
21
|
+
# A boolean indicating if this project is a production or demo mode project.
|
22
22
|
attr_accessor :production
|
23
23
|
|
24
24
|
# The amount (in grams) of allocated carbon offsets.
|
@@ -35,6 +35,8 @@ module Patch
|
|
35
35
|
|
36
36
|
attr_accessor :unit
|
37
37
|
|
38
|
+
attr_accessor :issued_to
|
39
|
+
|
38
40
|
class EnumAttributeValidator
|
39
41
|
attr_reader :datatype
|
40
42
|
attr_reader :allowable_values
|
@@ -69,7 +71,8 @@ module Patch
|
|
69
71
|
:'total_price' => :'total_price',
|
70
72
|
:'currency' => :'currency',
|
71
73
|
:'amount' => :'amount',
|
72
|
-
:'unit' => :'unit'
|
74
|
+
:'unit' => :'unit',
|
75
|
+
:'issued_to' => :'issued_to'
|
73
76
|
}
|
74
77
|
end
|
75
78
|
|
@@ -90,7 +93,8 @@ module Patch
|
|
90
93
|
:'total_price' => :'Integer',
|
91
94
|
:'currency' => :'String',
|
92
95
|
:'amount' => :'Integer',
|
93
|
-
:'unit' => :'String'
|
96
|
+
:'unit' => :'String',
|
97
|
+
:'issued_to' => :'V1OrdersIssuedTo'
|
94
98
|
}
|
95
99
|
end
|
96
100
|
|
@@ -106,7 +110,8 @@ module Patch
|
|
106
110
|
:'total_price',
|
107
111
|
:'currency',
|
108
112
|
:'amount',
|
109
|
-
:'unit'
|
113
|
+
:'unit',
|
114
|
+
:'issued_to'
|
110
115
|
])
|
111
116
|
end
|
112
117
|
|
@@ -176,6 +181,10 @@ module Patch
|
|
176
181
|
if attributes.key?(:'unit')
|
177
182
|
self.unit = attributes[:'unit']
|
178
183
|
end
|
184
|
+
|
185
|
+
if attributes.key?(:'issued_to')
|
186
|
+
self.issued_to = attributes[:'issued_to']
|
187
|
+
end
|
179
188
|
end
|
180
189
|
|
181
190
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -331,7 +340,8 @@ module Patch
|
|
331
340
|
total_price == o.total_price &&
|
332
341
|
currency == o.currency &&
|
333
342
|
amount == o.amount &&
|
334
|
-
unit == o.unit
|
343
|
+
unit == o.unit &&
|
344
|
+
issued_to == o.issued_to
|
335
345
|
end
|
336
346
|
|
337
347
|
# @see the `==` method
|
@@ -343,7 +353,7 @@ module Patch
|
|
343
353
|
# Calculates hash code according to all attributes.
|
344
354
|
# @return [Integer] Hash code
|
345
355
|
def hash
|
346
|
-
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year, total_price, currency, amount, unit].hash
|
356
|
+
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year, total_price, currency, amount, unit, issued_to].hash
|
347
357
|
end
|
348
358
|
|
349
359
|
# Builds the object from hash
|
@@ -18,7 +18,7 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by est_prod or est_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# A boolean indicating if this estimate is a production or
|
21
|
+
# A boolean indicating if this estimate is a production or demo mode estimate.
|
22
22
|
attr_accessor :production
|
23
23
|
|
24
24
|
# The type of estimate. Available types are mass, flight, shipping, vehicle, and crypto.
|
@@ -0,0 +1,242 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: engineering@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
# An object containing the name & email of the party the inventory will be issued to.
|
18
|
+
class IssuedTo
|
19
|
+
# Name provided for the issuee
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
# Email address provided for the issuee
|
23
|
+
attr_accessor :email
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'name' => :'name',
|
29
|
+
:'email' => :'email'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'name' => :'String',
|
42
|
+
:'email' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
:'name',
|
50
|
+
:'email'
|
51
|
+
])
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
56
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
57
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
58
|
+
def self.method_missing(message, *args, &block)
|
59
|
+
if Object.const_defined?('Patch::IssuedTosApi::OPERATIONS') && Patch::IssuedTosApi::OPERATIONS.include?(message)
|
60
|
+
Patch::IssuedTosApi.new.send(message, *args)
|
61
|
+
else
|
62
|
+
super
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::IssuedTo` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::IssuedTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
+
end
|
78
|
+
h[k.to_sym] = v
|
79
|
+
}
|
80
|
+
|
81
|
+
if attributes.key?(:'name')
|
82
|
+
self.name = attributes[:'name']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'email')
|
86
|
+
self.email = attributes[:'email']
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
91
|
+
# @return Array for valid properties with the reasons
|
92
|
+
def list_invalid_properties
|
93
|
+
invalid_properties = Array.new
|
94
|
+
invalid_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
# Checks equality by comparing each attribute.
|
104
|
+
# @param [Object] Object to be compared
|
105
|
+
def ==(o)
|
106
|
+
return true if self.equal?(o)
|
107
|
+
self.class == o.class &&
|
108
|
+
name == o.name &&
|
109
|
+
email == o.email
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Integer] Hash code
|
120
|
+
def hash
|
121
|
+
[name, email].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def self.build_from_hash(attributes)
|
128
|
+
new.build_from_hash(attributes)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Builds the object from hash
|
132
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
133
|
+
# @return [Object] Returns the model itself
|
134
|
+
def build_from_hash(attributes)
|
135
|
+
return nil unless attributes.is_a?(Hash)
|
136
|
+
self.class.openapi_types.each_pair do |key, type|
|
137
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
138
|
+
self.send("#{key}=", nil)
|
139
|
+
elsif type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the attribute
|
141
|
+
# is documented as an array but the input is not
|
142
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
143
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
144
|
+
end
|
145
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
146
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def _deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :Time
|
160
|
+
Time.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :Boolean
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
# models (e.g. Pet) or oneOf
|
191
|
+
klass = Patch.const_get(type)
|
192
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the string representation of the object
|
197
|
+
# @return [String] String presentation of the object
|
198
|
+
def to_s
|
199
|
+
to_hash.to_s
|
200
|
+
end
|
201
|
+
|
202
|
+
# to_body is an alias to to_hash (backward compatibility)
|
203
|
+
# @return [Hash] Returns the object in the form of hash
|
204
|
+
def to_body
|
205
|
+
to_hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# Returns the object in the form of hash
|
209
|
+
# @return [Hash] Returns the object in the form of hash
|
210
|
+
def to_hash
|
211
|
+
hash = {}
|
212
|
+
self.class.attribute_map.each_pair do |attr, param|
|
213
|
+
value = self.send(attr)
|
214
|
+
if value.nil?
|
215
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
216
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
217
|
+
end
|
218
|
+
|
219
|
+
hash[param] = _to_hash(value)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Outputs non-array value in the form of hash
|
225
|
+
# For object, use to_hash. Otherwise, just return the value
|
226
|
+
# @param [Object] value Any valid value
|
227
|
+
# @return [Hash] Returns the value in the form of hash
|
228
|
+
def _to_hash(value)
|
229
|
+
if value.is_a?(Array)
|
230
|
+
value.compact.map { |v| _to_hash(v) }
|
231
|
+
elsif value.is_a?(Hash)
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
234
|
+
end
|
235
|
+
elsif value.respond_to? :to_hash
|
236
|
+
value.to_hash
|
237
|
+
else
|
238
|
+
value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
@@ -24,7 +24,7 @@ module Patch
|
|
24
24
|
# DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order.
|
25
25
|
attr_accessor :mass_g
|
26
26
|
|
27
|
-
# A boolean indicating if this order is a production or
|
27
|
+
# A boolean indicating if this order is a production or demo mode order.
|
28
28
|
attr_accessor :production
|
29
29
|
|
30
30
|
# The current state of the order.
|
@@ -66,6 +66,8 @@ module Patch
|
|
66
66
|
# An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price.
|
67
67
|
attr_accessor :inventory
|
68
68
|
|
69
|
+
attr_accessor :issued_to
|
70
|
+
|
69
71
|
class EnumAttributeValidator
|
70
72
|
attr_reader :datatype
|
71
73
|
attr_reader :allowable_values
|
@@ -107,7 +109,8 @@ module Patch
|
|
107
109
|
:'allocations' => :'allocations',
|
108
110
|
:'registry_url' => :'registry_url',
|
109
111
|
:'metadata' => :'metadata',
|
110
|
-
:'inventory' => :'inventory'
|
112
|
+
:'inventory' => :'inventory',
|
113
|
+
:'issued_to' => :'issued_to'
|
111
114
|
}
|
112
115
|
end
|
113
116
|
|
@@ -135,7 +138,8 @@ module Patch
|
|
135
138
|
:'allocations' => :'Array<Allocation>',
|
136
139
|
:'registry_url' => :'String',
|
137
140
|
:'metadata' => :'Object',
|
138
|
-
:'inventory' => :'Array<OrderInventory>'
|
141
|
+
:'inventory' => :'Array<OrderInventory>',
|
142
|
+
:'issued_to' => :'IssuedTo'
|
139
143
|
}
|
140
144
|
end
|
141
145
|
|
@@ -245,6 +249,10 @@ module Patch
|
|
245
249
|
self.inventory = value
|
246
250
|
end
|
247
251
|
end
|
252
|
+
|
253
|
+
if attributes.key?(:'issued_to')
|
254
|
+
self.issued_to = attributes[:'issued_to']
|
255
|
+
end
|
248
256
|
end
|
249
257
|
|
250
258
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -416,7 +424,8 @@ module Patch
|
|
416
424
|
allocations == o.allocations &&
|
417
425
|
registry_url == o.registry_url &&
|
418
426
|
metadata == o.metadata &&
|
419
|
-
inventory == o.inventory
|
427
|
+
inventory == o.inventory &&
|
428
|
+
issued_to == o.issued_to
|
420
429
|
end
|
421
430
|
|
422
431
|
# @see the `==` method
|
@@ -428,7 +437,7 @@ module Patch
|
|
428
437
|
# Calculates hash code according to all attributes.
|
429
438
|
# @return [Integer] Hash code
|
430
439
|
def hash
|
431
|
-
[id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory].hash
|
440
|
+
[id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory, issued_to].hash
|
432
441
|
end
|
433
442
|
|
434
443
|
# Builds the object from hash
|
@@ -0,0 +1,229 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: engineering@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
class PlaceOrderRequest
|
18
|
+
attr_accessor :issued_to
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'issued_to' => :'issued_to'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
:'issued_to' => :'V1OrdersIssuedTo'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
:'issued_to'
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
48
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
49
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
50
|
+
def self.method_missing(message, *args, &block)
|
51
|
+
if Object.const_defined?('Patch::PlaceOrderRequestsApi::OPERATIONS') && Patch::PlaceOrderRequestsApi::OPERATIONS.include?(message)
|
52
|
+
Patch::PlaceOrderRequestsApi.new.send(message, *args)
|
53
|
+
else
|
54
|
+
super
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Initializes the object
|
59
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
60
|
+
def initialize(attributes = {})
|
61
|
+
if (!attributes.is_a?(Hash))
|
62
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::PlaceOrderRequest` initialize method"
|
63
|
+
end
|
64
|
+
|
65
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
66
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
67
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
68
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PlaceOrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
69
|
+
end
|
70
|
+
h[k.to_sym] = v
|
71
|
+
}
|
72
|
+
|
73
|
+
if attributes.key?(:'issued_to')
|
74
|
+
self.issued_to = attributes[:'issued_to']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def list_invalid_properties
|
81
|
+
invalid_properties = Array.new
|
82
|
+
invalid_properties
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check to see if the all the properties in the model are valid
|
86
|
+
# @return true if the model is valid
|
87
|
+
def valid?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
issued_to == o.issued_to
|
97
|
+
end
|
98
|
+
|
99
|
+
# @see the `==` method
|
100
|
+
# @param [Object] Object to be compared
|
101
|
+
def eql?(o)
|
102
|
+
self == o
|
103
|
+
end
|
104
|
+
|
105
|
+
# Calculates hash code according to all attributes.
|
106
|
+
# @return [Integer] Hash code
|
107
|
+
def hash
|
108
|
+
[issued_to].hash
|
109
|
+
end
|
110
|
+
|
111
|
+
# Builds the object from hash
|
112
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
113
|
+
# @return [Object] Returns the model itself
|
114
|
+
def self.build_from_hash(attributes)
|
115
|
+
new.build_from_hash(attributes)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Builds the object from hash
|
119
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
120
|
+
# @return [Object] Returns the model itself
|
121
|
+
def build_from_hash(attributes)
|
122
|
+
return nil unless attributes.is_a?(Hash)
|
123
|
+
self.class.openapi_types.each_pair do |key, type|
|
124
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
125
|
+
self.send("#{key}=", nil)
|
126
|
+
elsif type =~ /\AArray<(.*)>/i
|
127
|
+
# check to ensure the input is an array given that the attribute
|
128
|
+
# is documented as an array but the input is not
|
129
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
130
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
131
|
+
end
|
132
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
133
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
140
|
+
# Deserializes the data based on type
|
141
|
+
# @param string type Data type
|
142
|
+
# @param string value Value to be deserialized
|
143
|
+
# @return [Object] Deserialized data
|
144
|
+
def _deserialize(type, value)
|
145
|
+
case type.to_sym
|
146
|
+
when :Time
|
147
|
+
Time.parse(value)
|
148
|
+
when :Date
|
149
|
+
Date.parse(value)
|
150
|
+
when :String
|
151
|
+
value.to_s
|
152
|
+
when :Integer
|
153
|
+
value.to_i
|
154
|
+
when :Float
|
155
|
+
value.to_f
|
156
|
+
when :Boolean
|
157
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
158
|
+
true
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
162
|
+
when :Object
|
163
|
+
# generic object (usually a Hash), return directly
|
164
|
+
value
|
165
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
166
|
+
inner_type = Regexp.last_match[:inner_type]
|
167
|
+
value.map { |v| _deserialize(inner_type, v) }
|
168
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
169
|
+
k_type = Regexp.last_match[:k_type]
|
170
|
+
v_type = Regexp.last_match[:v_type]
|
171
|
+
{}.tap do |hash|
|
172
|
+
value.each do |k, v|
|
173
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
else # model
|
177
|
+
# models (e.g. Pet) or oneOf
|
178
|
+
klass = Patch.const_get(type)
|
179
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns the string representation of the object
|
184
|
+
# @return [String] String presentation of the object
|
185
|
+
def to_s
|
186
|
+
to_hash.to_s
|
187
|
+
end
|
188
|
+
|
189
|
+
# to_body is an alias to to_hash (backward compatibility)
|
190
|
+
# @return [Hash] Returns the object in the form of hash
|
191
|
+
def to_body
|
192
|
+
to_hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Returns the object in the form of hash
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
197
|
+
def to_hash
|
198
|
+
hash = {}
|
199
|
+
self.class.attribute_map.each_pair do |attr, param|
|
200
|
+
value = self.send(attr)
|
201
|
+
if value.nil?
|
202
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
203
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
204
|
+
end
|
205
|
+
|
206
|
+
hash[param] = _to_hash(value)
|
207
|
+
end
|
208
|
+
hash
|
209
|
+
end
|
210
|
+
|
211
|
+
# Outputs non-array value in the form of hash
|
212
|
+
# For object, use to_hash. Otherwise, just return the value
|
213
|
+
# @param [Object] value Any valid value
|
214
|
+
# @return [Hash] Returns the value in the form of hash
|
215
|
+
def _to_hash(value)
|
216
|
+
if value.is_a?(Array)
|
217
|
+
value.compact.map { |v| _to_hash(v) }
|
218
|
+
elsif value.is_a?(Hash)
|
219
|
+
{}.tap do |hash|
|
220
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
221
|
+
end
|
222
|
+
elsif value.respond_to? :to_hash
|
223
|
+
value.to_hash
|
224
|
+
else
|
225
|
+
value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -18,7 +18,7 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# A boolean indicating if this project is a production or
|
21
|
+
# A boolean indicating if this project is a production or demo mode project.
|
22
22
|
attr_accessor :production
|
23
23
|
|
24
24
|
# The name of the project.
|
@@ -0,0 +1,239 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: engineering@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
class V1OrdersIssuedTo
|
18
|
+
attr_accessor :email
|
19
|
+
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'email' => :'email',
|
26
|
+
:'name' => :'name'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'email' => :'String',
|
39
|
+
:'name' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
:'email',
|
47
|
+
:'name'
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
53
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
54
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
55
|
+
def self.method_missing(message, *args, &block)
|
56
|
+
if Object.const_defined?('Patch::V1OrdersIssuedTosApi::OPERATIONS') && Patch::V1OrdersIssuedTosApi::OPERATIONS.include?(message)
|
57
|
+
Patch::V1OrdersIssuedTosApi.new.send(message, *args)
|
58
|
+
else
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Initializes the object
|
64
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
65
|
+
def initialize(attributes = {})
|
66
|
+
if (!attributes.is_a?(Hash))
|
67
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::V1OrdersIssuedTo` initialize method"
|
68
|
+
end
|
69
|
+
|
70
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
72
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
73
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::V1OrdersIssuedTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
74
|
+
end
|
75
|
+
h[k.to_sym] = v
|
76
|
+
}
|
77
|
+
|
78
|
+
if attributes.key?(:'email')
|
79
|
+
self.email = attributes[:'email']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'name')
|
83
|
+
self.name = attributes[:'name']
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
88
|
+
# @return Array for valid properties with the reasons
|
89
|
+
def list_invalid_properties
|
90
|
+
invalid_properties = Array.new
|
91
|
+
invalid_properties
|
92
|
+
end
|
93
|
+
|
94
|
+
# Check to see if the all the properties in the model are valid
|
95
|
+
# @return true if the model is valid
|
96
|
+
def valid?
|
97
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
# Checks equality by comparing each attribute.
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def ==(o)
|
103
|
+
return true if self.equal?(o)
|
104
|
+
self.class == o.class &&
|
105
|
+
email == o.email &&
|
106
|
+
name == o.name
|
107
|
+
end
|
108
|
+
|
109
|
+
# @see the `==` method
|
110
|
+
# @param [Object] Object to be compared
|
111
|
+
def eql?(o)
|
112
|
+
self == o
|
113
|
+
end
|
114
|
+
|
115
|
+
# Calculates hash code according to all attributes.
|
116
|
+
# @return [Integer] Hash code
|
117
|
+
def hash
|
118
|
+
[email, name].hash
|
119
|
+
end
|
120
|
+
|
121
|
+
# Builds the object from hash
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
123
|
+
# @return [Object] Returns the model itself
|
124
|
+
def self.build_from_hash(attributes)
|
125
|
+
new.build_from_hash(attributes)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Builds the object from hash
|
129
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
130
|
+
# @return [Object] Returns the model itself
|
131
|
+
def build_from_hash(attributes)
|
132
|
+
return nil unless attributes.is_a?(Hash)
|
133
|
+
self.class.openapi_types.each_pair do |key, type|
|
134
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
135
|
+
self.send("#{key}=", nil)
|
136
|
+
elsif type =~ /\AArray<(.*)>/i
|
137
|
+
# check to ensure the input is an array given that the attribute
|
138
|
+
# is documented as an array but the input is not
|
139
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
141
|
+
end
|
142
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
143
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def _deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :Time
|
157
|
+
Time.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
# models (e.g. Pet) or oneOf
|
188
|
+
klass = Patch.const_get(type)
|
189
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns the string representation of the object
|
194
|
+
# @return [String] String presentation of the object
|
195
|
+
def to_s
|
196
|
+
to_hash.to_s
|
197
|
+
end
|
198
|
+
|
199
|
+
# to_body is an alias to to_hash (backward compatibility)
|
200
|
+
# @return [Hash] Returns the object in the form of hash
|
201
|
+
def to_body
|
202
|
+
to_hash
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns the object in the form of hash
|
206
|
+
# @return [Hash] Returns the object in the form of hash
|
207
|
+
def to_hash
|
208
|
+
hash = {}
|
209
|
+
self.class.attribute_map.each_pair do |attr, param|
|
210
|
+
value = self.send(attr)
|
211
|
+
if value.nil?
|
212
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
213
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
214
|
+
end
|
215
|
+
|
216
|
+
hash[param] = _to_hash(value)
|
217
|
+
end
|
218
|
+
hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Outputs non-array value in the form of hash
|
222
|
+
# For object, use to_hash. Otherwise, just return the value
|
223
|
+
# @param [Object] value Any valid value
|
224
|
+
# @return [Hash] Returns the value in the form of hash
|
225
|
+
def _to_hash(value)
|
226
|
+
if value.is_a?(Array)
|
227
|
+
value.compact.map { |v| _to_hash(v) }
|
228
|
+
elsif value.is_a?(Hash)
|
229
|
+
{}.tap do |hash|
|
230
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
231
|
+
end
|
232
|
+
elsif value.respond_to? :to_hash
|
233
|
+
value.to_hash
|
234
|
+
else
|
235
|
+
value
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
data/lib/patch_ruby/version.rb
CHANGED
data/lib/patch_ruby.rb
CHANGED
@@ -33,6 +33,7 @@ require 'patch_ruby/models/estimate_list_response'
|
|
33
33
|
require 'patch_ruby/models/estimate_response'
|
34
34
|
require 'patch_ruby/models/highlight'
|
35
35
|
require 'patch_ruby/models/inventory'
|
36
|
+
require 'patch_ruby/models/issued_to'
|
36
37
|
require 'patch_ruby/models/meta_index_object'
|
37
38
|
require 'patch_ruby/models/order'
|
38
39
|
require 'patch_ruby/models/order_inventory'
|
@@ -41,6 +42,7 @@ require 'patch_ruby/models/order_list_response'
|
|
41
42
|
require 'patch_ruby/models/order_response'
|
42
43
|
require 'patch_ruby/models/parent_technology_type'
|
43
44
|
require 'patch_ruby/models/photo'
|
45
|
+
require 'patch_ruby/models/place_order_request'
|
44
46
|
require 'patch_ruby/models/project'
|
45
47
|
require 'patch_ruby/models/project_list_response'
|
46
48
|
require 'patch_ruby/models/project_response'
|
@@ -48,6 +50,7 @@ require 'patch_ruby/models/sdg'
|
|
48
50
|
require 'patch_ruby/models/standard'
|
49
51
|
require 'patch_ruby/models/technology_type'
|
50
52
|
require 'patch_ruby/models/technology_type_list_response'
|
53
|
+
require 'patch_ruby/models/v1_orders_issued_to'
|
51
54
|
|
52
55
|
# APIs
|
53
56
|
require 'patch_ruby/api/estimates_api'
|
@@ -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)
|
@@ -31,7 +31,7 @@ describe 'CreateOrderRequest' do
|
|
31
31
|
let(:instance) { @instance }
|
32
32
|
let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
|
33
33
|
let(:nullable_properties) do
|
34
|
-
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit])
|
34
|
+
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit issued_to])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
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.23.0
|
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-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/patch_ruby/models/estimate_response.rb
|
117
117
|
- lib/patch_ruby/models/highlight.rb
|
118
118
|
- lib/patch_ruby/models/inventory.rb
|
119
|
+
- lib/patch_ruby/models/issued_to.rb
|
119
120
|
- lib/patch_ruby/models/meta_index_object.rb
|
120
121
|
- lib/patch_ruby/models/order.rb
|
121
122
|
- lib/patch_ruby/models/order_inventory.rb
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- lib/patch_ruby/models/order_response.rb
|
125
126
|
- lib/patch_ruby/models/parent_technology_type.rb
|
126
127
|
- lib/patch_ruby/models/photo.rb
|
128
|
+
- lib/patch_ruby/models/place_order_request.rb
|
127
129
|
- lib/patch_ruby/models/project.rb
|
128
130
|
- lib/patch_ruby/models/project_list_response.rb
|
129
131
|
- lib/patch_ruby/models/project_response.rb
|
@@ -131,6 +133,7 @@ files:
|
|
131
133
|
- lib/patch_ruby/models/standard.rb
|
132
134
|
- lib/patch_ruby/models/technology_type.rb
|
133
135
|
- lib/patch_ruby/models/technology_type_list_response.rb
|
136
|
+
- lib/patch_ruby/models/v1_orders_issued_to.rb
|
134
137
|
- lib/patch_ruby/version.rb
|
135
138
|
- patch_ruby.gemspec
|
136
139
|
- spec/api/estimates_api_spec.rb
|
@@ -202,48 +205,48 @@ signing_key:
|
|
202
205
|
specification_version: 4
|
203
206
|
summary: Ruby wrapper for the Patch API
|
204
207
|
test_files:
|
208
|
+
- spec/api/technology_types_api_spec.rb
|
209
|
+
- spec/api/estimates_api_spec.rb
|
205
210
|
- spec/api/projects_api_spec.rb
|
206
211
|
- spec/api/orders_api_spec.rb
|
207
|
-
- spec/api/estimates_api_spec.rb
|
208
|
-
- spec/api/technology_types_api_spec.rb
|
209
212
|
- spec/api_client_spec.rb
|
210
213
|
- spec/configuration_spec.rb
|
211
214
|
- spec/constants.rb
|
212
215
|
- spec/factories/estimates.rb
|
216
|
+
- spec/factories/project_responses.rb
|
217
|
+
- spec/factories/estimate_responses.rb
|
213
218
|
- spec/factories/meta_index_objects.rb
|
214
219
|
- spec/factories/order_responses.rb
|
215
|
-
- spec/factories/orders.rb
|
216
|
-
- spec/factories/estimate_responses.rb
|
217
220
|
- spec/factories/project_list_responses.rb
|
218
|
-
- spec/factories/projects.rb
|
219
|
-
- spec/factories/allocations.rb
|
220
221
|
- spec/factories/error_responses.rb
|
221
|
-
- spec/factories/
|
222
|
+
- spec/factories/create_mass_estimate_requests.rb
|
223
|
+
- spec/factories/parent_technology_type.rb
|
224
|
+
- spec/factories/orders.rb
|
225
|
+
- spec/factories/sdgs.rb
|
222
226
|
- spec/factories/create_order_requests.rb
|
227
|
+
- spec/factories/allocations.rb
|
223
228
|
- spec/factories/technology_type.rb
|
229
|
+
- spec/factories/projects.rb
|
224
230
|
- spec/factories/estimate_list_responses.rb
|
225
|
-
- spec/factories/create_mass_estimate_requests.rb
|
226
|
-
- spec/factories/sdgs.rb
|
227
|
-
- spec/factories/parent_technology_type.rb
|
228
231
|
- spec/factories/order_list_responses.rb
|
229
|
-
- spec/integration/estimates_spec.rb
|
230
|
-
- spec/integration/projects/technology_types_spec.rb
|
231
232
|
- spec/integration/projects_spec.rb
|
233
|
+
- spec/integration/projects/technology_types_spec.rb
|
232
234
|
- spec/integration/orders_spec.rb
|
233
|
-
- spec/
|
234
|
-
- spec/models/
|
235
|
-
- spec/models/
|
236
|
-
- spec/models/project_response_spec.rb
|
235
|
+
- spec/integration/estimates_spec.rb
|
236
|
+
- spec/models/meta_index_object_spec.rb
|
237
|
+
- spec/models/estimate_spec.rb
|
237
238
|
- spec/models/estimate_list_response_spec.rb
|
238
239
|
- spec/models/estimate_response_spec.rb
|
239
|
-
- spec/models/
|
240
|
-
- spec/models/estimate_spec.rb
|
240
|
+
- spec/models/project_list_response_spec.rb
|
241
241
|
- spec/models/create_order_request_spec.rb
|
242
|
-
- spec/models/
|
243
|
-
- spec/models/
|
242
|
+
- spec/models/project_spec.rb
|
243
|
+
- spec/models/allocation_spec.rb
|
244
|
+
- spec/models/order_list_response_spec.rb
|
244
245
|
- spec/models/error_response_spec.rb
|
246
|
+
- spec/models/project_response_spec.rb
|
247
|
+
- spec/models/order_spec.rb
|
248
|
+
- spec/models/create_mass_estimate_request_spec.rb
|
245
249
|
- spec/models/order_response_spec.rb
|
246
|
-
- spec/models/allocation_spec.rb
|
247
250
|
- spec/patch_ruby_spec.rb
|
248
251
|
- spec/spec_helper.rb
|
249
252
|
- spec/support/shared/generated_classes.rb
|