patch_ruby 1.17.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b155fa6ec075f760c3a917898b8e970995c500ff5b3d31488216e018d98418c
4
- data.tar.gz: 212fccee52313135c68c8568df430d6bce2e41de56610c84c5badb2b5c7d13e0
3
+ metadata.gz: a90772be1e6d26b5b7ffef9d2f06f344a650e1c285f350dface3df5e019d3cf4
4
+ data.tar.gz: 96e12b69d309e6083a1e0e10dcd2e66b44f6d86fa6c1c27bd407d4bac388a069
5
5
  SHA512:
6
- metadata.gz: d0af1c92005e56b3a1249cef852bf0cd6005d4e734c9a237bed90c1704f8ef676a725fad3c7d95daee0e83bfbfbaaefedebf7bcc71c69ad3cd7d6d89ae5917f6
7
- data.tar.gz: 46bf38a886fd7c4767b3cd5a87794e55b683c0ffeaecd688700b2d9b028460608bff5d355aef0d591807e12208497d9b8cecb13e38c27aba7c81d79e7637fe37
6
+ metadata.gz: 7c1d0d76f771cdda09b4694697544007e14484462167846527917a3a28f9d327c70af5e4f24f8e2312c61cebe1927b9a8080f7a73cc9f85018483a8a664021db
7
+ data.tar.gz: c4a2539ad216e42349dede7c98fdd4512f519d1b0820c2235e356d4a7772154007941bec55402a1383e8b8456664e1493ddb53341d8cfde60617b6e18198a784
data/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.19.0] - 2022-04-05
9
+
10
+ ### Added
11
+
12
+ - Adds `Patch::Estimate.create_hotel_estimate` method
13
+
14
+ ## [1.18.0] - 2022-03-22
15
+
16
+ ### Changed
17
+
18
+ - Adds optional `state` field to `order` creation
19
+
8
20
  ## [1.17.0] - 2022-01-11
9
21
 
10
22
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.17.0)
4
+ patch_ruby (1.19.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -188,33 +188,6 @@ Patch::Project.retrieve_projects(type: type)
188
188
  minimum_available_mass = 100
189
189
  Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
190
190
  ```
191
-
192
- ### Preferences
193
-
194
- 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.patch.io/projects).
195
-
196
- [API Reference](https://docs.patch.io/#/?id=preferences)
197
-
198
- #### Examples
199
-
200
- ```ruby
201
- # Create a preference
202
- project_id = 'pro_test_1234' # Pass in the project_id for your preference
203
- Patch::Preference.create_preference(project_id: project_id)
204
-
205
- # Retrieve a preference
206
- preference_id = 'pre_test_1234' # Pass in the preferences's id
207
- Patch::Preference.retrieve_preference(preference_id)
208
-
209
- # Delete a preference
210
- preference_id = 'pre_test_1234' # Pass in the preferences's id
211
- Patch::Preference.delete_preference(preference_id)
212
-
213
- # Retrieve a list of preferences
214
- page = 1 # Pass in which page of preferences you'd like
215
- Patch::Preference.retrieve_preferences(page: page)
216
- ```
217
-
218
191
  ## Contributing
219
192
 
220
193
  While we value open-source contributions to this SDK, the core of this library is generated programmatically. Complex additions made directly to the library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
@@ -18,6 +18,7 @@ module Patch
18
18
  :create_bitcoin_estimate,
19
19
  :create_ethereum_estimate,
20
20
  :create_flight_estimate,
21
+ :create_hotel_estimate,
21
22
  :create_mass_estimate,
22
23
  :create_shipping_estimate,
23
24
  :create_vehicle_estimate,
@@ -237,6 +238,75 @@ module Patch
237
238
  return data, status_code, headers
238
239
  end
239
240
 
241
+ # Create a hotel estimate.
242
+ # Creates a hotel estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
243
+ # @param create_hotel_estimate_request [CreateHotelEstimateRequest]
244
+ # @param [Hash] opts the optional parameters
245
+ # @return [EstimateResponse]
246
+ def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
247
+ _create_hotel_estimate_request = Patch::CreateHotelEstimateRequest.new(create_hotel_estimate_request)
248
+ data, _status_code, _headers = create_hotel_estimate_with_http_info(_create_hotel_estimate_request, opts)
249
+ data
250
+ end
251
+
252
+ # Create a hotel estimate.
253
+ # Creates a hotel estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
254
+ # @param create_hotel_estimate_request [CreateHotelEstimateRequest]
255
+ # @param [Hash] opts the optional parameters
256
+ # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
257
+ def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = {})
258
+ if @api_client.config.debugging
259
+ @api_client.config.logger.debug 'Calling API: EstimatesApi.create_hotel_estimate ...'
260
+ end
261
+ # verify the required parameter 'create_hotel_estimate_request' is set
262
+ if @api_client.config.client_side_validation && create_hotel_estimate_request.nil?
263
+ fail ArgumentError, "Missing the required parameter 'create_hotel_estimate_request' when calling EstimatesApi.create_hotel_estimate"
264
+ end
265
+ # resource path
266
+ local_var_path = '/v1/estimates/hotel'
267
+
268
+ # query parameters
269
+ query_params = opts[:query_params] || {}
270
+
271
+ # header parameters
272
+ header_params = opts[:header_params] || {}
273
+ # HTTP header 'Accept' (if needed)
274
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
275
+ # HTTP header 'Content-Type'
276
+ content_type = @api_client.select_header_content_type(['application/json'])
277
+ if !content_type.nil?
278
+ header_params['Content-Type'] = content_type
279
+ end
280
+
281
+ # form parameters
282
+ form_params = opts[:form_params] || {}
283
+
284
+ # http body (model)
285
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_hotel_estimate_request)
286
+
287
+ # return_type
288
+ return_type = opts[:debug_return_type] || 'EstimateResponse'
289
+
290
+ # auth_names
291
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
292
+
293
+ new_options = opts.merge(
294
+ :operation => :"EstimatesApi.create_hotel_estimate",
295
+ :header_params => header_params,
296
+ :query_params => query_params,
297
+ :form_params => form_params,
298
+ :body => post_body,
299
+ :auth_names => auth_names,
300
+ :return_type => return_type
301
+ )
302
+
303
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
304
+ if @api_client.config.debugging
305
+ @api_client.config.logger.debug "API called: EstimatesApi#create_hotel_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
306
+ end
307
+ return data, status_code, headers
308
+ end
309
+
240
310
  # Create an estimate based on mass of CO2
241
311
  # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate.
242
312
  # @param create_mass_estimate_request [CreateMassEstimateRequest]
@@ -92,7 +92,7 @@ module Patch
92
92
  end
93
93
 
94
94
  # Creates an order
95
- # Creates an order in the `placed` state. To create a `draft` order, create an estimate first.
95
+ # Creates an order in the `placed` or `draft` state.
96
96
  # @param create_order_request [CreateOrderRequest]
97
97
  # @param [Hash] opts the optional parameters
98
98
  # @return [OrderResponse]
@@ -103,7 +103,7 @@ module Patch
103
103
  end
104
104
 
105
105
  # Creates an order
106
- # Creates an order in the &#x60;placed&#x60; state. To create a &#x60;draft&#x60; order, create an estimate first.
106
+ # Creates an order in the &#x60;placed&#x60; or &#x60;draft&#x60; state.
107
107
  # @param create_order_request [CreateOrderRequest]
108
108
  # @param [Hash] opts the optional parameters
109
109
  # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
@@ -31,7 +31,7 @@ module Patch
31
31
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
32
  def initialize(config = Configuration.default)
33
33
  @config = config
34
- @user_agent = "patch-ruby/1.17.0"
34
+ @user_agent = "patch-ruby/1.19.0"
35
35
  @default_headers = {
36
36
  'Content-Type' => 'application/json',
37
37
  'User-Agent' => @user_agent
@@ -0,0 +1,300 @@
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: 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 CreateHotelEstimateRequest
18
+ attr_accessor :country_code
19
+
20
+ attr_accessor :city
21
+
22
+ attr_accessor :region
23
+
24
+ attr_accessor :star_rating
25
+
26
+ attr_accessor :number_of_nights
27
+
28
+ attr_accessor :number_of_rooms
29
+
30
+ attr_accessor :project_id
31
+
32
+ attr_accessor :create_order
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'country_code' => :'country_code',
38
+ :'city' => :'city',
39
+ :'region' => :'region',
40
+ :'star_rating' => :'star_rating',
41
+ :'number_of_nights' => :'number_of_nights',
42
+ :'number_of_rooms' => :'number_of_rooms',
43
+ :'project_id' => :'project_id',
44
+ :'create_order' => :'create_order'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'country_code' => :'String',
57
+ :'city' => :'String',
58
+ :'region' => :'String',
59
+ :'star_rating' => :'Integer',
60
+ :'number_of_nights' => :'Integer',
61
+ :'number_of_rooms' => :'Integer',
62
+ :'project_id' => :'String',
63
+ :'create_order' => :'Boolean'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ :'project_id',
71
+ :'create_order'
72
+ ])
73
+ end
74
+
75
+
76
+ # Allows models with corresponding API classes to delegate API operations to those API classes
77
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
78
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
79
+ def self.method_missing(message, *args, &block)
80
+ if Object.const_defined?('Patch::CreateHotelEstimateRequestsApi::OPERATIONS') && Patch::CreateHotelEstimateRequestsApi::OPERATIONS.include?(message)
81
+ Patch::CreateHotelEstimateRequestsApi.new.send(message, *args)
82
+ else
83
+ super
84
+ end
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateHotelEstimateRequest` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!self.class.attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateHotelEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'country_code')
103
+ self.country_code = attributes[:'country_code']
104
+ end
105
+
106
+ if attributes.key?(:'city')
107
+ self.city = attributes[:'city']
108
+ end
109
+
110
+ if attributes.key?(:'region')
111
+ self.region = attributes[:'region']
112
+ end
113
+
114
+ if attributes.key?(:'star_rating')
115
+ self.star_rating = attributes[:'star_rating']
116
+ end
117
+
118
+ if attributes.key?(:'number_of_nights')
119
+ self.number_of_nights = attributes[:'number_of_nights']
120
+ end
121
+
122
+ if attributes.key?(:'number_of_rooms')
123
+ self.number_of_rooms = attributes[:'number_of_rooms']
124
+ end
125
+
126
+ if attributes.key?(:'project_id')
127
+ self.project_id = attributes[:'project_id']
128
+ end
129
+
130
+ if attributes.key?(:'create_order')
131
+ self.create_order = attributes[:'create_order']
132
+ else
133
+ self.create_order = false
134
+ end
135
+ end
136
+
137
+ # Show invalid properties with the reasons. Usually used together with valid?
138
+ # @return Array for valid properties with the reasons
139
+ def list_invalid_properties
140
+ invalid_properties = Array.new
141
+ if @country_code.nil?
142
+ invalid_properties.push('invalid value for "country_code", country_code cannot be nil.')
143
+ end
144
+
145
+ invalid_properties
146
+ end
147
+
148
+ # Check to see if the all the properties in the model are valid
149
+ # @return true if the model is valid
150
+ def valid?
151
+ return false if @country_code.nil?
152
+ true
153
+ end
154
+
155
+ # Checks equality by comparing each attribute.
156
+ # @param [Object] Object to be compared
157
+ def ==(o)
158
+ return true if self.equal?(o)
159
+ self.class == o.class &&
160
+ country_code == o.country_code &&
161
+ city == o.city &&
162
+ region == o.region &&
163
+ star_rating == o.star_rating &&
164
+ number_of_nights == o.number_of_nights &&
165
+ number_of_rooms == o.number_of_rooms &&
166
+ project_id == o.project_id &&
167
+ create_order == o.create_order
168
+ end
169
+
170
+ # @see the `==` method
171
+ # @param [Object] Object to be compared
172
+ def eql?(o)
173
+ self == o
174
+ end
175
+
176
+ # Calculates hash code according to all attributes.
177
+ # @return [Integer] Hash code
178
+ def hash
179
+ [country_code, city, region, star_rating, number_of_nights, number_of_rooms, project_id, create_order].hash
180
+ end
181
+
182
+ # Builds the object from hash
183
+ # @param [Hash] attributes Model attributes in the form of hash
184
+ # @return [Object] Returns the model itself
185
+ def self.build_from_hash(attributes)
186
+ new.build_from_hash(attributes)
187
+ end
188
+
189
+ # Builds the object from hash
190
+ # @param [Hash] attributes Model attributes in the form of hash
191
+ # @return [Object] Returns the model itself
192
+ def build_from_hash(attributes)
193
+ return nil unless attributes.is_a?(Hash)
194
+ self.class.openapi_types.each_pair do |key, type|
195
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
196
+ self.send("#{key}=", nil)
197
+ elsif type =~ /\AArray<(.*)>/i
198
+ # check to ensure the input is an array given that the attribute
199
+ # is documented as an array but the input is not
200
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
201
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
202
+ end
203
+ elsif !attributes[self.class.attribute_map[key]].nil?
204
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
205
+ end
206
+ end
207
+
208
+ self
209
+ end
210
+
211
+ # Deserializes the data based on type
212
+ # @param string type Data type
213
+ # @param string value Value to be deserialized
214
+ # @return [Object] Deserialized data
215
+ def _deserialize(type, value)
216
+ case type.to_sym
217
+ when :Time
218
+ Time.parse(value)
219
+ when :Date
220
+ Date.parse(value)
221
+ when :String
222
+ value.to_s
223
+ when :Integer
224
+ value.to_i
225
+ when :Float
226
+ value.to_f
227
+ when :Boolean
228
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
229
+ true
230
+ else
231
+ false
232
+ end
233
+ when :Object
234
+ # generic object (usually a Hash), return directly
235
+ value
236
+ when /\AArray<(?<inner_type>.+)>\z/
237
+ inner_type = Regexp.last_match[:inner_type]
238
+ value.map { |v| _deserialize(inner_type, v) }
239
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
240
+ k_type = Regexp.last_match[:k_type]
241
+ v_type = Regexp.last_match[:v_type]
242
+ {}.tap do |hash|
243
+ value.each do |k, v|
244
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
245
+ end
246
+ end
247
+ else # model
248
+ # models (e.g. Pet) or oneOf
249
+ klass = Patch.const_get(type)
250
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
251
+ end
252
+ end
253
+
254
+ # Returns the string representation of the object
255
+ # @return [String] String presentation of the object
256
+ def to_s
257
+ to_hash.to_s
258
+ end
259
+
260
+ # to_body is an alias to to_hash (backward compatibility)
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_body
263
+ to_hash
264
+ end
265
+
266
+ # Returns the object in the form of hash
267
+ # @return [Hash] Returns the object in the form of hash
268
+ def to_hash
269
+ hash = {}
270
+ self.class.attribute_map.each_pair do |attr, param|
271
+ value = self.send(attr)
272
+ if value.nil?
273
+ is_nullable = self.class.openapi_nullable.include?(attr)
274
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
275
+ end
276
+
277
+ hash[param] = _to_hash(value)
278
+ end
279
+ hash
280
+ end
281
+
282
+ # Outputs non-array value in the form of hash
283
+ # For object, use to_hash. Otherwise, just return the value
284
+ # @param [Object] value Any valid value
285
+ # @return [Hash] Returns the value in the form of hash
286
+ def _to_hash(value)
287
+ if value.is_a?(Array)
288
+ value.compact.map { |v| _to_hash(v) }
289
+ elsif value.is_a?(Hash)
290
+ {}.tap do |hash|
291
+ value.each { |k, v| hash[k] = _to_hash(v) }
292
+ end
293
+ elsif value.respond_to? :to_hash
294
+ value.to_hash
295
+ else
296
+ value
297
+ end
298
+ end
299
+ end
300
+ end
@@ -23,13 +23,38 @@ module Patch
23
23
 
24
24
  attr_accessor :metadata
25
25
 
26
+ attr_accessor :state
27
+
28
+ class EnumAttributeValidator
29
+ attr_reader :datatype
30
+ attr_reader :allowable_values
31
+
32
+ def initialize(datatype, allowable_values)
33
+ @allowable_values = allowable_values.map do |value|
34
+ case datatype.to_s
35
+ when /Integer/i
36
+ value.to_i
37
+ when /Float/i
38
+ value.to_f
39
+ else
40
+ value
41
+ end
42
+ end
43
+ end
44
+
45
+ def valid?(value)
46
+ !value || allowable_values.include?(value)
47
+ end
48
+ end
49
+
26
50
  # Attribute mapping from ruby-style variable name to JSON key.
27
51
  def self.attribute_map
28
52
  {
29
53
  :'mass_g' => :'mass_g',
30
54
  :'total_price_cents_usd' => :'total_price_cents_usd',
31
55
  :'project_id' => :'project_id',
32
- :'metadata' => :'metadata'
56
+ :'metadata' => :'metadata',
57
+ :'state' => :'state'
33
58
  }
34
59
  end
35
60
 
@@ -44,7 +69,8 @@ module Patch
44
69
  :'mass_g' => :'Integer',
45
70
  :'total_price_cents_usd' => :'Integer',
46
71
  :'project_id' => :'String',
47
- :'metadata' => :'Object'
72
+ :'metadata' => :'Object',
73
+ :'state' => :'String'
48
74
  }
49
75
  end
50
76
 
@@ -96,6 +122,10 @@ module Patch
96
122
  if attributes.key?(:'metadata')
97
123
  self.metadata = attributes[:'metadata']
98
124
  end
125
+
126
+ if attributes.key?(:'state')
127
+ self.state = attributes[:'state']
128
+ end
99
129
  end
100
130
 
101
131
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -123,6 +153,8 @@ module Patch
123
153
  return false if !@mass_g.nil? && @mass_g > 100000000000
124
154
  return false if !@mass_g.nil? && @mass_g < 0
125
155
  return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
156
+ state_validator = EnumAttributeValidator.new('String', ["draft", "placed"])
157
+ return false unless state_validator.valid?(@state)
126
158
  true
127
159
  end
128
160
 
@@ -150,6 +182,16 @@ module Patch
150
182
  @total_price_cents_usd = total_price_cents_usd
151
183
  end
152
184
 
185
+ # Custom attribute writer method checking allowed values (enum).
186
+ # @param [Object] state Object to be assigned
187
+ def state=(state)
188
+ validator = EnumAttributeValidator.new('String', ["draft", "placed"])
189
+ unless validator.valid?(state)
190
+ fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
191
+ end
192
+ @state = state
193
+ end
194
+
153
195
  # Checks equality by comparing each attribute.
154
196
  # @param [Object] Object to be compared
155
197
  def ==(o)
@@ -158,7 +200,8 @@ module Patch
158
200
  mass_g == o.mass_g &&
159
201
  total_price_cents_usd == o.total_price_cents_usd &&
160
202
  project_id == o.project_id &&
161
- metadata == o.metadata
203
+ metadata == o.metadata &&
204
+ state == o.state
162
205
  end
163
206
 
164
207
  # @see the `==` method
@@ -170,7 +213,7 @@ module Patch
170
213
  # Calculates hash code according to all attributes.
171
214
  # @return [Integer] Hash code
172
215
  def hash
173
- [mass_g, total_price_cents_usd, project_id, metadata].hash
216
+ [mass_g, total_price_cents_usd, project_id, metadata, state].hash
174
217
  end
175
218
 
176
219
  # Builds the object from hash
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.17.0'
14
+ VERSION = '1.19.0'
15
15
  end
data/lib/patch_ruby.rb CHANGED
@@ -21,6 +21,7 @@ require 'patch_ruby/models/allocation'
21
21
  require 'patch_ruby/models/create_bitcoin_estimate_request'
22
22
  require 'patch_ruby/models/create_ethereum_estimate_request'
23
23
  require 'patch_ruby/models/create_flight_estimate_request'
24
+ require 'patch_ruby/models/create_hotel_estimate_request'
24
25
  require 'patch_ruby/models/create_mass_estimate_request'
25
26
  require 'patch_ruby/models/create_order_request'
26
27
  require 'patch_ruby/models/create_shipping_estimate_request'
@@ -87,7 +87,7 @@ RSpec.describe 'Estimates Integration' do
87
87
  )
88
88
 
89
89
  expect(create_estimate_response.data.type).to eq 'shipping'
90
- expect(create_estimate_response.data.mass_g).to eq 12_431
90
+ expect(create_estimate_response.data.mass_g).to be >= 10_000
91
91
  end
92
92
 
93
93
 
@@ -156,4 +156,19 @@ RSpec.describe 'Estimates Integration' do
156
156
  expect(ethereum_estimate.data.type).to eq 'ethereum'
157
157
  expect(ethereum_estimate.data.mass_g).to be >= 2_000
158
158
  end
159
+
160
+ it 'supports creating hotel estimates' do
161
+ create_estimate_response = Patch::Estimate.create_hotel_estimate(
162
+ country_code: "US",
163
+ city: "Denver",
164
+ star_rating: 5,
165
+ number_of_nights: 2,
166
+ number_of_rooms: 2
167
+ )
168
+
169
+ expect(create_estimate_response.success).to eq(true)
170
+ expect(create_estimate_response.data.type).to eq 'hotel'
171
+ expect(create_estimate_response.data.mass_g).to be >= 100_000
172
+ expect(create_estimate_response.data.id).not_to be_nil
173
+ end
159
174
  end
@@ -84,7 +84,17 @@ RSpec.describe 'Orders Integration' do
84
84
  .to all(have_key(:user))
85
85
  end
86
86
 
87
- it 'supports place and cancel for orders created via an estimate' do
87
+ it 'supports creation in draft state' do
88
+ create_order_response =
89
+ Patch::Order.create_order(mass_g: 100, state: "draft")
90
+
91
+ expect(create_order_response.success).to eq true
92
+ expect(create_order_response.data.id).not_to be_nil
93
+ expect(create_order_response.data.mass_g).to eq(100)
94
+ expect(create_order_response.data.state).to eq("draft")
95
+ end
96
+
97
+ xit 'supports place and cancel for orders created via an estimate' do
88
98
  create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true)
89
99
  order_to_place_id = create_estimate_to_place_response.data.order.id
90
100
 
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.17.0
4
+ version: 1.19.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: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -95,7 +95,6 @@ files:
95
95
  - lib/patch_ruby.rb
96
96
  - lib/patch_ruby/api/estimates_api.rb
97
97
  - lib/patch_ruby/api/orders_api.rb
98
- - lib/patch_ruby/api/preferences_api.rb
99
98
  - lib/patch_ruby/api/projects_api.rb
100
99
  - lib/patch_ruby/api/technology_types_api.rb
101
100
  - lib/patch_ruby/api_client.rb
@@ -105,6 +104,7 @@ files:
105
104
  - lib/patch_ruby/models/create_bitcoin_estimate_request.rb
106
105
  - lib/patch_ruby/models/create_ethereum_estimate_request.rb
107
106
  - lib/patch_ruby/models/create_flight_estimate_request.rb
107
+ - lib/patch_ruby/models/create_hotel_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
110
  - lib/patch_ruby/models/create_shipping_estimate_request.rb
@@ -199,48 +199,48 @@ signing_key:
199
199
  specification_version: 4
200
200
  summary: Ruby wrapper for the Patch API
201
201
  test_files:
202
- - spec/api/orders_api_spec.rb
203
202
  - spec/api/projects_api_spec.rb
204
- - spec/api/technology_types_api_spec.rb
205
203
  - spec/api/estimates_api_spec.rb
204
+ - spec/api/technology_types_api_spec.rb
205
+ - spec/api/orders_api_spec.rb
206
206
  - spec/api_client_spec.rb
207
207
  - spec/configuration_spec.rb
208
208
  - spec/constants.rb
209
- - spec/factories/allocations.rb
210
- - spec/factories/meta_index_objects.rb
211
- - spec/factories/error_responses.rb
209
+ - spec/factories/project_list_responses.rb
210
+ - spec/factories/orders.rb
211
+ - spec/factories/estimates.rb
212
+ - spec/factories/create_order_requests.rb
212
213
  - spec/factories/create_mass_estimate_requests.rb
213
- - spec/factories/sdgs.rb
214
+ - spec/factories/estimate_list_responses.rb
214
215
  - spec/factories/order_responses.rb
215
- - spec/factories/order_list_responses.rb
216
- - spec/factories/estimates.rb
217
- - spec/factories/project_responses.rb
218
216
  - spec/factories/projects.rb
219
217
  - spec/factories/technology_type.rb
220
- - spec/factories/estimate_responses.rb
221
- - spec/factories/estimate_list_responses.rb
222
- - spec/factories/orders.rb
223
218
  - spec/factories/parent_technology_type.rb
224
- - spec/factories/create_order_requests.rb
225
- - spec/factories/project_list_responses.rb
219
+ - spec/factories/order_list_responses.rb
220
+ - spec/factories/error_responses.rb
221
+ - spec/factories/allocations.rb
222
+ - spec/factories/project_responses.rb
223
+ - spec/factories/sdgs.rb
224
+ - spec/factories/estimate_responses.rb
225
+ - spec/factories/meta_index_objects.rb
226
226
  - spec/integration/projects_spec.rb
227
+ - spec/integration/estimates_spec.rb
227
228
  - spec/integration/orders_spec.rb
228
229
  - spec/integration/projects/technology_types_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
230
+ - spec/models/estimate_spec.rb
233
231
  - spec/models/create_order_request_spec.rb
234
- - spec/models/project_list_response_spec.rb
235
- - spec/models/estimate_list_response_spec.rb
236
- - spec/models/project_spec.rb
237
- - spec/models/estimate_response_spec.rb
232
+ - spec/models/create_mass_estimate_request_spec.rb
233
+ - spec/models/error_response_spec.rb
238
234
  - spec/models/order_list_response_spec.rb
235
+ - spec/models/order_response_spec.rb
236
+ - spec/models/estimate_response_spec.rb
239
237
  - spec/models/order_spec.rb
238
+ - spec/models/project_spec.rb
239
+ - spec/models/project_list_response_spec.rb
240
240
  - spec/models/project_response_spec.rb
241
+ - spec/models/allocation_spec.rb
241
242
  - spec/models/meta_index_object_spec.rb
242
- - spec/models/estimate_spec.rb
243
- - spec/models/create_mass_estimate_request_spec.rb
243
+ - spec/models/estimate_list_response_spec.rb
244
244
  - spec/patch_ruby_spec.rb
245
245
  - spec/spec_helper.rb
246
246
  - spec/support/shared/generated_classes.rb
@@ -1,284 +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 'cgi'
14
-
15
- module Patch
16
- class PreferencesApi
17
- OPERATIONS = [
18
- :create_preference,
19
- :delete_preference,
20
- :retrieve_preference,
21
- :retrieve_preferences,
22
- ]
23
-
24
- attr_accessor :api_client
25
-
26
- def initialize(api_client = ApiClient.default)
27
- @api_client = api_client
28
- end
29
- # creates a project preference
30
- # Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to.
31
- # @param create_preference_request [CreatePreferenceRequest]
32
- # @param [Hash] opts the optional parameters
33
- # @return [PreferenceResponse]
34
- def create_preference(create_preference_request = {}, opts = {})
35
- _create_preference_request = Patch::CreatePreferenceRequest.new(create_preference_request)
36
- data, _status_code, _headers = create_preference_with_http_info(_create_preference_request, opts)
37
- data
38
- end
39
-
40
- # creates a project preference
41
- # 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.
42
- # @param create_preference_request [CreatePreferenceRequest]
43
- # @param [Hash] opts the optional parameters
44
- # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers
45
- def create_preference_with_http_info(create_preference_request, opts = {})
46
- if @api_client.config.debugging
47
- @api_client.config.logger.debug 'Calling API: PreferencesApi.create_preference ...'
48
- end
49
- # verify the required parameter 'create_preference_request' is set
50
- if @api_client.config.client_side_validation && create_preference_request.nil?
51
- fail ArgumentError, "Missing the required parameter 'create_preference_request' when calling PreferencesApi.create_preference"
52
- end
53
- # resource path
54
- local_var_path = '/v1/preferences'
55
-
56
- # query parameters
57
- query_params = opts[:query_params] || {}
58
-
59
- # header parameters
60
- header_params = opts[:header_params] || {}
61
- # HTTP header 'Accept' (if needed)
62
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
63
- # HTTP header 'Content-Type'
64
- header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
65
-
66
- # form parameters
67
- form_params = opts[:form_params] || {}
68
-
69
- # http body (model)
70
- post_body = opts[:debug_body] || @api_client.object_to_http_body(create_preference_request)
71
-
72
- # return_type
73
- return_type = opts[:debug_return_type] || 'PreferenceResponse'
74
-
75
- # auth_names
76
- auth_names = opts[:debug_auth_names] || ['bearer_auth']
77
-
78
- new_options = opts.merge(
79
- :operation => :"PreferencesApi.create_preference",
80
- :header_params => header_params,
81
- :query_params => query_params,
82
- :form_params => form_params,
83
- :body => post_body,
84
- :auth_names => auth_names,
85
- :return_type => return_type
86
- )
87
-
88
- data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
89
- if @api_client.config.debugging
90
- @api_client.config.logger.debug "API called: PreferencesApi#create_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
91
- end
92
- return data, status_code, headers
93
- end
94
-
95
- # Deletes an organization's preference for a project
96
- # Deletes the given `preference`. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
97
- # @param id [String]
98
- # @param [Hash] opts the optional parameters
99
- # @return [PreferenceResponse]
100
- def delete_preference(id, opts = {})
101
-
102
- data, _status_code, _headers = delete_preference_with_http_info(id, opts)
103
- data
104
- end
105
-
106
- # Deletes an organization&#39;s preference for a project
107
- # 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.
108
- # @param id [String]
109
- # @param [Hash] opts the optional parameters
110
- # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers
111
- def delete_preference_with_http_info(id, opts = {})
112
- if @api_client.config.debugging
113
- @api_client.config.logger.debug 'Calling API: PreferencesApi.delete_preference ...'
114
- end
115
- # verify the required parameter 'id' is set
116
- if @api_client.config.client_side_validation && id.nil?
117
- fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.delete_preference"
118
- end
119
- # resource path
120
- local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
121
-
122
- # query parameters
123
- query_params = opts[:query_params] || {}
124
-
125
- # header parameters
126
- header_params = opts[:header_params] || {}
127
- # HTTP header 'Accept' (if needed)
128
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
129
-
130
- # form parameters
131
- form_params = opts[:form_params] || {}
132
-
133
- # http body (model)
134
- post_body = opts[:debug_body]
135
-
136
- # return_type
137
- return_type = opts[:debug_return_type] || 'PreferenceResponse'
138
-
139
- # auth_names
140
- auth_names = opts[:debug_auth_names] || ['bearer_auth']
141
-
142
- new_options = opts.merge(
143
- :operation => :"PreferencesApi.delete_preference",
144
- :header_params => header_params,
145
- :query_params => query_params,
146
- :form_params => form_params,
147
- :body => post_body,
148
- :auth_names => auth_names,
149
- :return_type => return_type
150
- )
151
-
152
- data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
153
- if @api_client.config.debugging
154
- @api_client.config.logger.debug "API called: PreferencesApi#delete_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
155
- end
156
- return data, status_code, headers
157
- end
158
-
159
- # Retrieve the preference
160
- # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
161
- # @param id [String]
162
- # @param [Hash] opts the optional parameters
163
- # @return [PreferenceResponse]
164
- def retrieve_preference(id, opts = {})
165
-
166
- data, _status_code, _headers = retrieve_preference_with_http_info(id, opts)
167
- data
168
- end
169
-
170
- # Retrieve the preference
171
- # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
172
- # @param id [String]
173
- # @param [Hash] opts the optional parameters
174
- # @return [Array<(PreferenceResponse, Integer, Hash)>] PreferenceResponse data, response status code and response headers
175
- def retrieve_preference_with_http_info(id, opts = {})
176
- if @api_client.config.debugging
177
- @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preference ...'
178
- end
179
- # verify the required parameter 'id' is set
180
- if @api_client.config.client_side_validation && id.nil?
181
- fail ArgumentError, "Missing the required parameter 'id' when calling PreferencesApi.retrieve_preference"
182
- end
183
- # resource path
184
- local_var_path = '/v1/preferences/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
185
-
186
- # query parameters
187
- query_params = opts[:query_params] || {}
188
-
189
- # header parameters
190
- header_params = opts[:header_params] || {}
191
- # HTTP header 'Accept' (if needed)
192
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
193
-
194
- # form parameters
195
- form_params = opts[:form_params] || {}
196
-
197
- # http body (model)
198
- post_body = opts[:debug_body]
199
-
200
- # return_type
201
- return_type = opts[:debug_return_type] || 'PreferenceResponse'
202
-
203
- # auth_names
204
- auth_names = opts[:debug_auth_names] || ['bearer_auth']
205
-
206
- new_options = opts.merge(
207
- :operation => :"PreferencesApi.retrieve_preference",
208
- :header_params => header_params,
209
- :query_params => query_params,
210
- :form_params => form_params,
211
- :body => post_body,
212
- :auth_names => auth_names,
213
- :return_type => return_type
214
- )
215
-
216
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
217
- if @api_client.config.debugging
218
- @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
219
- end
220
- return data, status_code, headers
221
- end
222
-
223
- # Retrieves a list of preferences
224
- # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
225
- # @param [Hash] opts the optional parameters
226
- # @option opts [Integer] :page
227
- # @return [PreferenceListResponse]
228
- def retrieve_preferences(opts = {})
229
-
230
- data, _status_code, _headers = retrieve_preferences_with_http_info(opts)
231
- data
232
- end
233
-
234
- # Retrieves a list of preferences
235
- # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
236
- # @param [Hash] opts the optional parameters
237
- # @option opts [Integer] :page
238
- # @return [Array<(PreferenceListResponse, Integer, Hash)>] PreferenceListResponse data, response status code and response headers
239
- def retrieve_preferences_with_http_info(opts = {})
240
- if @api_client.config.debugging
241
- @api_client.config.logger.debug 'Calling API: PreferencesApi.retrieve_preferences ...'
242
- end
243
- # resource path
244
- local_var_path = '/v1/preferences'
245
-
246
- # query parameters
247
- query_params = opts[:query_params] || {}
248
- query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
249
-
250
- # header parameters
251
- header_params = opts[:header_params] || {}
252
- # HTTP header 'Accept' (if needed)
253
- header_params['Accept'] = @api_client.select_header_accept(['application/json'])
254
-
255
- # form parameters
256
- form_params = opts[:form_params] || {}
257
-
258
- # http body (model)
259
- post_body = opts[:debug_body]
260
-
261
- # return_type
262
- return_type = opts[:debug_return_type] || 'PreferenceListResponse'
263
-
264
- # auth_names
265
- auth_names = opts[:debug_auth_names] || ['bearer_auth']
266
-
267
- new_options = opts.merge(
268
- :operation => :"PreferencesApi.retrieve_preferences",
269
- :header_params => header_params,
270
- :query_params => query_params,
271
- :form_params => form_params,
272
- :body => post_body,
273
- :auth_names => auth_names,
274
- :return_type => return_type
275
- )
276
-
277
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
278
- if @api_client.config.debugging
279
- @api_client.config.logger.debug "API called: PreferencesApi#retrieve_preferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
280
- end
281
- return data, status_code, headers
282
- end
283
- end
284
- end