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,194 @@
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 AccountSettings
17
+ # Name of the config
18
+ attr_accessor :name
19
+
20
+ attr_accessor :value
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'name' => :'name',
26
+ :'value' => :'value'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'name' => :'String',
34
+ :'value' => :'String'
35
+ }
36
+ end
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ return unless attributes.is_a?(Hash)
42
+
43
+ # convert string to symbol for hash key
44
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
45
+
46
+ if attributes.has_key?(:'name')
47
+ self.name = attributes[:'name']
48
+ end
49
+
50
+ if attributes.has_key?(:'value')
51
+ self.value = attributes[:'value']
52
+ end
53
+ end
54
+
55
+ # Show invalid properties with the reasons. Usually used together with valid?
56
+ # @return Array for valid properties with the reasons
57
+ def list_invalid_properties
58
+ invalid_properties = Array.new
59
+ invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ 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
+ name == o.name &&
74
+ value == o.value
75
+ end
76
+
77
+ # @see the `==` method
78
+ # @param [Object] Object to be compared
79
+ def eql?(o)
80
+ self == o
81
+ end
82
+
83
+ # Calculates hash code according to all attributes.
84
+ # @return [Fixnum] Hash code
85
+ def hash
86
+ [name, value].hash
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def build_from_hash(attributes)
93
+ return nil unless attributes.is_a?(Hash)
94
+ self.class.swagger_types.each_pair do |key, type|
95
+ if type =~ /\AArray<(.*)>/i
96
+ # check to ensure the input is an array given that the attribute
97
+ # is documented as an array but the input is not
98
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
99
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
100
+ end
101
+ elsif !attributes[self.class.attribute_map[key]].nil?
102
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
103
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
104
+ end
105
+
106
+ self
107
+ end
108
+
109
+ # Deserializes the data based on type
110
+ # @param string type Data type
111
+ # @param string value Value to be deserialized
112
+ # @return [Object] Deserialized data
113
+ def _deserialize(type, value)
114
+ case type.to_sym
115
+ when :DateTime
116
+ DateTime.parse(value)
117
+ when :Date
118
+ Date.parse(value)
119
+ when :String
120
+ value.to_s
121
+ when :Integer
122
+ value.to_i
123
+ when :Float
124
+ value.to_f
125
+ when :BOOLEAN
126
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
127
+ true
128
+ else
129
+ false
130
+ end
131
+ when :Object
132
+ # generic object (usually a Hash), return directly
133
+ value
134
+ when /\AArray<(?<inner_type>.+)>\z/
135
+ inner_type = Regexp.last_match[:inner_type]
136
+ value.map { |v| _deserialize(inner_type, v) }
137
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
138
+ k_type = Regexp.last_match[:k_type]
139
+ v_type = Regexp.last_match[:v_type]
140
+ {}.tap do |hash|
141
+ value.each do |k, v|
142
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
143
+ end
144
+ end
145
+ else # model
146
+ temp_model = Mimepost.const_get(type).new
147
+ temp_model.build_from_hash(value)
148
+ end
149
+ end
150
+
151
+ # Returns the string representation of the object
152
+ # @return [String] String presentation of the object
153
+ def to_s
154
+ to_hash.to_s
155
+ end
156
+
157
+ # to_body is an alias to to_hash (backward compatibility)
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_body
160
+ to_hash
161
+ end
162
+
163
+ # Returns the object in the form of hash
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_hash
166
+ hash = {}
167
+ self.class.attribute_map.each_pair do |attr, param|
168
+ value = self.send(attr)
169
+ next if value.nil?
170
+ hash[param] = _to_hash(value)
171
+ end
172
+ hash
173
+ end
174
+
175
+ # Outputs non-array value in the form of hash
176
+ # For object, use to_hash. Otherwise, just return the value
177
+ # @param [Object] value Any valid value
178
+ # @return [Hash] Returns the value in the form of hash
179
+ def _to_hash(value)
180
+ if value.is_a?(Array)
181
+ value.compact.map { |v| _to_hash(v) }
182
+ elsif value.is_a?(Hash)
183
+ {}.tap do |hash|
184
+ value.each { |k, v| hash[k] = _to_hash(v) }
185
+ end
186
+ elsif value.respond_to? :to_hash
187
+ value.to_hash
188
+ else
189
+ value
190
+ end
191
+ end
192
+
193
+ end
194
+ 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 ApiResponse
17
+ # Success status, 0 for failed 1 for success
18
+ attr_accessor :success
19
+
20
+ attr_accessor :message
21
+
22
+ attr_accessor :error_code
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
+ :'error_code' => :'error_code'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.swagger_types
35
+ {
36
+ :'success' => :'Integer',
37
+ :'message' => :'String',
38
+ :'error_code' => :'Integer'
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?(:'error_code')
59
+ self.error_code = attributes[:'error_code']
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
+ error_code == o.error_code
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, error_code].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
@@ -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 ApiResponseAllWebhooks
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<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
+ 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