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