ultracart_api 4.1.207 → 4.1.209

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -2
  3. data/docs/SfvbApi.md +773 -48
  4. data/docs/SfvbArchiveRequest.md +18 -0
  5. data/docs/SfvbCampaign.md +16 -0
  6. data/docs/SfvbCampaignMembership.md +24 -0
  7. data/docs/SfvbCampaignWriteRequest.md +32 -0
  8. data/docs/SfvbCommsEmail.md +6 -0
  9. data/docs/SfvbCommsList.md +24 -0
  10. data/docs/SfvbCommsListsResponse.md +18 -0
  11. data/docs/SfvbCommsSegment.md +26 -0
  12. data/docs/SfvbCommsSegmentsResponse.md +18 -0
  13. data/docs/SfvbEmail.md +40 -0
  14. data/docs/SfvbEmailUpdateRequest.md +20 -0
  15. data/docs/SfvbFlow.md +22 -0
  16. data/docs/SfvbFlowStatusRequest.md +18 -0
  17. data/docs/SfvbFlowWriteRequest.md +38 -0
  18. data/lib/ultracart_api/api/sfvb_api.rb +5346 -4330
  19. data/lib/ultracart_api/models/item_third_party_email_marketing.rb +2 -2
  20. data/lib/ultracart_api/models/sfvb_archive_request.rb +220 -0
  21. data/lib/ultracart_api/models/sfvb_campaign.rb +85 -1
  22. data/lib/ultracart_api/models/sfvb_campaign_membership.rb +250 -0
  23. data/lib/ultracart_api/models/sfvb_campaign_write_request.rb +292 -0
  24. data/lib/ultracart_api/models/sfvb_comms_email.rb +31 -1
  25. data/lib/ultracart_api/models/sfvb_comms_list.rb +250 -0
  26. data/lib/ultracart_api/models/sfvb_comms_lists_response.rb +222 -0
  27. data/lib/ultracart_api/models/sfvb_comms_segment.rb +260 -0
  28. data/lib/ultracart_api/models/sfvb_comms_segments_response.rb +222 -0
  29. data/lib/ultracart_api/models/sfvb_email.rb +330 -0
  30. data/lib/ultracart_api/models/sfvb_email_update_request.rb +230 -0
  31. data/lib/ultracart_api/models/sfvb_flow.rb +113 -1
  32. data/lib/ultracart_api/models/sfvb_flow_status_request.rb +254 -0
  33. data/lib/ultracart_api/models/sfvb_flow_write_request.rb +354 -0
  34. data/lib/ultracart_api/version.rb +1 -1
  35. data/lib/ultracart_api.rb +11 -0
  36. metadata +24 -2
@@ -139,7 +139,7 @@ module UltracartClient
139
139
  # Check to see if the all the properties in the model are valid
140
140
  # @return true if the model is valid
141
141
  def valid?
142
- provider_name_validator = EnumAttributeValidator.new('String', ["ActiveCampaign", "AWeber", "Campaign Monitor", "ConstantContact", "Emma", "GetResponse", "iContact", "Klaviyo", "Lyris", "LyrisHQ", "MailChimp"])
142
+ provider_name_validator = EnumAttributeValidator.new('String', ["ActiveCampaign", "AWeber", "Campaign Monitor", "ConstantContact", "Emma", "GetResponse", "iContact", "Klaviyo", "MailChimp"])
143
143
  return false unless provider_name_validator.valid?(@provider_name)
144
144
  true
145
145
  end
@@ -147,7 +147,7 @@ module UltracartClient
147
147
  # Custom attribute writer method checking allowed values (enum).
148
148
  # @param [Object] provider_name Object to be assigned
149
149
  def provider_name=(provider_name)
150
- validator = EnumAttributeValidator.new('String', ["ActiveCampaign", "AWeber", "Campaign Monitor", "ConstantContact", "Emma", "GetResponse", "iContact", "Klaviyo", "Lyris", "LyrisHQ", "MailChimp"])
150
+ validator = EnumAttributeValidator.new('String', ["ActiveCampaign", "AWeber", "Campaign Monitor", "ConstantContact", "Emma", "GetResponse", "iContact", "Klaviyo", "MailChimp"])
151
151
  unless validator.valid?(provider_name)
152
152
  fail ArgumentError, "invalid value for \"provider_name\", must be one of #{validator.allowable_values}."
153
153
  end
@@ -0,0 +1,220 @@
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 SfvbArchiveRequest
18
+ # True to archive, false to unarchive.
19
+ attr_accessor :archived
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'archived' => :'archived'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'archived' => :'Boolean'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbArchiveRequest` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbArchiveRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'archived')
62
+ self.archived = attributes[:'archived']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ archived == o.archived
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [archived].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = UltracartClient.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -30,18 +30,42 @@ module UltracartClient
30
30
  # Its emails, in step order.
31
31
  attr_accessor :emails
32
32
 
33
+ # True when a customer leaves the campaign once they buy from one of its emails.
34
+ attr_accessor :end_once_customer_purchases
35
+
36
+ # True when a customer leaves the campaign once they buy from any source.
37
+ attr_accessor :end_once_customer_purchases_anywhere
38
+
39
+ # Send this as If-Match when changing or archiving the campaign.
40
+ attr_accessor :hash_sha256
41
+
33
42
  # True when the emails and postcards reach customers now, so a change to one shows at once. False only in a status that sends nothing.
34
43
  attr_accessor :live
35
44
 
45
+ # The lists and segments it sends to or leaves out.
46
+ attr_accessor :memberships
47
+
36
48
  # The campaign name.
37
49
  attr_accessor :name
38
50
 
51
+ # What a write did beyond the fields it was asked to change, such as putting emails back to needing review or setting a scheduled campaign back to draft. Only on a write.
52
+ attr_accessor :notes
53
+
39
54
  # Its postcards, in step order.
40
55
  attr_accessor :postcards
41
56
 
42
57
  # When the campaign is scheduled to send (ISO 8601, UTC), when it is.
43
58
  attr_accessor :scheduled_dts
44
59
 
60
+ # The sending domain uuid. Defaults to the storefront's marketing sending domain.
61
+ attr_accessor :sending_domain_uuid
62
+
63
+ # The from name. Defaults to the storefront's marketing setting.
64
+ attr_accessor :sending_name
65
+
66
+ # The part of the from address before the at sign. Defaults to the storefront's marketing setting.
67
+ attr_accessor :sending_user
68
+
45
69
  # The status, such as draft, scheduled, sending, sent or archived.
46
70
  attr_accessor :status
47
71
 
@@ -56,10 +80,18 @@ module UltracartClient
56
80
  :'created_dts' => :'created_dts',
57
81
  :'deleted' => :'deleted',
58
82
  :'emails' => :'emails',
83
+ :'end_once_customer_purchases' => :'end_once_customer_purchases',
84
+ :'end_once_customer_purchases_anywhere' => :'end_once_customer_purchases_anywhere',
85
+ :'hash_sha256' => :'hash_sha256',
59
86
  :'live' => :'live',
87
+ :'memberships' => :'memberships',
60
88
  :'name' => :'name',
89
+ :'notes' => :'notes',
61
90
  :'postcards' => :'postcards',
62
91
  :'scheduled_dts' => :'scheduled_dts',
92
+ :'sending_domain_uuid' => :'sending_domain_uuid',
93
+ :'sending_name' => :'sending_name',
94
+ :'sending_user' => :'sending_user',
63
95
  :'status' => :'status',
64
96
  :'status_dts' => :'status_dts'
65
97
  }
@@ -78,10 +110,18 @@ module UltracartClient
78
110
  :'created_dts' => :'String',
79
111
  :'deleted' => :'Boolean',
80
112
  :'emails' => :'Array<SfvbCommsEmail>',
113
+ :'end_once_customer_purchases' => :'Boolean',
114
+ :'end_once_customer_purchases_anywhere' => :'Boolean',
115
+ :'hash_sha256' => :'String',
81
116
  :'live' => :'Boolean',
117
+ :'memberships' => :'Array<SfvbCampaignMembership>',
82
118
  :'name' => :'String',
119
+ :'notes' => :'Array<String>',
83
120
  :'postcards' => :'Array<SfvbCommsPostcard>',
84
121
  :'scheduled_dts' => :'String',
122
+ :'sending_domain_uuid' => :'String',
123
+ :'sending_name' => :'String',
124
+ :'sending_user' => :'String',
85
125
  :'status' => :'String',
86
126
  :'status_dts' => :'String'
87
127
  }
@@ -130,14 +170,38 @@ module UltracartClient
130
170
  end
131
171
  end
132
172
 
173
+ if attributes.key?(:'end_once_customer_purchases')
174
+ self.end_once_customer_purchases = attributes[:'end_once_customer_purchases']
175
+ end
176
+
177
+ if attributes.key?(:'end_once_customer_purchases_anywhere')
178
+ self.end_once_customer_purchases_anywhere = attributes[:'end_once_customer_purchases_anywhere']
179
+ end
180
+
181
+ if attributes.key?(:'hash_sha256')
182
+ self.hash_sha256 = attributes[:'hash_sha256']
183
+ end
184
+
133
185
  if attributes.key?(:'live')
134
186
  self.live = attributes[:'live']
135
187
  end
136
188
 
189
+ if attributes.key?(:'memberships')
190
+ if (value = attributes[:'memberships']).is_a?(Array)
191
+ self.memberships = value
192
+ end
193
+ end
194
+
137
195
  if attributes.key?(:'name')
138
196
  self.name = attributes[:'name']
139
197
  end
140
198
 
199
+ if attributes.key?(:'notes')
200
+ if (value = attributes[:'notes']).is_a?(Array)
201
+ self.notes = value
202
+ end
203
+ end
204
+
141
205
  if attributes.key?(:'postcards')
142
206
  if (value = attributes[:'postcards']).is_a?(Array)
143
207
  self.postcards = value
@@ -148,6 +212,18 @@ module UltracartClient
148
212
  self.scheduled_dts = attributes[:'scheduled_dts']
149
213
  end
150
214
 
215
+ if attributes.key?(:'sending_domain_uuid')
216
+ self.sending_domain_uuid = attributes[:'sending_domain_uuid']
217
+ end
218
+
219
+ if attributes.key?(:'sending_name')
220
+ self.sending_name = attributes[:'sending_name']
221
+ end
222
+
223
+ if attributes.key?(:'sending_user')
224
+ self.sending_user = attributes[:'sending_user']
225
+ end
226
+
151
227
  if attributes.key?(:'status')
152
228
  self.status = attributes[:'status']
153
229
  end
@@ -180,10 +256,18 @@ module UltracartClient
180
256
  created_dts == o.created_dts &&
181
257
  deleted == o.deleted &&
182
258
  emails == o.emails &&
259
+ end_once_customer_purchases == o.end_once_customer_purchases &&
260
+ end_once_customer_purchases_anywhere == o.end_once_customer_purchases_anywhere &&
261
+ hash_sha256 == o.hash_sha256 &&
183
262
  live == o.live &&
263
+ memberships == o.memberships &&
184
264
  name == o.name &&
265
+ notes == o.notes &&
185
266
  postcards == o.postcards &&
186
267
  scheduled_dts == o.scheduled_dts &&
268
+ sending_domain_uuid == o.sending_domain_uuid &&
269
+ sending_name == o.sending_name &&
270
+ sending_user == o.sending_user &&
187
271
  status == o.status &&
188
272
  status_dts == o.status_dts
189
273
  end
@@ -197,7 +281,7 @@ module UltracartClient
197
281
  # Calculates hash code according to all attributes.
198
282
  # @return [Integer] Hash code
199
283
  def hash
200
- [campaign_uuid, communication_sequence_uuid, created_dts, deleted, emails, live, name, postcards, scheduled_dts, status, status_dts].hash
284
+ [campaign_uuid, communication_sequence_uuid, created_dts, deleted, emails, end_once_customer_purchases, end_once_customer_purchases_anywhere, hash_sha256, live, memberships, name, notes, postcards, scheduled_dts, sending_domain_uuid, sending_name, sending_user, status, status_dts].hash
201
285
  end
202
286
 
203
287
  # Builds the object from hash
@@ -0,0 +1,250 @@
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 SfvbCampaignMembership
18
+ # True to leave its members out instead of sending to them.
19
+ attr_accessor :exclude
20
+
21
+ # The list uuid, for a list.
22
+ attr_accessor :list_uuid
23
+
24
+ # The list or segment name. Set by the server.
25
+ attr_accessor :name
26
+
27
+ # The segment uuid, for a segment.
28
+ attr_accessor :segment_uuid
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'exclude' => :'exclude',
34
+ :'list_uuid' => :'list_uuid',
35
+ :'name' => :'name',
36
+ :'segment_uuid' => :'segment_uuid'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'exclude' => :'Boolean',
49
+ :'list_uuid' => :'String',
50
+ :'name' => :'String',
51
+ :'segment_uuid' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbCampaignMembership` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbCampaignMembership`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'exclude')
77
+ self.exclude = attributes[:'exclude']
78
+ end
79
+
80
+ if attributes.key?(:'list_uuid')
81
+ self.list_uuid = attributes[:'list_uuid']
82
+ end
83
+
84
+ if attributes.key?(:'name')
85
+ self.name = attributes[:'name']
86
+ end
87
+
88
+ if attributes.key?(:'segment_uuid')
89
+ self.segment_uuid = attributes[:'segment_uuid']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ exclude == o.exclude &&
112
+ list_uuid == o.list_uuid &&
113
+ name == o.name &&
114
+ segment_uuid == o.segment_uuid
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [exclude, list_uuid, name, segment_uuid].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ attributes = attributes.transform_keys(&:to_sym)
142
+ self.class.openapi_types.each_pair do |key, type|
143
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
144
+ self.send("#{key}=", nil)
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
149
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
150
+ end
151
+ elsif !attributes[self.class.attribute_map[key]].nil?
152
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153
+ end
154
+ end
155
+
156
+ self
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def _deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ # models (e.g. Pet) or oneOf
197
+ klass = UltracartClient.const_get(type)
198
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ end