patch_ruby 1.15.1 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +4 -2
- data/README.md +11 -12
- data/lib/patch_ruby/api/estimates_api.rb +28 -10
- data/lib/patch_ruby/api/orders_api.rb +10 -7
- data/lib/patch_ruby/api/projects_api.rb +4 -4
- data/lib/patch_ruby/api/technology_types_api.rb +3 -3
- data/lib/patch_ruby/api_client.rb +6 -6
- data/lib/patch_ruby/api_error.rb +2 -2
- data/lib/patch_ruby/configuration.rb +6 -6
- data/lib/patch_ruby/models/allocation.rb +2 -2
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -7
- data/lib/patch_ruby/models/create_order_request.rb +7 -7
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/create_success_response.rb +3 -7
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -2
- data/lib/patch_ruby/models/error_response.rb +3 -7
- data/lib/patch_ruby/models/estimate.rb +5 -2
- data/lib/patch_ruby/models/estimate_list_response.rb +2 -2
- data/lib/patch_ruby/models/estimate_response.rb +2 -2
- data/lib/patch_ruby/models/{preference_response.rb → highlight.rb} +40 -33
- data/lib/patch_ruby/models/meta_index_object.rb +2 -2
- data/lib/patch_ruby/models/order.rb +10 -15
- data/lib/patch_ruby/models/order_list_response.rb +2 -2
- data/lib/patch_ruby/models/order_response.rb +2 -2
- data/lib/patch_ruby/models/parent_technology_type.rb +2 -2
- data/lib/patch_ruby/models/photo.rb +2 -2
- data/lib/patch_ruby/models/project.rb +29 -9
- data/lib/patch_ruby/models/project_list_response.rb +2 -2
- data/lib/patch_ruby/models/project_response.rb +2 -2
- data/lib/patch_ruby/models/sdg.rb +2 -2
- data/lib/patch_ruby/models/standard.rb +2 -2
- data/lib/patch_ruby/models/technology_type.rb +2 -2
- data/lib/patch_ruby/models/technology_type_list_response.rb +2 -2
- data/lib/patch_ruby/version.rb +3 -3
- data/lib/patch_ruby.rb +3 -7
- data/patch_ruby.gemspec +2 -2
- data/spec/api_client_spec.rb +4 -4
- data/spec/configuration_spec.rb +2 -2
- data/spec/integration/orders_spec.rb +1 -3
- data/spec/integration/projects_spec.rb +2 -0
- data/spec/models/error_response_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +25 -48
- data/lib/patch_ruby/models/create_preference_request.rb +0 -233
- data/lib/patch_ruby/models/preference.rb +0 -264
- data/lib/patch_ruby/models/preference_list_response.rb +0 -273
- data/spec/api/preferences_api_spec.rb +0 -82
- data/spec/factories/create_preference_requests.rb +0 -5
- data/spec/factories/preference_list_responses.rb +0 -8
- data/spec/factories/preference_responses.rb +0 -7
- data/spec/factories/preferences.rb +0 -7
- data/spec/integration/preferences_spec.rb +0 -32
- data/spec/models/create_preference_request_spec.rb +0 -47
- data/spec/models/preference_list_response_spec.rb +0 -64
- data/spec/models/preference_response_spec.rb +0 -58
- data/spec/models/preference_spec.rb +0 -58
@@ -1,264 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Patch API V1
|
3
|
-
|
4
|
-
#The core API used to integrate with Patch's service
|
5
|
-
|
6
|
-
The version of the OpenAPI document: v1
|
7
|
-
Contact: developers@usepatch.com
|
8
|
-
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 5.2.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
require 'time'
|
15
|
-
|
16
|
-
module Patch
|
17
|
-
class Preference
|
18
|
-
# A unique uid for the record. UIDs will be prepended by pre_prod or pre_test depending on the mode it was created in.
|
19
|
-
attr_accessor :id
|
20
|
-
|
21
|
-
# Percentage of total purchased offsets that should go to a project. Default is 100%.
|
22
|
-
attr_accessor :allocation_percentage
|
23
|
-
|
24
|
-
# An object returning the Project record this Preference is associated with. See the [Project section](/?id=projects) for the full schema.
|
25
|
-
attr_accessor :project
|
26
|
-
|
27
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
-
def self.attribute_map
|
29
|
-
{
|
30
|
-
:'id' => :'id',
|
31
|
-
:'allocation_percentage' => :'allocation_percentage',
|
32
|
-
:'project' => :'project'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns all the JSON keys this model knows about
|
37
|
-
def self.acceptable_attributes
|
38
|
-
attribute_map.values
|
39
|
-
end
|
40
|
-
|
41
|
-
# Attribute type mapping.
|
42
|
-
def self.openapi_types
|
43
|
-
{
|
44
|
-
:'id' => :'String',
|
45
|
-
:'allocation_percentage' => :'Integer',
|
46
|
-
:'project' => :'Project'
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
# List of attributes with nullable: true
|
51
|
-
def self.openapi_nullable
|
52
|
-
Set.new([
|
53
|
-
])
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
# Allows models with corresponding API classes to delegate API operations to those API classes
|
58
|
-
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
59
|
-
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
60
|
-
def self.method_missing(message, *args, &block)
|
61
|
-
if Object.const_defined?('Patch::PreferencesApi::OPERATIONS') && Patch::PreferencesApi::OPERATIONS.include?(message)
|
62
|
-
Patch::PreferencesApi.new.send(message, *args)
|
63
|
-
else
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Initializes the object
|
69
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
70
|
-
def initialize(attributes = {})
|
71
|
-
if (!attributes.is_a?(Hash))
|
72
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Preference` initialize method"
|
73
|
-
end
|
74
|
-
|
75
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
76
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
77
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
78
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Preference`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
79
|
-
end
|
80
|
-
h[k.to_sym] = v
|
81
|
-
}
|
82
|
-
|
83
|
-
if attributes.key?(:'id')
|
84
|
-
self.id = attributes[:'id']
|
85
|
-
end
|
86
|
-
|
87
|
-
if attributes.key?(:'allocation_percentage')
|
88
|
-
self.allocation_percentage = attributes[:'allocation_percentage']
|
89
|
-
end
|
90
|
-
|
91
|
-
if attributes.key?(:'project')
|
92
|
-
self.project = attributes[:'project']
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
97
|
-
# @return Array for valid properties with the reasons
|
98
|
-
def list_invalid_properties
|
99
|
-
invalid_properties = Array.new
|
100
|
-
if @id.nil?
|
101
|
-
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
102
|
-
end
|
103
|
-
|
104
|
-
if @allocation_percentage.nil?
|
105
|
-
invalid_properties.push('invalid value for "allocation_percentage", allocation_percentage cannot be nil.')
|
106
|
-
end
|
107
|
-
|
108
|
-
if @project.nil?
|
109
|
-
invalid_properties.push('invalid value for "project", project cannot be nil.')
|
110
|
-
end
|
111
|
-
|
112
|
-
invalid_properties
|
113
|
-
end
|
114
|
-
|
115
|
-
# Check to see if the all the properties in the model are valid
|
116
|
-
# @return true if the model is valid
|
117
|
-
def valid?
|
118
|
-
return false if @id.nil?
|
119
|
-
return false if @allocation_percentage.nil?
|
120
|
-
return false if @project.nil?
|
121
|
-
true
|
122
|
-
end
|
123
|
-
|
124
|
-
# Checks equality by comparing each attribute.
|
125
|
-
# @param [Object] Object to be compared
|
126
|
-
def ==(o)
|
127
|
-
return true if self.equal?(o)
|
128
|
-
self.class == o.class &&
|
129
|
-
id == o.id &&
|
130
|
-
allocation_percentage == o.allocation_percentage &&
|
131
|
-
project == o.project
|
132
|
-
end
|
133
|
-
|
134
|
-
# @see the `==` method
|
135
|
-
# @param [Object] Object to be compared
|
136
|
-
def eql?(o)
|
137
|
-
self == o
|
138
|
-
end
|
139
|
-
|
140
|
-
# Calculates hash code according to all attributes.
|
141
|
-
# @return [Integer] Hash code
|
142
|
-
def hash
|
143
|
-
[id, allocation_percentage, project].hash
|
144
|
-
end
|
145
|
-
|
146
|
-
# Builds the object from hash
|
147
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
148
|
-
# @return [Object] Returns the model itself
|
149
|
-
def self.build_from_hash(attributes)
|
150
|
-
new.build_from_hash(attributes)
|
151
|
-
end
|
152
|
-
|
153
|
-
# Builds the object from hash
|
154
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
-
# @return [Object] Returns the model itself
|
156
|
-
def build_from_hash(attributes)
|
157
|
-
return nil unless attributes.is_a?(Hash)
|
158
|
-
self.class.openapi_types.each_pair do |key, type|
|
159
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
160
|
-
self.send("#{key}=", nil)
|
161
|
-
elsif type =~ /\AArray<(.*)>/i
|
162
|
-
# check to ensure the input is an array given that the attribute
|
163
|
-
# is documented as an array but the input is not
|
164
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
165
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
166
|
-
end
|
167
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
168
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
self
|
173
|
-
end
|
174
|
-
|
175
|
-
# Deserializes the data based on type
|
176
|
-
# @param string type Data type
|
177
|
-
# @param string value Value to be deserialized
|
178
|
-
# @return [Object] Deserialized data
|
179
|
-
def _deserialize(type, value)
|
180
|
-
case type.to_sym
|
181
|
-
when :Time
|
182
|
-
Time.parse(value)
|
183
|
-
when :Date
|
184
|
-
Date.parse(value)
|
185
|
-
when :String
|
186
|
-
value.to_s
|
187
|
-
when :Integer
|
188
|
-
value.to_i
|
189
|
-
when :Float
|
190
|
-
value.to_f
|
191
|
-
when :Boolean
|
192
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
193
|
-
true
|
194
|
-
else
|
195
|
-
false
|
196
|
-
end
|
197
|
-
when :Object
|
198
|
-
# generic object (usually a Hash), return directly
|
199
|
-
value
|
200
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
201
|
-
inner_type = Regexp.last_match[:inner_type]
|
202
|
-
value.map { |v| _deserialize(inner_type, v) }
|
203
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
204
|
-
k_type = Regexp.last_match[:k_type]
|
205
|
-
v_type = Regexp.last_match[:v_type]
|
206
|
-
{}.tap do |hash|
|
207
|
-
value.each do |k, v|
|
208
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
else # model
|
212
|
-
# models (e.g. Pet) or oneOf
|
213
|
-
klass = Patch.const_get(type)
|
214
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# Returns the string representation of the object
|
219
|
-
# @return [String] String presentation of the object
|
220
|
-
def to_s
|
221
|
-
to_hash.to_s
|
222
|
-
end
|
223
|
-
|
224
|
-
# to_body is an alias to to_hash (backward compatibility)
|
225
|
-
# @return [Hash] Returns the object in the form of hash
|
226
|
-
def to_body
|
227
|
-
to_hash
|
228
|
-
end
|
229
|
-
|
230
|
-
# Returns the object in the form of hash
|
231
|
-
# @return [Hash] Returns the object in the form of hash
|
232
|
-
def to_hash
|
233
|
-
hash = {}
|
234
|
-
self.class.attribute_map.each_pair do |attr, param|
|
235
|
-
value = self.send(attr)
|
236
|
-
if value.nil?
|
237
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
238
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
239
|
-
end
|
240
|
-
|
241
|
-
hash[param] = _to_hash(value)
|
242
|
-
end
|
243
|
-
hash
|
244
|
-
end
|
245
|
-
|
246
|
-
# Outputs non-array value in the form of hash
|
247
|
-
# For object, use to_hash. Otherwise, just return the value
|
248
|
-
# @param [Object] value Any valid value
|
249
|
-
# @return [Hash] Returns the value in the form of hash
|
250
|
-
def _to_hash(value)
|
251
|
-
if value.is_a?(Array)
|
252
|
-
value.compact.map { |v| _to_hash(v) }
|
253
|
-
elsif value.is_a?(Hash)
|
254
|
-
{}.tap do |hash|
|
255
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
256
|
-
end
|
257
|
-
elsif value.respond_to? :to_hash
|
258
|
-
value.to_hash
|
259
|
-
else
|
260
|
-
value
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
@@ -1,273 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Patch API V1
|
3
|
-
|
4
|
-
#The core API used to integrate with Patch's service
|
5
|
-
|
6
|
-
The version of the OpenAPI document: v1
|
7
|
-
Contact: developers@usepatch.com
|
8
|
-
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 5.2.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
require 'time'
|
15
|
-
|
16
|
-
module Patch
|
17
|
-
class PreferenceListResponse
|
18
|
-
attr_accessor :success
|
19
|
-
|
20
|
-
attr_accessor :error
|
21
|
-
|
22
|
-
attr_accessor :data
|
23
|
-
|
24
|
-
attr_accessor :meta
|
25
|
-
|
26
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
-
def self.attribute_map
|
28
|
-
{
|
29
|
-
:'success' => :'success',
|
30
|
-
:'error' => :'error',
|
31
|
-
:'data' => :'data',
|
32
|
-
:'meta' => :'meta'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns all the JSON keys this model knows about
|
37
|
-
def self.acceptable_attributes
|
38
|
-
attribute_map.values
|
39
|
-
end
|
40
|
-
|
41
|
-
# Attribute type mapping.
|
42
|
-
def self.openapi_types
|
43
|
-
{
|
44
|
-
:'success' => :'Boolean',
|
45
|
-
:'error' => :'Object',
|
46
|
-
:'data' => :'Array<Preference>',
|
47
|
-
:'meta' => :'MetaIndexObject'
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
# List of attributes with nullable: true
|
52
|
-
def self.openapi_nullable
|
53
|
-
Set.new([
|
54
|
-
:'error',
|
55
|
-
])
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
# Allows models with corresponding API classes to delegate API operations to those API classes
|
60
|
-
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
61
|
-
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
62
|
-
def self.method_missing(message, *args, &block)
|
63
|
-
if Object.const_defined?('Patch::PreferenceListResponsesApi::OPERATIONS') && Patch::PreferenceListResponsesApi::OPERATIONS.include?(message)
|
64
|
-
Patch::PreferenceListResponsesApi.new.send(message, *args)
|
65
|
-
else
|
66
|
-
super
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# Initializes the object
|
71
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
-
def initialize(attributes = {})
|
73
|
-
if (!attributes.is_a?(Hash))
|
74
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::PreferenceListResponse` initialize method"
|
75
|
-
end
|
76
|
-
|
77
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
78
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
79
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
80
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PreferenceListResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
81
|
-
end
|
82
|
-
h[k.to_sym] = v
|
83
|
-
}
|
84
|
-
|
85
|
-
if attributes.key?(:'success')
|
86
|
-
self.success = attributes[:'success']
|
87
|
-
end
|
88
|
-
|
89
|
-
if attributes.key?(:'error')
|
90
|
-
self.error = attributes[:'error']
|
91
|
-
end
|
92
|
-
|
93
|
-
if attributes.key?(:'data')
|
94
|
-
if (value = attributes[:'data']).is_a?(Array)
|
95
|
-
self.data = value
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
if attributes.key?(:'meta')
|
100
|
-
self.meta = attributes[:'meta']
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
105
|
-
# @return Array for valid properties with the reasons
|
106
|
-
def list_invalid_properties
|
107
|
-
invalid_properties = Array.new
|
108
|
-
if @success.nil?
|
109
|
-
invalid_properties.push('invalid value for "success", success cannot be nil.')
|
110
|
-
end
|
111
|
-
|
112
|
-
if @data.nil?
|
113
|
-
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
114
|
-
end
|
115
|
-
|
116
|
-
if @meta.nil?
|
117
|
-
invalid_properties.push('invalid value for "meta", meta cannot be nil.')
|
118
|
-
end
|
119
|
-
|
120
|
-
invalid_properties
|
121
|
-
end
|
122
|
-
|
123
|
-
# Check to see if the all the properties in the model are valid
|
124
|
-
# @return true if the model is valid
|
125
|
-
def valid?
|
126
|
-
return false if @success.nil?
|
127
|
-
return false if @data.nil?
|
128
|
-
return false if @meta.nil?
|
129
|
-
true
|
130
|
-
end
|
131
|
-
|
132
|
-
# Checks equality by comparing each attribute.
|
133
|
-
# @param [Object] Object to be compared
|
134
|
-
def ==(o)
|
135
|
-
return true if self.equal?(o)
|
136
|
-
self.class == o.class &&
|
137
|
-
success == o.success &&
|
138
|
-
error == o.error &&
|
139
|
-
data == o.data &&
|
140
|
-
meta == o.meta
|
141
|
-
end
|
142
|
-
|
143
|
-
# @see the `==` method
|
144
|
-
# @param [Object] Object to be compared
|
145
|
-
def eql?(o)
|
146
|
-
self == o
|
147
|
-
end
|
148
|
-
|
149
|
-
# Calculates hash code according to all attributes.
|
150
|
-
# @return [Integer] Hash code
|
151
|
-
def hash
|
152
|
-
[success, error, data, meta].hash
|
153
|
-
end
|
154
|
-
|
155
|
-
# Builds the object from hash
|
156
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
-
# @return [Object] Returns the model itself
|
158
|
-
def self.build_from_hash(attributes)
|
159
|
-
new.build_from_hash(attributes)
|
160
|
-
end
|
161
|
-
|
162
|
-
# Builds the object from hash
|
163
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
164
|
-
# @return [Object] Returns the model itself
|
165
|
-
def build_from_hash(attributes)
|
166
|
-
return nil unless attributes.is_a?(Hash)
|
167
|
-
self.class.openapi_types.each_pair do |key, type|
|
168
|
-
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
169
|
-
self.send("#{key}=", nil)
|
170
|
-
elsif type =~ /\AArray<(.*)>/i
|
171
|
-
# check to ensure the input is an array given that the attribute
|
172
|
-
# is documented as an array but the input is not
|
173
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
174
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
175
|
-
end
|
176
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
177
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
self
|
182
|
-
end
|
183
|
-
|
184
|
-
# Deserializes the data based on type
|
185
|
-
# @param string type Data type
|
186
|
-
# @param string value Value to be deserialized
|
187
|
-
# @return [Object] Deserialized data
|
188
|
-
def _deserialize(type, value)
|
189
|
-
case type.to_sym
|
190
|
-
when :Time
|
191
|
-
Time.parse(value)
|
192
|
-
when :Date
|
193
|
-
Date.parse(value)
|
194
|
-
when :String
|
195
|
-
value.to_s
|
196
|
-
when :Integer
|
197
|
-
value.to_i
|
198
|
-
when :Float
|
199
|
-
value.to_f
|
200
|
-
when :Boolean
|
201
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
202
|
-
true
|
203
|
-
else
|
204
|
-
false
|
205
|
-
end
|
206
|
-
when :Object
|
207
|
-
# generic object (usually a Hash), return directly
|
208
|
-
value
|
209
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
210
|
-
inner_type = Regexp.last_match[:inner_type]
|
211
|
-
value.map { |v| _deserialize(inner_type, v) }
|
212
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
213
|
-
k_type = Regexp.last_match[:k_type]
|
214
|
-
v_type = Regexp.last_match[:v_type]
|
215
|
-
{}.tap do |hash|
|
216
|
-
value.each do |k, v|
|
217
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
else # model
|
221
|
-
# models (e.g. Pet) or oneOf
|
222
|
-
klass = Patch.const_get(type)
|
223
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
# Returns the string representation of the object
|
228
|
-
# @return [String] String presentation of the object
|
229
|
-
def to_s
|
230
|
-
to_hash.to_s
|
231
|
-
end
|
232
|
-
|
233
|
-
# to_body is an alias to to_hash (backward compatibility)
|
234
|
-
# @return [Hash] Returns the object in the form of hash
|
235
|
-
def to_body
|
236
|
-
to_hash
|
237
|
-
end
|
238
|
-
|
239
|
-
# Returns the object in the form of hash
|
240
|
-
# @return [Hash] Returns the object in the form of hash
|
241
|
-
def to_hash
|
242
|
-
hash = {}
|
243
|
-
self.class.attribute_map.each_pair do |attr, param|
|
244
|
-
value = self.send(attr)
|
245
|
-
if value.nil?
|
246
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
247
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
248
|
-
end
|
249
|
-
|
250
|
-
hash[param] = _to_hash(value)
|
251
|
-
end
|
252
|
-
hash
|
253
|
-
end
|
254
|
-
|
255
|
-
# Outputs non-array value in the form of hash
|
256
|
-
# For object, use to_hash. Otherwise, just return the value
|
257
|
-
# @param [Object] value Any valid value
|
258
|
-
# @return [Hash] Returns the value in the form of hash
|
259
|
-
def _to_hash(value)
|
260
|
-
if value.is_a?(Array)
|
261
|
-
value.compact.map { |v| _to_hash(v) }
|
262
|
-
elsif value.is_a?(Hash)
|
263
|
-
{}.tap do |hash|
|
264
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
265
|
-
end
|
266
|
-
elsif value.respond_to? :to_hash
|
267
|
-
value.to_hash
|
268
|
-
else
|
269
|
-
value
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
@@ -1,82 +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: 4.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'spec_helper'
|
14
|
-
require 'json'
|
15
|
-
|
16
|
-
# Unit tests for Patch::PreferencesApi
|
17
|
-
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
-
# Please update as you see appropriate
|
19
|
-
describe 'PreferencesApi' do
|
20
|
-
before do
|
21
|
-
# run before each test
|
22
|
-
@api_instance = Patch::PreferencesApi.new
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
# run after each test
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'test an instance of PreferencesApi' do
|
30
|
-
it 'should create an instance of PreferencesApi' do
|
31
|
-
expect(@api_instance).to be_instance_of(Patch::PreferencesApi)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# unit tests for create_preference
|
36
|
-
# creates a project preference
|
37
|
-
# 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.
|
38
|
-
# @param create_preference_request
|
39
|
-
# @param [Hash] opts the optional parameters
|
40
|
-
# @return [PreferenceResponse]
|
41
|
-
describe 'create_preference test' do
|
42
|
-
it 'should work' do
|
43
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# unit tests for delete_preference
|
48
|
-
# Deletes an organization's preference for a project
|
49
|
-
# 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.
|
50
|
-
# @param id
|
51
|
-
# @param [Hash] opts the optional parameters
|
52
|
-
# @return [PreferenceResponse]
|
53
|
-
describe 'delete_preference test' do
|
54
|
-
it 'should work' do
|
55
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# unit tests for retrieve_preference
|
60
|
-
# Retrieve the preference
|
61
|
-
# Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
|
62
|
-
# @param id
|
63
|
-
# @param [Hash] opts the optional parameters
|
64
|
-
# @return [PreferenceResponse]
|
65
|
-
describe 'retrieve_preference test' do
|
66
|
-
it 'should work' do
|
67
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# unit tests for retrieve_preferences
|
72
|
-
# Retrieves a list of preferences
|
73
|
-
# Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
|
74
|
-
# @param [Hash] opts the optional parameters
|
75
|
-
# @option opts [Integer] :page
|
76
|
-
# @return [PreferenceListResponse]
|
77
|
-
describe 'retrieve_preferences test' do
|
78
|
-
it 'should work' do
|
79
|
-
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
RSpec.describe 'Preferences Integration' do
|
2
|
-
it 'supports create, delete, retrieve and list' do
|
3
|
-
retrieve_projects_response = Patch::Project.retrieve_projects
|
4
|
-
expect(retrieve_projects_response.data.length).not_to be_zero
|
5
|
-
project_id = retrieve_projects_response.data.first.id
|
6
|
-
|
7
|
-
begin
|
8
|
-
create_preference_response = Patch::Preference.create_preference(project_id: project_id)
|
9
|
-
preference_id = create_preference_response.data.id
|
10
|
-
rescue Patch::ApiError => e
|
11
|
-
preference_id = Patch::Preference.retrieve_preferences().data.first.id
|
12
|
-
end
|
13
|
-
|
14
|
-
retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
|
15
|
-
expect(retrieve_preference_response.data.id).to eq preference_id
|
16
|
-
|
17
|
-
page_limit = 1
|
18
|
-
next_page = 1
|
19
|
-
preferences = []
|
20
|
-
|
21
|
-
while !next_page.nil? && next_page <= page_limit
|
22
|
-
retrieve_preferences_response = Patch::Preference.retrieve_preferences(page: next_page)
|
23
|
-
next_page = retrieve_preferences_response.meta.next_page
|
24
|
-
preferences += retrieve_preferences_response.data
|
25
|
-
end
|
26
|
-
|
27
|
-
expect(preferences.length).not_to be_zero
|
28
|
-
|
29
|
-
delete_preference_response = Patch::Preference.delete_preference(preference_id)
|
30
|
-
expect(delete_preference_response.data.id).to eq preference_id
|
31
|
-
end
|
32
|
-
end
|