patch_ruby 1.0.0.pre

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