sib-api-v3-sdk 2.1.3 → 2.1.4
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.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/docs/AttributesApi.md +78 -12
- data/docs/ContactsApi.md +78 -12
- data/docs/CreateAttribute.md +3 -5
- data/docs/CreateAttributeEnumeration.md +9 -0
- data/docs/GetAttributesAttributes.md +0 -1
- data/docs/SendSms.md +1 -0
- data/docs/UpdateAttribute.md +9 -0
- data/docs/{CreateAttributeEnumemaration.md → UpdateAttributeEnumeration.md} +1 -1
- data/lib/sib-api-v3-sdk.rb +3 -1
- data/lib/sib-api-v3-sdk/api/attributes_api.rb +115 -20
- data/lib/sib-api-v3-sdk/api/contacts_api.rb +115 -20
- data/lib/sib-api-v3-sdk/models/create_attribute.rb +12 -59
- data/lib/sib-api-v3-sdk/models/create_attribute_enumeration.rb +209 -0
- data/lib/sib-api-v3-sdk/models/error_model.rb +2 -2
- data/lib/sib-api-v3-sdk/models/get_attributes_attributes.rb +1 -16
- data/lib/sib-api-v3-sdk/models/send_sms.rb +18 -4
- data/lib/sib-api-v3-sdk/models/update_attribute.rb +201 -0
- data/lib/sib-api-v3-sdk/models/{create_attribute_enumemaration.rb → update_attribute_enumeration.rb} +1 -1
- data/lib/sib-api-v3-sdk/version.rb +1 -1
- data/spec/api/attributes_api_spec.rb +20 -3
- data/spec/api/contacts_api_spec.rb +20 -3
- data/spec/models/{create_attribute_enumemaration_spec.rb → create_attribute_enumeration_spec.rb} +7 -7
- data/spec/models/create_attribute_spec.rb +2 -18
- data/spec/models/error_model_spec.rb +1 -1
- data/spec/models/get_attributes_attributes_spec.rb +0 -6
- data/spec/models/send_sms_spec.rb +6 -0
- data/spec/models/update_attribute_enumeration_spec.rb +48 -0
- data/spec/models/update_attribute_spec.rb +48 -0
- metadata +14 -6
@@ -0,0 +1,209 @@
|
|
1
|
+
=begin
|
2
|
+
#SendinBlue API
|
3
|
+
|
4
|
+
#SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/sendinblue **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed |
|
5
|
+
|
6
|
+
OpenAPI spec version: 3.0.0
|
7
|
+
Contact: contact@sendinblue.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
|
17
|
+
class CreateAttributeEnumeration
|
18
|
+
# Id of the value
|
19
|
+
attr_accessor :value
|
20
|
+
|
21
|
+
# Label of the value
|
22
|
+
attr_accessor :label
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'value' => :'value',
|
29
|
+
:'label' => :'label'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
:'value' => :'Integer',
|
37
|
+
:'label' => :'String'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
return unless attributes.is_a?(Hash)
|
45
|
+
|
46
|
+
# convert string to symbol for hash key
|
47
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
48
|
+
|
49
|
+
if attributes.has_key?(:'value')
|
50
|
+
self.value = attributes[:'value']
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.has_key?(:'label')
|
54
|
+
self.label = attributes[:'label']
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
60
|
+
# @return Array for valid properies with the reasons
|
61
|
+
def list_invalid_properties
|
62
|
+
invalid_properties = Array.new
|
63
|
+
if @value.nil?
|
64
|
+
invalid_properties.push("invalid value for 'value', value cannot be nil.")
|
65
|
+
end
|
66
|
+
|
67
|
+
if @label.nil?
|
68
|
+
invalid_properties.push("invalid value for 'label', label cannot be nil.")
|
69
|
+
end
|
70
|
+
|
71
|
+
return 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 @value.nil?
|
78
|
+
return false if @label.nil?
|
79
|
+
return true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Checks equality by comparing each attribute.
|
83
|
+
# @param [Object] Object to be compared
|
84
|
+
def ==(o)
|
85
|
+
return true if self.equal?(o)
|
86
|
+
self.class == o.class &&
|
87
|
+
value == o.value &&
|
88
|
+
label == o.label
|
89
|
+
end
|
90
|
+
|
91
|
+
# @see the `==` method
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def eql?(o)
|
94
|
+
self == o
|
95
|
+
end
|
96
|
+
|
97
|
+
# Calculates hash code according to all attributes.
|
98
|
+
# @return [Fixnum] Hash code
|
99
|
+
def hash
|
100
|
+
[value, label].hash
|
101
|
+
end
|
102
|
+
|
103
|
+
# Builds the object from hash
|
104
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
105
|
+
# @return [Object] Returns the model itself
|
106
|
+
def build_from_hash(attributes)
|
107
|
+
return nil unless attributes.is_a?(Hash)
|
108
|
+
self.class.swagger_types.each_pair do |key, type|
|
109
|
+
if type =~ /\AArray<(.*)>/i
|
110
|
+
# check to ensure the input is an array given that the the attribute
|
111
|
+
# is documented as an array but the input is not
|
112
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
113
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
114
|
+
end
|
115
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
116
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
117
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
118
|
+
end
|
119
|
+
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
# Deserializes the data based on type
|
124
|
+
# @param string type Data type
|
125
|
+
# @param string value Value to be deserialized
|
126
|
+
# @return [Object] Deserialized data
|
127
|
+
def _deserialize(type, value)
|
128
|
+
case type.to_sym
|
129
|
+
when :DateTime
|
130
|
+
DateTime.parse(value)
|
131
|
+
when :Date
|
132
|
+
Date.parse(value)
|
133
|
+
when :String
|
134
|
+
value.to_s
|
135
|
+
when :Integer
|
136
|
+
value.to_i
|
137
|
+
when :Float
|
138
|
+
value.to_f
|
139
|
+
when :BOOLEAN
|
140
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
141
|
+
true
|
142
|
+
else
|
143
|
+
false
|
144
|
+
end
|
145
|
+
when :Object
|
146
|
+
# generic object (usually a Hash), return directly
|
147
|
+
value
|
148
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
149
|
+
inner_type = Regexp.last_match[:inner_type]
|
150
|
+
value.map { |v| _deserialize(inner_type, v) }
|
151
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
152
|
+
k_type = Regexp.last_match[:k_type]
|
153
|
+
v_type = Regexp.last_match[:v_type]
|
154
|
+
{}.tap do |hash|
|
155
|
+
value.each do |k, v|
|
156
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
else # model
|
160
|
+
temp_model = SibApiV3Sdk.const_get(type).new
|
161
|
+
temp_model.build_from_hash(value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Returns the string representation of the object
|
166
|
+
# @return [String] String presentation of the object
|
167
|
+
def to_s
|
168
|
+
to_hash.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
# to_body is an alias to to_hash (backward compatibility)
|
172
|
+
# @return [Hash] Returns the object in the form of hash
|
173
|
+
def to_body
|
174
|
+
to_hash
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns the object in the form of hash
|
178
|
+
# @return [Hash] Returns the object in the form of hash
|
179
|
+
def to_hash
|
180
|
+
hash = {}
|
181
|
+
self.class.attribute_map.each_pair do |attr, param|
|
182
|
+
value = self.send(attr)
|
183
|
+
next if value.nil?
|
184
|
+
hash[param] = _to_hash(value)
|
185
|
+
end
|
186
|
+
hash
|
187
|
+
end
|
188
|
+
|
189
|
+
# Outputs non-array value in the form of hash
|
190
|
+
# For object, use to_hash. Otherwise, just return the value
|
191
|
+
# @param [Object] value Any valid value
|
192
|
+
# @return [Hash] Returns the value in the form of hash
|
193
|
+
def _to_hash(value)
|
194
|
+
if value.is_a?(Array)
|
195
|
+
value.compact.map{ |v| _to_hash(v) }
|
196
|
+
elsif value.is_a?(Hash)
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
199
|
+
end
|
200
|
+
elsif value.respond_to? :to_hash
|
201
|
+
value.to_hash
|
202
|
+
else
|
203
|
+
value
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
@@ -96,7 +96,7 @@ module SibApiV3Sdk
|
|
96
96
|
# @return true if the model is valid
|
97
97
|
def valid?
|
98
98
|
return false if @code.nil?
|
99
|
-
code_validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission", "not_enough_credits", "permission_denied", "duplicate_parameter", "method_not_allowed", "unauthorized", "account_under_validation", "not_acceptable"])
|
99
|
+
code_validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission", "not_enough_credits", "permission_denied", "duplicate_parameter", "duplicate_request", "method_not_allowed", "unauthorized", "account_under_validation", "not_acceptable"])
|
100
100
|
return false unless code_validator.valid?(@code)
|
101
101
|
return false if @message.nil?
|
102
102
|
return true
|
@@ -105,7 +105,7 @@ module SibApiV3Sdk
|
|
105
105
|
# Custom attribute writer method checking allowed values (enum).
|
106
106
|
# @param [Object] code Object to be assigned
|
107
107
|
def code=(code)
|
108
|
-
validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission", "not_enough_credits", "permission_denied", "duplicate_parameter", "method_not_allowed", "unauthorized", "account_under_validation", "not_acceptable"])
|
108
|
+
validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission", "not_enough_credits", "permission_denied", "duplicate_parameter", "duplicate_request", "method_not_allowed", "unauthorized", "account_under_validation", "not_acceptable"])
|
109
109
|
unless validator.valid?(code)
|
110
110
|
fail ArgumentError, "invalid value for 'code', must be one of #{validator.allowable_values}."
|
111
111
|
end
|
@@ -15,9 +15,6 @@ require 'date'
|
|
15
15
|
module SibApiV3Sdk
|
16
16
|
|
17
17
|
class GetAttributesAttributes
|
18
|
-
# ID of the attribute
|
19
|
-
attr_accessor :id
|
20
|
-
|
21
18
|
# Name of the attribute
|
22
19
|
attr_accessor :name
|
23
20
|
|
@@ -58,7 +55,6 @@ module SibApiV3Sdk
|
|
58
55
|
# Attribute mapping from ruby-style variable name to JSON key.
|
59
56
|
def self.attribute_map
|
60
57
|
{
|
61
|
-
:'id' => :'id',
|
62
58
|
:'name' => :'name',
|
63
59
|
:'category' => :'category',
|
64
60
|
:'type' => :'type',
|
@@ -70,7 +66,6 @@ module SibApiV3Sdk
|
|
70
66
|
# Attribute type mapping.
|
71
67
|
def self.swagger_types
|
72
68
|
{
|
73
|
-
:'id' => :'Integer',
|
74
69
|
:'name' => :'String',
|
75
70
|
:'category' => :'String',
|
76
71
|
:'type' => :'String',
|
@@ -87,10 +82,6 @@ module SibApiV3Sdk
|
|
87
82
|
# convert string to symbol for hash key
|
88
83
|
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
89
84
|
|
90
|
-
if attributes.has_key?(:'id')
|
91
|
-
self.id = attributes[:'id']
|
92
|
-
end
|
93
|
-
|
94
85
|
if attributes.has_key?(:'name')
|
95
86
|
self.name = attributes[:'name']
|
96
87
|
end
|
@@ -119,10 +110,6 @@ module SibApiV3Sdk
|
|
119
110
|
# @return Array for valid properies with the reasons
|
120
111
|
def list_invalid_properties
|
121
112
|
invalid_properties = Array.new
|
122
|
-
if @id.nil?
|
123
|
-
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
124
|
-
end
|
125
|
-
|
126
113
|
if @name.nil?
|
127
114
|
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
128
115
|
end
|
@@ -137,7 +124,6 @@ module SibApiV3Sdk
|
|
137
124
|
# Check to see if the all the properties in the model are valid
|
138
125
|
# @return true if the model is valid
|
139
126
|
def valid?
|
140
|
-
return false if @id.nil?
|
141
127
|
return false if @name.nil?
|
142
128
|
return false if @category.nil?
|
143
129
|
category_validator = EnumAttributeValidator.new('String', ["normal", "transactional", "category", "calculated", "global"])
|
@@ -172,7 +158,6 @@ module SibApiV3Sdk
|
|
172
158
|
def ==(o)
|
173
159
|
return true if self.equal?(o)
|
174
160
|
self.class == o.class &&
|
175
|
-
id == o.id &&
|
176
161
|
name == o.name &&
|
177
162
|
category == o.category &&
|
178
163
|
type == o.type &&
|
@@ -189,7 +174,7 @@ module SibApiV3Sdk
|
|
189
174
|
# Calculates hash code according to all attributes.
|
190
175
|
# @return [Fixnum] Hash code
|
191
176
|
def hash
|
192
|
-
[
|
177
|
+
[name, category, type, enumeration, calculated_value].hash
|
193
178
|
end
|
194
179
|
|
195
180
|
# Builds the object from hash
|
@@ -17,18 +17,22 @@ module SibApiV3Sdk
|
|
17
17
|
class SendSms
|
18
18
|
attr_accessor :reference
|
19
19
|
|
20
|
+
attr_accessor :message_id
|
21
|
+
|
20
22
|
|
21
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
24
|
def self.attribute_map
|
23
25
|
{
|
24
|
-
:'reference' => :'reference'
|
26
|
+
:'reference' => :'reference',
|
27
|
+
:'message_id' => :'messageId'
|
25
28
|
}
|
26
29
|
end
|
27
30
|
|
28
31
|
# Attribute type mapping.
|
29
32
|
def self.swagger_types
|
30
33
|
{
|
31
|
-
:'reference' => :'String'
|
34
|
+
:'reference' => :'String',
|
35
|
+
:'message_id' => :'Integer'
|
32
36
|
}
|
33
37
|
end
|
34
38
|
|
@@ -44,6 +48,10 @@ module SibApiV3Sdk
|
|
44
48
|
self.reference = attributes[:'reference']
|
45
49
|
end
|
46
50
|
|
51
|
+
if attributes.has_key?(:'messageId')
|
52
|
+
self.message_id = attributes[:'messageId']
|
53
|
+
end
|
54
|
+
|
47
55
|
end
|
48
56
|
|
49
57
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -54,6 +62,10 @@ module SibApiV3Sdk
|
|
54
62
|
invalid_properties.push("invalid value for 'reference', reference cannot be nil.")
|
55
63
|
end
|
56
64
|
|
65
|
+
if @message_id.nil?
|
66
|
+
invalid_properties.push("invalid value for 'message_id', message_id cannot be nil.")
|
67
|
+
end
|
68
|
+
|
57
69
|
return invalid_properties
|
58
70
|
end
|
59
71
|
|
@@ -61,6 +73,7 @@ module SibApiV3Sdk
|
|
61
73
|
# @return true if the model is valid
|
62
74
|
def valid?
|
63
75
|
return false if @reference.nil?
|
76
|
+
return false if @message_id.nil?
|
64
77
|
return true
|
65
78
|
end
|
66
79
|
|
@@ -69,7 +82,8 @@ module SibApiV3Sdk
|
|
69
82
|
def ==(o)
|
70
83
|
return true if self.equal?(o)
|
71
84
|
self.class == o.class &&
|
72
|
-
reference == o.reference
|
85
|
+
reference == o.reference &&
|
86
|
+
message_id == o.message_id
|
73
87
|
end
|
74
88
|
|
75
89
|
# @see the `==` method
|
@@ -81,7 +95,7 @@ module SibApiV3Sdk
|
|
81
95
|
# Calculates hash code according to all attributes.
|
82
96
|
# @return [Fixnum] Hash code
|
83
97
|
def hash
|
84
|
-
[reference].hash
|
98
|
+
[reference, message_id].hash
|
85
99
|
end
|
86
100
|
|
87
101
|
# Builds the object from hash
|
@@ -0,0 +1,201 @@
|
|
1
|
+
=begin
|
2
|
+
#SendinBlue API
|
3
|
+
|
4
|
+
#SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/sendinblue **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed |
|
5
|
+
|
6
|
+
OpenAPI spec version: 3.0.0
|
7
|
+
Contact: contact@sendinblue.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
|
17
|
+
class UpdateAttribute
|
18
|
+
# Value of the attribute. Use only if the attribute's category is calculated or global
|
19
|
+
attr_accessor :value
|
20
|
+
|
21
|
+
# Values that the attribute can take. Use only if the attribute's category is category
|
22
|
+
attr_accessor :enumeration
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'value' => :'value',
|
29
|
+
:'enumeration' => :'enumeration'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
:'value' => :'String',
|
37
|
+
:'enumeration' => :'Array<UpdateAttributeEnumeration>'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Initializes the object
|
42
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
43
|
+
def initialize(attributes = {})
|
44
|
+
return unless attributes.is_a?(Hash)
|
45
|
+
|
46
|
+
# convert string to symbol for hash key
|
47
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
48
|
+
|
49
|
+
if attributes.has_key?(:'value')
|
50
|
+
self.value = attributes[:'value']
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.has_key?(:'enumeration')
|
54
|
+
if (value = attributes[:'enumeration']).is_a?(Array)
|
55
|
+
self.enumeration = value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
62
|
+
# @return Array for valid properies with the reasons
|
63
|
+
def list_invalid_properties
|
64
|
+
invalid_properties = Array.new
|
65
|
+
return invalid_properties
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check to see if the all the properties in the model are valid
|
69
|
+
# @return true if the model is valid
|
70
|
+
def valid?
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
|
74
|
+
# Checks equality by comparing each attribute.
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def ==(o)
|
77
|
+
return true if self.equal?(o)
|
78
|
+
self.class == o.class &&
|
79
|
+
value == o.value &&
|
80
|
+
enumeration == o.enumeration
|
81
|
+
end
|
82
|
+
|
83
|
+
# @see the `==` method
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def eql?(o)
|
86
|
+
self == o
|
87
|
+
end
|
88
|
+
|
89
|
+
# Calculates hash code according to all attributes.
|
90
|
+
# @return [Fixnum] Hash code
|
91
|
+
def hash
|
92
|
+
[value, enumeration].hash
|
93
|
+
end
|
94
|
+
|
95
|
+
# Builds the object from hash
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
97
|
+
# @return [Object] Returns the model itself
|
98
|
+
def build_from_hash(attributes)
|
99
|
+
return nil unless attributes.is_a?(Hash)
|
100
|
+
self.class.swagger_types.each_pair do |key, type|
|
101
|
+
if type =~ /\AArray<(.*)>/i
|
102
|
+
# check to ensure the input is an array given that the the attribute
|
103
|
+
# is documented as an array but the input is not
|
104
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
105
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
106
|
+
end
|
107
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
108
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
109
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
110
|
+
end
|
111
|
+
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
# Deserializes the data based on type
|
116
|
+
# @param string type Data type
|
117
|
+
# @param string value Value to be deserialized
|
118
|
+
# @return [Object] Deserialized data
|
119
|
+
def _deserialize(type, value)
|
120
|
+
case type.to_sym
|
121
|
+
when :DateTime
|
122
|
+
DateTime.parse(value)
|
123
|
+
when :Date
|
124
|
+
Date.parse(value)
|
125
|
+
when :String
|
126
|
+
value.to_s
|
127
|
+
when :Integer
|
128
|
+
value.to_i
|
129
|
+
when :Float
|
130
|
+
value.to_f
|
131
|
+
when :BOOLEAN
|
132
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
133
|
+
true
|
134
|
+
else
|
135
|
+
false
|
136
|
+
end
|
137
|
+
when :Object
|
138
|
+
# generic object (usually a Hash), return directly
|
139
|
+
value
|
140
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
141
|
+
inner_type = Regexp.last_match[:inner_type]
|
142
|
+
value.map { |v| _deserialize(inner_type, v) }
|
143
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
144
|
+
k_type = Regexp.last_match[:k_type]
|
145
|
+
v_type = Regexp.last_match[:v_type]
|
146
|
+
{}.tap do |hash|
|
147
|
+
value.each do |k, v|
|
148
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
else # model
|
152
|
+
temp_model = SibApiV3Sdk.const_get(type).new
|
153
|
+
temp_model.build_from_hash(value)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the string representation of the object
|
158
|
+
# @return [String] String presentation of the object
|
159
|
+
def to_s
|
160
|
+
to_hash.to_s
|
161
|
+
end
|
162
|
+
|
163
|
+
# to_body is an alias to to_hash (backward compatibility)
|
164
|
+
# @return [Hash] Returns the object in the form of hash
|
165
|
+
def to_body
|
166
|
+
to_hash
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the object in the form of hash
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_hash
|
172
|
+
hash = {}
|
173
|
+
self.class.attribute_map.each_pair do |attr, param|
|
174
|
+
value = self.send(attr)
|
175
|
+
next if value.nil?
|
176
|
+
hash[param] = _to_hash(value)
|
177
|
+
end
|
178
|
+
hash
|
179
|
+
end
|
180
|
+
|
181
|
+
# Outputs non-array value in the form of hash
|
182
|
+
# For object, use to_hash. Otherwise, just return the value
|
183
|
+
# @param [Object] value Any valid value
|
184
|
+
# @return [Hash] Returns the value in the form of hash
|
185
|
+
def _to_hash(value)
|
186
|
+
if value.is_a?(Array)
|
187
|
+
value.compact.map{ |v| _to_hash(v) }
|
188
|
+
elsif value.is_a?(Hash)
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
191
|
+
end
|
192
|
+
elsif value.respond_to? :to_hash
|
193
|
+
value.to_hash
|
194
|
+
else
|
195
|
+
value
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|