patch_ruby 1.20.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 +27 -0
- data/Gemfile.lock +3 -1
- data/README.md +52 -11
- data/lib/patch_ruby/api/orders_api.rb +41 -34
- data/lib/patch_ruby/api/projects_api.rb +6 -0
- 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 +106 -5
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/inventory.rb +294 -0
- data/lib/patch_ruby/models/issued_to.rb +242 -0
- data/lib/patch_ruby/models/order.rb +132 -8
- data/lib/patch_ruby/models/order_inventory.rb +312 -0
- data/lib/patch_ruby/models/order_inventory_project.rb +249 -0
- data/lib/patch_ruby/models/place_order_request.rb +229 -0
- data/lib/patch_ruby/models/project.rb +24 -41
- 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 +6 -0
- data/spec/integration/estimates_spec.rb +3 -3
- data/spec/integration/orders_spec.rb +62 -0
- data/spec/integration/projects_spec.rb +43 -26
- data/spec/models/create_order_request_spec.rb +1 -1
- metadata +31 -25
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,33 @@ 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
|
+
|
14
|
+
## [1.22.0] - 2022-05-16
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Adds support for the `accept_language` option on `projects`, to add support for the `Accept-Language` header.
|
19
|
+
|
20
|
+
## [1.21.0] - 2022-05-03
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Adds optional `total_price` and `currency` field to `order` creation
|
25
|
+
- Adds optional `amount` and `unit` field to `order` creation
|
26
|
+
- Adds inventory to `project` responses
|
27
|
+
- Adds inventory to `order` responses
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
- Deprecates `mass_g` and `total_price_cents_usd` fields for create `order` requests
|
32
|
+
- Deprecates `average_price_per_tonne_cents_usd` and `remaining_mass_g` from `project` responses
|
33
|
+
- Deprecates `price_cents_usd`, `patch_fee_cents_usd`, and `mass_g` from `order` responses
|
34
|
+
|
8
35
|
## [1.20.0] - 2022-04-18
|
9
36
|
|
10
37
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
patch_ruby (1.
|
4
|
+
patch_ruby (1.23.0)
|
5
5
|
typhoeus (~> 1.0, >= 1.0.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -73,6 +73,8 @@ PLATFORMS
|
|
73
73
|
arm64-darwin-20
|
74
74
|
arm64-darwin-21
|
75
75
|
x86_64-darwin-20
|
76
|
+
x86_64-darwin-21
|
77
|
+
x86_64-linux
|
76
78
|
|
77
79
|
DEPENDENCIES
|
78
80
|
factory_bot (~> 6.2)
|
data/README.md
CHANGED
@@ -51,9 +51,9 @@ end
|
|
51
51
|
|
52
52
|
### Orders
|
53
53
|
|
54
|
-
In Patch, orders represent a purchase of carbon offsets or negative emissions by
|
54
|
+
In Patch, orders represent a purchase of carbon offsets or negative emissions by amount. Place orders directly if you know the amount of carbon dioxide you would like to sequester. If you do not know how much to purchase, use an estimate.
|
55
55
|
|
56
|
-
You can also create an order with a maximum desired price, and we'll allocate enough
|
56
|
+
You can also create an order with a maximum desired price, and we'll allocate enough to
|
57
57
|
fulfill the order for you.
|
58
58
|
|
59
59
|
[API Reference](https://docs.patch.io/#/?id=orders)
|
@@ -62,23 +62,31 @@ fulfill the order for you.
|
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
# Create an order - you can create an order
|
65
|
-
# providing either
|
65
|
+
# providing either amount (and unit) or total_price (and currency), but not both
|
66
66
|
|
67
|
-
# Create order with
|
68
|
-
|
69
|
-
|
67
|
+
# Create order with amount
|
68
|
+
amount = 1_000_000 # Pass in the amount in unit specified
|
69
|
+
unit = "g"
|
70
|
+
Patch::Order.create_order(amount: amount, unit: unit)
|
71
|
+
|
72
|
+
# Create an order with total price
|
73
|
+
total_price = 5_00 # Pass in the total price in smallest currency unit (ie cents for USD).
|
74
|
+
currency = "USD"
|
75
|
+
Patch::Order.create_order(total_price: total_price, currency: currency)
|
70
76
|
|
71
|
-
# Create an order with
|
72
|
-
|
73
|
-
|
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)
|
74
82
|
|
75
83
|
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
76
84
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
77
|
-
Patch::Order.create_order(
|
85
|
+
Patch::Order.create_order(amount: amount, unit: unit, project_id: project_id)
|
78
86
|
|
79
87
|
## Orders also accept a metadata field (optional)
|
80
88
|
metadata = {user: "john doe"}
|
81
|
-
Patch::Order.create_order(
|
89
|
+
Patch::Order.create_order(amount: amount, unit: unit, metadata: metadata)
|
82
90
|
|
83
91
|
# Retrieve an order
|
84
92
|
order_id = 'ord_test_1234' # Pass in the order's id
|
@@ -88,6 +96,11 @@ Patch::Order.retrieve_order(order_id)
|
|
88
96
|
order_id = 'ord_test_1234' # Pass in the order's id
|
89
97
|
Patch::Order.place_order(order_id)
|
90
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
|
+
|
91
104
|
# Cancel an order
|
92
105
|
order_id = 'ord_test_1234' # Pass in the order's id
|
93
106
|
Patch::Order.cancel_order(order_id)
|
@@ -187,6 +200,15 @@ Patch::Project.retrieve_projects(type: type)
|
|
187
200
|
# Retrieve a list of projects with at least 100 grams of available offsets
|
188
201
|
minimum_available_mass = 100
|
189
202
|
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
203
|
+
|
204
|
+
# Retrieve a project in a different language
|
205
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
206
|
+
project_id = 'pro_test_1234'
|
207
|
+
Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
208
|
+
|
209
|
+
# Retrieve a list of projects in a different language
|
210
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
211
|
+
Patch::Project.retrieve_projects(accept_language: 'fr')
|
190
212
|
```
|
191
213
|
## Contributing
|
192
214
|
|
@@ -208,6 +230,25 @@ This will create a .gem file. To install the local gem:
|
|
208
230
|
gem install patch_ruby-1.x.x.gem
|
209
231
|
```
|
210
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
|
+
|
211
252
|
### Running tests
|
212
253
|
|
213
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
|
@@ -28,6 +28,7 @@ module Patch
|
|
28
28
|
# Retrieves a project available on Patch's platform.
|
29
29
|
# @param id [String]
|
30
30
|
# @param [Hash] opts the optional parameters
|
31
|
+
# @option opts [String] :accept_language
|
31
32
|
# @return [ProjectResponse]
|
32
33
|
def retrieve_project(id, opts = {})
|
33
34
|
|
@@ -39,6 +40,7 @@ module Patch
|
|
39
40
|
# Retrieves a project available on Patch's platform.
|
40
41
|
# @param id [String]
|
41
42
|
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [String] :accept_language
|
42
44
|
# @return [Array<(ProjectResponse, Integer, Hash)>] ProjectResponse data, response status code and response headers
|
43
45
|
def retrieve_project_with_http_info(id, opts = {})
|
44
46
|
if @api_client.config.debugging
|
@@ -58,6 +60,7 @@ module Patch
|
|
58
60
|
header_params = opts[:header_params] || {}
|
59
61
|
# HTTP header 'Accept' (if needed)
|
60
62
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
63
|
+
header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
|
61
64
|
|
62
65
|
# form parameters
|
63
66
|
form_params = opts[:form_params] || {}
|
@@ -95,6 +98,7 @@ module Patch
|
|
95
98
|
# @option opts [String] :country
|
96
99
|
# @option opts [String] :type
|
97
100
|
# @option opts [Integer] :minimum_available_mass
|
101
|
+
# @option opts [String] :accept_language
|
98
102
|
# @return [ProjectListResponse]
|
99
103
|
def retrieve_projects(opts = {})
|
100
104
|
|
@@ -109,6 +113,7 @@ module Patch
|
|
109
113
|
# @option opts [String] :country
|
110
114
|
# @option opts [String] :type
|
111
115
|
# @option opts [Integer] :minimum_available_mass
|
116
|
+
# @option opts [String] :accept_language
|
112
117
|
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
|
113
118
|
def retrieve_projects_with_http_info(opts = {})
|
114
119
|
if @api_client.config.debugging
|
@@ -128,6 +133,7 @@ module Patch
|
|
128
133
|
header_params = opts[:header_params] || {}
|
129
134
|
# HTTP header 'Accept' (if needed)
|
130
135
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
136
|
+
header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
|
131
137
|
|
132
138
|
# form parameters
|
133
139
|
form_params = opts[:form_params] || {}
|
@@ -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.
|
@@ -27,6 +27,16 @@ module Patch
|
|
27
27
|
|
28
28
|
attr_accessor :vintage_year
|
29
29
|
|
30
|
+
attr_accessor :total_price
|
31
|
+
|
32
|
+
attr_accessor :currency
|
33
|
+
|
34
|
+
attr_accessor :amount
|
35
|
+
|
36
|
+
attr_accessor :unit
|
37
|
+
|
38
|
+
attr_accessor :issued_to
|
39
|
+
|
30
40
|
class EnumAttributeValidator
|
31
41
|
attr_reader :datatype
|
32
42
|
attr_reader :allowable_values
|
@@ -57,7 +67,12 @@ module Patch
|
|
57
67
|
:'project_id' => :'project_id',
|
58
68
|
:'metadata' => :'metadata',
|
59
69
|
:'state' => :'state',
|
60
|
-
:'vintage_year' => :'vintage_year'
|
70
|
+
:'vintage_year' => :'vintage_year',
|
71
|
+
:'total_price' => :'total_price',
|
72
|
+
:'currency' => :'currency',
|
73
|
+
:'amount' => :'amount',
|
74
|
+
:'unit' => :'unit',
|
75
|
+
:'issued_to' => :'issued_to'
|
61
76
|
}
|
62
77
|
end
|
63
78
|
|
@@ -74,7 +89,12 @@ module Patch
|
|
74
89
|
:'project_id' => :'String',
|
75
90
|
:'metadata' => :'Object',
|
76
91
|
:'state' => :'String',
|
77
|
-
:'vintage_year' => :'Integer'
|
92
|
+
:'vintage_year' => :'Integer',
|
93
|
+
:'total_price' => :'Integer',
|
94
|
+
:'currency' => :'String',
|
95
|
+
:'amount' => :'Integer',
|
96
|
+
:'unit' => :'String',
|
97
|
+
:'issued_to' => :'V1OrdersIssuedTo'
|
78
98
|
}
|
79
99
|
end
|
80
100
|
|
@@ -86,7 +106,12 @@ module Patch
|
|
86
106
|
:'project_id',
|
87
107
|
:'metadata',
|
88
108
|
:'state',
|
89
|
-
:'vintage_year'
|
109
|
+
:'vintage_year',
|
110
|
+
:'total_price',
|
111
|
+
:'currency',
|
112
|
+
:'amount',
|
113
|
+
:'unit',
|
114
|
+
:'issued_to'
|
90
115
|
])
|
91
116
|
end
|
92
117
|
|
@@ -140,6 +165,26 @@ module Patch
|
|
140
165
|
if attributes.key?(:'vintage_year')
|
141
166
|
self.vintage_year = attributes[:'vintage_year']
|
142
167
|
end
|
168
|
+
|
169
|
+
if attributes.key?(:'total_price')
|
170
|
+
self.total_price = attributes[:'total_price']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:'currency')
|
174
|
+
self.currency = attributes[:'currency']
|
175
|
+
end
|
176
|
+
|
177
|
+
if attributes.key?(:'amount')
|
178
|
+
self.amount = attributes[:'amount']
|
179
|
+
end
|
180
|
+
|
181
|
+
if attributes.key?(:'unit')
|
182
|
+
self.unit = attributes[:'unit']
|
183
|
+
end
|
184
|
+
|
185
|
+
if attributes.key?(:'issued_to')
|
186
|
+
self.issued_to = attributes[:'issued_to']
|
187
|
+
end
|
143
188
|
end
|
144
189
|
|
145
190
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -166,6 +211,18 @@ module Patch
|
|
166
211
|
invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
|
167
212
|
end
|
168
213
|
|
214
|
+
if !@total_price.nil? && @total_price < 1
|
215
|
+
invalid_properties.push('invalid value for "total_price", must be greater than or equal to 1.')
|
216
|
+
end
|
217
|
+
|
218
|
+
if !@amount.nil? && @amount > 100000000000
|
219
|
+
invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000.')
|
220
|
+
end
|
221
|
+
|
222
|
+
if !@amount.nil? && @amount < 0
|
223
|
+
invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.')
|
224
|
+
end
|
225
|
+
|
169
226
|
invalid_properties
|
170
227
|
end
|
171
228
|
|
@@ -179,6 +236,11 @@ module Patch
|
|
179
236
|
return false unless state_validator.valid?(@state)
|
180
237
|
return false if !@vintage_year.nil? && @vintage_year > 2100
|
181
238
|
return false if !@vintage_year.nil? && @vintage_year < 1900
|
239
|
+
return false if !@total_price.nil? && @total_price < 1
|
240
|
+
return false if !@amount.nil? && @amount > 100000000000
|
241
|
+
return false if !@amount.nil? && @amount < 0
|
242
|
+
unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"])
|
243
|
+
return false unless unit_validator.valid?(@unit)
|
182
244
|
true
|
183
245
|
end
|
184
246
|
|
@@ -230,6 +292,40 @@ module Patch
|
|
230
292
|
@vintage_year = vintage_year
|
231
293
|
end
|
232
294
|
|
295
|
+
# Custom attribute writer method with validation
|
296
|
+
# @param [Object] total_price Value to be assigned
|
297
|
+
def total_price=(total_price)
|
298
|
+
if !total_price.nil? && total_price < 1
|
299
|
+
fail ArgumentError, 'invalid value for "total_price", must be greater than or equal to 1.'
|
300
|
+
end
|
301
|
+
|
302
|
+
@total_price = total_price
|
303
|
+
end
|
304
|
+
|
305
|
+
# Custom attribute writer method with validation
|
306
|
+
# @param [Object] amount Value to be assigned
|
307
|
+
def amount=(amount)
|
308
|
+
if !amount.nil? && amount > 100000000000
|
309
|
+
fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000.'
|
310
|
+
end
|
311
|
+
|
312
|
+
if !amount.nil? && amount < 0
|
313
|
+
fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.'
|
314
|
+
end
|
315
|
+
|
316
|
+
@amount = amount
|
317
|
+
end
|
318
|
+
|
319
|
+
# Custom attribute writer method checking allowed values (enum).
|
320
|
+
# @param [Object] unit Object to be assigned
|
321
|
+
def unit=(unit)
|
322
|
+
validator = EnumAttributeValidator.new('String', ["g", "Wh"])
|
323
|
+
unless validator.valid?(unit)
|
324
|
+
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
325
|
+
end
|
326
|
+
@unit = unit
|
327
|
+
end
|
328
|
+
|
233
329
|
# Checks equality by comparing each attribute.
|
234
330
|
# @param [Object] Object to be compared
|
235
331
|
def ==(o)
|
@@ -240,7 +336,12 @@ module Patch
|
|
240
336
|
project_id == o.project_id &&
|
241
337
|
metadata == o.metadata &&
|
242
338
|
state == o.state &&
|
243
|
-
vintage_year == o.vintage_year
|
339
|
+
vintage_year == o.vintage_year &&
|
340
|
+
total_price == o.total_price &&
|
341
|
+
currency == o.currency &&
|
342
|
+
amount == o.amount &&
|
343
|
+
unit == o.unit &&
|
344
|
+
issued_to == o.issued_to
|
244
345
|
end
|
245
346
|
|
246
347
|
# @see the `==` method
|
@@ -252,7 +353,7 @@ module Patch
|
|
252
353
|
# Calculates hash code according to all attributes.
|
253
354
|
# @return [Integer] Hash code
|
254
355
|
def hash
|
255
|
-
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year].hash
|
356
|
+
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year, total_price, currency, amount, unit, issued_to].hash
|
256
357
|
end
|
257
358
|
|
258
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.
|