ultracart_api 3.7.38 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,297 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class GiftCertificate
17
+ # True if this gift certificate is activated and ready to apply to purchases.
18
+ attr_accessor :activated
19
+
20
+ # The code used by the customer to purchase against this gift certificate.
21
+ attr_accessor :code
22
+
23
+ # True if this gift certificate was deleted.
24
+ attr_accessor :deleted
25
+
26
+ # Email of the customer associated with this gift certificate.
27
+ attr_accessor :email
28
+
29
+ # Expiration date time.
30
+ attr_accessor :expiration_dts
31
+
32
+ # Gift certificate oid.
33
+ attr_accessor :gift_certificate_oid
34
+
35
+ # A list of all ledger activity for this gift certificate.
36
+ attr_accessor :ledger_entries
37
+
38
+ # Merchant Id
39
+ attr_accessor :merchant_id
40
+
41
+ # A list of all ledger activity for this gift certificate.
42
+ attr_accessor :merchant_note
43
+
44
+ # Original balance of the gift certificate.
45
+ attr_accessor :original_balance
46
+
47
+ # The order used to purchase this gift certificate. This value is ONLY set during checkout when a certificate is purchased, not when it is used. Any usage is recorded in the ledger
48
+ attr_accessor :reference_order_id
49
+
50
+ # The remaining balance on the gift certificate. This is never set directly, but calculated from the ledger. To change the remaining balance, add a ledger entry.
51
+ attr_accessor :remaining_balance
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'activated' => :'activated',
57
+ :'code' => :'code',
58
+ :'deleted' => :'deleted',
59
+ :'email' => :'email',
60
+ :'expiration_dts' => :'expiration_dts',
61
+ :'gift_certificate_oid' => :'gift_certificate_oid',
62
+ :'ledger_entries' => :'ledger_entries',
63
+ :'merchant_id' => :'merchant_id',
64
+ :'merchant_note' => :'merchant_note',
65
+ :'original_balance' => :'original_balance',
66
+ :'reference_order_id' => :'reference_order_id',
67
+ :'remaining_balance' => :'remaining_balance'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.swagger_types
73
+ {
74
+ :'activated' => :'BOOLEAN',
75
+ :'code' => :'String',
76
+ :'deleted' => :'BOOLEAN',
77
+ :'email' => :'String',
78
+ :'expiration_dts' => :'String',
79
+ :'gift_certificate_oid' => :'Integer',
80
+ :'ledger_entries' => :'Array<GiftCertificateLedgerEntry>',
81
+ :'merchant_id' => :'String',
82
+ :'merchant_note' => :'String',
83
+ :'original_balance' => :'Float',
84
+ :'reference_order_id' => :'String',
85
+ :'remaining_balance' => :'Float'
86
+ }
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ return unless attributes.is_a?(Hash)
93
+
94
+ # convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
96
+
97
+ if attributes.has_key?(:'activated')
98
+ self.activated = attributes[:'activated']
99
+ end
100
+
101
+ if attributes.has_key?(:'code')
102
+ self.code = attributes[:'code']
103
+ end
104
+
105
+ if attributes.has_key?(:'deleted')
106
+ self.deleted = attributes[:'deleted']
107
+ end
108
+
109
+ if attributes.has_key?(:'email')
110
+ self.email = attributes[:'email']
111
+ end
112
+
113
+ if attributes.has_key?(:'expiration_dts')
114
+ self.expiration_dts = attributes[:'expiration_dts']
115
+ end
116
+
117
+ if attributes.has_key?(:'gift_certificate_oid')
118
+ self.gift_certificate_oid = attributes[:'gift_certificate_oid']
119
+ end
120
+
121
+ if attributes.has_key?(:'ledger_entries')
122
+ if (value = attributes[:'ledger_entries']).is_a?(Array)
123
+ self.ledger_entries = value
124
+ end
125
+ end
126
+
127
+ if attributes.has_key?(:'merchant_id')
128
+ self.merchant_id = attributes[:'merchant_id']
129
+ end
130
+
131
+ if attributes.has_key?(:'merchant_note')
132
+ self.merchant_note = attributes[:'merchant_note']
133
+ end
134
+
135
+ if attributes.has_key?(:'original_balance')
136
+ self.original_balance = attributes[:'original_balance']
137
+ end
138
+
139
+ if attributes.has_key?(:'reference_order_id')
140
+ self.reference_order_id = attributes[:'reference_order_id']
141
+ end
142
+
143
+ if attributes.has_key?(:'remaining_balance')
144
+ self.remaining_balance = attributes[:'remaining_balance']
145
+ end
146
+ end
147
+
148
+ # Show invalid properties with the reasons. Usually used together with valid?
149
+ # @return Array for valid properties with the reasons
150
+ def list_invalid_properties
151
+ invalid_properties = Array.new
152
+ invalid_properties
153
+ end
154
+
155
+ # Check to see if the all the properties in the model are valid
156
+ # @return true if the model is valid
157
+ def valid?
158
+ true
159
+ end
160
+
161
+ # Checks equality by comparing each attribute.
162
+ # @param [Object] Object to be compared
163
+ def ==(o)
164
+ return true if self.equal?(o)
165
+ self.class == o.class &&
166
+ activated == o.activated &&
167
+ code == o.code &&
168
+ deleted == o.deleted &&
169
+ email == o.email &&
170
+ expiration_dts == o.expiration_dts &&
171
+ gift_certificate_oid == o.gift_certificate_oid &&
172
+ ledger_entries == o.ledger_entries &&
173
+ merchant_id == o.merchant_id &&
174
+ merchant_note == o.merchant_note &&
175
+ original_balance == o.original_balance &&
176
+ reference_order_id == o.reference_order_id &&
177
+ remaining_balance == o.remaining_balance
178
+ end
179
+
180
+ # @see the `==` method
181
+ # @param [Object] Object to be compared
182
+ def eql?(o)
183
+ self == o
184
+ end
185
+
186
+ # Calculates hash code according to all attributes.
187
+ # @return [Fixnum] Hash code
188
+ def hash
189
+ [activated, code, deleted, email, expiration_dts, gift_certificate_oid, ledger_entries, merchant_id, merchant_note, original_balance, reference_order_id, remaining_balance].hash
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def build_from_hash(attributes)
196
+ return nil unless attributes.is_a?(Hash)
197
+ self.class.swagger_types.each_pair do |key, type|
198
+ if type =~ /\AArray<(.*)>/i
199
+ # check to ensure the input is an array given that the attribute
200
+ # is documented as an array but the input is not
201
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
202
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
203
+ end
204
+ elsif !attributes[self.class.attribute_map[key]].nil?
205
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
206
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
207
+ end
208
+
209
+ self
210
+ end
211
+
212
+ # Deserializes the data based on type
213
+ # @param string type Data type
214
+ # @param string value Value to be deserialized
215
+ # @return [Object] Deserialized data
216
+ def _deserialize(type, value)
217
+ case type.to_sym
218
+ when :DateTime
219
+ DateTime.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :BOOLEAN
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ temp_model = UltracartClient.const_get(type).new
250
+ temp_model.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
+ next if value.nil?
273
+ hash[param] = _to_hash(value)
274
+ end
275
+ hash
276
+ end
277
+
278
+ # Outputs non-array value in the form of hash
279
+ # For object, use to_hash. Otherwise, just return the value
280
+ # @param [Object] value Any valid value
281
+ # @return [Hash] Returns the value in the form of hash
282
+ def _to_hash(value)
283
+ if value.is_a?(Array)
284
+ value.compact.map { |v| _to_hash(v) }
285
+ elsif value.is_a?(Hash)
286
+ {}.tap do |hash|
287
+ value.each { |k, v| hash[k] = _to_hash(v) }
288
+ end
289
+ elsif value.respond_to? :to_hash
290
+ value.to_hash
291
+ else
292
+ value
293
+ end
294
+ end
295
+
296
+ end
297
+ end
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class GiftCertificateCreateRequest
17
+ # Initial amount of this gift certificate.
18
+ attr_accessor :amount
19
+
20
+ # Expiration date time.
21
+ attr_accessor :expiration_dts
22
+
23
+ # A brief description of how and/or why this gift certificate was created.
24
+ attr_accessor :initial_ledger_description
25
+
26
+ # Any internal details you wish to record about this gift certificate.
27
+ attr_accessor :merchant_note
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'amount' => :'amount',
33
+ :'expiration_dts' => :'expiration_dts',
34
+ :'initial_ledger_description' => :'initial_ledger_description',
35
+ :'merchant_note' => :'merchant_note'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'amount' => :'Float',
43
+ :'expiration_dts' => :'String',
44
+ :'initial_ledger_description' => :'String',
45
+ :'merchant_note' => :'String'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
56
+
57
+ if attributes.has_key?(:'amount')
58
+ self.amount = attributes[:'amount']
59
+ end
60
+
61
+ if attributes.has_key?(:'expiration_dts')
62
+ self.expiration_dts = attributes[:'expiration_dts']
63
+ end
64
+
65
+ if attributes.has_key?(:'initial_ledger_description')
66
+ self.initial_ledger_description = attributes[:'initial_ledger_description']
67
+ end
68
+
69
+ if attributes.has_key?(:'merchant_note')
70
+ self.merchant_note = attributes[:'merchant_note']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ amount == o.amount &&
93
+ expiration_dts == o.expiration_dts &&
94
+ initial_ledger_description == o.initial_ledger_description &&
95
+ merchant_note == o.merchant_note
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Fixnum] Hash code
106
+ def hash
107
+ [amount, expiration_dts, initial_ledger_description, merchant_note].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.swagger_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :BOOLEAN
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ temp_model = UltracartClient.const_get(type).new
168
+ temp_model.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ next if value.nil?
191
+ hash[param] = _to_hash(value)
192
+ end
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map { |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to? :to_hash
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+ end