sib-api-v3-sdk 3.0.1 → 4.0.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.
- checksums.yaml +4 -4
- data/README.md +14 -11
- data/docs/AddContactToList.md +8 -0
- data/docs/AddCredits.md +2 -2
- data/docs/ContactsApi.md +9 -9
- data/docs/CreateReseller.md +8 -0
- data/docs/GetChildInfo.md +2 -2
- data/docs/GetChildInfoApiKeys.md +2 -3
- data/docs/GetChildInfoApiKeysV2.md +9 -0
- data/docs/GetChildInfoApiKeysV3.md +9 -0
- data/docs/GetEmailCampaign.md +2 -0
- data/docs/GetSmsCampaign.md +2 -0
- data/docs/ListsApi.md +9 -9
- data/docs/ManageIp.md +1 -1
- data/docs/RemoveContactFromList.md +9 -0
- data/docs/RemoveCredits.md +2 -2
- data/docs/ResellerApi.md +45 -45
- data/docs/SendSmtpEmail.md +7 -5
- data/docs/UpdateChild.md +0 -1
- data/lib/sib-api-v3-sdk.rb +5 -2
- data/lib/sib-api-v3-sdk/api/contacts_api.rb +7 -7
- data/lib/sib-api-v3-sdk/api/lists_api.rb +7 -7
- data/lib/sib-api-v3-sdk/api/reseller_api.rb +82 -82
- data/lib/sib-api-v3-sdk/models/{add_remove_contact_to_list.rb → add_contact_to_list.rb} +2 -2
- data/lib/sib-api-v3-sdk/models/add_credits.rb +2 -2
- data/lib/sib-api-v3-sdk/models/create_reseller.rb +194 -0
- data/lib/sib-api-v3-sdk/models/error_model.rb +2 -2
- data/lib/sib-api-v3-sdk/models/get_child_info.rb +3 -6
- data/lib/sib-api-v3-sdk/models/get_child_info_api_keys.rb +21 -34
- data/lib/sib-api-v3-sdk/models/get_child_info_api_keys_v2.rb +209 -0
- data/lib/sib-api-v3-sdk/models/get_child_info_api_keys_v3.rb +209 -0
- data/lib/sib-api-v3-sdk/models/get_email_campaign.rb +32 -4
- data/lib/sib-api-v3-sdk/models/get_sms_campaign.rb +32 -4
- data/lib/sib-api-v3-sdk/models/manage_ip.rb +8 -8
- data/lib/sib-api-v3-sdk/models/{get_child_info_ips.rb → remove_contact_from_list.rb} +18 -26
- data/lib/sib-api-v3-sdk/models/remove_credits.rb +2 -2
- data/lib/sib-api-v3-sdk/models/send_smtp_email.rb +29 -23
- data/lib/sib-api-v3-sdk/models/send_smtp_email_sender.rb +1 -1
- data/lib/sib-api-v3-sdk/models/update_child.rb +4 -15
- data/lib/sib-api-v3-sdk/version.rb +1 -1
- data/spec/api/contacts_api_spec.rb +2 -2
- data/spec/api/lists_api_spec.rb +2 -2
- data/spec/api/reseller_api_spec.rb +12 -12
- data/spec/models/{add_remove_contact_to_list_spec.rb → add_contact_to_list_spec.rb} +6 -6
- data/spec/models/create_reseller_spec.rb +42 -0
- data/spec/models/error_model_spec.rb +1 -1
- data/spec/models/get_child_info_api_keys_spec.rb +2 -8
- data/spec/models/{get_child_info_ips_spec.rb → get_child_info_api_keys_v2_spec.rb} +8 -8
- data/spec/models/get_child_info_api_keys_v3_spec.rb +48 -0
- data/spec/models/get_email_campaign_spec.rb +12 -0
- data/spec/models/get_sms_campaign_spec.rb +12 -0
- data/spec/models/manage_ip_spec.rb +1 -1
- data/spec/models/remove_contact_from_list_spec.rb +48 -0
- data/spec/models/send_smtp_email_spec.rb +12 -0
- data/spec/models/update_child_spec.rb +0 -6
- metadata +22 -10
- data/docs/AddRemoveContactToList.md +0 -8
- data/docs/GetChildInfoIps.md +0 -9
@@ -15,10 +15,10 @@ require 'date'
|
|
15
15
|
module SibApiV3Sdk
|
16
16
|
|
17
17
|
class AddCredits
|
18
|
-
# SMS credits to be added to the child account
|
18
|
+
# Required if email credits are empty. SMS credits to be added to the child account
|
19
19
|
attr_accessor :sms
|
20
20
|
|
21
|
-
# Email credits to be added to the child account
|
21
|
+
# Required if sms credits are empty. Email credits to be added to the child account
|
22
22
|
attr_accessor :email
|
23
23
|
|
24
24
|
|
@@ -0,0 +1,194 @@
|
|
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.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
|
17
|
+
class CreateReseller
|
18
|
+
# AuthKey of Reseller child created
|
19
|
+
attr_accessor :auth_key
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'auth_key' => :'authKey'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'auth_key' => :'String'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
return unless attributes.is_a?(Hash)
|
40
|
+
|
41
|
+
# convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
43
|
+
|
44
|
+
if attributes.has_key?(:'authKey')
|
45
|
+
self.auth_key = attributes[:'authKey']
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
51
|
+
# @return Array for valid properties with the reasons
|
52
|
+
def list_invalid_properties
|
53
|
+
invalid_properties = Array.new
|
54
|
+
if @auth_key.nil?
|
55
|
+
invalid_properties.push("invalid value for 'auth_key', auth_key cannot be nil.")
|
56
|
+
end
|
57
|
+
|
58
|
+
return invalid_properties
|
59
|
+
end
|
60
|
+
|
61
|
+
# Check to see if the all the properties in the model are valid
|
62
|
+
# @return true if the model is valid
|
63
|
+
def valid?
|
64
|
+
return false if @auth_key.nil?
|
65
|
+
return true
|
66
|
+
end
|
67
|
+
|
68
|
+
# Checks equality by comparing each attribute.
|
69
|
+
# @param [Object] Object to be compared
|
70
|
+
def ==(o)
|
71
|
+
return true if self.equal?(o)
|
72
|
+
self.class == o.class &&
|
73
|
+
auth_key == o.auth_key
|
74
|
+
end
|
75
|
+
|
76
|
+
# @see the `==` method
|
77
|
+
# @param [Object] Object to be compared
|
78
|
+
def eql?(o)
|
79
|
+
self == o
|
80
|
+
end
|
81
|
+
|
82
|
+
# Calculates hash code according to all attributes.
|
83
|
+
# @return [Fixnum] Hash code
|
84
|
+
def hash
|
85
|
+
[auth_key].hash
|
86
|
+
end
|
87
|
+
|
88
|
+
# Builds the object from hash
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
90
|
+
# @return [Object] Returns the model itself
|
91
|
+
def build_from_hash(attributes)
|
92
|
+
return nil unless attributes.is_a?(Hash)
|
93
|
+
self.class.swagger_types.each_pair do |key, type|
|
94
|
+
if type =~ /\AArray<(.*)>/i
|
95
|
+
# check to ensure the input is an array given that the the attribute
|
96
|
+
# is documented as an array but the input is not
|
97
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
98
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
99
|
+
end
|
100
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
101
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
102
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
# Deserializes the data based on type
|
109
|
+
# @param string type Data type
|
110
|
+
# @param string value Value to be deserialized
|
111
|
+
# @return [Object] Deserialized data
|
112
|
+
def _deserialize(type, value)
|
113
|
+
case type.to_sym
|
114
|
+
when :DateTime
|
115
|
+
DateTime.parse(value)
|
116
|
+
when :Date
|
117
|
+
Date.parse(value)
|
118
|
+
when :String
|
119
|
+
value.to_s
|
120
|
+
when :Integer
|
121
|
+
value.to_i
|
122
|
+
when :Float
|
123
|
+
value.to_f
|
124
|
+
when :BOOLEAN
|
125
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
else # model
|
145
|
+
temp_model = SibApiV3Sdk.const_get(type).new
|
146
|
+
temp_model.build_from_hash(value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns the string representation of the object
|
151
|
+
# @return [String] String presentation of the object
|
152
|
+
def to_s
|
153
|
+
to_hash.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
# to_body is an alias to to_hash (backward compatibility)
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the object in the form of hash
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Outputs non-array value in the form of hash
|
175
|
+
# For object, use to_hash. Otherwise, just return the value
|
176
|
+
# @param [Object] value Any valid value
|
177
|
+
# @return [Hash] Returns the value in the form of hash
|
178
|
+
def _to_hash(value)
|
179
|
+
if value.is_a?(Array)
|
180
|
+
value.compact.map{ |v| _to_hash(v) }
|
181
|
+
elsif value.is_a?(Hash)
|
182
|
+
{}.tap do |hash|
|
183
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
184
|
+
end
|
185
|
+
elsif value.respond_to? :to_hash
|
186
|
+
value.to_hash
|
187
|
+
else
|
188
|
+
value
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
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", "
|
99
|
+
code_validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission_denied", "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", "
|
108
|
+
validator = EnumAttributeValidator.new('String', ["invalid_parameter", "missing_parameter", "out_of_range", "campaign_processing", "campaign_sent", "document_not_found", "reseller_permission_denied", "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
|
@@ -37,7 +37,6 @@ module SibApiV3Sdk
|
|
37
37
|
# IP(s) associated to a child account user
|
38
38
|
attr_accessor :ips
|
39
39
|
|
40
|
-
# API Keys associated to child account
|
41
40
|
attr_accessor :api_keys
|
42
41
|
|
43
42
|
|
@@ -66,8 +65,8 @@ module SibApiV3Sdk
|
|
66
65
|
:'credits' => :'GetChildInfoCredits',
|
67
66
|
:'statistics' => :'GetChildInfoStatistics',
|
68
67
|
:'password' => :'String',
|
69
|
-
:'ips' => :'Array<
|
70
|
-
:'api_keys' => :'
|
68
|
+
:'ips' => :'Array<String>',
|
69
|
+
:'api_keys' => :'GetChildInfoApiKeys'
|
71
70
|
}
|
72
71
|
end
|
73
72
|
|
@@ -114,9 +113,7 @@ module SibApiV3Sdk
|
|
114
113
|
end
|
115
114
|
|
116
115
|
if attributes.has_key?(:'apiKeys')
|
117
|
-
|
118
|
-
self.api_keys = value
|
119
|
-
end
|
116
|
+
self.api_keys = attributes[:'apiKeys']
|
120
117
|
end
|
121
118
|
|
122
119
|
end
|
@@ -13,33 +13,26 @@ Swagger Codegen version: 2.3.1
|
|
13
13
|
require 'date'
|
14
14
|
|
15
15
|
module SibApiV3Sdk
|
16
|
-
|
16
|
+
# API Keys associated to child account
|
17
17
|
class GetChildInfoApiKeys
|
18
|
-
|
19
|
-
attr_accessor :name
|
20
|
-
|
21
|
-
# API Key
|
22
|
-
attr_accessor :key
|
18
|
+
attr_accessor :v2
|
23
19
|
|
24
|
-
|
25
|
-
attr_accessor :secret
|
20
|
+
attr_accessor :v3
|
26
21
|
|
27
22
|
|
28
23
|
# Attribute mapping from ruby-style variable name to JSON key.
|
29
24
|
def self.attribute_map
|
30
25
|
{
|
31
|
-
:'
|
32
|
-
:'
|
33
|
-
:'secret' => :'secret'
|
26
|
+
:'v2' => :'v2',
|
27
|
+
:'v3' => :'v3'
|
34
28
|
}
|
35
29
|
end
|
36
30
|
|
37
31
|
# Attribute type mapping.
|
38
32
|
def self.swagger_types
|
39
33
|
{
|
40
|
-
:'
|
41
|
-
:'
|
42
|
-
:'secret' => :'String'
|
34
|
+
:'v2' => :'Array<GetChildInfoApiKeysV2>',
|
35
|
+
:'v3' => :'Array<GetChildInfoApiKeysV3>'
|
43
36
|
}
|
44
37
|
end
|
45
38
|
|
@@ -51,16 +44,16 @@ module SibApiV3Sdk
|
|
51
44
|
# convert string to symbol for hash key
|
52
45
|
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
53
46
|
|
54
|
-
if attributes.has_key?(:'
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
if attributes.has_key?(:'key')
|
59
|
-
self.key = attributes[:'key']
|
47
|
+
if attributes.has_key?(:'v2')
|
48
|
+
if (value = attributes[:'v2']).is_a?(Array)
|
49
|
+
self.v2 = value
|
50
|
+
end
|
60
51
|
end
|
61
52
|
|
62
|
-
if attributes.has_key?(:'
|
63
|
-
|
53
|
+
if attributes.has_key?(:'v3')
|
54
|
+
if (value = attributes[:'v3']).is_a?(Array)
|
55
|
+
self.v3 = value
|
56
|
+
end
|
64
57
|
end
|
65
58
|
|
66
59
|
end
|
@@ -69,12 +62,8 @@ module SibApiV3Sdk
|
|
69
62
|
# @return Array for valid properties with the reasons
|
70
63
|
def list_invalid_properties
|
71
64
|
invalid_properties = Array.new
|
72
|
-
if @
|
73
|
-
invalid_properties.push("invalid value for '
|
74
|
-
end
|
75
|
-
|
76
|
-
if @key.nil?
|
77
|
-
invalid_properties.push("invalid value for 'key', key cannot be nil.")
|
65
|
+
if @v2.nil?
|
66
|
+
invalid_properties.push("invalid value for 'v2', v2 cannot be nil.")
|
78
67
|
end
|
79
68
|
|
80
69
|
return invalid_properties
|
@@ -83,8 +72,7 @@ module SibApiV3Sdk
|
|
83
72
|
# Check to see if the all the properties in the model are valid
|
84
73
|
# @return true if the model is valid
|
85
74
|
def valid?
|
86
|
-
return false if @
|
87
|
-
return false if @key.nil?
|
75
|
+
return false if @v2.nil?
|
88
76
|
return true
|
89
77
|
end
|
90
78
|
|
@@ -93,9 +81,8 @@ module SibApiV3Sdk
|
|
93
81
|
def ==(o)
|
94
82
|
return true if self.equal?(o)
|
95
83
|
self.class == o.class &&
|
96
|
-
|
97
|
-
|
98
|
-
secret == o.secret
|
84
|
+
v2 == o.v2 &&
|
85
|
+
v3 == o.v3
|
99
86
|
end
|
100
87
|
|
101
88
|
# @see the `==` method
|
@@ -107,7 +94,7 @@ module SibApiV3Sdk
|
|
107
94
|
# Calculates hash code according to all attributes.
|
108
95
|
# @return [Fixnum] Hash code
|
109
96
|
def hash
|
110
|
-
[
|
97
|
+
[v2, v3].hash
|
111
98
|
end
|
112
99
|
|
113
100
|
# Builds the object from hash
|
@@ -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.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
|
17
|
+
class GetChildInfoApiKeysV2
|
18
|
+
# Name of the key for version 2
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# API Key for version 2
|
22
|
+
attr_accessor :key
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'name' => :'name',
|
29
|
+
:'key' => :'key'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
:'name' => :'String',
|
37
|
+
:'key' => :'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?(:'name')
|
50
|
+
self.name = attributes[:'name']
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes.has_key?(:'key')
|
54
|
+
self.key = attributes[:'key']
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
60
|
+
# @return Array for valid properties with the reasons
|
61
|
+
def list_invalid_properties
|
62
|
+
invalid_properties = Array.new
|
63
|
+
if @name.nil?
|
64
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
65
|
+
end
|
66
|
+
|
67
|
+
if @key.nil?
|
68
|
+
invalid_properties.push("invalid value for 'key', key 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 @name.nil?
|
78
|
+
return false if @key.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
|
+
name == o.name &&
|
88
|
+
key == o.key
|
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
|
+
[name, key].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
|