ultracart_api 4.1.260 → 4.1.261

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.
@@ -0,0 +1,366 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class SfvbItemTranslationBatchResponse
18
+ # True after an apply.
19
+ attr_accessor :applied
20
+
21
+ # Rows that would be stored, from a dry run.
22
+ attr_accessor :change
23
+
24
+ # Rows the apply ran out of time for. Nothing about them changed; send them again as a new batch.
25
+ attr_accessor :deferred
26
+
27
+ # Rows that could not be stored, after an apply.
28
+ attr_accessor :error
29
+
30
+ # The fields of the rows that would be stored, or were.
31
+ attr_accessor :fields
32
+
33
+ # Rows refused by the checks.
34
+ attr_accessor :invalid
35
+
36
+ # Distinct items with at least one row that would be stored, or was.
37
+ attr_accessor :item_count
38
+
39
+ # The languages of the rows that would be stored, or were.
40
+ attr_accessor :languages
41
+
42
+ # Rows naming an item that does not exist.
43
+ attr_accessor :not_found
44
+
45
+ # The hash of the rows answered as change, with their current_sha256. Apply exactly those rows with this hash.
46
+ attr_accessor :plan_hash
47
+
48
+ # One result per row, in request order.
49
+ attr_accessor :rows
50
+
51
+ # Rows left alone because a hand translation is already there.
52
+ attr_accessor :skipped_hand
53
+
54
+ # Rows skipped because the translation changed since the dry run.
55
+ attr_accessor :stale
56
+
57
+ # Rows checked.
58
+ attr_accessor :total
59
+
60
+ # Rows stored, after an apply.
61
+ attr_accessor :updated
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'applied' => :'applied',
67
+ :'change' => :'change',
68
+ :'deferred' => :'deferred',
69
+ :'error' => :'error',
70
+ :'fields' => :'fields',
71
+ :'invalid' => :'invalid',
72
+ :'item_count' => :'item_count',
73
+ :'languages' => :'languages',
74
+ :'not_found' => :'not_found',
75
+ :'plan_hash' => :'plan_hash',
76
+ :'rows' => :'rows',
77
+ :'skipped_hand' => :'skipped_hand',
78
+ :'stale' => :'stale',
79
+ :'total' => :'total',
80
+ :'updated' => :'updated'
81
+ }
82
+ end
83
+
84
+ # Returns all the JSON keys this model knows about
85
+ def self.acceptable_attributes
86
+ attribute_map.values
87
+ end
88
+
89
+ # Attribute type mapping.
90
+ def self.openapi_types
91
+ {
92
+ :'applied' => :'Boolean',
93
+ :'change' => :'Integer',
94
+ :'deferred' => :'Integer',
95
+ :'error' => :'Integer',
96
+ :'fields' => :'Array<String>',
97
+ :'invalid' => :'Integer',
98
+ :'item_count' => :'Integer',
99
+ :'languages' => :'Array<String>',
100
+ :'not_found' => :'Integer',
101
+ :'plan_hash' => :'String',
102
+ :'rows' => :'Array<SfvbItemTranslationBatchRowResult>',
103
+ :'skipped_hand' => :'Integer',
104
+ :'stale' => :'Integer',
105
+ :'total' => :'Integer',
106
+ :'updated' => :'Integer'
107
+ }
108
+ end
109
+
110
+ # List of attributes with nullable: true
111
+ def self.openapi_nullable
112
+ Set.new([
113
+ ])
114
+ end
115
+
116
+ # Initializes the object
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ def initialize(attributes = {})
119
+ if (!attributes.is_a?(Hash))
120
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbItemTranslationBatchResponse` initialize method"
121
+ end
122
+
123
+ # check to see if the attribute exists and convert string to symbol for hash key
124
+ attributes = attributes.each_with_object({}) { |(k, v), h|
125
+ if (!self.class.attribute_map.key?(k.to_sym))
126
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbItemTranslationBatchResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
127
+ end
128
+ h[k.to_sym] = v
129
+ }
130
+
131
+ if attributes.key?(:'applied')
132
+ self.applied = attributes[:'applied']
133
+ end
134
+
135
+ if attributes.key?(:'change')
136
+ self.change = attributes[:'change']
137
+ end
138
+
139
+ if attributes.key?(:'deferred')
140
+ self.deferred = attributes[:'deferred']
141
+ end
142
+
143
+ if attributes.key?(:'error')
144
+ self.error = attributes[:'error']
145
+ end
146
+
147
+ if attributes.key?(:'fields')
148
+ if (value = attributes[:'fields']).is_a?(Array)
149
+ self.fields = value
150
+ end
151
+ end
152
+
153
+ if attributes.key?(:'invalid')
154
+ self.invalid = attributes[:'invalid']
155
+ end
156
+
157
+ if attributes.key?(:'item_count')
158
+ self.item_count = attributes[:'item_count']
159
+ end
160
+
161
+ if attributes.key?(:'languages')
162
+ if (value = attributes[:'languages']).is_a?(Array)
163
+ self.languages = value
164
+ end
165
+ end
166
+
167
+ if attributes.key?(:'not_found')
168
+ self.not_found = attributes[:'not_found']
169
+ end
170
+
171
+ if attributes.key?(:'plan_hash')
172
+ self.plan_hash = attributes[:'plan_hash']
173
+ end
174
+
175
+ if attributes.key?(:'rows')
176
+ if (value = attributes[:'rows']).is_a?(Array)
177
+ self.rows = value
178
+ end
179
+ end
180
+
181
+ if attributes.key?(:'skipped_hand')
182
+ self.skipped_hand = attributes[:'skipped_hand']
183
+ end
184
+
185
+ if attributes.key?(:'stale')
186
+ self.stale = attributes[:'stale']
187
+ end
188
+
189
+ if attributes.key?(:'total')
190
+ self.total = attributes[:'total']
191
+ end
192
+
193
+ if attributes.key?(:'updated')
194
+ self.updated = attributes[:'updated']
195
+ end
196
+ end
197
+
198
+ # Show invalid properties with the reasons. Usually used together with valid?
199
+ # @return Array for valid properties with the reasons
200
+ def list_invalid_properties
201
+ invalid_properties = Array.new
202
+ invalid_properties
203
+ end
204
+
205
+ # Check to see if the all the properties in the model are valid
206
+ # @return true if the model is valid
207
+ def valid?
208
+ true
209
+ end
210
+
211
+ # Checks equality by comparing each attribute.
212
+ # @param [Object] Object to be compared
213
+ def ==(o)
214
+ return true if self.equal?(o)
215
+ self.class == o.class &&
216
+ applied == o.applied &&
217
+ change == o.change &&
218
+ deferred == o.deferred &&
219
+ error == o.error &&
220
+ fields == o.fields &&
221
+ invalid == o.invalid &&
222
+ item_count == o.item_count &&
223
+ languages == o.languages &&
224
+ not_found == o.not_found &&
225
+ plan_hash == o.plan_hash &&
226
+ rows == o.rows &&
227
+ skipped_hand == o.skipped_hand &&
228
+ stale == o.stale &&
229
+ total == o.total &&
230
+ updated == o.updated
231
+ end
232
+
233
+ # @see the `==` method
234
+ # @param [Object] Object to be compared
235
+ def eql?(o)
236
+ self == o
237
+ end
238
+
239
+ # Calculates hash code according to all attributes.
240
+ # @return [Integer] Hash code
241
+ def hash
242
+ [applied, change, deferred, error, fields, invalid, item_count, languages, not_found, plan_hash, rows, skipped_hand, stale, total, updated].hash
243
+ end
244
+
245
+ # Builds the object from hash
246
+ # @param [Hash] attributes Model attributes in the form of hash
247
+ # @return [Object] Returns the model itself
248
+ def self.build_from_hash(attributes)
249
+ new.build_from_hash(attributes)
250
+ end
251
+
252
+ # Builds the object from hash
253
+ # @param [Hash] attributes Model attributes in the form of hash
254
+ # @return [Object] Returns the model itself
255
+ def build_from_hash(attributes)
256
+ return nil unless attributes.is_a?(Hash)
257
+ attributes = attributes.transform_keys(&:to_sym)
258
+ self.class.openapi_types.each_pair do |key, type|
259
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
260
+ self.send("#{key}=", nil)
261
+ elsif type =~ /\AArray<(.*)>/i
262
+ # check to ensure the input is an array given that the attribute
263
+ # is documented as an array but the input is not
264
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
265
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
266
+ end
267
+ elsif !attributes[self.class.attribute_map[key]].nil?
268
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
269
+ end
270
+ end
271
+
272
+ self
273
+ end
274
+
275
+ # Deserializes the data based on type
276
+ # @param string type Data type
277
+ # @param string value Value to be deserialized
278
+ # @return [Object] Deserialized data
279
+ def _deserialize(type, value)
280
+ case type.to_sym
281
+ when :Time
282
+ Time.parse(value)
283
+ when :Date
284
+ Date.parse(value)
285
+ when :String
286
+ value.to_s
287
+ when :Integer
288
+ value.to_i
289
+ when :Float
290
+ value.to_f
291
+ when :Boolean
292
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
293
+ true
294
+ else
295
+ false
296
+ end
297
+ when :Object
298
+ # generic object (usually a Hash), return directly
299
+ value
300
+ when /\AArray<(?<inner_type>.+)>\z/
301
+ inner_type = Regexp.last_match[:inner_type]
302
+ value.map { |v| _deserialize(inner_type, v) }
303
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
304
+ k_type = Regexp.last_match[:k_type]
305
+ v_type = Regexp.last_match[:v_type]
306
+ {}.tap do |hash|
307
+ value.each do |k, v|
308
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
309
+ end
310
+ end
311
+ else # model
312
+ # models (e.g. Pet) or oneOf
313
+ klass = UltracartClient.const_get(type)
314
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
315
+ end
316
+ end
317
+
318
+ # Returns the string representation of the object
319
+ # @return [String] String presentation of the object
320
+ def to_s
321
+ to_hash.to_s
322
+ end
323
+
324
+ # to_body is an alias to to_hash (backward compatibility)
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_body
327
+ to_hash
328
+ end
329
+
330
+ # Returns the object in the form of hash
331
+ # @return [Hash] Returns the object in the form of hash
332
+ def to_hash
333
+ hash = {}
334
+ self.class.attribute_map.each_pair do |attr, param|
335
+ value = self.send(attr)
336
+ if value.nil?
337
+ is_nullable = self.class.openapi_nullable.include?(attr)
338
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
339
+ end
340
+
341
+ hash[param] = _to_hash(value)
342
+ end
343
+ hash
344
+ end
345
+
346
+ # Outputs non-array value in the form of hash
347
+ # For object, use to_hash. Otherwise, just return the value
348
+ # @param [Object] value Any valid value
349
+ # @return [Hash] Returns the value in the form of hash
350
+ def _to_hash(value)
351
+ if value.is_a?(Array)
352
+ value.compact.map { |v| _to_hash(v) }
353
+ elsif value.is_a?(Hash)
354
+ {}.tap do |hash|
355
+ value.each { |k, v| hash[k] = _to_hash(v) }
356
+ end
357
+ elsif value.respond_to? :to_hash
358
+ value.to_hash
359
+ else
360
+ value
361
+ end
362
+ end
363
+
364
+ end
365
+
366
+ end
@@ -0,0 +1,304 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class SfvbItemTranslationBatchRow
18
+ # The current_sha256 the dry run answered for this row. Required to apply.
19
+ attr_accessor :current_sha256
20
+
21
+ # title or extended_description.
22
+ attr_accessor :field
23
+
24
+ # The language code. To apply, send the code the dry run answered.
25
+ attr_accessor :language
26
+
27
+ # The item by its merchant item id, for a dry run. Send this or merchant_item_oid, not both.
28
+ attr_accessor :merchant_item_id
29
+
30
+ # The item. Required to apply; the dry run answers it for a row that named merchant_item_id.
31
+ attr_accessor :merchant_item_oid
32
+
33
+ # The hand translation. Must not be empty.
34
+ attr_accessor :text
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'current_sha256' => :'current_sha256',
62
+ :'field' => :'field',
63
+ :'language' => :'language',
64
+ :'merchant_item_id' => :'merchant_item_id',
65
+ :'merchant_item_oid' => :'merchant_item_oid',
66
+ :'text' => :'text'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'current_sha256' => :'String',
79
+ :'field' => :'String',
80
+ :'language' => :'String',
81
+ :'merchant_item_id' => :'String',
82
+ :'merchant_item_oid' => :'Integer',
83
+ :'text' => :'String'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbItemTranslationBatchRow` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbItemTranslationBatchRow`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'current_sha256')
109
+ self.current_sha256 = attributes[:'current_sha256']
110
+ end
111
+
112
+ if attributes.key?(:'field')
113
+ self.field = attributes[:'field']
114
+ end
115
+
116
+ if attributes.key?(:'language')
117
+ self.language = attributes[:'language']
118
+ end
119
+
120
+ if attributes.key?(:'merchant_item_id')
121
+ self.merchant_item_id = attributes[:'merchant_item_id']
122
+ end
123
+
124
+ if attributes.key?(:'merchant_item_oid')
125
+ self.merchant_item_oid = attributes[:'merchant_item_oid']
126
+ end
127
+
128
+ if attributes.key?(:'text')
129
+ self.text = attributes[:'text']
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ invalid_properties = Array.new
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ field_validator = EnumAttributeValidator.new('String', ["title", "extended_description"])
144
+ return false unless field_validator.valid?(@field)
145
+ true
146
+ end
147
+
148
+ # Custom attribute writer method checking allowed values (enum).
149
+ # @param [Object] field Object to be assigned
150
+ def field=(field)
151
+ validator = EnumAttributeValidator.new('String', ["title", "extended_description"])
152
+ unless validator.valid?(field)
153
+ fail ArgumentError, "invalid value for \"field\", must be one of #{validator.allowable_values}."
154
+ end
155
+ @field = field
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ current_sha256 == o.current_sha256 &&
164
+ field == o.field &&
165
+ language == o.language &&
166
+ merchant_item_id == o.merchant_item_id &&
167
+ merchant_item_oid == o.merchant_item_oid &&
168
+ text == o.text
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [current_sha256, field, language, merchant_item_id, merchant_item_oid, text].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ attributes = attributes.transform_keys(&:to_sym)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
203
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
204
+ end
205
+ elsif !attributes[self.class.attribute_map[key]].nil?
206
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
207
+ end
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ # Deserializes the data based on type
214
+ # @param string type Data type
215
+ # @param string value Value to be deserialized
216
+ # @return [Object] Deserialized data
217
+ def _deserialize(type, value)
218
+ case type.to_sym
219
+ when :Time
220
+ Time.parse(value)
221
+ when :Date
222
+ Date.parse(value)
223
+ when :String
224
+ value.to_s
225
+ when :Integer
226
+ value.to_i
227
+ when :Float
228
+ value.to_f
229
+ when :Boolean
230
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
231
+ true
232
+ else
233
+ false
234
+ end
235
+ when :Object
236
+ # generic object (usually a Hash), return directly
237
+ value
238
+ when /\AArray<(?<inner_type>.+)>\z/
239
+ inner_type = Regexp.last_match[:inner_type]
240
+ value.map { |v| _deserialize(inner_type, v) }
241
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
242
+ k_type = Regexp.last_match[:k_type]
243
+ v_type = Regexp.last_match[:v_type]
244
+ {}.tap do |hash|
245
+ value.each do |k, v|
246
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
247
+ end
248
+ end
249
+ else # model
250
+ # models (e.g. Pet) or oneOf
251
+ klass = UltracartClient.const_get(type)
252
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+
302
+ end
303
+
304
+ end