talon_one 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -10
- data/docs/ApplicationCustomer.md +1 -1
- data/docs/CustomerProfile.md +1 -1
- data/docs/ManagementApi.md +3 -3
- data/lib/talon_one.rb +0 -6
- data/lib/talon_one/api/management_api.rb +4 -4
- data/lib/talon_one/models/application_customer.rb +0 -5
- data/lib/talon_one/models/customer_profile.rb +0 -5
- data/lib/talon_one/version.rb +1 -1
- data/spec/api/management_api_spec.rb +2 -2
- data/talon_one-1.0.0.gem +0 -0
- data/talon_one-1.1.0.gem +0 -0
- data/talon_one.gemspec +1 -1
- metadata +5 -22
- data/fck.rb +0 -64
- data/lib/talon_one/models/application_storage.rb +0 -292
- data/lib/talon_one/models/application_storage_data.rb +0 -175
- data/lib/talon_one/models/application_storage_tuple.rb +0 -283
- data/lib/talon_one/models/new_application_storage.rb +0 -214
- data/lib/talon_one/models/new_application_storage_data.rb +0 -175
- data/lib/talon_one/models/new_application_storage_tuple.rb +0 -222
- data/spec/models/application_storage_data_spec.rb +0 -35
- data/spec/models/application_storage_spec.rb +0 -83
- data/spec/models/application_storage_tuple_spec.rb +0 -71
- data/spec/models/new_application_storage_data_spec.rb +0 -35
- data/spec/models/new_application_storage_spec.rb +0 -53
- data/spec/models/new_application_storage_tuple_spec.rb +0 -47
@@ -1,214 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Talon.One API
|
3
|
-
|
4
|
-
#The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
|
5
|
-
|
6
|
-
OpenAPI spec version: 1.0.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.7
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module TalonOne
|
16
|
-
class NewApplicationStorage
|
17
|
-
# Identifier for the information to be saved, e.g. \"Loyalty points for SKU\".
|
18
|
-
attr_accessor :name
|
19
|
-
|
20
|
-
# A JSON Schema describing the information to be saved in the storage
|
21
|
-
attr_accessor :datatype
|
22
|
-
|
23
|
-
# Description of the application store
|
24
|
-
attr_accessor :description
|
25
|
-
|
26
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
-
def self.attribute_map
|
28
|
-
{
|
29
|
-
:'name' => :'name',
|
30
|
-
:'datatype' => :'datatype',
|
31
|
-
:'description' => :'description'
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
# Attribute type mapping.
|
36
|
-
def self.swagger_types
|
37
|
-
{
|
38
|
-
:'name' => :'String',
|
39
|
-
:'datatype' => :'Object',
|
40
|
-
:'description' => :'String'
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
# Initializes the object
|
45
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
-
def initialize(attributes = {})
|
47
|
-
return unless attributes.is_a?(Hash)
|
48
|
-
|
49
|
-
# convert string to symbol for hash key
|
50
|
-
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
51
|
-
|
52
|
-
if attributes.has_key?(:'name')
|
53
|
-
self.name = attributes[:'name']
|
54
|
-
end
|
55
|
-
|
56
|
-
if attributes.has_key?(:'datatype')
|
57
|
-
self.datatype = attributes[:'datatype']
|
58
|
-
end
|
59
|
-
|
60
|
-
if attributes.has_key?(:'description')
|
61
|
-
self.description = attributes[:'description']
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
-
# @return Array for valid properties with the reasons
|
67
|
-
def list_invalid_properties
|
68
|
-
invalid_properties = Array.new
|
69
|
-
if @name.nil?
|
70
|
-
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
71
|
-
end
|
72
|
-
|
73
|
-
if @datatype.nil?
|
74
|
-
invalid_properties.push('invalid value for "datatype", datatype cannot be nil.')
|
75
|
-
end
|
76
|
-
|
77
|
-
invalid_properties
|
78
|
-
end
|
79
|
-
|
80
|
-
# Check to see if the all the properties in the model are valid
|
81
|
-
# @return true if the model is valid
|
82
|
-
def valid?
|
83
|
-
return false if @name.nil?
|
84
|
-
return false if @datatype.nil?
|
85
|
-
true
|
86
|
-
end
|
87
|
-
|
88
|
-
# Checks equality by comparing each attribute.
|
89
|
-
# @param [Object] Object to be compared
|
90
|
-
def ==(o)
|
91
|
-
return true if self.equal?(o)
|
92
|
-
self.class == o.class &&
|
93
|
-
name == o.name &&
|
94
|
-
datatype == o.datatype &&
|
95
|
-
description == o.description
|
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
|
-
[name, datatype, description].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 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 = TalonOne.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
|
-
end
|
214
|
-
end
|
@@ -1,175 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Talon.One API
|
3
|
-
|
4
|
-
#The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
|
5
|
-
|
6
|
-
OpenAPI spec version: 1.0.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.7
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module TalonOne
|
16
|
-
# Array of ApplicationStorageData to be created.
|
17
|
-
class NewApplicationStorageData
|
18
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
-
def self.attribute_map
|
20
|
-
{
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
# Attribute type mapping.
|
25
|
-
def self.swagger_types
|
26
|
-
{
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# Initializes the object
|
31
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
32
|
-
def initialize(attributes = {})
|
33
|
-
return unless attributes.is_a?(Hash)
|
34
|
-
|
35
|
-
# convert string to symbol for hash key
|
36
|
-
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
37
|
-
end
|
38
|
-
|
39
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
40
|
-
# @return Array for valid properties with the reasons
|
41
|
-
def list_invalid_properties
|
42
|
-
invalid_properties = Array.new
|
43
|
-
invalid_properties
|
44
|
-
end
|
45
|
-
|
46
|
-
# Check to see if the all the properties in the model are valid
|
47
|
-
# @return true if the model is valid
|
48
|
-
def valid?
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
# Checks equality by comparing each attribute.
|
53
|
-
# @param [Object] Object to be compared
|
54
|
-
def ==(o)
|
55
|
-
return true if self.equal?(o)
|
56
|
-
self.class == o.class
|
57
|
-
end
|
58
|
-
|
59
|
-
# @see the `==` method
|
60
|
-
# @param [Object] Object to be compared
|
61
|
-
def eql?(o)
|
62
|
-
self == o
|
63
|
-
end
|
64
|
-
|
65
|
-
# Calculates hash code according to all attributes.
|
66
|
-
# @return [Fixnum] Hash code
|
67
|
-
def hash
|
68
|
-
[].hash
|
69
|
-
end
|
70
|
-
|
71
|
-
# Builds the object from hash
|
72
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
-
# @return [Object] Returns the model itself
|
74
|
-
def build_from_hash(attributes)
|
75
|
-
return nil unless attributes.is_a?(Hash)
|
76
|
-
self.class.swagger_types.each_pair do |key, type|
|
77
|
-
if type =~ /\AArray<(.*)>/i
|
78
|
-
# check to ensure the input is an array given that the the attribute
|
79
|
-
# is documented as an array but the input is not
|
80
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
81
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
82
|
-
end
|
83
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
84
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
85
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
86
|
-
end
|
87
|
-
|
88
|
-
self
|
89
|
-
end
|
90
|
-
|
91
|
-
# Deserializes the data based on type
|
92
|
-
# @param string type Data type
|
93
|
-
# @param string value Value to be deserialized
|
94
|
-
# @return [Object] Deserialized data
|
95
|
-
def _deserialize(type, value)
|
96
|
-
case type.to_sym
|
97
|
-
when :DateTime
|
98
|
-
DateTime.parse(value)
|
99
|
-
when :Date
|
100
|
-
Date.parse(value)
|
101
|
-
when :String
|
102
|
-
value.to_s
|
103
|
-
when :Integer
|
104
|
-
value.to_i
|
105
|
-
when :Float
|
106
|
-
value.to_f
|
107
|
-
when :BOOLEAN
|
108
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
109
|
-
true
|
110
|
-
else
|
111
|
-
false
|
112
|
-
end
|
113
|
-
when :Object
|
114
|
-
# generic object (usually a Hash), return directly
|
115
|
-
value
|
116
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
117
|
-
inner_type = Regexp.last_match[:inner_type]
|
118
|
-
value.map { |v| _deserialize(inner_type, v) }
|
119
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
120
|
-
k_type = Regexp.last_match[:k_type]
|
121
|
-
v_type = Regexp.last_match[:v_type]
|
122
|
-
{}.tap do |hash|
|
123
|
-
value.each do |k, v|
|
124
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
else # model
|
128
|
-
temp_model = TalonOne.const_get(type).new
|
129
|
-
temp_model.build_from_hash(value)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# Returns the string representation of the object
|
134
|
-
# @return [String] String presentation of the object
|
135
|
-
def to_s
|
136
|
-
to_hash.to_s
|
137
|
-
end
|
138
|
-
|
139
|
-
# to_body is an alias to to_hash (backward compatibility)
|
140
|
-
# @return [Hash] Returns the object in the form of hash
|
141
|
-
def to_body
|
142
|
-
to_hash
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the object in the form of hash
|
146
|
-
# @return [Hash] Returns the object in the form of hash
|
147
|
-
def to_hash
|
148
|
-
hash = {}
|
149
|
-
self.class.attribute_map.each_pair do |attr, param|
|
150
|
-
value = self.send(attr)
|
151
|
-
next if value.nil?
|
152
|
-
hash[param] = _to_hash(value)
|
153
|
-
end
|
154
|
-
hash
|
155
|
-
end
|
156
|
-
|
157
|
-
# Outputs non-array value in the form of hash
|
158
|
-
# For object, use to_hash. Otherwise, just return the value
|
159
|
-
# @param [Object] value Any valid value
|
160
|
-
# @return [Hash] Returns the value in the form of hash
|
161
|
-
def _to_hash(value)
|
162
|
-
if value.is_a?(Array)
|
163
|
-
value.compact.map { |v| _to_hash(v) }
|
164
|
-
elsif value.is_a?(Hash)
|
165
|
-
{}.tap do |hash|
|
166
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
167
|
-
end
|
168
|
-
elsif value.respond_to? :to_hash
|
169
|
-
value.to_hash
|
170
|
-
else
|
171
|
-
value
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
@@ -1,222 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Talon.One API
|
3
|
-
|
4
|
-
#The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
|
5
|
-
|
6
|
-
OpenAPI spec version: 1.0.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.7
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module TalonOne
|
16
|
-
class NewApplicationStorageTuple
|
17
|
-
# Key information that will map to a value, e.g. SKU number \"LEV-JN-SL-36-GN\".
|
18
|
-
attr_accessor :key
|
19
|
-
|
20
|
-
attr_accessor :value
|
21
|
-
|
22
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
-
def self.attribute_map
|
24
|
-
{
|
25
|
-
:'key' => :'key',
|
26
|
-
:'value' => :'value'
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# Attribute type mapping.
|
31
|
-
def self.swagger_types
|
32
|
-
{
|
33
|
-
:'key' => :'String',
|
34
|
-
:'value' => :'Object'
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
# Initializes the object
|
39
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
40
|
-
def initialize(attributes = {})
|
41
|
-
return unless attributes.is_a?(Hash)
|
42
|
-
|
43
|
-
# convert string to symbol for hash key
|
44
|
-
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
45
|
-
|
46
|
-
if attributes.has_key?(:'key')
|
47
|
-
self.key = attributes[:'key']
|
48
|
-
end
|
49
|
-
|
50
|
-
if attributes.has_key?(:'value')
|
51
|
-
self.value = attributes[:'value']
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
56
|
-
# @return Array for valid properties with the reasons
|
57
|
-
def list_invalid_properties
|
58
|
-
invalid_properties = Array.new
|
59
|
-
if @key.nil?
|
60
|
-
invalid_properties.push('invalid value for "key", key cannot be nil.')
|
61
|
-
end
|
62
|
-
|
63
|
-
if @key.to_s.length < 1
|
64
|
-
invalid_properties.push('invalid value for "key", the character length must be great than or equal to 1.')
|
65
|
-
end
|
66
|
-
|
67
|
-
if @value.nil?
|
68
|
-
invalid_properties.push('invalid value for "value", value cannot be nil.')
|
69
|
-
end
|
70
|
-
|
71
|
-
invalid_properties
|
72
|
-
end
|
73
|
-
|
74
|
-
# Check to see if the all the properties in the model are valid
|
75
|
-
# @return true if the model is valid
|
76
|
-
def valid?
|
77
|
-
return false if @key.nil?
|
78
|
-
return false if @key.to_s.length < 1
|
79
|
-
return false if @value.nil?
|
80
|
-
true
|
81
|
-
end
|
82
|
-
|
83
|
-
# Custom attribute writer method with validation
|
84
|
-
# @param [Object] key Value to be assigned
|
85
|
-
def key=(key)
|
86
|
-
if key.nil?
|
87
|
-
fail ArgumentError, 'key cannot be nil'
|
88
|
-
end
|
89
|
-
|
90
|
-
if key.to_s.length < 1
|
91
|
-
fail ArgumentError, 'invalid value for "key", the character length must be great than or equal to 1.'
|
92
|
-
end
|
93
|
-
|
94
|
-
@key = key
|
95
|
-
end
|
96
|
-
|
97
|
-
# Checks equality by comparing each attribute.
|
98
|
-
# @param [Object] Object to be compared
|
99
|
-
def ==(o)
|
100
|
-
return true if self.equal?(o)
|
101
|
-
self.class == o.class &&
|
102
|
-
key == o.key &&
|
103
|
-
value == o.value
|
104
|
-
end
|
105
|
-
|
106
|
-
# @see the `==` method
|
107
|
-
# @param [Object] Object to be compared
|
108
|
-
def eql?(o)
|
109
|
-
self == o
|
110
|
-
end
|
111
|
-
|
112
|
-
# Calculates hash code according to all attributes.
|
113
|
-
# @return [Fixnum] Hash code
|
114
|
-
def hash
|
115
|
-
[key, value].hash
|
116
|
-
end
|
117
|
-
|
118
|
-
# Builds the object from hash
|
119
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
120
|
-
# @return [Object] Returns the model itself
|
121
|
-
def build_from_hash(attributes)
|
122
|
-
return nil unless attributes.is_a?(Hash)
|
123
|
-
self.class.swagger_types.each_pair do |key, type|
|
124
|
-
if type =~ /\AArray<(.*)>/i
|
125
|
-
# check to ensure the input is an array given that the the attribute
|
126
|
-
# is documented as an array but the input is not
|
127
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
128
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
129
|
-
end
|
130
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
131
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
132
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
133
|
-
end
|
134
|
-
|
135
|
-
self
|
136
|
-
end
|
137
|
-
|
138
|
-
# Deserializes the data based on type
|
139
|
-
# @param string type Data type
|
140
|
-
# @param string value Value to be deserialized
|
141
|
-
# @return [Object] Deserialized data
|
142
|
-
def _deserialize(type, value)
|
143
|
-
case type.to_sym
|
144
|
-
when :DateTime
|
145
|
-
DateTime.parse(value)
|
146
|
-
when :Date
|
147
|
-
Date.parse(value)
|
148
|
-
when :String
|
149
|
-
value.to_s
|
150
|
-
when :Integer
|
151
|
-
value.to_i
|
152
|
-
when :Float
|
153
|
-
value.to_f
|
154
|
-
when :BOOLEAN
|
155
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
156
|
-
true
|
157
|
-
else
|
158
|
-
false
|
159
|
-
end
|
160
|
-
when :Object
|
161
|
-
# generic object (usually a Hash), return directly
|
162
|
-
value
|
163
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
164
|
-
inner_type = Regexp.last_match[:inner_type]
|
165
|
-
value.map { |v| _deserialize(inner_type, v) }
|
166
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
167
|
-
k_type = Regexp.last_match[:k_type]
|
168
|
-
v_type = Regexp.last_match[:v_type]
|
169
|
-
{}.tap do |hash|
|
170
|
-
value.each do |k, v|
|
171
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
else # model
|
175
|
-
temp_model = TalonOne.const_get(type).new
|
176
|
-
temp_model.build_from_hash(value)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Returns the string representation of the object
|
181
|
-
# @return [String] String presentation of the object
|
182
|
-
def to_s
|
183
|
-
to_hash.to_s
|
184
|
-
end
|
185
|
-
|
186
|
-
# to_body is an alias to to_hash (backward compatibility)
|
187
|
-
# @return [Hash] Returns the object in the form of hash
|
188
|
-
def to_body
|
189
|
-
to_hash
|
190
|
-
end
|
191
|
-
|
192
|
-
# Returns the object in the form of hash
|
193
|
-
# @return [Hash] Returns the object in the form of hash
|
194
|
-
def to_hash
|
195
|
-
hash = {}
|
196
|
-
self.class.attribute_map.each_pair do |attr, param|
|
197
|
-
value = self.send(attr)
|
198
|
-
next if value.nil?
|
199
|
-
hash[param] = _to_hash(value)
|
200
|
-
end
|
201
|
-
hash
|
202
|
-
end
|
203
|
-
|
204
|
-
# Outputs non-array value in the form of hash
|
205
|
-
# For object, use to_hash. Otherwise, just return the value
|
206
|
-
# @param [Object] value Any valid value
|
207
|
-
# @return [Hash] Returns the value in the form of hash
|
208
|
-
def _to_hash(value)
|
209
|
-
if value.is_a?(Array)
|
210
|
-
value.compact.map { |v| _to_hash(v) }
|
211
|
-
elsif value.is_a?(Hash)
|
212
|
-
{}.tap do |hash|
|
213
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
214
|
-
end
|
215
|
-
elsif value.respond_to? :to_hash
|
216
|
-
value.to_hash
|
217
|
-
else
|
218
|
-
value
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|