sib-api-v3-sdk 5.5.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -21
- data/docs/AbTestCampaignResult.md +2 -0
- data/docs/AbTestCampaignResultClickedLinks.md +9 -0
- data/docs/AbTestCampaignResultStatistics.md +13 -0
- data/docs/AbTestVersionClicks.md +7 -0
- data/docs/AbTestVersionClicksInner.md +10 -0
- data/docs/AbTestVersionStats.md +9 -0
- data/docs/AddContactToList.md +2 -1
- data/docs/ContactsApi.md +24 -24
- data/docs/CreateDoiContact.md +1 -1
- data/docs/CreateSmsCampaign.md +1 -1
- data/docs/CreateWebhook.md +1 -1
- data/docs/GetAggregatedReport.md +13 -13
- data/docs/GetCampaignStats.md +1 -0
- data/docs/ListsApi.md +4 -4
- data/docs/RemoveContactFromList.md +2 -1
- data/docs/SendSmtpEmailSender.md +1 -0
- data/docs/SendTransacSms.md +1 -1
- data/docs/{SMTPApi.md → TransactionalEmailsApi.md} +52 -52
- data/docs/UpdateSmsCampaign.md +1 -1
- data/docs/UpdateWebhook.md +1 -1
- data/lib/sib-api-v3-sdk.rb +6 -1
- data/lib/sib-api-v3-sdk/api/contacts_api.rb +40 -40
- data/lib/sib-api-v3-sdk/api/lists_api.rb +4 -4
- data/lib/sib-api-v3-sdk/api/{smtp_api.rb → transactional_emails_api.rb} +52 -52
- data/lib/sib-api-v3-sdk/models/ab_test_campaign_result.rb +22 -4
- data/lib/sib-api-v3-sdk/models/ab_test_campaign_result_clicked_links.rb +202 -0
- data/lib/sib-api-v3-sdk/models/ab_test_campaign_result_statistics.rb +258 -0
- data/lib/sib-api-v3-sdk/models/ab_test_version_clicks.rb +175 -0
- data/lib/sib-api-v3-sdk/models/ab_test_version_clicks_inner.rb +219 -0
- data/lib/sib-api-v3-sdk/models/ab_test_version_stats.rb +205 -0
- data/lib/sib-api-v3-sdk/models/add_contact_to_list.rb +17 -5
- data/lib/sib-api-v3-sdk/models/create_doi_contact.rb +5 -0
- data/lib/sib-api-v3-sdk/models/create_sms_campaign.rb +6 -6
- data/lib/sib-api-v3-sdk/models/create_webhook.rb +1 -1
- data/lib/sib-api-v3-sdk/models/get_aggregated_report.rb +0 -65
- data/lib/sib-api-v3-sdk/models/get_campaign_stats.rb +14 -4
- data/lib/sib-api-v3-sdk/models/remove_contact_from_list.rb +14 -2
- data/lib/sib-api-v3-sdk/models/send_smtp_email_sender.rb +15 -5
- data/lib/sib-api-v3-sdk/models/send_transac_sms.rb +6 -6
- data/lib/sib-api-v3-sdk/models/update_sms_campaign.rb +6 -6
- data/lib/sib-api-v3-sdk/models/update_webhook.rb +1 -1
- data/lib/sib-api-v3-sdk/version.rb +1 -1
- data/spec/api/contacts_api_spec.rb +6 -6
- data/spec/api/lists_api_spec.rb +2 -2
- data/spec/api/{smtp_api_spec.rb → transactional_emails_api_spec.rb} +6 -6
- data/spec/models/ab_test_campaign_result_clicked_links_spec.rb +47 -0
- data/spec/models/ab_test_campaign_result_spec.rb +12 -0
- data/spec/models/ab_test_campaign_result_statistics_spec.rb +71 -0
- data/spec/models/ab_test_version_clicks_inner_spec.rb +53 -0
- data/spec/models/ab_test_version_clicks_spec.rb +35 -0
- data/spec/models/ab_test_version_stats_spec.rb +47 -0
- data/spec/models/add_contact_to_list_spec.rb +6 -0
- data/spec/models/get_campaign_stats_spec.rb +6 -0
- data/spec/models/remove_contact_from_list_spec.rb +6 -0
- data/spec/models/send_smtp_email_sender_spec.rb +6 -0
- data/testfile.rb +23 -0
- metadata +31 -10
@@ -0,0 +1,202 @@
|
|
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 | | 406 | Error. Not Acceptable |
|
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.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
class AbTestCampaignResultClickedLinks
|
17
|
+
attr_accessor :version_a
|
18
|
+
|
19
|
+
attr_accessor :version_b
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'version_a' => :'Version A',
|
25
|
+
:'version_b' => :'Version B'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'version_a' => :'AbTestVersionClicks',
|
33
|
+
:'version_b' => :'AbTestVersionClicks'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
44
|
+
|
45
|
+
if attributes.has_key?(:'Version A')
|
46
|
+
self.version_a = attributes[:'Version A']
|
47
|
+
end
|
48
|
+
|
49
|
+
if attributes.has_key?(:'Version B')
|
50
|
+
self.version_b = attributes[:'Version B']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def list_invalid_properties
|
57
|
+
invalid_properties = Array.new
|
58
|
+
if @version_a.nil?
|
59
|
+
invalid_properties.push('invalid value for "version_a", version_a cannot be nil.')
|
60
|
+
end
|
61
|
+
|
62
|
+
if @version_b.nil?
|
63
|
+
invalid_properties.push('invalid value for "version_b", version_b cannot be nil.')
|
64
|
+
end
|
65
|
+
|
66
|
+
invalid_properties
|
67
|
+
end
|
68
|
+
|
69
|
+
# Check to see if the all the properties in the model are valid
|
70
|
+
# @return true if the model is valid
|
71
|
+
def valid?
|
72
|
+
return false if @version_a.nil?
|
73
|
+
return false if @version_b.nil?
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# Checks equality by comparing each attribute.
|
78
|
+
# @param [Object] Object to be compared
|
79
|
+
def ==(o)
|
80
|
+
return true if self.equal?(o)
|
81
|
+
self.class == o.class &&
|
82
|
+
version_a == o.version_a &&
|
83
|
+
version_b == o.version_b
|
84
|
+
end
|
85
|
+
|
86
|
+
# @see the `==` method
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def eql?(o)
|
89
|
+
self == o
|
90
|
+
end
|
91
|
+
|
92
|
+
# Calculates hash code according to all attributes.
|
93
|
+
# @return [Fixnum] Hash code
|
94
|
+
def hash
|
95
|
+
[version_a, version_b].hash
|
96
|
+
end
|
97
|
+
|
98
|
+
# Builds the object from hash
|
99
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
100
|
+
# @return [Object] Returns the model itself
|
101
|
+
def build_from_hash(attributes)
|
102
|
+
return nil unless attributes.is_a?(Hash)
|
103
|
+
self.class.swagger_types.each_pair do |key, type|
|
104
|
+
if type =~ /\AArray<(.*)>/i
|
105
|
+
# check to ensure the input is an array given that the the attribute
|
106
|
+
# is documented as an array but the input is not
|
107
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
108
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
109
|
+
end
|
110
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
111
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
112
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
113
|
+
end
|
114
|
+
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
# Deserializes the data based on type
|
119
|
+
# @param string type Data type
|
120
|
+
# @param string value Value to be deserialized
|
121
|
+
# @return [Object] Deserialized data
|
122
|
+
def _deserialize(type, value)
|
123
|
+
case type.to_sym
|
124
|
+
when :DateTime
|
125
|
+
DateTime.parse(value)
|
126
|
+
when :Date
|
127
|
+
Date.parse(value)
|
128
|
+
when :String
|
129
|
+
value.to_s
|
130
|
+
when :Integer
|
131
|
+
value.to_i
|
132
|
+
when :Float
|
133
|
+
value.to_f
|
134
|
+
when :BOOLEAN
|
135
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
136
|
+
true
|
137
|
+
else
|
138
|
+
false
|
139
|
+
end
|
140
|
+
when :Object
|
141
|
+
# generic object (usually a Hash), return directly
|
142
|
+
value
|
143
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
144
|
+
inner_type = Regexp.last_match[:inner_type]
|
145
|
+
value.map { |v| _deserialize(inner_type, v) }
|
146
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
147
|
+
k_type = Regexp.last_match[:k_type]
|
148
|
+
v_type = Regexp.last_match[:v_type]
|
149
|
+
{}.tap do |hash|
|
150
|
+
value.each do |k, v|
|
151
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
else # model
|
155
|
+
temp_model = SibApiV3Sdk.const_get(type).new
|
156
|
+
temp_model.build_from_hash(value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the string representation of the object
|
161
|
+
# @return [String] String presentation of the object
|
162
|
+
def to_s
|
163
|
+
to_hash.to_s
|
164
|
+
end
|
165
|
+
|
166
|
+
# to_body is an alias to to_hash (backward compatibility)
|
167
|
+
# @return [Hash] Returns the object in the form of hash
|
168
|
+
def to_body
|
169
|
+
to_hash
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the object in the form of hash
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
174
|
+
def to_hash
|
175
|
+
hash = {}
|
176
|
+
self.class.attribute_map.each_pair do |attr, param|
|
177
|
+
value = self.send(attr)
|
178
|
+
next if value.nil?
|
179
|
+
hash[param] = _to_hash(value)
|
180
|
+
end
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Outputs non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
# @param [Object] value Any valid value
|
187
|
+
# @return [Hash] Returns the value in the form of hash
|
188
|
+
def _to_hash(value)
|
189
|
+
if value.is_a?(Array)
|
190
|
+
value.compact.map { |v| _to_hash(v) }
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
194
|
+
end
|
195
|
+
elsif value.respond_to? :to_hash
|
196
|
+
value.to_hash
|
197
|
+
else
|
198
|
+
value
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,258 @@
|
|
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 | | 406 | Error. Not Acceptable |
|
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.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SibApiV3Sdk
|
16
|
+
class AbTestCampaignResultStatistics
|
17
|
+
attr_accessor :openers
|
18
|
+
|
19
|
+
attr_accessor :clicks
|
20
|
+
|
21
|
+
attr_accessor :unsubscribed
|
22
|
+
|
23
|
+
attr_accessor :hard_bounces
|
24
|
+
|
25
|
+
attr_accessor :soft_bounces
|
26
|
+
|
27
|
+
attr_accessor :complaints
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'openers' => :'openers',
|
33
|
+
:'clicks' => :'clicks',
|
34
|
+
:'unsubscribed' => :'unsubscribed',
|
35
|
+
:'hard_bounces' => :'hardBounces',
|
36
|
+
:'soft_bounces' => :'softBounces',
|
37
|
+
:'complaints' => :'complaints'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.swagger_types
|
43
|
+
{
|
44
|
+
:'openers' => :'AbTestVersionStats',
|
45
|
+
:'clicks' => :'AbTestVersionStats',
|
46
|
+
:'unsubscribed' => :'AbTestVersionStats',
|
47
|
+
:'hard_bounces' => :'AbTestVersionStats',
|
48
|
+
:'soft_bounces' => :'AbTestVersionStats',
|
49
|
+
:'complaints' => :'AbTestVersionStats'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
return unless attributes.is_a?(Hash)
|
57
|
+
|
58
|
+
# convert string to symbol for hash key
|
59
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
60
|
+
|
61
|
+
if attributes.has_key?(:'openers')
|
62
|
+
self.openers = attributes[:'openers']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.has_key?(:'clicks')
|
66
|
+
self.clicks = attributes[:'clicks']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.has_key?(:'unsubscribed')
|
70
|
+
self.unsubscribed = attributes[:'unsubscribed']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'hardBounces')
|
74
|
+
self.hard_bounces = attributes[:'hardBounces']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'softBounces')
|
78
|
+
self.soft_bounces = attributes[:'softBounces']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'complaints')
|
82
|
+
self.complaints = attributes[:'complaints']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
87
|
+
# @return Array for valid properties with the reasons
|
88
|
+
def list_invalid_properties
|
89
|
+
invalid_properties = Array.new
|
90
|
+
if @openers.nil?
|
91
|
+
invalid_properties.push('invalid value for "openers", openers cannot be nil.')
|
92
|
+
end
|
93
|
+
|
94
|
+
if @clicks.nil?
|
95
|
+
invalid_properties.push('invalid value for "clicks", clicks cannot be nil.')
|
96
|
+
end
|
97
|
+
|
98
|
+
if @unsubscribed.nil?
|
99
|
+
invalid_properties.push('invalid value for "unsubscribed", unsubscribed cannot be nil.')
|
100
|
+
end
|
101
|
+
|
102
|
+
if @hard_bounces.nil?
|
103
|
+
invalid_properties.push('invalid value for "hard_bounces", hard_bounces cannot be nil.')
|
104
|
+
end
|
105
|
+
|
106
|
+
if @soft_bounces.nil?
|
107
|
+
invalid_properties.push('invalid value for "soft_bounces", soft_bounces cannot be nil.')
|
108
|
+
end
|
109
|
+
|
110
|
+
if @complaints.nil?
|
111
|
+
invalid_properties.push('invalid value for "complaints", complaints cannot be nil.')
|
112
|
+
end
|
113
|
+
|
114
|
+
invalid_properties
|
115
|
+
end
|
116
|
+
|
117
|
+
# Check to see if the all the properties in the model are valid
|
118
|
+
# @return true if the model is valid
|
119
|
+
def valid?
|
120
|
+
return false if @openers.nil?
|
121
|
+
return false if @clicks.nil?
|
122
|
+
return false if @unsubscribed.nil?
|
123
|
+
return false if @hard_bounces.nil?
|
124
|
+
return false if @soft_bounces.nil?
|
125
|
+
return false if @complaints.nil?
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
# Checks equality by comparing each attribute.
|
130
|
+
# @param [Object] Object to be compared
|
131
|
+
def ==(o)
|
132
|
+
return true if self.equal?(o)
|
133
|
+
self.class == o.class &&
|
134
|
+
openers == o.openers &&
|
135
|
+
clicks == o.clicks &&
|
136
|
+
unsubscribed == o.unsubscribed &&
|
137
|
+
hard_bounces == o.hard_bounces &&
|
138
|
+
soft_bounces == o.soft_bounces &&
|
139
|
+
complaints == o.complaints
|
140
|
+
end
|
141
|
+
|
142
|
+
# @see the `==` method
|
143
|
+
# @param [Object] Object to be compared
|
144
|
+
def eql?(o)
|
145
|
+
self == o
|
146
|
+
end
|
147
|
+
|
148
|
+
# Calculates hash code according to all attributes.
|
149
|
+
# @return [Fixnum] Hash code
|
150
|
+
def hash
|
151
|
+
[openers, clicks, unsubscribed, hard_bounces, soft_bounces, complaints].hash
|
152
|
+
end
|
153
|
+
|
154
|
+
# Builds the object from hash
|
155
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
156
|
+
# @return [Object] Returns the model itself
|
157
|
+
def build_from_hash(attributes)
|
158
|
+
return nil unless attributes.is_a?(Hash)
|
159
|
+
self.class.swagger_types.each_pair do |key, type|
|
160
|
+
if type =~ /\AArray<(.*)>/i
|
161
|
+
# check to ensure the input is an array given that the the attribute
|
162
|
+
# is documented as an array but the input is not
|
163
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
164
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
165
|
+
end
|
166
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
167
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
168
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
169
|
+
end
|
170
|
+
|
171
|
+
self
|
172
|
+
end
|
173
|
+
|
174
|
+
# Deserializes the data based on type
|
175
|
+
# @param string type Data type
|
176
|
+
# @param string value Value to be deserialized
|
177
|
+
# @return [Object] Deserialized data
|
178
|
+
def _deserialize(type, value)
|
179
|
+
case type.to_sym
|
180
|
+
when :DateTime
|
181
|
+
DateTime.parse(value)
|
182
|
+
when :Date
|
183
|
+
Date.parse(value)
|
184
|
+
when :String
|
185
|
+
value.to_s
|
186
|
+
when :Integer
|
187
|
+
value.to_i
|
188
|
+
when :Float
|
189
|
+
value.to_f
|
190
|
+
when :BOOLEAN
|
191
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
192
|
+
true
|
193
|
+
else
|
194
|
+
false
|
195
|
+
end
|
196
|
+
when :Object
|
197
|
+
# generic object (usually a Hash), return directly
|
198
|
+
value
|
199
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
200
|
+
inner_type = Regexp.last_match[:inner_type]
|
201
|
+
value.map { |v| _deserialize(inner_type, v) }
|
202
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
203
|
+
k_type = Regexp.last_match[:k_type]
|
204
|
+
v_type = Regexp.last_match[:v_type]
|
205
|
+
{}.tap do |hash|
|
206
|
+
value.each do |k, v|
|
207
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
else # model
|
211
|
+
temp_model = SibApiV3Sdk.const_get(type).new
|
212
|
+
temp_model.build_from_hash(value)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the string representation of the object
|
217
|
+
# @return [String] String presentation of the object
|
218
|
+
def to_s
|
219
|
+
to_hash.to_s
|
220
|
+
end
|
221
|
+
|
222
|
+
# to_body is an alias to to_hash (backward compatibility)
|
223
|
+
# @return [Hash] Returns the object in the form of hash
|
224
|
+
def to_body
|
225
|
+
to_hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Returns the object in the form of hash
|
229
|
+
# @return [Hash] Returns the object in the form of hash
|
230
|
+
def to_hash
|
231
|
+
hash = {}
|
232
|
+
self.class.attribute_map.each_pair do |attr, param|
|
233
|
+
value = self.send(attr)
|
234
|
+
next if value.nil?
|
235
|
+
hash[param] = _to_hash(value)
|
236
|
+
end
|
237
|
+
hash
|
238
|
+
end
|
239
|
+
|
240
|
+
# Outputs non-array value in the form of hash
|
241
|
+
# For object, use to_hash. Otherwise, just return the value
|
242
|
+
# @param [Object] value Any valid value
|
243
|
+
# @return [Hash] Returns the value in the form of hash
|
244
|
+
def _to_hash(value)
|
245
|
+
if value.is_a?(Array)
|
246
|
+
value.compact.map { |v| _to_hash(v) }
|
247
|
+
elsif value.is_a?(Hash)
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
250
|
+
end
|
251
|
+
elsif value.respond_to? :to_hash
|
252
|
+
value.to_hash
|
253
|
+
else
|
254
|
+
value
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|