patch_ruby 1.15.1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Gemfile.lock +4 -2
  4. data/README.md +11 -12
  5. data/lib/patch_ruby/api/estimates_api.rb +28 -10
  6. data/lib/patch_ruby/api/orders_api.rb +10 -7
  7. data/lib/patch_ruby/api/projects_api.rb +4 -4
  8. data/lib/patch_ruby/api/technology_types_api.rb +3 -3
  9. data/lib/patch_ruby/api_client.rb +6 -6
  10. data/lib/patch_ruby/api_error.rb +2 -2
  11. data/lib/patch_ruby/configuration.rb +6 -6
  12. data/lib/patch_ruby/models/allocation.rb +2 -2
  13. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +2 -2
  14. data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +2 -2
  15. data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -2
  16. data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -7
  17. data/lib/patch_ruby/models/create_order_request.rb +7 -7
  18. data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -2
  19. data/lib/patch_ruby/models/create_success_response.rb +3 -7
  20. data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -2
  21. data/lib/patch_ruby/models/error_response.rb +3 -7
  22. data/lib/patch_ruby/models/estimate.rb +5 -2
  23. data/lib/patch_ruby/models/estimate_list_response.rb +2 -2
  24. data/lib/patch_ruby/models/estimate_response.rb +2 -2
  25. data/lib/patch_ruby/models/{preference_response.rb → highlight.rb} +40 -33
  26. data/lib/patch_ruby/models/meta_index_object.rb +2 -2
  27. data/lib/patch_ruby/models/order.rb +10 -15
  28. data/lib/patch_ruby/models/order_list_response.rb +2 -2
  29. data/lib/patch_ruby/models/order_response.rb +2 -2
  30. data/lib/patch_ruby/models/parent_technology_type.rb +2 -2
  31. data/lib/patch_ruby/models/photo.rb +2 -2
  32. data/lib/patch_ruby/models/project.rb +29 -9
  33. data/lib/patch_ruby/models/project_list_response.rb +2 -2
  34. data/lib/patch_ruby/models/project_response.rb +2 -2
  35. data/lib/patch_ruby/models/sdg.rb +2 -2
  36. data/lib/patch_ruby/models/standard.rb +2 -2
  37. data/lib/patch_ruby/models/technology_type.rb +2 -2
  38. data/lib/patch_ruby/models/technology_type_list_response.rb +2 -2
  39. data/lib/patch_ruby/version.rb +3 -3
  40. data/lib/patch_ruby.rb +3 -7
  41. data/patch_ruby.gemspec +2 -2
  42. data/spec/api_client_spec.rb +4 -4
  43. data/spec/configuration_spec.rb +2 -2
  44. data/spec/integration/orders_spec.rb +1 -3
  45. data/spec/integration/projects_spec.rb +2 -0
  46. data/spec/models/error_response_spec.rb +1 -1
  47. data/spec/spec_helper.rb +2 -2
  48. metadata +25 -48
  49. data/lib/patch_ruby/models/create_preference_request.rb +0 -233
  50. data/lib/patch_ruby/models/preference.rb +0 -264
  51. data/lib/patch_ruby/models/preference_list_response.rb +0 -273
  52. data/spec/api/preferences_api_spec.rb +0 -82
  53. data/spec/factories/create_preference_requests.rb +0 -5
  54. data/spec/factories/preference_list_responses.rb +0 -8
  55. data/spec/factories/preference_responses.rb +0 -7
  56. data/spec/factories/preferences.rb +0 -7
  57. data/spec/integration/preferences_spec.rb +0 -32
  58. data/spec/models/create_preference_request_spec.rb +0 -47
  59. data/spec/models/preference_list_response_spec.rb +0 -64
  60. data/spec/models/preference_response_spec.rb +0 -58
  61. data/spec/models/preference_spec.rb +0 -58
@@ -30,8 +30,6 @@ RSpec.describe 'Orders Integration' do
30
30
  order_mass_g = 100_000
31
31
  tonne_per_gram = 1_000_000
32
32
 
33
- expected_price = (average_price_per_tonne_cents_usd.to_f / tonne_per_gram) * order_mass_g
34
-
35
33
  create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id)
36
34
 
37
35
  order = create_order_response.data
@@ -39,7 +37,7 @@ RSpec.describe 'Orders Integration' do
39
37
  expect(order.id).not_to be_nil
40
38
  expect(order.created_at).to be_a_kind_of(Time)
41
39
  expect(order.mass_g).to eq(order_mass_g)
42
- expect(order.price_cents_usd).to be_between(expected_price - 2, expected_price + 2)
40
+ expect(order.price_cents_usd).to be_kind_of(Integer)
43
41
  expect(order.patch_fee_cents_usd).to be_kind_of(Integer)
44
42
  expect(order.registry_url).not_to be_empty
45
43
  end
@@ -61,6 +61,8 @@ RSpec.describe 'Projects Integration' do
61
61
  expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType)
62
62
  expect(parent_type.name).to be_an_instance_of(String)
63
63
  expect(parent_type.slug).to be_an_instance_of(String)
64
+
65
+ expect(project.highlights).to be_an_instance_of(Array)
64
66
  end
65
67
  end
66
68
  end
@@ -30,7 +30,7 @@ describe 'ErrorResponse' do
30
30
  it_behaves_like "a generated class" do
31
31
  let(:instance) { @instance }
32
32
  let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } }
33
- let(:nullable_properties) { Set.new([:data]) }
33
+ let(:nullable_properties) { Set.new([:data, :error]) }
34
34
  end
35
35
 
36
36
  describe 'test an instance of ErrorResponse' do
data/spec/spec_helper.rb CHANGED
@@ -4,9 +4,9 @@
4
4
  #The core API used to integrate with Patch's service
5
5
 
6
6
  The version of the OpenAPI document: v1
7
- Contact: developers@usepatch.com
7
+ Contact: engineering@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.2.1
9
+ OpenAPI Generator version: 5.3.1
10
10
 
11
11
  =end
12
12
 
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.15.1
4
+ version: 1.17.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: 2021-11-04 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -107,7 +107,6 @@ files:
107
107
  - lib/patch_ruby/models/create_flight_estimate_request.rb
108
108
  - lib/patch_ruby/models/create_mass_estimate_request.rb
109
109
  - lib/patch_ruby/models/create_order_request.rb
110
- - lib/patch_ruby/models/create_preference_request.rb
111
110
  - lib/patch_ruby/models/create_shipping_estimate_request.rb
112
111
  - lib/patch_ruby/models/create_success_response.rb
113
112
  - lib/patch_ruby/models/create_vehicle_estimate_request.rb
@@ -115,15 +114,13 @@ files:
115
114
  - lib/patch_ruby/models/estimate.rb
116
115
  - lib/patch_ruby/models/estimate_list_response.rb
117
116
  - lib/patch_ruby/models/estimate_response.rb
117
+ - lib/patch_ruby/models/highlight.rb
118
118
  - lib/patch_ruby/models/meta_index_object.rb
119
119
  - lib/patch_ruby/models/order.rb
120
120
  - lib/patch_ruby/models/order_list_response.rb
121
121
  - lib/patch_ruby/models/order_response.rb
122
122
  - lib/patch_ruby/models/parent_technology_type.rb
123
123
  - lib/patch_ruby/models/photo.rb
124
- - lib/patch_ruby/models/preference.rb
125
- - lib/patch_ruby/models/preference_list_response.rb
126
- - lib/patch_ruby/models/preference_response.rb
127
124
  - lib/patch_ruby/models/project.rb
128
125
  - lib/patch_ruby/models/project_list_response.rb
129
126
  - lib/patch_ruby/models/project_response.rb
@@ -135,7 +132,6 @@ files:
135
132
  - patch_ruby.gemspec
136
133
  - spec/api/estimates_api_spec.rb
137
134
  - spec/api/orders_api_spec.rb
138
- - spec/api/preferences_api_spec.rb
139
135
  - spec/api/projects_api_spec.rb
140
136
  - spec/api/technology_types_api_spec.rb
141
137
  - spec/api_client_spec.rb
@@ -144,7 +140,6 @@ files:
144
140
  - spec/factories/allocations.rb
145
141
  - spec/factories/create_mass_estimate_requests.rb
146
142
  - spec/factories/create_order_requests.rb
147
- - spec/factories/create_preference_requests.rb
148
143
  - spec/factories/error_responses.rb
149
144
  - spec/factories/estimate_list_responses.rb
150
145
  - spec/factories/estimate_responses.rb
@@ -154,9 +149,6 @@ files:
154
149
  - spec/factories/order_responses.rb
155
150
  - spec/factories/orders.rb
156
151
  - spec/factories/parent_technology_type.rb
157
- - spec/factories/preference_list_responses.rb
158
- - spec/factories/preference_responses.rb
159
- - spec/factories/preferences.rb
160
152
  - spec/factories/project_list_responses.rb
161
153
  - spec/factories/project_responses.rb
162
154
  - spec/factories/projects.rb
@@ -164,13 +156,11 @@ files:
164
156
  - spec/factories/technology_type.rb
165
157
  - spec/integration/estimates_spec.rb
166
158
  - spec/integration/orders_spec.rb
167
- - spec/integration/preferences_spec.rb
168
159
  - spec/integration/projects/technology_types_spec.rb
169
160
  - spec/integration/projects_spec.rb
170
161
  - spec/models/allocation_spec.rb
171
162
  - spec/models/create_mass_estimate_request_spec.rb
172
163
  - spec/models/create_order_request_spec.rb
173
- - spec/models/create_preference_request_spec.rb
174
164
  - spec/models/error_response_spec.rb
175
165
  - spec/models/estimate_list_response_spec.rb
176
166
  - spec/models/estimate_response_spec.rb
@@ -179,9 +169,6 @@ files:
179
169
  - spec/models/order_list_response_spec.rb
180
170
  - spec/models/order_response_spec.rb
181
171
  - spec/models/order_spec.rb
182
- - spec/models/preference_list_response_spec.rb
183
- - spec/models/preference_response_spec.rb
184
- - spec/models/preference_spec.rb
185
172
  - spec/models/project_list_response_spec.rb
186
173
  - spec/models/project_response_spec.rb
187
174
  - spec/models/project_spec.rb
@@ -212,57 +199,47 @@ signing_key:
212
199
  specification_version: 4
213
200
  summary: Ruby wrapper for the Patch API
214
201
  test_files:
215
- - spec/api/projects_api_spec.rb
216
202
  - spec/api/orders_api_spec.rb
203
+ - spec/api/projects_api_spec.rb
217
204
  - spec/api/technology_types_api_spec.rb
218
- - spec/api/preferences_api_spec.rb
219
205
  - spec/api/estimates_api_spec.rb
220
206
  - spec/api_client_spec.rb
221
207
  - spec/configuration_spec.rb
222
208
  - spec/constants.rb
209
+ - spec/factories/allocations.rb
210
+ - spec/factories/meta_index_objects.rb
211
+ - spec/factories/error_responses.rb
212
+ - spec/factories/create_mass_estimate_requests.rb
223
213
  - spec/factories/sdgs.rb
224
214
  - spec/factories/order_responses.rb
225
- - spec/factories/orders.rb
226
- - spec/factories/create_mass_estimate_requests.rb
227
- - spec/factories/create_preference_requests.rb
228
- - spec/factories/project_responses.rb
229
- - spec/factories/meta_index_objects.rb
230
- - spec/factories/estimates.rb
231
215
  - spec/factories/order_list_responses.rb
232
- - spec/factories/parent_technology_type.rb
233
- - spec/factories/preferences.rb
234
- - spec/factories/estimate_list_responses.rb
235
- - spec/factories/preference_responses.rb
236
- - spec/factories/error_responses.rb
216
+ - spec/factories/estimates.rb
217
+ - spec/factories/project_responses.rb
237
218
  - spec/factories/projects.rb
238
- - spec/factories/preference_list_responses.rb
239
- - spec/factories/estimate_responses.rb
240
- - spec/factories/allocations.rb
241
- - spec/factories/project_list_responses.rb
242
219
  - spec/factories/technology_type.rb
220
+ - spec/factories/estimate_responses.rb
221
+ - spec/factories/estimate_list_responses.rb
222
+ - spec/factories/orders.rb
223
+ - spec/factories/parent_technology_type.rb
243
224
  - spec/factories/create_order_requests.rb
244
- - spec/integration/preferences_spec.rb
245
- - spec/integration/estimates_spec.rb
225
+ - spec/factories/project_list_responses.rb
226
+ - spec/integration/projects_spec.rb
246
227
  - spec/integration/orders_spec.rb
247
228
  - spec/integration/projects/technology_types_spec.rb
248
- - spec/integration/projects_spec.rb
249
- - spec/models/estimate_list_response_spec.rb
250
- - spec/models/preference_response_spec.rb
251
- - spec/models/estimate_spec.rb
229
+ - spec/integration/estimates_spec.rb
230
+ - spec/models/allocation_spec.rb
231
+ - spec/models/order_response_spec.rb
232
+ - spec/models/error_response_spec.rb
252
233
  - spec/models/create_order_request_spec.rb
253
- - spec/models/order_list_response_spec.rb
254
- - spec/models/preference_list_response_spec.rb
255
- - spec/models/create_preference_request_spec.rb
256
- - spec/models/preference_spec.rb
234
+ - spec/models/project_list_response_spec.rb
235
+ - spec/models/estimate_list_response_spec.rb
236
+ - spec/models/project_spec.rb
257
237
  - spec/models/estimate_response_spec.rb
238
+ - spec/models/order_list_response_spec.rb
258
239
  - spec/models/order_spec.rb
259
240
  - spec/models/project_response_spec.rb
260
- - spec/models/order_response_spec.rb
261
241
  - spec/models/meta_index_object_spec.rb
262
- - spec/models/project_list_response_spec.rb
263
- - spec/models/error_response_spec.rb
264
- - spec/models/allocation_spec.rb
265
- - spec/models/project_spec.rb
242
+ - spec/models/estimate_spec.rb
266
243
  - spec/models/create_mass_estimate_request_spec.rb
267
244
  - spec/patch_ruby_spec.rb
268
245
  - spec/spec_helper.rb
@@ -1,233 +0,0 @@
1
- =begin
2
- #Patch API V1
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: v1
7
- Contact: developers@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.2.1
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Patch
17
- class CreatePreferenceRequest
18
- attr_accessor :project_id
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :'project_id' => :'project_id'
24
- }
25
- end
26
-
27
- # Returns all the JSON keys this model knows about
28
- def self.acceptable_attributes
29
- attribute_map.values
30
- end
31
-
32
- # Attribute type mapping.
33
- def self.openapi_types
34
- {
35
- :'project_id' => :'String'
36
- }
37
- end
38
-
39
- # List of attributes with nullable: true
40
- def self.openapi_nullable
41
- Set.new([
42
- ])
43
- end
44
-
45
-
46
- # Allows models with corresponding API classes to delegate API operations to those API classes
47
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
48
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
49
- def self.method_missing(message, *args, &block)
50
- if Object.const_defined?('Patch::CreatePreferenceRequestsApi::OPERATIONS') && Patch::CreatePreferenceRequestsApi::OPERATIONS.include?(message)
51
- Patch::CreatePreferenceRequestsApi.new.send(message, *args)
52
- else
53
- super
54
- end
55
- end
56
-
57
- # Initializes the object
58
- # @param [Hash] attributes Model attributes in the form of hash
59
- def initialize(attributes = {})
60
- if (!attributes.is_a?(Hash))
61
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreatePreferenceRequest` initialize method"
62
- end
63
-
64
- # check to see if the attribute exists and convert string to symbol for hash key
65
- attributes = attributes.each_with_object({}) { |(k, v), h|
66
- if (!self.class.attribute_map.key?(k.to_sym))
67
- fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreatePreferenceRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
- end
69
- h[k.to_sym] = v
70
- }
71
-
72
- if attributes.key?(:'project_id')
73
- self.project_id = attributes[:'project_id']
74
- end
75
- end
76
-
77
- # Show invalid properties with the reasons. Usually used together with valid?
78
- # @return Array for valid properties with the reasons
79
- def list_invalid_properties
80
- invalid_properties = Array.new
81
- if @project_id.nil?
82
- invalid_properties.push('invalid value for "project_id", project_id cannot be nil.')
83
- end
84
-
85
- invalid_properties
86
- end
87
-
88
- # Check to see if the all the properties in the model are valid
89
- # @return true if the model is valid
90
- def valid?
91
- return false if @project_id.nil?
92
- true
93
- end
94
-
95
- # Checks equality by comparing each attribute.
96
- # @param [Object] Object to be compared
97
- def ==(o)
98
- return true if self.equal?(o)
99
- self.class == o.class &&
100
- project_id == o.project_id
101
- end
102
-
103
- # @see the `==` method
104
- # @param [Object] Object to be compared
105
- def eql?(o)
106
- self == o
107
- end
108
-
109
- # Calculates hash code according to all attributes.
110
- # @return [Integer] Hash code
111
- def hash
112
- [project_id].hash
113
- end
114
-
115
- # Builds the object from hash
116
- # @param [Hash] attributes Model attributes in the form of hash
117
- # @return [Object] Returns the model itself
118
- def self.build_from_hash(attributes)
119
- new.build_from_hash(attributes)
120
- end
121
-
122
- # Builds the object from hash
123
- # @param [Hash] attributes Model attributes in the form of hash
124
- # @return [Object] Returns the model itself
125
- def build_from_hash(attributes)
126
- return nil unless attributes.is_a?(Hash)
127
- self.class.openapi_types.each_pair do |key, type|
128
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
129
- self.send("#{key}=", nil)
130
- elsif type =~ /\AArray<(.*)>/i
131
- # check to ensure the input is an array given that the attribute
132
- # is documented as an array but the input is not
133
- if attributes[self.class.attribute_map[key]].is_a?(Array)
134
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
- end
136
- elsif !attributes[self.class.attribute_map[key]].nil?
137
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
- end
139
- end
140
-
141
- self
142
- end
143
-
144
- # Deserializes the data based on type
145
- # @param string type Data type
146
- # @param string value Value to be deserialized
147
- # @return [Object] Deserialized data
148
- def _deserialize(type, value)
149
- case type.to_sym
150
- when :Time
151
- Time.parse(value)
152
- when :Date
153
- Date.parse(value)
154
- when :String
155
- value.to_s
156
- when :Integer
157
- value.to_i
158
- when :Float
159
- value.to_f
160
- when :Boolean
161
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
- true
163
- else
164
- false
165
- end
166
- when :Object
167
- # generic object (usually a Hash), return directly
168
- value
169
- when /\AArray<(?<inner_type>.+)>\z/
170
- inner_type = Regexp.last_match[:inner_type]
171
- value.map { |v| _deserialize(inner_type, v) }
172
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
- k_type = Regexp.last_match[:k_type]
174
- v_type = Regexp.last_match[:v_type]
175
- {}.tap do |hash|
176
- value.each do |k, v|
177
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
- end
179
- end
180
- else # model
181
- # models (e.g. Pet) or oneOf
182
- klass = Patch.const_get(type)
183
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
- end
185
- end
186
-
187
- # Returns the string representation of the object
188
- # @return [String] String presentation of the object
189
- def to_s
190
- to_hash.to_s
191
- end
192
-
193
- # to_body is an alias to to_hash (backward compatibility)
194
- # @return [Hash] Returns the object in the form of hash
195
- def to_body
196
- to_hash
197
- end
198
-
199
- # Returns the object in the form of hash
200
- # @return [Hash] Returns the object in the form of hash
201
- def to_hash
202
- hash = {}
203
- self.class.attribute_map.each_pair do |attr, param|
204
- value = self.send(attr)
205
- if value.nil?
206
- is_nullable = self.class.openapi_nullable.include?(attr)
207
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
- end
209
-
210
- hash[param] = _to_hash(value)
211
- end
212
- hash
213
- end
214
-
215
- # Outputs non-array value in the form of hash
216
- # For object, use to_hash. Otherwise, just return the value
217
- # @param [Object] value Any valid value
218
- # @return [Hash] Returns the value in the form of hash
219
- def _to_hash(value)
220
- if value.is_a?(Array)
221
- value.compact.map { |v| _to_hash(v) }
222
- elsif value.is_a?(Hash)
223
- {}.tap do |hash|
224
- value.each { |k, v| hash[k] = _to_hash(v) }
225
- end
226
- elsif value.respond_to? :to_hash
227
- value.to_hash
228
- else
229
- value
230
- end
231
- end
232
- end
233
- end