patch_ruby 2.1.1 → 2.3.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.
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '2.1.1'
14
+ VERSION = '2.3.0'
15
15
  end
data/lib/patch_ruby.rb CHANGED
@@ -20,7 +20,6 @@ require 'patch_ruby/configuration'
20
20
  require 'patch_ruby/models/create_air_shipping_estimate_request'
21
21
  require 'patch_ruby/models/create_bitcoin_estimate_request'
22
22
  require 'patch_ruby/models/create_ecommerce_estimate_request'
23
- require 'patch_ruby/models/create_ethereum_estimate_request'
24
23
  require 'patch_ruby/models/create_flight_estimate_request'
25
24
  require 'patch_ruby/models/create_hotel_estimate_request'
26
25
  require 'patch_ruby/models/create_mass_estimate_request'
@@ -29,9 +28,7 @@ require 'patch_ruby/models/create_order_request'
29
28
  require 'patch_ruby/models/create_rail_shipping_estimate_request'
30
29
  require 'patch_ruby/models/create_road_shipping_estimate_request'
31
30
  require 'patch_ruby/models/create_sea_shipping_estimate_request'
32
- require 'patch_ruby/models/create_shipping_estimate_request'
33
31
  require 'patch_ruby/models/create_success_response'
34
- require 'patch_ruby/models/create_vehicle_estimate_request'
35
32
  require 'patch_ruby/models/delete_order_line_item_response'
36
33
  require 'patch_ruby/models/delete_order_response'
37
34
  require 'patch_ruby/models/disclaimer'
data/patch_ruby.gemspec CHANGED
@@ -41,4 +41,4 @@ Gem::Specification.new do |s|
41
41
  s.add_development_dependency 'pry'
42
42
  # End custom
43
43
 
44
- end
44
+ end
@@ -45,51 +45,6 @@ RSpec.describe 'Estimates Integration' do
45
45
  expect(flight_estimate_longer.data.mass_g).to be > 2 * flight_estimate.data.mass_g
46
46
  end
47
47
 
48
- it 'supports creating vehicle estimates' do
49
- distance_m = 10_000
50
- make = "Toyota"
51
- model = "Corolla"
52
- year = 2000
53
-
54
- vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
55
- distance_m: distance_m,
56
- make: make,
57
- model: model,
58
- year: year,
59
- create_order: true
60
- )
61
-
62
- expect(vehicle_estimate.data.type).to eq 'vehicle'
63
- expect(vehicle_estimate.data.mass_g).to be >= 1_000
64
- expect(vehicle_estimate.data.order.amount).to be >= 1_000
65
- end
66
-
67
- it 'supports creating vehicle estimates with partial information' do
68
- distance_m = 10_000
69
-
70
- vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
71
- distance_m: distance_m,
72
- create_order: false
73
- )
74
-
75
- expect(vehicle_estimate.data.type).to eq 'vehicle'
76
- expect(vehicle_estimate.data.mass_g).to eq 2_132
77
- end
78
-
79
- it 'supports creating shipping estimates' do
80
- distance_m = 100_000_000
81
- package_mass_g = 10_000
82
- create_estimate_response = Patch::Estimate.create_shipping_estimate(
83
- distance_m: distance_m,
84
- package_mass_g: package_mass_g,
85
- transportation_method: 'rail',
86
- create_order: false
87
- )
88
-
89
- expect(create_estimate_response.data.type).to eq 'ecommerce'
90
- expect(create_estimate_response.data.mass_g).to be >= 10_000
91
- end
92
-
93
48
  it 'supports creating bitcoin estimates with partial information' do
94
49
  bitcoin_estimate = Patch::Estimate.create_bitcoin_estimate()
95
50
 
@@ -136,26 +91,6 @@ RSpec.describe 'Estimates Integration' do
136
91
  expect(bitcoin_estimate_1.data.mass_g).to be < bitcoin_estimate_2.data.mass_g
137
92
  end
138
93
 
139
- it 'supports creating ethereum estimates with a gas amount' do
140
- ethereum_estimate = Patch::Estimate.create_ethereum_estimate(
141
- gas_used: 100
142
- )
143
-
144
- ethereum_estimate_2 = Patch::Estimate.create_ethereum_estimate(
145
- gas_used: 1000
146
- )
147
-
148
- expect(ethereum_estimate.data.type).to eq 'ethereum'
149
- expect(ethereum_estimate.data.mass_g).to be < ethereum_estimate_2.data.mass_g
150
- end
151
-
152
- it 'supports creating ethereum estimates with partial information' do
153
- ethereum_estimate = Patch::Estimate.create_ethereum_estimate({ create_order: false })
154
-
155
- expect(ethereum_estimate.data.type).to eq 'ethereum'
156
- expect(ethereum_estimate.data.mass_g).to be >= 2_000
157
- end
158
-
159
94
  it 'supports creating hotel estimates' do
160
95
  create_estimate_response = Patch::Estimate.create_hotel_estimate(
161
96
  country_code: "US",
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: 2.1.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patch Technology
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-18 00:00:00.000000000 Z
11
+ date: 2025-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -104,7 +104,6 @@ files:
104
104
  - lib/patch_ruby/models/create_air_shipping_estimate_request.rb
105
105
  - lib/patch_ruby/models/create_bitcoin_estimate_request.rb
106
106
  - lib/patch_ruby/models/create_ecommerce_estimate_request.rb
107
- - lib/patch_ruby/models/create_ethereum_estimate_request.rb
108
107
  - lib/patch_ruby/models/create_flight_estimate_request.rb
109
108
  - lib/patch_ruby/models/create_hotel_estimate_request.rb
110
109
  - lib/patch_ruby/models/create_mass_estimate_request.rb
@@ -113,9 +112,7 @@ files:
113
112
  - lib/patch_ruby/models/create_rail_shipping_estimate_request.rb
114
113
  - lib/patch_ruby/models/create_road_shipping_estimate_request.rb
115
114
  - lib/patch_ruby/models/create_sea_shipping_estimate_request.rb
116
- - lib/patch_ruby/models/create_shipping_estimate_request.rb
117
115
  - lib/patch_ruby/models/create_success_response.rb
118
- - lib/patch_ruby/models/create_vehicle_estimate_request.rb
119
116
  - lib/patch_ruby/models/delete_order_line_item_response.rb
120
117
  - lib/patch_ruby/models/delete_order_response.rb
121
118
  - lib/patch_ruby/models/disclaimer.rb
@@ -194,7 +191,7 @@ homepage: https://www.patch.io
194
191
  licenses:
195
192
  - MIT
196
193
  metadata: {}
197
- post_install_message:
194
+ post_install_message:
198
195
  rdoc_options: []
199
196
  require_paths:
200
197
  - lib
@@ -210,51 +207,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
207
  version: '0'
211
208
  requirements: []
212
209
  rubygems_version: 3.1.2
213
- signing_key:
210
+ signing_key:
214
211
  specification_version: 4
215
212
  summary: Ruby wrapper for the Patch API
216
213
  test_files:
217
- - spec/api/projects_api_spec.rb
218
- - spec/api/estimates_api_spec.rb
219
- - spec/api/orders_api_spec.rb
220
214
  - spec/api/order_line_items_api_spec.rb
221
215
  - spec/api/technology_types_api_spec.rb
216
+ - spec/api/projects_api_spec.rb
217
+ - spec/api/orders_api_spec.rb
218
+ - spec/api/estimates_api_spec.rb
222
219
  - spec/api_client_spec.rb
223
220
  - spec/configuration_spec.rb
224
221
  - spec/constants.rb
225
- - spec/factories/meta_index_objects.rb
226
- - spec/factories/estimate_list_responses.rb
227
- - spec/factories/create_mass_estimate_requests.rb
228
- - spec/factories/projects.rb
229
- - spec/factories/order_list_responses.rb
230
- - spec/factories/technology_type.rb
231
222
  - spec/factories/estimates.rb
232
- - spec/factories/error_responses.rb
233
223
  - spec/factories/parent_technology_type.rb
224
+ - spec/factories/meta_index_objects.rb
234
225
  - spec/factories/project_responses.rb
235
- - spec/factories/create_order_requests.rb
226
+ - spec/factories/technology_type.rb
236
227
  - spec/factories/orders.rb
237
- - spec/factories/sdgs.rb
228
+ - spec/factories/estimate_list_responses.rb
229
+ - spec/factories/estimate_responses.rb
230
+ - spec/factories/projects.rb
231
+ - spec/factories/create_order_requests.rb
238
232
  - spec/factories/order_responses.rb
233
+ - spec/factories/create_mass_estimate_requests.rb
234
+ - spec/factories/sdgs.rb
235
+ - spec/factories/order_list_responses.rb
236
+ - spec/factories/error_responses.rb
239
237
  - spec/factories/project_list_responses.rb
240
- - spec/factories/estimate_responses.rb
241
- - spec/integration/projects/technology_types_spec.rb
242
- - spec/integration/estimates_spec.rb
243
238
  - spec/integration/projects_spec.rb
244
239
  - spec/integration/orders_spec.rb
245
- - spec/models/order_response_spec.rb
246
- - spec/models/meta_index_object_spec.rb
247
- - spec/models/project_spec.rb
248
- - spec/models/create_order_request_spec.rb
240
+ - spec/integration/projects/technology_types_spec.rb
241
+ - spec/integration/estimates_spec.rb
249
242
  - spec/models/project_response_spec.rb
250
- - spec/models/create_mass_estimate_request_spec.rb
251
- - spec/models/project_list_response_spec.rb
243
+ - spec/models/meta_index_object_spec.rb
252
244
  - spec/models/order_spec.rb
253
- - spec/models/error_response_spec.rb
245
+ - spec/models/project_list_response_spec.rb
254
246
  - spec/models/estimate_spec.rb
255
- - spec/models/order_list_response_spec.rb
247
+ - spec/models/order_response_spec.rb
256
248
  - spec/models/estimate_list_response_spec.rb
257
249
  - spec/models/estimate_response_spec.rb
250
+ - spec/models/error_response_spec.rb
251
+ - spec/models/create_mass_estimate_request_spec.rb
252
+ - spec/models/project_spec.rb
253
+ - spec/models/order_list_response_spec.rb
254
+ - spec/models/create_order_request_spec.rb
258
255
  - spec/patch_ruby_spec.rb
259
256
  - spec/spec_helper.rb
260
257
  - spec/support/shared/generated_classes.rb
@@ -1,281 +0,0 @@
1
- =begin
2
- #Patch API V2
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: 2
7
- Contact: engineering@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.3.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 :average_daily_balance_eth_gwei
25
-
26
- attr_accessor :project_id
27
-
28
- attr_accessor :create_order
29
-
30
- # Attribute mapping from ruby-style variable name to JSON key.
31
- def self.attribute_map
32
- {
33
- :'timestamp' => :'timestamp',
34
- :'gas_used' => :'gas_used',
35
- :'transaction_value_eth_gwei' => :'transaction_value_eth_gwei',
36
- :'average_daily_balance_eth_gwei' => :'average_daily_balance_eth_gwei',
37
- :'project_id' => :'project_id',
38
- :'create_order' => :'create_order'
39
- }
40
- end
41
-
42
- # Returns all the JSON keys this model knows about
43
- def self.acceptable_attributes
44
- attribute_map.values
45
- end
46
-
47
- # Attribute type mapping.
48
- def self.openapi_types
49
- {
50
- :'timestamp' => :'String',
51
- :'gas_used' => :'Integer',
52
- :'transaction_value_eth_gwei' => :'Integer',
53
- :'average_daily_balance_eth_gwei' => :'Integer',
54
- :'project_id' => :'String',
55
- :'create_order' => :'Boolean'
56
- }
57
- end
58
-
59
- # List of attributes with nullable: true
60
- def self.openapi_nullable
61
- Set.new([
62
- :'timestamp',
63
- :'gas_used',
64
- :'transaction_value_eth_gwei',
65
- :'average_daily_balance_eth_gwei',
66
- :'project_id',
67
- :'create_order'
68
- ])
69
- end
70
-
71
-
72
- # Allows models with corresponding API classes to delegate API operations to those API classes
73
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
74
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
75
- def self.method_missing(message, *args, &block)
76
- if Object.const_defined?('Patch::CreateEthereumEstimateRequestsApi::OPERATIONS') && Patch::CreateEthereumEstimateRequestsApi::OPERATIONS.include?(message)
77
- Patch::CreateEthereumEstimateRequestsApi.new.send(message, *args)
78
- else
79
- super
80
- end
81
- end
82
-
83
- # Initializes the object
84
- # @param [Hash] attributes Model attributes in the form of hash
85
- def initialize(attributes = {})
86
- if (!attributes.is_a?(Hash))
87
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateEthereumEstimateRequest` initialize method"
88
- end
89
-
90
- # check to see if the attribute exists and convert string to symbol for hash key
91
- attributes = attributes.each_with_object({}) { |(k, v), h|
92
- if (!self.class.attribute_map.key?(k.to_sym))
93
- 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
94
- end
95
- h[k.to_sym] = v
96
- }
97
-
98
- if attributes.key?(:'timestamp')
99
- self.timestamp = attributes[:'timestamp']
100
- end
101
-
102
- if attributes.key?(:'gas_used')
103
- self.gas_used = attributes[:'gas_used']
104
- end
105
-
106
- if attributes.key?(:'transaction_value_eth_gwei')
107
- self.transaction_value_eth_gwei = attributes[:'transaction_value_eth_gwei']
108
- end
109
-
110
- if attributes.key?(:'average_daily_balance_eth_gwei')
111
- self.average_daily_balance_eth_gwei = attributes[:'average_daily_balance_eth_gwei']
112
- end
113
-
114
- if attributes.key?(:'project_id')
115
- self.project_id = attributes[:'project_id']
116
- end
117
-
118
- if attributes.key?(:'create_order')
119
- self.create_order = attributes[:'create_order']
120
- else
121
- self.create_order = false
122
- end
123
- end
124
-
125
- # Show invalid properties with the reasons. Usually used together with valid?
126
- # @return Array for valid properties with the reasons
127
- def list_invalid_properties
128
- invalid_properties = Array.new
129
- invalid_properties
130
- end
131
-
132
- # Check to see if the all the properties in the model are valid
133
- # @return true if the model is valid
134
- def valid?
135
- true
136
- end
137
-
138
- # Checks equality by comparing each attribute.
139
- # @param [Object] Object to be compared
140
- def ==(o)
141
- return true if self.equal?(o)
142
- self.class == o.class &&
143
- timestamp == o.timestamp &&
144
- gas_used == o.gas_used &&
145
- transaction_value_eth_gwei == o.transaction_value_eth_gwei &&
146
- average_daily_balance_eth_gwei == o.average_daily_balance_eth_gwei &&
147
- project_id == o.project_id &&
148
- create_order == o.create_order
149
- end
150
-
151
- # @see the `==` method
152
- # @param [Object] Object to be compared
153
- def eql?(o)
154
- self == o
155
- end
156
-
157
- # Calculates hash code according to all attributes.
158
- # @return [Integer] Hash code
159
- def hash
160
- [timestamp, gas_used, transaction_value_eth_gwei, average_daily_balance_eth_gwei, project_id, create_order].hash
161
- end
162
-
163
- # Builds the object from hash
164
- # @param [Hash] attributes Model attributes in the form of hash
165
- # @return [Object] Returns the model itself
166
- def self.build_from_hash(attributes)
167
- new.build_from_hash(attributes)
168
- end
169
-
170
- # Builds the object from hash
171
- # @param [Hash] attributes Model attributes in the form of hash
172
- # @return [Object] Returns the model itself
173
- def build_from_hash(attributes)
174
- return nil unless attributes.is_a?(Hash)
175
- self.class.openapi_types.each_pair do |key, type|
176
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
177
- self.send("#{key}=", nil)
178
- elsif type =~ /\AArray<(.*)>/i
179
- # check to ensure the input is an array given that the attribute
180
- # is documented as an array but the input is not
181
- if attributes[self.class.attribute_map[key]].is_a?(Array)
182
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
- end
184
- elsif !attributes[self.class.attribute_map[key]].nil?
185
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
- end
187
- end
188
-
189
- self
190
- end
191
-
192
- # Deserializes the data based on type
193
- # @param string type Data type
194
- # @param string value Value to be deserialized
195
- # @return [Object] Deserialized data
196
- def _deserialize(type, value)
197
- case type.to_sym
198
- when :Time
199
- Time.parse(value)
200
- when :Date
201
- Date.parse(value)
202
- when :String
203
- value.to_s
204
- when :Integer
205
- value.to_i
206
- when :Float
207
- value.to_f
208
- when :Boolean
209
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
210
- true
211
- else
212
- false
213
- end
214
- when :Object
215
- # generic object (usually a Hash), return directly
216
- value
217
- when /\AArray<(?<inner_type>.+)>\z/
218
- inner_type = Regexp.last_match[:inner_type]
219
- value.map { |v| _deserialize(inner_type, v) }
220
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
221
- k_type = Regexp.last_match[:k_type]
222
- v_type = Regexp.last_match[:v_type]
223
- {}.tap do |hash|
224
- value.each do |k, v|
225
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
226
- end
227
- end
228
- else # model
229
- # models (e.g. Pet) or oneOf
230
- klass = Patch.const_get(type)
231
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
- end
233
- end
234
-
235
- # Returns the string representation of the object
236
- # @return [String] String presentation of the object
237
- def to_s
238
- to_hash.to_s
239
- end
240
-
241
- # to_body is an alias to to_hash (backward compatibility)
242
- # @return [Hash] Returns the object in the form of hash
243
- def to_body
244
- to_hash
245
- end
246
-
247
- # Returns the object in the form of hash
248
- # @return [Hash] Returns the object in the form of hash
249
- def to_hash
250
- hash = {}
251
- self.class.attribute_map.each_pair do |attr, param|
252
- value = self.send(attr)
253
- if value.nil?
254
- is_nullable = self.class.openapi_nullable.include?(attr)
255
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
- end
257
-
258
- hash[param] = _to_hash(value)
259
- end
260
- hash
261
- end
262
-
263
- # Outputs non-array value in the form of hash
264
- # For object, use to_hash. Otherwise, just return the value
265
- # @param [Object] value Any valid value
266
- # @return [Hash] Returns the value in the form of hash
267
- def _to_hash(value)
268
- if value.is_a?(Array)
269
- value.compact.map { |v| _to_hash(v) }
270
- elsif value.is_a?(Hash)
271
- {}.tap do |hash|
272
- value.each { |k, v| hash[k] = _to_hash(v) }
273
- end
274
- elsif value.respond_to? :to_hash
275
- value.to_hash
276
- else
277
- value
278
- end
279
- end
280
- end
281
- end