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