zyphr 0.1.19 → 0.1.21

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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -6
  3. data/docs/AuthEmailTemplate.md +42 -0
  4. data/docs/AuthEmailTemplateDefault.md +26 -0
  5. data/docs/AuthEmailTemplateDefaultResponse.md +20 -0
  6. data/docs/AuthEmailTemplateDeleteResponse.md +20 -0
  7. data/docs/{SuccessResultData.md → AuthEmailTemplateDeleteResponseData.md} +2 -2
  8. data/docs/AuthEmailTemplateListResponse.md +20 -0
  9. data/docs/AuthEmailTemplatePreviewDraft.md +28 -0
  10. data/docs/AuthEmailTemplatePreviewRequest.md +20 -0
  11. data/docs/AuthEmailTemplatePreviewResponse.md +20 -0
  12. data/docs/AuthEmailTemplatePreviewResult.md +26 -0
  13. data/docs/AuthEmailTemplateResponse.md +20 -0
  14. data/docs/AuthEmailTemplateTestRequest.md +20 -0
  15. data/docs/AuthEmailTemplateTestResponse.md +20 -0
  16. data/docs/AuthEmailTemplateTestResult.md +20 -0
  17. data/docs/AuthEmailTemplateVersion.md +38 -0
  18. data/docs/AuthEmailTemplateVersionsResponse.md +20 -0
  19. data/docs/AuthEmailTemplatesApi.md +782 -0
  20. data/docs/AuthEmailType.md +15 -0
  21. data/docs/BulkUpsertAuthEmailTemplatesRequest.md +22 -0
  22. data/docs/BulkUpsertAuthEmailTemplatesResponse.md +20 -0
  23. data/docs/ResubscribeResponse.md +1 -1
  24. data/docs/SendSlackMessageRequest.md +40 -0
  25. data/docs/SendSlackMessageResponse.md +20 -0
  26. data/docs/SendSlackMessageResult.md +28 -0
  27. data/docs/SlackApi.md +233 -0
  28. data/docs/SlackMessage.md +50 -0
  29. data/docs/SlackMessageListResponse.md +20 -0
  30. data/docs/SlackMessageListResponseMeta.md +24 -0
  31. data/docs/SlackMessageResponse.md +20 -0
  32. data/docs/SlackMessageStatus.md +15 -0
  33. data/docs/SlackMessageSummary.md +38 -0
  34. data/docs/SuccessResult.md +1 -1
  35. data/docs/UpsertAuthEmailTemplateRequest.md +34 -0
  36. data/lib/zyphr/api/auth_email_templates_api.rb +688 -0
  37. data/lib/zyphr/api/slack_api.rb +233 -0
  38. data/lib/zyphr/models/auth_email_template.rb +372 -0
  39. data/lib/zyphr/models/auth_email_template_default.rb +281 -0
  40. data/lib/zyphr/models/auth_email_template_default_response.rb +229 -0
  41. data/lib/zyphr/models/auth_email_template_delete_response.rb +229 -0
  42. data/lib/zyphr/models/{success_result_data.rb → auth_email_template_delete_response_data.rb} +3 -3
  43. data/lib/zyphr/models/auth_email_template_list_response.rb +231 -0
  44. data/lib/zyphr/models/auth_email_template_preview_draft.rb +272 -0
  45. data/lib/zyphr/models/auth_email_template_preview_request.rb +232 -0
  46. data/lib/zyphr/models/auth_email_template_preview_response.rb +229 -0
  47. data/lib/zyphr/models/auth_email_template_preview_result.rb +258 -0
  48. data/lib/zyphr/models/auth_email_template_response.rb +229 -0
  49. data/lib/zyphr/models/auth_email_template_test_request.rb +249 -0
  50. data/lib/zyphr/models/auth_email_template_test_response.rb +229 -0
  51. data/lib/zyphr/models/auth_email_template_test_result.rb +229 -0
  52. data/lib/zyphr/models/auth_email_template_version.rb +352 -0
  53. data/lib/zyphr/models/auth_email_template_versions_response.rb +231 -0
  54. data/lib/zyphr/models/auth_email_type.rb +41 -0
  55. data/lib/zyphr/models/bulk_upsert_auth_email_templates_request.rb +239 -0
  56. data/lib/zyphr/models/bulk_upsert_auth_email_templates_response.rb +231 -0
  57. data/lib/zyphr/models/resubscribe_response.rb +1 -1
  58. data/lib/zyphr/models/send_slack_message_request.rb +340 -0
  59. data/lib/zyphr/models/send_slack_message_response.rb +229 -0
  60. data/lib/zyphr/models/send_slack_message_result.rb +289 -0
  61. data/lib/zyphr/models/slack_message.rb +406 -0
  62. data/lib/zyphr/models/slack_message_list_response.rb +231 -0
  63. data/lib/zyphr/models/slack_message_list_response_meta.rb +254 -0
  64. data/lib/zyphr/models/slack_message_response.rb +229 -0
  65. data/lib/zyphr/models/slack_message_status.rb +43 -0
  66. data/lib/zyphr/models/slack_message_summary.rb +340 -0
  67. data/lib/zyphr/models/success_result.rb +1 -1
  68. data/lib/zyphr/models/upsert_auth_email_template_request.rb +335 -0
  69. data/lib/zyphr.rb +31 -1
  70. data/spec/api/auth_email_templates_api_spec.rb +157 -0
  71. data/spec/api/slack_api_spec.rb +75 -0
  72. data/spec/models/auth_email_template_default_response_spec.rb +42 -0
  73. data/spec/models/auth_email_template_default_spec.rb +60 -0
  74. data/spec/models/{success_result_data_spec.rb → auth_email_template_delete_response_data_spec.rb} +6 -6
  75. data/spec/models/auth_email_template_delete_response_spec.rb +42 -0
  76. data/spec/models/auth_email_template_list_response_spec.rb +42 -0
  77. data/spec/models/auth_email_template_preview_draft_spec.rb +66 -0
  78. data/spec/models/auth_email_template_preview_request_spec.rb +42 -0
  79. data/spec/models/auth_email_template_preview_response_spec.rb +42 -0
  80. data/spec/models/auth_email_template_preview_result_spec.rb +60 -0
  81. data/spec/models/auth_email_template_response_spec.rb +42 -0
  82. data/spec/models/auth_email_template_spec.rb +112 -0
  83. data/spec/models/auth_email_template_test_request_spec.rb +42 -0
  84. data/spec/models/auth_email_template_test_response_spec.rb +42 -0
  85. data/spec/models/auth_email_template_test_result_spec.rb +42 -0
  86. data/spec/models/auth_email_template_version_spec.rb +100 -0
  87. data/spec/models/auth_email_template_versions_response_spec.rb +42 -0
  88. data/spec/models/auth_email_type_spec.rb +30 -0
  89. data/spec/models/bulk_upsert_auth_email_templates_request_spec.rb +48 -0
  90. data/spec/models/bulk_upsert_auth_email_templates_response_spec.rb +42 -0
  91. data/spec/models/send_slack_message_request_spec.rb +102 -0
  92. data/spec/models/send_slack_message_response_spec.rb +42 -0
  93. data/spec/models/send_slack_message_result_spec.rb +66 -0
  94. data/spec/models/slack_message_list_response_meta_spec.rb +54 -0
  95. data/spec/models/slack_message_list_response_spec.rb +42 -0
  96. data/spec/models/slack_message_response_spec.rb +42 -0
  97. data/spec/models/slack_message_spec.rb +132 -0
  98. data/spec/models/slack_message_status_spec.rb +30 -0
  99. data/spec/models/slack_message_summary_spec.rb +96 -0
  100. data/spec/models/upsert_auth_email_template_request_spec.rb +88 -0
  101. data/zyphr.gemspec +1 -1
  102. metadata +126 -6
@@ -0,0 +1,233 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Zyphr
16
+ class SlackApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get a Slack message
23
+ # Retrieve a single Slack message by ID, including its full block/attachment payload and status timestamps.
24
+ # @param id [String]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [SlackMessageResponse]
27
+ def get_slack_message(id, opts = {})
28
+ data, _status_code, _headers = get_slack_message_with_http_info(id, opts)
29
+ data
30
+ end
31
+
32
+ # Get a Slack message
33
+ # Retrieve a single Slack message by ID, including its full block/attachment payload and status timestamps.
34
+ # @param id [String]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(SlackMessageResponse, Integer, Hash)>] SlackMessageResponse data, response status code and response headers
37
+ def get_slack_message_with_http_info(id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: SlackApi.get_slack_message ...'
40
+ end
41
+ # verify the required parameter 'id' is set
42
+ if @api_client.config.client_side_validation && id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'id' when calling SlackApi.get_slack_message"
44
+ end
45
+ # resource path
46
+ local_var_path = '/slack/messages/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:debug_body]
61
+
62
+ # return_type
63
+ return_type = opts[:debug_return_type] || 'SlackMessageResponse'
64
+
65
+ # auth_names
66
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
67
+
68
+ new_options = opts.merge(
69
+ :operation => :"SlackApi.get_slack_message",
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => return_type
76
+ )
77
+
78
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: SlackApi#get_slack_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+
85
+ # List Slack messages
86
+ # List Slack messages sent through the project, with optional filtering by connection, channel, and status.
87
+ # @param [Hash] opts the optional parameters
88
+ # @option opts [String] :connection_id Filter by Slack connection ID.
89
+ # @option opts [String] :channel_id Filter by Slack channel ID.
90
+ # @option opts [String] :status Filter by message status.
91
+ # @option opts [Integer] :limit (default to 50)
92
+ # @option opts [Integer] :offset (default to 0)
93
+ # @return [SlackMessageListResponse]
94
+ def list_slack_messages(opts = {})
95
+ data, _status_code, _headers = list_slack_messages_with_http_info(opts)
96
+ data
97
+ end
98
+
99
+ # List Slack messages
100
+ # List Slack messages sent through the project, with optional filtering by connection, channel, and status.
101
+ # @param [Hash] opts the optional parameters
102
+ # @option opts [String] :connection_id Filter by Slack connection ID.
103
+ # @option opts [String] :channel_id Filter by Slack channel ID.
104
+ # @option opts [String] :status Filter by message status.
105
+ # @option opts [Integer] :limit (default to 50)
106
+ # @option opts [Integer] :offset (default to 0)
107
+ # @return [Array<(SlackMessageListResponse, Integer, Hash)>] SlackMessageListResponse data, response status code and response headers
108
+ def list_slack_messages_with_http_info(opts = {})
109
+ if @api_client.config.debugging
110
+ @api_client.config.logger.debug 'Calling API: SlackApi.list_slack_messages ...'
111
+ end
112
+ allowable_values = ["queued", "sending", "sent", "delivered", "failed"]
113
+ if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
114
+ fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
115
+ end
116
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 200
117
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SlackApi.list_slack_messages, must be smaller than or equal to 200.'
118
+ end
119
+
120
+ # resource path
121
+ local_var_path = '/slack/messages'
122
+
123
+ # query parameters
124
+ query_params = opts[:query_params] || {}
125
+ query_params[:'connection_id'] = opts[:'connection_id'] if !opts[:'connection_id'].nil?
126
+ query_params[:'channel_id'] = opts[:'channel_id'] if !opts[:'channel_id'].nil?
127
+ query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
128
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
129
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
130
+
131
+ # header parameters
132
+ header_params = opts[:header_params] || {}
133
+ # HTTP header 'Accept' (if needed)
134
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
135
+
136
+ # form parameters
137
+ form_params = opts[:form_params] || {}
138
+
139
+ # http body (model)
140
+ post_body = opts[:debug_body]
141
+
142
+ # return_type
143
+ return_type = opts[:debug_return_type] || 'SlackMessageListResponse'
144
+
145
+ # auth_names
146
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
147
+
148
+ new_options = opts.merge(
149
+ :operation => :"SlackApi.list_slack_messages",
150
+ :header_params => header_params,
151
+ :query_params => query_params,
152
+ :form_params => form_params,
153
+ :body => post_body,
154
+ :auth_names => auth_names,
155
+ :return_type => return_type
156
+ )
157
+
158
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
159
+ if @api_client.config.debugging
160
+ @api_client.config.logger.debug "API called: SlackApi#list_slack_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
161
+ end
162
+ return data, status_code, headers
163
+ end
164
+
165
+ # Send a Slack message
166
+ # Send a message to a Slack channel through a connected Slack workspace. Either `text` or `blocks` must be provided. If `connection_id` is omitted, the project's active Slack connection is used. If `channel` is omitted, the connection's default channel is used.
167
+ # @param send_slack_message_request [SendSlackMessageRequest]
168
+ # @param [Hash] opts the optional parameters
169
+ # @return [SendSlackMessageResponse]
170
+ def send_slack_message(send_slack_message_request, opts = {})
171
+ data, _status_code, _headers = send_slack_message_with_http_info(send_slack_message_request, opts)
172
+ data
173
+ end
174
+
175
+ # Send a Slack message
176
+ # Send a message to a Slack channel through a connected Slack workspace. Either &#x60;text&#x60; or &#x60;blocks&#x60; must be provided. If &#x60;connection_id&#x60; is omitted, the project&#39;s active Slack connection is used. If &#x60;channel&#x60; is omitted, the connection&#39;s default channel is used.
177
+ # @param send_slack_message_request [SendSlackMessageRequest]
178
+ # @param [Hash] opts the optional parameters
179
+ # @return [Array<(SendSlackMessageResponse, Integer, Hash)>] SendSlackMessageResponse data, response status code and response headers
180
+ def send_slack_message_with_http_info(send_slack_message_request, opts = {})
181
+ if @api_client.config.debugging
182
+ @api_client.config.logger.debug 'Calling API: SlackApi.send_slack_message ...'
183
+ end
184
+ # verify the required parameter 'send_slack_message_request' is set
185
+ if @api_client.config.client_side_validation && send_slack_message_request.nil?
186
+ fail ArgumentError, "Missing the required parameter 'send_slack_message_request' when calling SlackApi.send_slack_message"
187
+ end
188
+ # resource path
189
+ local_var_path = '/slack/send'
190
+
191
+ # query parameters
192
+ query_params = opts[:query_params] || {}
193
+
194
+ # header parameters
195
+ header_params = opts[:header_params] || {}
196
+ # HTTP header 'Accept' (if needed)
197
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
198
+ # HTTP header 'Content-Type'
199
+ content_type = @api_client.select_header_content_type(['application/json'])
200
+ if !content_type.nil?
201
+ header_params['Content-Type'] = content_type
202
+ end
203
+
204
+ # form parameters
205
+ form_params = opts[:form_params] || {}
206
+
207
+ # http body (model)
208
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(send_slack_message_request)
209
+
210
+ # return_type
211
+ return_type = opts[:debug_return_type] || 'SendSlackMessageResponse'
212
+
213
+ # auth_names
214
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
215
+
216
+ new_options = opts.merge(
217
+ :operation => :"SlackApi.send_slack_message",
218
+ :header_params => header_params,
219
+ :query_params => query_params,
220
+ :form_params => form_params,
221
+ :body => post_body,
222
+ :auth_names => auth_names,
223
+ :return_type => return_type
224
+ )
225
+
226
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
227
+ if @api_client.config.debugging
228
+ @api_client.config.logger.debug "API called: SlackApi#send_slack_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
229
+ end
230
+ return data, status_code, headers
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,372 @@
1
+ =begin
2
+ #Zyphr API
3
+
4
+ #Zyphr is a multi-channel notification platform that enables developers to send emails, push notifications, SMS, and in-app messages through a unified API. ## Authentication All API requests require authentication using an API key. Include your API key in the `X-API-Key` header: ``` X-API-Key: zy_live_xxxxxxxxxxxx ``` API keys can be created in the Zyphr Dashboard. Use `zy_test_*` keys for testing and `zy_live_*` keys for production. ## Rate Limiting The API implements rate limiting to ensure fair usage. Rate limit information is included in response headers: - `X-RateLimit-Limit`: Maximum requests per window - `X-RateLimit-Remaining`: Remaining requests in current window - `X-RateLimit-Reset`: Unix timestamp when the window resets ## Errors All errors follow a consistent format: ```json { \"error\": { \"code\": \"error_code\", \"message\": \"Human readable message\", \"details\": {} }, \"meta\": { \"request_id\": \"req_xxxx\" } } ```
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: support@zyphr.dev
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Zyphr
17
+ class AuthEmailTemplate
18
+ attr_accessor :email_type
19
+
20
+ attr_accessor :subject
21
+
22
+ attr_accessor :html
23
+
24
+ attr_accessor :text
25
+
26
+ attr_accessor :mjml_source
27
+
28
+ attr_accessor :design_json
29
+
30
+ attr_accessor :editor_type
31
+
32
+ attr_accessor :from_name
33
+
34
+ attr_accessor :reply_to
35
+
36
+ attr_accessor :is_enabled
37
+
38
+ # True when the system default is being returned (no override exists)
39
+ attr_accessor :is_default
40
+
41
+ attr_accessor :has_override
42
+
43
+ attr_accessor :version
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'email_type' => :'email_type',
71
+ :'subject' => :'subject',
72
+ :'html' => :'html',
73
+ :'text' => :'text',
74
+ :'mjml_source' => :'mjml_source',
75
+ :'design_json' => :'design_json',
76
+ :'editor_type' => :'editor_type',
77
+ :'from_name' => :'from_name',
78
+ :'reply_to' => :'reply_to',
79
+ :'is_enabled' => :'is_enabled',
80
+ :'is_default' => :'is_default',
81
+ :'has_override' => :'has_override',
82
+ :'version' => :'version'
83
+ }
84
+ end
85
+
86
+ # Returns attribute mapping this model knows about
87
+ def self.acceptable_attribute_map
88
+ attribute_map
89
+ end
90
+
91
+ # Returns all the JSON keys this model knows about
92
+ def self.acceptable_attributes
93
+ acceptable_attribute_map.values
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.openapi_types
98
+ {
99
+ :'email_type' => :'AuthEmailType',
100
+ :'subject' => :'String',
101
+ :'html' => :'String',
102
+ :'text' => :'String',
103
+ :'mjml_source' => :'String',
104
+ :'design_json' => :'Hash<String, Object>',
105
+ :'editor_type' => :'String',
106
+ :'from_name' => :'String',
107
+ :'reply_to' => :'String',
108
+ :'is_enabled' => :'Boolean',
109
+ :'is_default' => :'Boolean',
110
+ :'has_override' => :'Boolean',
111
+ :'version' => :'Integer'
112
+ }
113
+ end
114
+
115
+ # List of attributes with nullable: true
116
+ def self.openapi_nullable
117
+ Set.new([
118
+ :'text',
119
+ :'mjml_source',
120
+ :'design_json',
121
+ :'editor_type',
122
+ :'from_name',
123
+ :'reply_to',
124
+ :'version'
125
+ ])
126
+ end
127
+
128
+ # Initializes the object
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ def initialize(attributes = {})
131
+ if (!attributes.is_a?(Hash))
132
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::AuthEmailTemplate` initialize method"
133
+ end
134
+
135
+ # check to see if the attribute exists and convert string to symbol for hash key
136
+ acceptable_attribute_map = self.class.acceptable_attribute_map
137
+ attributes = attributes.each_with_object({}) { |(k, v), h|
138
+ if (!acceptable_attribute_map.key?(k.to_sym))
139
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::AuthEmailTemplate`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
140
+ end
141
+ h[k.to_sym] = v
142
+ }
143
+
144
+ if attributes.key?(:'email_type')
145
+ self.email_type = attributes[:'email_type']
146
+ end
147
+
148
+ if attributes.key?(:'subject')
149
+ self.subject = attributes[:'subject']
150
+ end
151
+
152
+ if attributes.key?(:'html')
153
+ self.html = attributes[:'html']
154
+ end
155
+
156
+ if attributes.key?(:'text')
157
+ self.text = attributes[:'text']
158
+ end
159
+
160
+ if attributes.key?(:'mjml_source')
161
+ self.mjml_source = attributes[:'mjml_source']
162
+ end
163
+
164
+ if attributes.key?(:'design_json')
165
+ if (value = attributes[:'design_json']).is_a?(Hash)
166
+ self.design_json = value
167
+ end
168
+ end
169
+
170
+ if attributes.key?(:'editor_type')
171
+ self.editor_type = attributes[:'editor_type']
172
+ end
173
+
174
+ if attributes.key?(:'from_name')
175
+ self.from_name = attributes[:'from_name']
176
+ end
177
+
178
+ if attributes.key?(:'reply_to')
179
+ self.reply_to = attributes[:'reply_to']
180
+ end
181
+
182
+ if attributes.key?(:'is_enabled')
183
+ self.is_enabled = attributes[:'is_enabled']
184
+ end
185
+
186
+ if attributes.key?(:'is_default')
187
+ self.is_default = attributes[:'is_default']
188
+ end
189
+
190
+ if attributes.key?(:'has_override')
191
+ self.has_override = attributes[:'has_override']
192
+ end
193
+
194
+ if attributes.key?(:'version')
195
+ self.version = attributes[:'version']
196
+ end
197
+ end
198
+
199
+ # Show invalid properties with the reasons. Usually used together with valid?
200
+ # @return Array for valid properties with the reasons
201
+ def list_invalid_properties
202
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
203
+ invalid_properties = Array.new
204
+ invalid_properties
205
+ end
206
+
207
+ # Check to see if the all the properties in the model are valid
208
+ # @return true if the model is valid
209
+ def valid?
210
+ warn '[DEPRECATED] the `valid?` method is obsolete'
211
+ editor_type_validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
212
+ return false unless editor_type_validator.valid?(@editor_type)
213
+ true
214
+ end
215
+
216
+ # Custom attribute writer method checking allowed values (enum).
217
+ # @param [Object] editor_type Object to be assigned
218
+ def editor_type=(editor_type)
219
+ validator = EnumAttributeValidator.new('String', ["code", "mjml", "design"])
220
+ unless validator.valid?(editor_type)
221
+ fail ArgumentError, "invalid value for \"editor_type\", must be one of #{validator.allowable_values}."
222
+ end
223
+ @editor_type = editor_type
224
+ end
225
+
226
+ # Checks equality by comparing each attribute.
227
+ # @param [Object] Object to be compared
228
+ def ==(o)
229
+ return true if self.equal?(o)
230
+ self.class == o.class &&
231
+ email_type == o.email_type &&
232
+ subject == o.subject &&
233
+ html == o.html &&
234
+ text == o.text &&
235
+ mjml_source == o.mjml_source &&
236
+ design_json == o.design_json &&
237
+ editor_type == o.editor_type &&
238
+ from_name == o.from_name &&
239
+ reply_to == o.reply_to &&
240
+ is_enabled == o.is_enabled &&
241
+ is_default == o.is_default &&
242
+ has_override == o.has_override &&
243
+ version == o.version
244
+ end
245
+
246
+ # @see the `==` method
247
+ # @param [Object] Object to be compared
248
+ def eql?(o)
249
+ self == o
250
+ end
251
+
252
+ # Calculates hash code according to all attributes.
253
+ # @return [Integer] Hash code
254
+ def hash
255
+ [email_type, subject, html, text, mjml_source, design_json, editor_type, from_name, reply_to, is_enabled, is_default, has_override, version].hash
256
+ end
257
+
258
+ # Builds the object from hash
259
+ # @param [Hash] attributes Model attributes in the form of hash
260
+ # @return [Object] Returns the model itself
261
+ def self.build_from_hash(attributes)
262
+ return nil unless attributes.is_a?(Hash)
263
+ attributes = attributes.transform_keys(&:to_sym)
264
+ transformed_hash = {}
265
+ openapi_types.each_pair do |key, type|
266
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
267
+ transformed_hash["#{key}"] = nil
268
+ elsif type =~ /\AArray<(.*)>/i
269
+ # check to ensure the input is an array given that the attribute
270
+ # is documented as an array but the input is not
271
+ if attributes[attribute_map[key]].is_a?(Array)
272
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
273
+ end
274
+ elsif !attributes[attribute_map[key]].nil?
275
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
276
+ end
277
+ end
278
+ new(transformed_hash)
279
+ end
280
+
281
+ # Deserializes the data based on type
282
+ # @param string type Data type
283
+ # @param string value Value to be deserialized
284
+ # @return [Object] Deserialized data
285
+ def self._deserialize(type, value)
286
+ case type.to_sym
287
+ when :Time
288
+ Time.parse(value)
289
+ when :Date
290
+ Date.parse(value)
291
+ when :String
292
+ value.to_s
293
+ when :Integer
294
+ value.to_i
295
+ when :Float
296
+ value.to_f
297
+ when :Boolean
298
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
299
+ true
300
+ else
301
+ false
302
+ end
303
+ when :Object
304
+ # generic object (usually a Hash), return directly
305
+ value
306
+ when /\AArray<(?<inner_type>.+)>\z/
307
+ inner_type = Regexp.last_match[:inner_type]
308
+ value.map { |v| _deserialize(inner_type, v) }
309
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
310
+ k_type = Regexp.last_match[:k_type]
311
+ v_type = Regexp.last_match[:v_type]
312
+ {}.tap do |hash|
313
+ value.each do |k, v|
314
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
315
+ end
316
+ end
317
+ else # model
318
+ # models (e.g. Pet) or oneOf
319
+ klass = Zyphr.const_get(type)
320
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
321
+ end
322
+ end
323
+
324
+ # Returns the string representation of the object
325
+ # @return [String] String presentation of the object
326
+ def to_s
327
+ to_hash.to_s
328
+ end
329
+
330
+ # to_body is an alias to to_hash (backward compatibility)
331
+ # @return [Hash] Returns the object in the form of hash
332
+ def to_body
333
+ to_hash
334
+ end
335
+
336
+ # Returns the object in the form of hash
337
+ # @return [Hash] Returns the object in the form of hash
338
+ def to_hash
339
+ hash = {}
340
+ self.class.attribute_map.each_pair do |attr, param|
341
+ value = self.send(attr)
342
+ if value.nil?
343
+ is_nullable = self.class.openapi_nullable.include?(attr)
344
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
345
+ end
346
+
347
+ hash[param] = _to_hash(value)
348
+ end
349
+ hash
350
+ end
351
+
352
+ # Outputs non-array value in the form of hash
353
+ # For object, use to_hash. Otherwise, just return the value
354
+ # @param [Object] value Any valid value
355
+ # @return [Hash] Returns the value in the form of hash
356
+ def _to_hash(value)
357
+ if value.is_a?(Array)
358
+ value.compact.map { |v| _to_hash(v) }
359
+ elsif value.is_a?(Hash)
360
+ {}.tap do |hash|
361
+ value.each { |k, v| hash[k] = _to_hash(v) }
362
+ end
363
+ elsif value.respond_to? :to_hash
364
+ value.to_hash
365
+ else
366
+ value
367
+ end
368
+ end
369
+
370
+ end
371
+
372
+ end