patch_ruby 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +13 -10
  5. data/README.md +41 -1
  6. data/lib/patch_ruby/models/allocation.rb +15 -0
  7. data/lib/patch_ruby/models/create_mass_estimate_request.rb +13 -4
  8. data/lib/patch_ruby/models/create_order_request.rb +22 -4
  9. data/lib/patch_ruby/models/estimate.rb +15 -0
  10. data/lib/patch_ruby/models/order.rb +48 -4
  11. data/lib/patch_ruby/models/preference.rb +15 -0
  12. data/lib/patch_ruby/models/project.rb +73 -27
  13. data/lib/patch_ruby/version.rb +1 -1
  14. data/spec/api/estimates_api_spec.rb +6 -7
  15. data/spec/api/orders_api_spec.rb +10 -11
  16. data/spec/api/preferences_api_spec.rb +8 -9
  17. data/spec/api/projects_api_spec.rb +4 -5
  18. data/spec/integration/estimates_spec.rb +14 -2
  19. data/spec/integration/orders_spec.rb +22 -0
  20. data/spec/models/allocation_spec.rb +0 -1
  21. data/spec/models/create_mass_estimate_request_spec.rb +0 -1
  22. data/spec/models/create_order_request_spec.rb +0 -1
  23. data/spec/models/create_preference_request_spec.rb +0 -1
  24. data/spec/models/error_response_spec.rb +0 -1
  25. data/spec/models/estimate_list_response_spec.rb +0 -1
  26. data/spec/models/estimate_response_spec.rb +0 -1
  27. data/spec/models/estimate_spec.rb +0 -1
  28. data/spec/models/meta_index_object_spec.rb +0 -1
  29. data/spec/models/order_list_response_spec.rb +0 -1
  30. data/spec/models/order_response_spec.rb +0 -1
  31. data/spec/models/order_spec.rb +0 -1
  32. data/spec/models/preference_list_response_spec.rb +0 -1
  33. data/spec/models/preference_response_spec.rb +0 -1
  34. data/spec/models/preference_spec.rb +0 -1
  35. data/spec/models/project_list_response_spec.rb +0 -1
  36. data/spec/models/project_response_spec.rb +0 -1
  37. data/spec/models/project_spec.rb +0 -1
  38. metadata +21 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4c502af4271525d9883ffe131279f065edd0a089adcb0acc104271ee427e86a
4
- data.tar.gz: 0ec3666b9e93a7ad36a810c3d07ed53e1a46162eb566c04f473a572646881405
3
+ metadata.gz: 7d57ecb3d4eed4573df5b34a2fe8b15abff918db6d50343d483a94daeb832ef0
4
+ data.tar.gz: 01ef9aced2b39b3fc83e4139682bf2ef4671cd5a1cf22c04486bb5005a8fae50
5
5
  SHA512:
6
- metadata.gz: bcd3e4e634cb5faeeedcc9d3516b075858738d43cb8c1565000b15f95f2539a60d28e48df695030c31499fbeb83e06540a7f485fff4ddc27786ff01028795a9f
7
- data.tar.gz: eb808b4ca051b0922ffbcb9a98cd50be35795d0beaa01d3bc0811cf39eca0744dc249a4cd289e98761bb1e30673b880eabc135262e0008ac24c7421880a08013
6
+ metadata.gz: 915adff1e3f63bd96b7cf1c360914faa8f2bb4d901e8960c459c0f74134385c72906f5eb9f06d4d51cccdc023b01a618c1a438a049b8fa1f39e4373682ec711a
7
+ data.tar.gz: 3f16c440a5d2e67c4dc864605d6201b9fb10f0c6c28fd10b821b76758b36b8a319a990f124218515265621550f3db273bd75359b6a4579af3bb132b85d4b994f
@@ -0,0 +1,31 @@
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.1.0] - 2020-08-19
11
+
12
+ ### Added
13
+
14
+ - `project_id` optional field to `order` creation
15
+ - `metadata` optional field to `order` creation
16
+ - `project_id` optional field to `estimate` creation
17
+ - changelog file
18
+
19
+ ## [1.0.0] - 2020-07-05
20
+
21
+ ### Added
22
+
23
+ - This is the first official release of Patch's Ruby Gem.
24
+
25
+ ## [1.0.0.pre] - 2020-07-02
26
+
27
+ ### Added
28
+
29
+ - Pre-release of v1 Gem
30
+ - Adds support for Orders, Estimates, Projects and Preferences
31
+
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ gemspec
5
5
  group :development, :test do
6
6
  gem 'rake', '~> 13.0.1'
7
7
  gem 'pry-byebug'
8
- gem 'rubocop', '~> 0.66.0'
8
+ gem 'rubocop'
9
9
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.0.0.pre)
4
+ patch_ruby (1.1.0)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -15,7 +15,6 @@ GEM
15
15
  ethon (0.12.0)
16
16
  ffi (>= 1.3.0)
17
17
  ffi (1.13.1)
18
- jaro_winkler (1.5.4)
19
18
  json (2.3.1)
20
19
  method_source (1.0.0)
21
20
  parallel (1.19.2)
@@ -27,9 +26,10 @@ GEM
27
26
  pry-byebug (3.9.0)
28
27
  byebug (~> 11.0)
29
28
  pry (~> 0.13.0)
30
- psych (3.1.0)
31
29
  rainbow (3.0.0)
32
30
  rake (13.0.1)
31
+ regexp_parser (1.7.1)
32
+ rexml (3.2.4)
33
33
  rspec (3.9.0)
34
34
  rspec-core (~> 3.9.0)
35
35
  rspec-expectations (~> 3.9.0)
@@ -43,18 +43,21 @@ GEM
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
44
  rspec-support (~> 3.9.0)
45
45
  rspec-support (3.9.3)
46
- rubocop (0.66.0)
47
- jaro_winkler (~> 1.5.1)
46
+ rubocop (0.88.0)
48
47
  parallel (~> 1.10)
49
- parser (>= 2.5, != 2.5.1.1)
50
- psych (>= 3.1.0)
48
+ parser (>= 2.7.1.1)
51
49
  rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 1.7)
51
+ rexml
52
+ rubocop-ast (>= 0.1.0, < 1.0)
52
53
  ruby-progressbar (~> 1.7)
53
- unicode-display_width (>= 1.4.0, < 1.6)
54
+ unicode-display_width (>= 1.4.0, < 2.0)
55
+ rubocop-ast (0.3.0)
56
+ parser (>= 2.7.1.4)
54
57
  ruby-progressbar (1.10.1)
55
58
  typhoeus (1.4.0)
56
59
  ethon (>= 0.9.0)
57
- unicode-display_width (1.5.0)
60
+ unicode-display_width (1.7.0)
58
61
 
59
62
  PLATFORMS
60
63
  ruby
@@ -64,7 +67,7 @@ DEPENDENCIES
64
67
  pry-byebug
65
68
  rake (~> 13.0.1)
66
69
  rspec (~> 3.6, >= 3.6.0)
67
- rubocop (~> 0.66.0)
70
+ rubocop
68
71
 
69
72
  BUNDLED WITH
70
73
  2.1.4
data/README.md CHANGED
@@ -1,6 +1,7 @@
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
 
@@ -52,6 +53,14 @@ In Patch, orders represent a purchase of carbon offsets or negative emissions by
52
53
  mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
53
54
  Patch::Order.create_order(mass_g: mass)
54
55
 
56
+ ## You can also specify a project-id field (optional) to be used instead of the preferred one
57
+ project_id = 'pro_test_1234' # Pass in the project's ID
58
+ Patch::Order.create_order(mass_g: mass, project_id: project_id)
59
+
60
+ ## Orders also accept a metadata field (optional)
61
+ metadata = {user: "john doe"}
62
+ Patch::Order.create_order(mass_g: mass, metadata: metadata)
63
+
55
64
  # Retrieve an order
56
65
  order_id = 'ord_test_1234' # Pass in the order's id
57
66
  Patch::Order.retrieve_order(order_id)
@@ -80,6 +89,10 @@ Estimates allow API users to get a quote for the cost of compensating a certain
80
89
  mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
81
90
  Patch::Estimate.create_mass_estimate(mass_g: mass)
82
91
 
92
+ ## You can also specify a project-id field (optional) to be used instead of the preferred one
93
+ project_id = 'pro_test_1234' # Pass in the project's ID
94
+ Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
95
+
83
96
  # Retrieve an estimate
84
97
  estimate_id = 'est_test_1234'
85
98
  Patch::Estimate.retrieve_estimate(estimate_id)
@@ -106,7 +119,7 @@ Patch::Project.retrieve_projects(page: page)
106
119
  ```
107
120
 
108
121
  ### 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).
122
+ 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
123
 
111
124
  [API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1preferences/post)
112
125
 
@@ -128,3 +141,30 @@ Patch::Preference.delete_preference(preference_id)
128
141
  page = 1 # Pass in which page of preferences you'd like
129
142
  Patch::Preference.retrieve_preferences(page: page)
130
143
  ```
144
+
145
+ ## Development
146
+
147
+ To build the gem locally, run:
148
+ ```
149
+ $ gem build patch_ruby.gemspec
150
+ ```
151
+
152
+ This will create a .gem file. To install the local gem:
153
+ ```
154
+ $ gem install patch_ruby-1.x.x.gem
155
+ ```
156
+
157
+ Install dependencies:
158
+ ```
159
+ $ bundle install
160
+ ```
161
+
162
+ Set up required environment variables:
163
+ ```
164
+ $ export PATCH_RUBY_API_KEY=<SANDBOX API KEY>
165
+ ```
166
+
167
+ Run tests:
168
+ ```
169
+ $ bundle exec rspec
170
+ ```
@@ -81,12 +81,27 @@ module Patch
81
81
  # @return Array for valid properties with the reasons
82
82
  def list_invalid_properties
83
83
  invalid_properties = Array.new
84
+ if @id.nil?
85
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
86
+ end
87
+
88
+ if @production.nil?
89
+ invalid_properties.push('invalid value for "production", production cannot be nil.')
90
+ end
91
+
92
+ if @mass_g.nil?
93
+ invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
94
+ end
95
+
84
96
  invalid_properties
85
97
  end
86
98
 
87
99
  # Check to see if the all the properties in the model are valid
88
100
  # @return true if the model is valid
89
101
  def valid?
102
+ return false if @id.nil?
103
+ return false if @production.nil?
104
+ return false if @mass_g.nil?
90
105
  true
91
106
  end
92
107
 
@@ -16,17 +16,21 @@ 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
 
@@ -59,6 +63,10 @@ module Patch
59
63
  if attributes.key?(:'mass_g')
60
64
  self.mass_g = attributes[:'mass_g']
61
65
  end
66
+
67
+ if attributes.key?(:'project_id')
68
+ self.project_id = attributes[:'project_id']
69
+ end
62
70
  end
63
71
 
64
72
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -84,7 +92,8 @@ module Patch
84
92
  def ==(o)
85
93
  return true if self.equal?(o)
86
94
  self.class == o.class &&
87
- mass_g == o.mass_g
95
+ mass_g == o.mass_g &&
96
+ project_id == o.project_id
88
97
  end
89
98
 
90
99
  # @see the `==` method
@@ -96,7 +105,7 @@ module Patch
96
105
  # Calculates hash code according to all attributes.
97
106
  # @return [Integer] Hash code
98
107
  def hash
99
- [mass_g].hash
108
+ [mass_g, project_id].hash
100
109
  end
101
110
 
102
111
  # Builds the object from hash
@@ -16,17 +16,25 @@ module Patch
16
16
  class CreateOrderRequest
17
17
  attr_accessor :mass_g
18
18
 
19
+ attr_accessor :project_id
20
+
21
+ attr_accessor :metadata
22
+
19
23
  # Attribute mapping from ruby-style variable name to JSON key.
20
24
  def self.attribute_map
21
25
  {
22
- :'mass_g' => :'mass_g'
26
+ :'mass_g' => :'mass_g',
27
+ :'project_id' => :'project_id',
28
+ :'metadata' => :'metadata'
23
29
  }
24
30
  end
25
31
 
26
32
  # Attribute type mapping.
27
33
  def self.openapi_types
28
34
  {
29
- :'mass_g' => :'Integer'
35
+ :'mass_g' => :'Integer',
36
+ :'project_id' => :'String',
37
+ :'metadata' => :'Object'
30
38
  }
31
39
  end
32
40
 
@@ -59,6 +67,14 @@ module Patch
59
67
  if attributes.key?(:'mass_g')
60
68
  self.mass_g = attributes[:'mass_g']
61
69
  end
70
+
71
+ if attributes.key?(:'project_id')
72
+ self.project_id = attributes[:'project_id']
73
+ end
74
+
75
+ if attributes.key?(:'metadata')
76
+ self.metadata = attributes[:'metadata']
77
+ end
62
78
  end
63
79
 
64
80
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -84,7 +100,9 @@ module Patch
84
100
  def ==(o)
85
101
  return true if self.equal?(o)
86
102
  self.class == o.class &&
87
- mass_g == o.mass_g
103
+ mass_g == o.mass_g &&
104
+ project_id == o.project_id &&
105
+ metadata == o.metadata
88
106
  end
89
107
 
90
108
  # @see the `==` method
@@ -96,7 +114,7 @@ module Patch
96
114
  # Calculates hash code according to all attributes.
97
115
  # @return [Integer] Hash code
98
116
  def hash
99
- [mass_g].hash
117
+ [mass_g, project_id, metadata].hash
100
118
  end
101
119
 
102
120
  # Builds the object from hash
@@ -89,12 +89,27 @@ module Patch
89
89
  # @return Array for valid properties with the reasons
90
90
  def list_invalid_properties
91
91
  invalid_properties = Array.new
92
+ if @id.nil?
93
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
94
+ end
95
+
96
+ if @production.nil?
97
+ invalid_properties.push('invalid value for "production", production cannot be nil.')
98
+ end
99
+
100
+ if @type.nil?
101
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
102
+ end
103
+
92
104
  invalid_properties
93
105
  end
94
106
 
95
107
  # Check to see if the all the properties in the model are valid
96
108
  # @return true if the model is valid
97
109
  def valid?
110
+ return false if @id.nil?
111
+ return false if @production.nil?
112
+ return false if @type.nil?
98
113
  true
99
114
  end
100
115
 
@@ -28,6 +28,8 @@ module Patch
28
28
 
29
29
  attr_accessor :allocations
30
30
 
31
+ attr_accessor :metadata
32
+
31
33
  class EnumAttributeValidator
32
34
  attr_reader :datatype
33
35
  attr_reader :allowable_values
@@ -59,7 +61,8 @@ module Patch
59
61
  :'state' => :'state',
60
62
  :'allocation_state' => :'allocation_state',
61
63
  :'price_cents_usd' => :'price_cents_usd',
62
- :'allocations' => :'allocations'
64
+ :'allocations' => :'allocations',
65
+ :'metadata' => :'metadata'
63
66
  }
64
67
  end
65
68
 
@@ -72,7 +75,8 @@ module Patch
72
75
  :'state' => :'String',
73
76
  :'allocation_state' => :'String',
74
77
  :'price_cents_usd' => :'String',
75
- :'allocations' => :'Array<Allocation>'
78
+ :'allocations' => :'Array<Allocation>',
79
+ :'metadata' => :'Object'
76
80
  }
77
81
  end
78
82
 
@@ -131,22 +135,61 @@ module Patch
131
135
  self.allocations = value
132
136
  end
133
137
  end
138
+
139
+ if attributes.key?(:'metadata')
140
+ self.metadata = attributes[:'metadata']
141
+ end
134
142
  end
135
143
 
136
144
  # Show invalid properties with the reasons. Usually used together with valid?
137
145
  # @return Array for valid properties with the reasons
138
146
  def list_invalid_properties
139
147
  invalid_properties = Array.new
148
+ if @id.nil?
149
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
150
+ end
151
+
152
+ if @mass_g.nil?
153
+ invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
154
+ end
155
+
156
+ if @production.nil?
157
+ invalid_properties.push('invalid value for "production", production cannot be nil.')
158
+ end
159
+
160
+ if @state.nil?
161
+ invalid_properties.push('invalid value for "state", state cannot be nil.')
162
+ end
163
+
164
+ if @allocation_state.nil?
165
+ invalid_properties.push('invalid value for "allocation_state", allocation_state cannot be nil.')
166
+ end
167
+
168
+ if @allocations.nil?
169
+ invalid_properties.push('invalid value for "allocations", allocations cannot be nil.')
170
+ end
171
+
172
+ if @metadata.nil?
173
+ invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
174
+ end
175
+
140
176
  invalid_properties
141
177
  end
142
178
 
143
179
  # Check to see if the all the properties in the model are valid
144
180
  # @return true if the model is valid
145
181
  def valid?
182
+ return false if @id.nil?
183
+ return false if @mass_g.nil?
184
+ return false if @production.nil?
185
+ return false if @state.nil?
146
186
  state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "complete", "cancelled"])
147
187
  return false unless state_validator.valid?(@state)
188
+ return false if @allocation_state.nil?
148
189
  allocation_state_validator = EnumAttributeValidator.new('String', ["pending", "partially_allocated", "allocated"])
149
190
  return false unless allocation_state_validator.valid?(@allocation_state)
191
+ return false if @allocations.nil?
192
+ return false if @metadata.nil?
150
193
  true
151
194
  end
152
195
 
@@ -181,7 +224,8 @@ module Patch
181
224
  state == o.state &&
182
225
  allocation_state == o.allocation_state &&
183
226
  price_cents_usd == o.price_cents_usd &&
184
- allocations == o.allocations
227
+ allocations == o.allocations &&
228
+ metadata == o.metadata
185
229
  end
186
230
 
187
231
  # @see the `==` method
@@ -193,7 +237,7 @@ module Patch
193
237
  # Calculates hash code according to all attributes.
194
238
  # @return [Integer] Hash code
195
239
  def hash
196
- [id, mass_g, production, state, allocation_state, price_cents_usd, allocations].hash
240
+ [id, mass_g, production, state, allocation_state, price_cents_usd, allocations, metadata].hash
197
241
  end
198
242
 
199
243
  # Builds the object from hash
@@ -81,12 +81,27 @@ module Patch
81
81
  # @return Array for valid properties with the reasons
82
82
  def list_invalid_properties
83
83
  invalid_properties = Array.new
84
+ if @id.nil?
85
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
86
+ end
87
+
88
+ if @allocation_percentage.nil?
89
+ invalid_properties.push('invalid value for "allocation_percentage", allocation_percentage cannot be nil.')
90
+ end
91
+
92
+ if @project.nil?
93
+ invalid_properties.push('invalid value for "project", project cannot be nil.')
94
+ end
95
+
84
96
  invalid_properties
85
97
  end
86
98
 
87
99
  # Check to see if the all the properties in the model are valid
88
100
  # @return true if the model is valid
89
101
  def valid?
102
+ return false if @id.nil?
103
+ return false if @allocation_percentage.nil?
104
+ return false if @project.nil?
90
105
  true
91
106
  end
92
107
 
@@ -22,15 +22,33 @@ module Patch
22
22
 
23
23
  attr_accessor :description
24
24
 
25
- attr_accessor :country
25
+ attr_accessor :type
26
26
 
27
- attr_accessor :longitude
27
+ attr_accessor :country
28
28
 
29
- attr_accessor :latitude
29
+ attr_accessor :developer
30
30
 
31
- attr_accessor :verifier
31
+ class EnumAttributeValidator
32
+ attr_reader :datatype
33
+ attr_reader :allowable_values
34
+
35
+ def initialize(datatype, allowable_values)
36
+ @allowable_values = allowable_values.map do |value|
37
+ case datatype.to_s
38
+ when /Integer/i
39
+ value.to_i
40
+ when /Float/i
41
+ value.to_f
42
+ else
43
+ value
44
+ end
45
+ end
46
+ end
32
47
 
33
- attr_accessor :developer
48
+ def valid?(value)
49
+ !value || allowable_values.include?(value)
50
+ end
51
+ end
34
52
 
35
53
  # Attribute mapping from ruby-style variable name to JSON key.
36
54
  def self.attribute_map
@@ -39,10 +57,8 @@ module Patch
39
57
  :'production' => :'production',
40
58
  :'name' => :'name',
41
59
  :'description' => :'description',
60
+ :'type' => :'type',
42
61
  :'country' => :'country',
43
- :'longitude' => :'longitude',
44
- :'latitude' => :'latitude',
45
- :'verifier' => :'verifier',
46
62
  :'developer' => :'developer'
47
63
  }
48
64
  end
@@ -54,10 +70,8 @@ module Patch
54
70
  :'production' => :'Boolean',
55
71
  :'name' => :'String',
56
72
  :'description' => :'String',
73
+ :'type' => :'String',
57
74
  :'country' => :'String',
58
- :'longitude' => :'Float',
59
- :'latitude' => :'Float',
60
- :'verifier' => :'String',
61
75
  :'developer' => :'String'
62
76
  }
63
77
  end
@@ -104,20 +118,12 @@ module Patch
104
118
  self.description = attributes[:'description']
105
119
  end
106
120
 
107
- if attributes.key?(:'country')
108
- self.country = attributes[:'country']
109
- end
110
-
111
- if attributes.key?(:'longitude')
112
- self.longitude = attributes[:'longitude']
113
- end
114
-
115
- if attributes.key?(:'latitude')
116
- self.latitude = attributes[:'latitude']
121
+ if attributes.key?(:'type')
122
+ self.type = attributes[:'type']
117
123
  end
118
124
 
119
- if attributes.key?(:'verifier')
120
- self.verifier = attributes[:'verifier']
125
+ if attributes.key?(:'country')
126
+ self.country = attributes[:'country']
121
127
  end
122
128
 
123
129
  if attributes.key?(:'developer')
@@ -129,15 +135,57 @@ module Patch
129
135
  # @return Array for valid properties with the reasons
130
136
  def list_invalid_properties
131
137
  invalid_properties = Array.new
138
+ if @id.nil?
139
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
140
+ end
141
+
142
+ if @production.nil?
143
+ invalid_properties.push('invalid value for "production", production cannot be nil.')
144
+ end
145
+
146
+ if @name.nil?
147
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
148
+ end
149
+
150
+ if @description.nil?
151
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
152
+ end
153
+
154
+ if @country.nil?
155
+ invalid_properties.push('invalid value for "country", country cannot be nil.')
156
+ end
157
+
158
+ if @developer.nil?
159
+ invalid_properties.push('invalid value for "developer", developer cannot be nil.')
160
+ end
161
+
132
162
  invalid_properties
133
163
  end
134
164
 
135
165
  # Check to see if the all the properties in the model are valid
136
166
  # @return true if the model is valid
137
167
  def valid?
168
+ return false if @id.nil?
169
+ return false if @production.nil?
170
+ return false if @name.nil?
171
+ return false if @description.nil?
172
+ type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
173
+ return false unless type_validator.valid?(@type)
174
+ return false if @country.nil?
175
+ return false if @developer.nil?
138
176
  true
139
177
  end
140
178
 
179
+ # Custom attribute writer method checking allowed values (enum).
180
+ # @param [Object] type Object to be assigned
181
+ def type=(type)
182
+ validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
183
+ unless validator.valid?(type)
184
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
185
+ end
186
+ @type = type
187
+ end
188
+
141
189
  # Checks equality by comparing each attribute.
142
190
  # @param [Object] Object to be compared
143
191
  def ==(o)
@@ -147,10 +195,8 @@ module Patch
147
195
  production == o.production &&
148
196
  name == o.name &&
149
197
  description == o.description &&
198
+ type == o.type &&
150
199
  country == o.country &&
151
- longitude == o.longitude &&
152
- latitude == o.latitude &&
153
- verifier == o.verifier &&
154
200
  developer == o.developer
155
201
  end
156
202
 
@@ -163,7 +209,7 @@ module Patch
163
209
  # Calculates hash code according to all attributes.
164
210
  # @return [Integer] Hash code
165
211
  def hash
166
- [id, production, name, description, country, longitude, latitude, verifier, developer].hash
212
+ [id, production, name, description, type, country, developer].hash
167
213
  end
168
214
 
169
215
  # Builds the object from hash
@@ -11,5 +11,5 @@ OpenAPI Generator version: 4.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.0.0'
14
+ VERSION = '1.1.0'
15
15
  end
@@ -34,8 +34,8 @@ describe 'EstimatesApi' do
34
34
 
35
35
  # unit tests for create_mass_estimate
36
36
  # Create an estimate based on mass of CO2
37
- # Creates an estimate for the mass of CO2 to be compensated. An order in the &#x60;draft&#x60; state will also be created, linked to the estimate.
38
- # @param create_mass_estimate_request
37
+ # Creates an estimate for the mass of CO2 to be compensated. An order in the &#x60;draft&#x60; state will also be created, linked to the estimate.
38
+ # @param create_mass_estimate_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [EstimateResponse]
41
41
  describe 'create_mass_estimate test' do
@@ -46,8 +46,8 @@ describe 'EstimatesApi' do
46
46
 
47
47
  # unit tests for retrieve_estimate
48
48
  # Retrieves an estimate
49
- # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
- # @param id
49
+ # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [EstimateResponse]
53
53
  describe 'retrieve_estimate test' do
@@ -58,14 +58,13 @@ describe 'EstimatesApi' do
58
58
 
59
59
  # unit tests for retrieve_estimates
60
60
  # Retrieves a list of estimates
61
- # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
61
+ # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
62
62
  # @param [Hash] opts the optional parameters
63
- # @option opts [Integer] :page
63
+ # @option opts [Integer] :page
64
64
  # @return [EstimateListResponse]
65
65
  describe 'retrieve_estimates test' do
66
66
  it 'should work' do
67
67
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
68
  end
69
69
  end
70
-
71
70
  end
@@ -34,8 +34,8 @@ describe 'OrdersApi' do
34
34
 
35
35
  # unit tests for cancel_order
36
36
  # Cancel an order
37
- # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the &#x60;draft&#x60; state can be cancelled.
38
- # @param id
37
+ # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the &#x60;draft&#x60; state can be cancelled.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [OrderResponse]
41
41
  describe 'cancel_order test' do
@@ -46,8 +46,8 @@ describe 'OrdersApi' do
46
46
 
47
47
  # unit tests for create_order
48
48
  # Creates an order
49
- # Creates an order in the &#x60;placed&#x60; state. To create a &#x60;draft&#x60; order, create an estimate first.
50
- # @param create_order_request
49
+ # Creates an order in the &#x60;placed&#x60; state. To create a &#x60;draft&#x60; order, create an estimate first.
50
+ # @param create_order_request
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [OrderResponse]
53
53
  describe 'create_order test' do
@@ -58,8 +58,8 @@ describe 'OrdersApi' do
58
58
 
59
59
  # unit tests for place_order
60
60
  # Place an order
61
- # Placing an order confirms an order&#39;s allocation of offsets. Only orders that are in the &#x60;draft&#x60; state can be placed
62
- # @param id
61
+ # Placing an order confirms an order&#39;s allocation of offsets. Only orders that are in the &#x60;draft&#x60; state can be placed
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [OrderResponse]
65
65
  describe 'place_order test' do
@@ -70,8 +70,8 @@ describe 'OrdersApi' do
70
70
 
71
71
  # unit tests for retrieve_order
72
72
  # Retrieves an order
73
- # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
- # @param id
73
+ # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
+ # @param id
75
75
  # @param [Hash] opts the optional parameters
76
76
  # @return [OrderResponse]
77
77
  describe 'retrieve_order test' do
@@ -82,14 +82,13 @@ describe 'OrdersApi' do
82
82
 
83
83
  # unit tests for retrieve_orders
84
84
  # Retrieves a list of orders
85
- # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
85
+ # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
86
86
  # @param [Hash] opts the optional parameters
87
- # @option opts [Integer] :page
87
+ # @option opts [Integer] :page
88
88
  # @return [OrderListResponse]
89
89
  describe 'retrieve_orders test' do
90
90
  it 'should work' do
91
91
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
92
92
  end
93
93
  end
94
-
95
94
  end
@@ -34,8 +34,8 @@ describe 'PreferencesApi' do
34
34
 
35
35
  # unit tests for create_preference
36
36
  # creates a project preference
37
- # Creates a project preference for the given organization. If you have a &#x60;preference&#x60; in place, all of your orders will be directed to the project the preference points to.
38
- # @param create_preference_request
37
+ # Creates a project preference for the given organization. If you have a &#x60;preference&#x60; in place, all of your orders will be directed to the project the preference points to.
38
+ # @param create_preference_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [PreferenceResponse]
41
41
  describe 'create_preference test' do
@@ -46,8 +46,8 @@ describe 'PreferencesApi' do
46
46
 
47
47
  # unit tests for delete_preference
48
48
  # Deletes an organization&#39;s preference for a project
49
- # Deletes the given &#x60;preference&#x60;. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
- # @param id
49
+ # Deletes the given &#x60;preference&#x60;. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [PreferenceResponse]
53
53
  describe 'delete_preference test' do
@@ -58,8 +58,8 @@ describe 'PreferencesApi' do
58
58
 
59
59
  # unit tests for retrieve_preference
60
60
  # Retrieve the preference
61
- # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
- # @param id
61
+ # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [PreferenceResponse]
65
65
  describe 'retrieve_preference test' do
@@ -70,14 +70,13 @@ describe 'PreferencesApi' do
70
70
 
71
71
  # unit tests for retrieve_preferences
72
72
  # Retrieves a list of preferences
73
- # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
73
+ # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
74
74
  # @param [Hash] opts the optional parameters
75
- # @option opts [Integer] :page
75
+ # @option opts [Integer] :page
76
76
  # @return [PreferenceListResponse]
77
77
  describe 'retrieve_preferences test' do
78
78
  it 'should work' do
79
79
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
80
80
  end
81
81
  end
82
-
83
82
  end
@@ -34,8 +34,8 @@ describe 'ProjectsApi' do
34
34
 
35
35
  # unit tests for retrieve_project
36
36
  # Retrieves a project
37
- # Retrieves a project available on Patch&#39;s platform.
38
- # @param id
37
+ # Retrieves a project available on Patch&#39;s platform.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [ProjectResponse]
41
41
  describe 'retrieve_project test' do
@@ -46,14 +46,13 @@ describe 'ProjectsApi' do
46
46
 
47
47
  # unit tests for retrieve_projects
48
48
  # Retrieves a list of projects
49
- # Retrieves a list of projects available for purchase on Patch&#39;s platform.
49
+ # Retrieves a list of projects available for purchase on Patch&#39;s platform.
50
50
  # @param [Hash] opts the optional parameters
51
- # @option opts [Integer] :page
51
+ # @option opts [Integer] :page
52
52
  # @return [ProjectListResponse]
53
53
  describe 'retrieve_projects test' do
54
54
  it 'should work' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -1,10 +1,11 @@
1
1
  RSpec.describe 'Estimates Integration' do
2
- it 'supports create, retrieve and list' do
3
- # Configure the Patch gem
2
+ before do
4
3
  Patch.configure do |config|
5
4
  config.access_token = ENV['PATCH_RUBY_API_KEY']
6
5
  end
6
+ end
7
7
 
8
+ it 'supports create, retrieve and list' do
8
9
  create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
9
10
  estimate_id = create_estimate_response.data.id
10
11
 
@@ -23,4 +24,15 @@ RSpec.describe 'Estimates Integration' do
23
24
 
24
25
  expect(estimates.length).not_to be_zero
25
26
  end
27
+
28
+ it 'supports create with a project-id' do
29
+ retrieve_projects_response = Patch::Project.retrieve_projects(page: 1)
30
+ project_id = retrieve_projects_response.data.first.id
31
+ create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100, project_id: project_id)
32
+ estimate_id = create_estimate_response.data.id
33
+
34
+ expect(create_estimate_response.success).to eq true
35
+ expect(create_estimate_response.data.order.id).not_to be_nil
36
+ expect(create_estimate_response.data.order.mass_g).to eq(100)
37
+ end
26
38
  end
@@ -25,6 +25,28 @@ RSpec.describe 'Orders Integration' do
25
25
  expect(orders.length).not_to be_zero
26
26
  end
27
27
 
28
+ it 'supports create with a project-id' do
29
+ retrieve_projects_response = Patch::Project.retrieve_projects(page: 1)
30
+ project_id = retrieve_projects_response.data.first.id
31
+
32
+ create_order_response = Patch::Order.create_order(mass_g: 100, project_id: project_id)
33
+
34
+ expect(create_order_response.success).to eq true
35
+ expect(create_order_response.data.id).not_to be_nil
36
+ expect(create_order_response.data.mass_g).to eq(100)
37
+ end
38
+
39
+ it 'supports create with metadata' do
40
+ metadata = { user: 'john doe' }
41
+
42
+ create_order_response = Patch::Order.create_order(mass_g: 100, metadata: metadata)
43
+
44
+ expect(create_order_response.success).to eq true
45
+ expect(create_order_response.data.id).not_to be_nil
46
+ expect(create_order_response.data.mass_g).to eq(100)
47
+ expect(create_order_response.data.metadata).to eq(metadata)
48
+ end
49
+
28
50
  it 'supports place and cancel for orders created via an estimate' do
29
51
  create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
30
52
  order_to_place_id = create_estimate_to_place_response.data.order.id
@@ -49,5 +49,4 @@ describe 'Allocation' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -37,5 +37,4 @@ describe 'CreateMassEstimateRequest' do
37
37
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
38
  end
39
39
  end
40
-
41
40
  end
@@ -37,5 +37,4 @@ describe 'CreateOrderRequest' do
37
37
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
38
  end
39
39
  end
40
-
41
40
  end
@@ -37,5 +37,4 @@ describe 'CreatePreferenceRequest' do
37
37
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
38
  end
39
39
  end
40
-
41
40
  end
@@ -49,5 +49,4 @@ describe 'ErrorResponse' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -55,5 +55,4 @@ describe 'EstimateListResponse' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -49,5 +49,4 @@ describe 'EstimateResponse' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -55,5 +55,4 @@ describe 'Estimate' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -43,5 +43,4 @@ describe 'MetaIndexObject' do
43
43
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
44
  end
45
45
  end
46
-
47
46
  end
@@ -55,5 +55,4 @@ describe 'OrderListResponse' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -49,5 +49,4 @@ describe 'OrderResponse' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -81,5 +81,4 @@ describe 'Order' do
81
81
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
82
82
  end
83
83
  end
84
-
85
84
  end
@@ -55,5 +55,4 @@ describe 'PreferenceListResponse' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -49,5 +49,4 @@ describe 'PreferenceResponse' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -49,5 +49,4 @@ describe 'Preference' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -55,5 +55,4 @@ describe 'ProjectListResponse' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end
@@ -49,5 +49,4 @@ describe 'ProjectResponse' do
49
49
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
50
  end
51
51
  end
52
-
53
52
  end
@@ -85,5 +85,4 @@ describe 'Project' do
85
85
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
86
86
  end
87
87
  end
88
-
89
88
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2020-07-06 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -77,6 +77,7 @@ executables: []
77
77
  extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
+ - CHANGELOG.md
80
81
  - Gemfile
81
82
  - Gemfile.lock
82
83
  - README.md
@@ -162,32 +163,32 @@ signing_key:
162
163
  specification_version: 4
163
164
  summary: Ruby wrapper for the Patch API
164
165
  test_files:
166
+ - spec/api/preferences_api_spec.rb
165
167
  - spec/api/orders_api_spec.rb
166
- - spec/api/estimates_api_spec.rb
167
168
  - spec/api/projects_api_spec.rb
168
- - spec/api/preferences_api_spec.rb
169
+ - spec/api/estimates_api_spec.rb
169
170
  - spec/api_client_spec.rb
170
171
  - spec/configuration_spec.rb
171
- - spec/integration/orders_spec.rb
172
172
  - spec/integration/preferences_spec.rb
173
- - spec/integration/estimates_spec.rb
174
173
  - spec/integration/projects_spec.rb
175
- - spec/models/create_mass_estimate_request_spec.rb
176
- - spec/models/order_response_spec.rb
177
- - spec/models/order_list_response_spec.rb
178
- - spec/models/order_spec.rb
179
- - spec/models/create_preference_request_spec.rb
180
- - spec/models/error_response_spec.rb
181
- - spec/models/preference_spec.rb
182
- - spec/models/preference_list_response_spec.rb
174
+ - spec/integration/estimates_spec.rb
175
+ - spec/integration/orders_spec.rb
176
+ - spec/models/estimate_response_spec.rb
183
177
  - spec/models/project_list_response_spec.rb
184
- - spec/models/create_order_request_spec.rb
178
+ - spec/models/create_preference_request_spec.rb
179
+ - spec/models/project_response_spec.rb
180
+ - spec/models/allocation_spec.rb
181
+ - spec/models/estimate_spec.rb
185
182
  - spec/models/meta_index_object_spec.rb
186
183
  - spec/models/estimate_list_response_spec.rb
187
- - spec/models/preference_response_spec.rb
188
- - spec/models/estimate_spec.rb
189
- - spec/models/estimate_response_spec.rb
190
- - spec/models/project_response_spec.rb
191
184
  - spec/models/project_spec.rb
192
- - spec/models/allocation_spec.rb
185
+ - spec/models/order_list_response_spec.rb
186
+ - spec/models/create_mass_estimate_request_spec.rb
187
+ - spec/models/preference_spec.rb
188
+ - spec/models/error_response_spec.rb
189
+ - spec/models/order_response_spec.rb
190
+ - spec/models/preference_response_spec.rb
191
+ - spec/models/order_spec.rb
192
+ - spec/models/create_order_request_spec.rb
193
+ - spec/models/preference_list_response_spec.rb
193
194
  - spec/spec_helper.rb