patch_ruby 1.0.0 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +78 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +30 -11
- data/Makefile +10 -0
- data/README.md +61 -8
- data/lib/patch_ruby.rb +2 -0
- data/lib/patch_ruby/models/allocation.rb +25 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +48 -4
- data/lib/patch_ruby/models/create_order_request.rb +75 -7
- data/lib/patch_ruby/models/create_preference_request.rb +7 -0
- data/lib/patch_ruby/models/error_response.rb +9 -0
- data/lib/patch_ruby/models/estimate.rb +29 -1
- data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
- data/lib/patch_ruby/models/estimate_response.rb +9 -0
- data/lib/patch_ruby/models/meta_index_object.rb +11 -0
- data/lib/patch_ruby/models/order.rb +105 -4
- data/lib/patch_ruby/models/order_list_response.rb +9 -0
- data/lib/patch_ruby/models/order_response.rb +9 -0
- data/lib/patch_ruby/models/photo.rb +233 -0
- data/lib/patch_ruby/models/preference.rb +25 -0
- data/lib/patch_ruby/models/preference_list_response.rb +9 -0
- data/lib/patch_ruby/models/preference_response.rb +9 -0
- data/lib/patch_ruby/models/project.rb +141 -25
- data/lib/patch_ruby/models/project_list_response.rb +9 -0
- data/lib/patch_ruby/models/project_response.rb +9 -0
- data/lib/patch_ruby/models/standard.rb +254 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/api/estimates_api_spec.rb +6 -7
- data/spec/api/orders_api_spec.rb +10 -11
- data/spec/api/preferences_api_spec.rb +8 -9
- data/spec/api/projects_api_spec.rb +4 -5
- data/spec/constants.rb +3 -0
- data/spec/factories/allocations.rb +7 -0
- data/spec/factories/create_mass_estimate_requests.rb +6 -0
- data/spec/factories/create_order_requests.rb +8 -0
- data/spec/factories/create_preference_requests.rb +5 -0
- data/spec/factories/error_responses.rb +7 -0
- data/spec/factories/estimate_list_responses.rb +8 -0
- data/spec/factories/estimate_responses.rb +7 -0
- data/spec/factories/estimates.rb +8 -0
- data/spec/factories/meta_index_objects.rb +6 -0
- data/spec/factories/order_list_responses.rb +8 -0
- data/spec/factories/order_responses.rb +7 -0
- data/spec/factories/orders.rb +12 -0
- data/spec/factories/preference_list_responses.rb +8 -0
- data/spec/factories/preference_responses.rb +7 -0
- data/spec/factories/preferences.rb +7 -0
- data/spec/factories/project_list_responses.rb +8 -0
- data/spec/factories/project_responses.rb +7 -0
- data/spec/factories/projects.rb +15 -0
- data/spec/integration/estimates_spec.rb +4 -3
- data/spec/integration/orders_spec.rb +60 -1
- data/spec/integration/preferences_spec.rb +1 -1
- data/spec/integration/projects_spec.rb +19 -1
- data/spec/models/allocation_spec.rb +8 -2
- data/spec/models/create_mass_estimate_request_spec.rb +7 -2
- data/spec/models/create_order_request_spec.rb +7 -2
- data/spec/models/create_preference_request_spec.rb +8 -2
- data/spec/models/error_response_spec.rb +7 -2
- data/spec/models/estimate_list_response_spec.rb +7 -2
- data/spec/models/estimate_response_spec.rb +7 -2
- data/spec/models/estimate_spec.rb +8 -2
- data/spec/models/meta_index_object_spec.rb +7 -2
- data/spec/models/order_list_response_spec.rb +7 -2
- data/spec/models/order_response_spec.rb +7 -2
- data/spec/models/order_spec.rb +18 -2
- data/spec/models/preference_list_response_spec.rb +7 -2
- data/spec/models/preference_response_spec.rb +7 -2
- data/spec/models/preference_spec.rb +7 -2
- data/spec/models/project_list_response_spec.rb +7 -2
- data/spec/models/project_response_spec.rb +7 -2
- data/spec/models/project_spec.rb +21 -2
- data/spec/spec_helper.rb +11 -0
- data/spec/support/shared/generated_classes.rb +13 -0
- metadata +61 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 034d244a5779a4ba17a6cdd074f0099905f190ac25fa274b8efc37757b5f6cfc
|
4
|
+
data.tar.gz: acc6a37eb68e11f88e5092ffe666f962d14798d317761e55bf9777707615fb41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c371f8237161ec6fd8be9ddd5e269dc73168718016a5dbc3d3e8a2dca62df9c334171eec45ba8645451c4ee1933b1089844e42fc1002569f43671bac9b01f849
|
7
|
+
data.tar.gz: 8d8c39a9380511af517ad1057da04f1e69997f994cded647d41c4adfe016ec65ac5a5ce73ccac1b5323ae91cf56a88de94736dab8b44d19336cd80a94d276331
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [1.2.5] - 2020-01-08
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- Fixes [issues/5](https://github.com/patch-technology/patch-ruby/issues/5). Adds method `.openapi_nullable` which returns a set with all nullable properties. This method is referenced in `#to_hash` which returns a hash representation of the resource.
|
15
|
+
- Removes non-deterministic integration spec that is creating an Estimate with a specific project-id. Since we do not control the test data (yet) and make queries against our Test projects, we cannot be sure that we will have offsets available for a project ID. Instead we can rely on Patch core specs to cover this.
|
16
|
+
- Fixes a spec that was failing due to a Patch core change.
|
17
|
+
- Add spec factories and refactor generated method specs to shared examples.
|
18
|
+
|
19
|
+
## [1.2.4] - 2020-10-14
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- `total_price_cents_usd` field to `orders`
|
24
|
+
- allows users to create an order by total price
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
|
28
|
+
- order creation requires either `mass_g` or `total_price_cents_usd`, but not both
|
29
|
+
|
30
|
+
## [1.2.3] - 2020-10-05
|
31
|
+
|
32
|
+
### Added
|
33
|
+
|
34
|
+
- `patch_fee_cents_usd` field to `orders`
|
35
|
+
|
36
|
+
## [1.2.2] - 2020-09-18
|
37
|
+
|
38
|
+
### Added
|
39
|
+
|
40
|
+
- `photos` field to `projects`
|
41
|
+
|
42
|
+
## [1.2.1] - 2020-09-18
|
43
|
+
|
44
|
+
### Fixed
|
45
|
+
|
46
|
+
- Fixing an issue related to the OpenApi code generator.
|
47
|
+
|
48
|
+
## [1.2.0] - 2020-09-17
|
49
|
+
|
50
|
+
### Added
|
51
|
+
|
52
|
+
- `average_price_per_tonne_cents_usd` field to `projects`
|
53
|
+
- `remaining_mass_g` field to `projects`
|
54
|
+
- `standard` field to `projects`
|
55
|
+
- validations on `mass_g` field (has to be greater than 1 and less than 2,000,000,000).
|
56
|
+
|
57
|
+
## [1.1.0] - 2020-08-19
|
58
|
+
|
59
|
+
### Added
|
60
|
+
|
61
|
+
- `project_id` optional field to `order` creation
|
62
|
+
- `metadata` optional field to `order` creation
|
63
|
+
- `project_id` optional field to `estimate` creation
|
64
|
+
- changelog file
|
65
|
+
|
66
|
+
## [1.0.0] - 2020-07-05
|
67
|
+
|
68
|
+
### Added
|
69
|
+
|
70
|
+
- This is the first official release of Patch's Ruby Gem.
|
71
|
+
|
72
|
+
## [1.0.0.pre] - 2020-07-02
|
73
|
+
|
74
|
+
### Added
|
75
|
+
|
76
|
+
- Pre-release of v1 Gem
|
77
|
+
- Adds support for Orders, Estimates, Projects and Preferences
|
78
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
patch_ruby (1.
|
4
|
+
patch_ruby (1.2.5)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
typhoeus (~> 1.0, >= 1.0.1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
+
activesupport (6.1.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
11
17
|
ast (2.4.1)
|
12
18
|
byebug (11.1.3)
|
13
19
|
coderay (1.1.3)
|
20
|
+
concurrent-ruby (1.1.7)
|
14
21
|
diff-lcs (1.4.3)
|
15
22
|
ethon (0.12.0)
|
16
23
|
ffi (>= 1.3.0)
|
24
|
+
factory_bot (6.1.0)
|
25
|
+
activesupport (>= 5.0.0)
|
17
26
|
ffi (1.13.1)
|
18
|
-
|
19
|
-
|
27
|
+
i18n (1.8.7)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
json (2.4.1)
|
20
30
|
method_source (1.0.0)
|
31
|
+
minitest (5.14.3)
|
21
32
|
parallel (1.19.2)
|
22
33
|
parser (2.7.1.4)
|
23
34
|
ast (~> 2.4.1)
|
@@ -27,9 +38,10 @@ GEM
|
|
27
38
|
pry-byebug (3.9.0)
|
28
39
|
byebug (~> 11.0)
|
29
40
|
pry (~> 0.13.0)
|
30
|
-
psych (3.1.0)
|
31
41
|
rainbow (3.0.0)
|
32
42
|
rake (13.0.1)
|
43
|
+
regexp_parser (1.7.1)
|
44
|
+
rexml (3.2.4)
|
33
45
|
rspec (3.9.0)
|
34
46
|
rspec-core (~> 3.9.0)
|
35
47
|
rspec-expectations (~> 3.9.0)
|
@@ -43,28 +55,35 @@ GEM
|
|
43
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
56
|
rspec-support (~> 3.9.0)
|
45
57
|
rspec-support (3.9.3)
|
46
|
-
rubocop (0.
|
47
|
-
jaro_winkler (~> 1.5.1)
|
58
|
+
rubocop (0.88.0)
|
48
59
|
parallel (~> 1.10)
|
49
|
-
parser (>= 2.
|
50
|
-
psych (>= 3.1.0)
|
60
|
+
parser (>= 2.7.1.1)
|
51
61
|
rainbow (>= 2.2.2, < 4.0)
|
62
|
+
regexp_parser (>= 1.7)
|
63
|
+
rexml
|
64
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
52
65
|
ruby-progressbar (~> 1.7)
|
53
|
-
unicode-display_width (>= 1.4.0, <
|
66
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
67
|
+
rubocop-ast (0.3.0)
|
68
|
+
parser (>= 2.7.1.4)
|
54
69
|
ruby-progressbar (1.10.1)
|
55
70
|
typhoeus (1.4.0)
|
56
71
|
ethon (>= 0.9.0)
|
57
|
-
|
72
|
+
tzinfo (2.0.4)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
unicode-display_width (1.7.0)
|
75
|
+
zeitwerk (2.4.2)
|
58
76
|
|
59
77
|
PLATFORMS
|
60
78
|
ruby
|
61
79
|
|
62
80
|
DEPENDENCIES
|
81
|
+
factory_bot
|
63
82
|
patch_ruby!
|
64
83
|
pry-byebug
|
65
84
|
rake (~> 13.0.1)
|
66
85
|
rspec (~> 3.6, >= 3.6.0)
|
67
|
-
rubocop
|
86
|
+
rubocop
|
68
87
|
|
69
88
|
BUNDLED WITH
|
70
89
|
2.1.4
|
data/Makefile
ADDED
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Patch Ruby SDK
|
2
2
|
![Test](https://github.com/patch-technology/patch-ruby/workflows/Test/badge.svg)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/patch_ruby.svg)](https://badge.fury.io/rb/patch_ruby)
|
4
|
+
[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)
|
4
5
|
|
5
6
|
The official Ruby gem for the [Patch API](https://www.usepatch.com)
|
6
7
|
|
7
8
|
## Documentation
|
8
|
-
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/
|
9
|
+
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/)
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -37,21 +38,42 @@ require 'patch_ruby'
|
|
37
38
|
|
38
39
|
Patch.configure do |config|
|
39
40
|
# Configure the Patch gem with your API key here
|
40
|
-
config.access_token = ENV['
|
41
|
+
config.access_token = ENV['SANDBOX_API_KEY']
|
41
42
|
end
|
42
43
|
```
|
43
44
|
|
44
45
|
### Orders
|
45
46
|
In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. 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.
|
46
47
|
|
47
|
-
|
48
|
+
In Patch, orders represent a purchase of carbon offsets or negative emissions by mass.
|
49
|
+
Place orders directly if you know the amount of carbon dioxide you would like to sequester.
|
50
|
+
If you do not know how much to purchase, use an estimate.
|
51
|
+
You can also create an order with a maximum desired price, and we'll allocate enough mass to
|
52
|
+
fulfill the order for you.
|
53
|
+
|
54
|
+
[API Reference](https://docs.usepatch.com/#/?id=orders)
|
48
55
|
|
49
56
|
#### Examples
|
50
57
|
```ruby
|
51
|
-
# Create an order
|
58
|
+
# Create an order - you can create an order
|
59
|
+
# providing either mass_g or total_price_cents_usd, but not both
|
60
|
+
|
61
|
+
# Create order with mass
|
52
62
|
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
|
53
63
|
Patch::Order.create_order(mass_g: mass)
|
54
64
|
|
65
|
+
# Create an order with maximum total price
|
66
|
+
total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars)
|
67
|
+
Patch::Order.create_order(total_price_cents_usd: total_price_cents_usd)
|
68
|
+
|
69
|
+
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
70
|
+
project_id = 'pro_test_1234' # Pass in the project's ID
|
71
|
+
Patch::Order.create_order(mass_g: mass, project_id: project_id)
|
72
|
+
|
73
|
+
## Orders also accept a metadata field (optional)
|
74
|
+
metadata = {user: "john doe"}
|
75
|
+
Patch::Order.create_order(mass_g: mass, metadata: metadata)
|
76
|
+
|
55
77
|
# Retrieve an order
|
56
78
|
order_id = 'ord_test_1234' # Pass in the order's id
|
57
79
|
Patch::Order.retrieve_order(order_id)
|
@@ -72,7 +94,7 @@ Patch::Order.retrieve_orders(page: page)
|
|
72
94
|
### Estimates
|
73
95
|
Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled.
|
74
96
|
|
75
|
-
[API Reference](https://docs.usepatch.com
|
97
|
+
[API Reference](https://docs.usepatch.com/#/?id=estimates)
|
76
98
|
|
77
99
|
#### Examples
|
78
100
|
```ruby
|
@@ -80,6 +102,10 @@ Estimates allow API users to get a quote for the cost of compensating a certain
|
|
80
102
|
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
|
81
103
|
Patch::Estimate.create_mass_estimate(mass_g: mass)
|
82
104
|
|
105
|
+
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
106
|
+
project_id = 'pro_test_1234' # Pass in the project's ID
|
107
|
+
Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
|
108
|
+
|
83
109
|
# Retrieve an estimate
|
84
110
|
estimate_id = 'est_test_1234'
|
85
111
|
Patch::Estimate.retrieve_estimate(estimate_id)
|
@@ -92,7 +118,7 @@ Patch::Estimate.retrieve_estimates(page: page)
|
|
92
118
|
### Projects
|
93
119
|
Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.
|
94
120
|
|
95
|
-
[API Reference](https://docs.usepatch.com
|
121
|
+
[API Reference](https://docs.usepatch.com/#/?id=projects)
|
96
122
|
|
97
123
|
#### Examples
|
98
124
|
```ruby
|
@@ -106,9 +132,9 @@ Patch::Project.retrieve_projects(page: page)
|
|
106
132
|
```
|
107
133
|
|
108
134
|
### Preferences
|
109
|
-
Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](dashboard.usepatch.com/projects).
|
135
|
+
Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](https://dashboard.usepatch.com/projects).
|
110
136
|
|
111
|
-
[API Reference](https://docs.usepatch.com
|
137
|
+
[API Reference](https://docs.usepatch.com/#/?id=preferences)
|
112
138
|
|
113
139
|
#### Examples
|
114
140
|
```ruby
|
@@ -128,3 +154,30 @@ Patch::Preference.delete_preference(preference_id)
|
|
128
154
|
page = 1 # Pass in which page of preferences you'd like
|
129
155
|
Patch::Preference.retrieve_preferences(page: page)
|
130
156
|
```
|
157
|
+
|
158
|
+
## Development
|
159
|
+
|
160
|
+
To build the gem locally, run:
|
161
|
+
```
|
162
|
+
$ gem build patch_ruby.gemspec
|
163
|
+
```
|
164
|
+
|
165
|
+
This will create a .gem file. To install the local gem:
|
166
|
+
```
|
167
|
+
$ gem install patch_ruby-1.x.x.gem
|
168
|
+
```
|
169
|
+
|
170
|
+
Install dependencies:
|
171
|
+
```
|
172
|
+
$ bundle install
|
173
|
+
```
|
174
|
+
|
175
|
+
Set up required environment variables:
|
176
|
+
```
|
177
|
+
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
|
178
|
+
```
|
179
|
+
|
180
|
+
Run tests:
|
181
|
+
```
|
182
|
+
$ bundle exec rspec
|
183
|
+
```
|
data/lib/patch_ruby.rb
CHANGED
@@ -29,12 +29,14 @@ require 'patch_ruby/models/meta_index_object'
|
|
29
29
|
require 'patch_ruby/models/order'
|
30
30
|
require 'patch_ruby/models/order_list_response'
|
31
31
|
require 'patch_ruby/models/order_response'
|
32
|
+
require 'patch_ruby/models/photo'
|
32
33
|
require 'patch_ruby/models/preference'
|
33
34
|
require 'patch_ruby/models/preference_list_response'
|
34
35
|
require 'patch_ruby/models/preference_response'
|
35
36
|
require 'patch_ruby/models/project'
|
36
37
|
require 'patch_ruby/models/project_list_response'
|
37
38
|
require 'patch_ruby/models/project_response'
|
39
|
+
require 'patch_ruby/models/standard'
|
38
40
|
|
39
41
|
# APIs
|
40
42
|
require 'patch_ruby/api/estimates_api'
|
@@ -14,10 +14,13 @@ require 'date'
|
|
14
14
|
|
15
15
|
module Patch
|
16
16
|
class Allocation
|
17
|
+
# A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in.
|
17
18
|
attr_accessor :id
|
18
19
|
|
20
|
+
# A boolean indicating if this project is a production or test mode project.
|
19
21
|
attr_accessor :production
|
20
22
|
|
23
|
+
# The amount (in grams) of allocated carbon offsets.
|
21
24
|
attr_accessor :mass_g
|
22
25
|
|
23
26
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -38,6 +41,13 @@ module Patch
|
|
38
41
|
}
|
39
42
|
end
|
40
43
|
|
44
|
+
# Set with nullable attributes.
|
45
|
+
def self.openapi_nullable
|
46
|
+
nullable_properties = Set.new
|
47
|
+
|
48
|
+
nullable_properties
|
49
|
+
end
|
50
|
+
|
41
51
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
42
52
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
43
53
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -81,12 +91,27 @@ module Patch
|
|
81
91
|
# @return Array for valid properties with the reasons
|
82
92
|
def list_invalid_properties
|
83
93
|
invalid_properties = Array.new
|
94
|
+
if @id.nil?
|
95
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
96
|
+
end
|
97
|
+
|
98
|
+
if @production.nil?
|
99
|
+
invalid_properties.push('invalid value for "production", production cannot be nil.')
|
100
|
+
end
|
101
|
+
|
102
|
+
if @mass_g.nil?
|
103
|
+
invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
|
104
|
+
end
|
105
|
+
|
84
106
|
invalid_properties
|
85
107
|
end
|
86
108
|
|
87
109
|
# Check to see if the all the properties in the model are valid
|
88
110
|
# @return true if the model is valid
|
89
111
|
def valid?
|
112
|
+
return false if @id.nil?
|
113
|
+
return false if @production.nil?
|
114
|
+
return false if @mass_g.nil?
|
90
115
|
true
|
91
116
|
end
|
92
117
|
|
@@ -16,20 +16,31 @@ module Patch
|
|
16
16
|
class CreateMassEstimateRequest
|
17
17
|
attr_accessor :mass_g
|
18
18
|
|
19
|
+
attr_accessor :project_id
|
20
|
+
|
19
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
20
22
|
def self.attribute_map
|
21
23
|
{
|
22
|
-
:'mass_g' => :'mass_g'
|
24
|
+
:'mass_g' => :'mass_g',
|
25
|
+
:'project_id' => :'project_id'
|
23
26
|
}
|
24
27
|
end
|
25
28
|
|
26
29
|
# Attribute type mapping.
|
27
30
|
def self.openapi_types
|
28
31
|
{
|
29
|
-
:'mass_g' => :'Integer'
|
32
|
+
:'mass_g' => :'Integer',
|
33
|
+
:'project_id' => :'String'
|
30
34
|
}
|
31
35
|
end
|
32
36
|
|
37
|
+
# Set with nullable attributes.
|
38
|
+
def self.openapi_nullable
|
39
|
+
nullable_properties = Set.new
|
40
|
+
|
41
|
+
nullable_properties
|
42
|
+
end
|
43
|
+
|
33
44
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
34
45
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
35
46
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
@@ -59,6 +70,10 @@ module Patch
|
|
59
70
|
if attributes.key?(:'mass_g')
|
60
71
|
self.mass_g = attributes[:'mass_g']
|
61
72
|
end
|
73
|
+
|
74
|
+
if attributes.key?(:'project_id')
|
75
|
+
self.project_id = attributes[:'project_id']
|
76
|
+
end
|
62
77
|
end
|
63
78
|
|
64
79
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -69,6 +84,14 @@ module Patch
|
|
69
84
|
invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
|
70
85
|
end
|
71
86
|
|
87
|
+
if @mass_g > 2000000000
|
88
|
+
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
|
89
|
+
end
|
90
|
+
|
91
|
+
if @mass_g < 1
|
92
|
+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
|
93
|
+
end
|
94
|
+
|
72
95
|
invalid_properties
|
73
96
|
end
|
74
97
|
|
@@ -76,15 +99,36 @@ module Patch
|
|
76
99
|
# @return true if the model is valid
|
77
100
|
def valid?
|
78
101
|
return false if @mass_g.nil?
|
102
|
+
return false if @mass_g > 2000000000
|
103
|
+
return false if @mass_g < 1
|
79
104
|
true
|
80
105
|
end
|
81
106
|
|
107
|
+
# Custom attribute writer method with validation
|
108
|
+
# @param [Object] mass_g Value to be assigned
|
109
|
+
def mass_g=(mass_g)
|
110
|
+
if mass_g.nil?
|
111
|
+
fail ArgumentError, 'mass_g cannot be nil'
|
112
|
+
end
|
113
|
+
|
114
|
+
if mass_g > 2000000000
|
115
|
+
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
|
116
|
+
end
|
117
|
+
|
118
|
+
if mass_g < 1
|
119
|
+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
|
120
|
+
end
|
121
|
+
|
122
|
+
@mass_g = mass_g
|
123
|
+
end
|
124
|
+
|
82
125
|
# Checks equality by comparing each attribute.
|
83
126
|
# @param [Object] Object to be compared
|
84
127
|
def ==(o)
|
85
128
|
return true if self.equal?(o)
|
86
129
|
self.class == o.class &&
|
87
|
-
mass_g == o.mass_g
|
130
|
+
mass_g == o.mass_g &&
|
131
|
+
project_id == o.project_id
|
88
132
|
end
|
89
133
|
|
90
134
|
# @see the `==` method
|
@@ -96,7 +140,7 @@ module Patch
|
|
96
140
|
# Calculates hash code according to all attributes.
|
97
141
|
# @return [Integer] Hash code
|
98
142
|
def hash
|
99
|
-
[mass_g].hash
|
143
|
+
[mass_g, project_id].hash
|
100
144
|
end
|
101
145
|
|
102
146
|
# Builds the object from hash
|