mimepost 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +144 -0
  4. data/Rakefile +8 -0
  5. data/docs/AccountProfile.md +23 -0
  6. data/docs/AccountProfileResponse.md +10 -0
  7. data/docs/AccountSettings.md +9 -0
  8. data/docs/AccountsApi.md +216 -0
  9. data/docs/ApiResponse.md +10 -0
  10. data/docs/ApiResponseAllWebhooks.md +10 -0
  11. data/docs/ApiResponseAllWebhooksData.md +13 -0
  12. data/docs/ApiResponseDomainsList.md +10 -0
  13. data/docs/ApiResponseDomainsListData.md +20 -0
  14. data/docs/ApiResponseEmaillogs.md +10 -0
  15. data/docs/ApiResponseEmaillogsData.md +12 -0
  16. data/docs/ApiResponseSingleWebhooks.md +10 -0
  17. data/docs/ApiResponseStats.md +10 -0
  18. data/docs/ApiResponseStatsData.md +10 -0
  19. data/docs/ApiResponseStatsDataDatewiseSummary.md +8 -0
  20. data/docs/ApiResponseStatsDataGraphSummary.md +9 -0
  21. data/docs/ApiResponseStatsDataTotalSummary.md +8 -0
  22. data/docs/ApiResponseStatsDataTotalSummaryStatus.md +9 -0
  23. data/docs/ApiResponseWebhooks.md +10 -0
  24. data/docs/ApiResponseWebhooksData.md +8 -0
  25. data/docs/Domain.md +8 -0
  26. data/docs/DomainsApi.md +427 -0
  27. data/docs/Email.md +17 -0
  28. data/docs/EmailAttachments.md +10 -0
  29. data/docs/EmailGlobalMergeVars.md +9 -0
  30. data/docs/EmailMergeVars.md +9 -0
  31. data/docs/EmailTo.md +9 -0
  32. data/docs/EmailsApi.md +63 -0
  33. data/docs/StatsApi.md +130 -0
  34. data/docs/Webhook.md +11 -0
  35. data/docs/Webhook1.md +11 -0
  36. data/docs/WebhooksApi.md +272 -0
  37. data/example.accounts.rb +22 -0
  38. data/git_push.sh +55 -0
  39. data/lib/mimepost.rb +71 -0
  40. data/lib/mimepost/api/accounts_api.rb +227 -0
  41. data/lib/mimepost/api/domains_api.rb +429 -0
  42. data/lib/mimepost/api/emails_api.rb +77 -0
  43. data/lib/mimepost/api/stats_api.rb +158 -0
  44. data/lib/mimepost/api/webhooks_api.rb +275 -0
  45. data/lib/mimepost/api_client.rb +391 -0
  46. data/lib/mimepost/api_error.rb +38 -0
  47. data/lib/mimepost/configuration.rb +209 -0
  48. data/lib/mimepost/models/account_profile.rb +325 -0
  49. data/lib/mimepost/models/account_profile_response.rb +203 -0
  50. data/lib/mimepost/models/account_settings.rb +194 -0
  51. data/lib/mimepost/models/api_response.rb +203 -0
  52. data/lib/mimepost/models/api_response_all_webhooks.rb +205 -0
  53. data/lib/mimepost/models/api_response_all_webhooks_data.rb +231 -0
  54. data/lib/mimepost/models/api_response_domains_list.rb +205 -0
  55. data/lib/mimepost/models/api_response_domains_list_data.rb +326 -0
  56. data/lib/mimepost/models/api_response_emaillogs.rb +205 -0
  57. data/lib/mimepost/models/api_response_emaillogs_data.rb +220 -0
  58. data/lib/mimepost/models/api_response_single_webhooks.rb +203 -0
  59. data/lib/mimepost/models/api_response_stats.rb +203 -0
  60. data/lib/mimepost/models/api_response_stats_data.rb +202 -0
  61. data/lib/mimepost/models/api_response_stats_data_datewise_summary.rb +184 -0
  62. data/lib/mimepost/models/api_response_stats_data_graph_summary.rb +197 -0
  63. data/lib/mimepost/models/api_response_stats_data_total_summary.rb +184 -0
  64. data/lib/mimepost/models/api_response_stats_data_total_summary_status.rb +193 -0
  65. data/lib/mimepost/models/api_response_webhooks.rb +203 -0
  66. data/lib/mimepost/models/api_response_webhooks_data.rb +184 -0
  67. data/lib/mimepost/models/domain.rb +189 -0
  68. data/lib/mimepost/models/email.rb +297 -0
  69. data/lib/mimepost/models/email_attachments.rb +202 -0
  70. data/lib/mimepost/models/email_global_merge_vars.rb +193 -0
  71. data/lib/mimepost/models/email_merge_vars.rb +193 -0
  72. data/lib/mimepost/models/email_to.rb +195 -0
  73. data/lib/mimepost/models/webhook.rb +223 -0
  74. data/lib/mimepost/models/webhook_1.rb +223 -0
  75. data/lib/mimepost/version.rb +15 -0
  76. data/mimepost.gemspec +46 -0
  77. data/spec/api/accounts_api_spec.rb +81 -0
  78. data/spec/api/domains_api_spec.rb +122 -0
  79. data/spec/api/emails_api_spec.rb +47 -0
  80. data/spec/api/stats_api_spec.rb +63 -0
  81. data/spec/api/webhooks_api_spec.rb +90 -0
  82. data/spec/api_client_spec.rb +243 -0
  83. data/spec/configuration_spec.rb +42 -0
  84. data/spec/models/account_profile_response_spec.rb +53 -0
  85. data/spec/models/account_profile_spec.rb +131 -0
  86. data/spec/models/account_settings_spec.rb +47 -0
  87. data/spec/models/api_response_all_webhooks_data_spec.rb +71 -0
  88. data/spec/models/api_response_all_webhooks_spec.rb +53 -0
  89. data/spec/models/api_response_domains_list_data_spec.rb +117 -0
  90. data/spec/models/api_response_domains_list_spec.rb +53 -0
  91. data/spec/models/api_response_emaillogs_data_spec.rb +65 -0
  92. data/spec/models/api_response_emaillogs_spec.rb +53 -0
  93. data/spec/models/api_response_single_webhooks_spec.rb +53 -0
  94. data/spec/models/api_response_spec.rb +53 -0
  95. data/spec/models/api_response_stats_data_datewise_summary_spec.rb +41 -0
  96. data/spec/models/api_response_stats_data_graph_summary_spec.rb +47 -0
  97. data/spec/models/api_response_stats_data_spec.rb +53 -0
  98. data/spec/models/api_response_stats_data_total_summary_spec.rb +41 -0
  99. data/spec/models/api_response_stats_data_total_summary_status_spec.rb +47 -0
  100. data/spec/models/api_response_stats_spec.rb +53 -0
  101. data/spec/models/api_response_webhooks_data_spec.rb +41 -0
  102. data/spec/models/api_response_webhooks_spec.rb +53 -0
  103. data/spec/models/domain_spec.rb +41 -0
  104. data/spec/models/email_attachments_spec.rb +53 -0
  105. data/spec/models/email_global_merge_vars_spec.rb +47 -0
  106. data/spec/models/email_merge_vars_spec.rb +47 -0
  107. data/spec/models/email_spec.rb +95 -0
  108. data/spec/models/email_to_spec.rb +47 -0
  109. data/spec/models/webhook_1_spec.rb +59 -0
  110. data/spec/models/webhook_spec.rb +59 -0
  111. data/spec/spec_helper.rb +111 -0
  112. metadata +390 -0
@@ -0,0 +1,205 @@
1
+ =begin
2
+ #mimepost
3
+
4
+ #MimePost API for sending email. You can find out more about MimePost at [https://mimepost.com](http://mimepost.com). For this sample, you can use the api key `special-key` to test the authorization filters.
5
+
6
+ OpenAPI spec version: 0.1.0
7
+ Contact: support@mimepost.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.18
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Mimepost
16
+ class ApiResponseEmaillogs
17
+ # Success status, 0 for failed 1 for success
18
+ attr_accessor :success
19
+
20
+ attr_accessor :message
21
+
22
+ attr_accessor :data
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'success' => :'success',
28
+ :'message' => :'message',
29
+ :'data' => :'data'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'success' => :'Integer',
37
+ :'message' => :'String',
38
+ :'data' => :'Array<ApiResponseEmaillogsData>'
39
+ }
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ return unless attributes.is_a?(Hash)
46
+
47
+ # convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
49
+
50
+ if attributes.has_key?(:'success')
51
+ self.success = attributes[:'success']
52
+ end
53
+
54
+ if attributes.has_key?(:'message')
55
+ self.message = attributes[:'message']
56
+ end
57
+
58
+ if attributes.has_key?(:'data')
59
+ if (value = attributes[:'data']).is_a?(Array)
60
+ self.data = value
61
+ end
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
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ success == o.success &&
84
+ message == o.message &&
85
+ data == o.data
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Fixnum] Hash code
96
+ def hash
97
+ [success, message, data].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.swagger_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :BOOLEAN
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ temp_model = Mimepost.const_get(type).new
158
+ temp_model.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map { |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+ end
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #mimepost
3
+
4
+ #MimePost API for sending email. You can find out more about MimePost at [https://mimepost.com](http://mimepost.com). For this sample, you can use the api key `special-key` to test the authorization filters.
5
+
6
+ OpenAPI spec version: 0.1.0
7
+ Contact: support@mimepost.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.18
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Mimepost
16
+ class ApiResponseEmaillogsData
17
+ attr_accessor :datetime
18
+
19
+ attr_accessor :message_id
20
+
21
+ attr_accessor :to_email
22
+
23
+ attr_accessor :status
24
+
25
+ attr_accessor :details
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'datetime' => :'datetime',
31
+ :'message_id' => :'message_id',
32
+ :'to_email' => :'to_email',
33
+ :'status' => :'status',
34
+ :'details' => :'details'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.swagger_types
40
+ {
41
+ :'datetime' => :'String',
42
+ :'message_id' => :'String',
43
+ :'to_email' => :'String',
44
+ :'status' => :'String',
45
+ :'details' => :'String'
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
56
+
57
+ if attributes.has_key?(:'datetime')
58
+ self.datetime = attributes[:'datetime']
59
+ end
60
+
61
+ if attributes.has_key?(:'message_id')
62
+ self.message_id = attributes[:'message_id']
63
+ end
64
+
65
+ if attributes.has_key?(:'to_email')
66
+ self.to_email = attributes[:'to_email']
67
+ end
68
+
69
+ if attributes.has_key?(:'status')
70
+ self.status = attributes[:'status']
71
+ end
72
+
73
+ if attributes.has_key?(:'details')
74
+ self.details = attributes[:'details']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ datetime == o.datetime &&
97
+ message_id == o.message_id &&
98
+ to_email == o.to_email &&
99
+ status == o.status &&
100
+ details == o.details
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Fixnum] Hash code
111
+ def hash
112
+ [datetime, message_id, to_email, status, details].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.swagger_types.each_pair do |key, type|
121
+ if type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
126
+ end
127
+ elsif !attributes[self.class.attribute_map[key]].nil?
128
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def _deserialize(type, value)
140
+ case type.to_sym
141
+ when :DateTime
142
+ DateTime.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :BOOLEAN
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ temp_model = Mimepost.const_get(type).new
173
+ temp_model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ next if value.nil?
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+ end
@@ -0,0 +1,203 @@
1
+ =begin
2
+ #mimepost
3
+
4
+ #MimePost API for sending email. You can find out more about MimePost at [https://mimepost.com](http://mimepost.com). For this sample, you can use the api key `special-key` to test the authorization filters.
5
+
6
+ OpenAPI spec version: 0.1.0
7
+ Contact: support@mimepost.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.18
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Mimepost
16
+ class ApiResponseSingleWebhooks
17
+ # Success status, 0 for failed 1 for success
18
+ attr_accessor :success
19
+
20
+ attr_accessor :message
21
+
22
+ attr_accessor :data
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'success' => :'success',
28
+ :'message' => :'message',
29
+ :'data' => :'data'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'success' => :'Integer',
37
+ :'message' => :'String',
38
+ :'data' => :'ApiResponseAllWebhooksData'
39
+ }
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ return unless attributes.is_a?(Hash)
46
+
47
+ # convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
49
+
50
+ if attributes.has_key?(:'success')
51
+ self.success = attributes[:'success']
52
+ end
53
+
54
+ if attributes.has_key?(:'message')
55
+ self.message = attributes[:'message']
56
+ end
57
+
58
+ if attributes.has_key?(:'data')
59
+ self.data = attributes[:'data']
60
+ end
61
+ end
62
+
63
+ # Show invalid properties with the reasons. Usually used together with valid?
64
+ # @return Array for valid properties with the reasons
65
+ def list_invalid_properties
66
+ invalid_properties = Array.new
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ success == o.success &&
82
+ message == o.message &&
83
+ data == o.data
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
+ [success, message, data].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 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 = Mimepost.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
+
202
+ end
203
+ end