zyphr 0.1.33 → 0.1.34

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/docs/DomainsApi.md +73 -0
  4. data/docs/InboundAttachmentUrlResponse.md +20 -0
  5. data/docs/InboundAttachmentUrlResponseData.md +22 -0
  6. data/docs/InboundEmail.md +48 -0
  7. data/docs/InboundEmailApi.md +235 -0
  8. data/docs/InboundEmailAttachment.md +24 -0
  9. data/docs/InboundEmailFrom.md +20 -0
  10. data/docs/InboundEmailListResponse.md +20 -0
  11. data/docs/InboundEmailListResponseMeta.md +24 -0
  12. data/docs/InboundEmailResponse.md +20 -0
  13. data/docs/SetDomainInboundRequest.md +18 -0
  14. data/lib/zyphr/api/domains_api.rb +72 -0
  15. data/lib/zyphr/api/inbound_email_api.rb +234 -0
  16. data/lib/zyphr/models/inbound_attachment_url_response.rb +229 -0
  17. data/lib/zyphr/models/inbound_attachment_url_response_data.rb +240 -0
  18. data/lib/zyphr/models/inbound_email.rb +441 -0
  19. data/lib/zyphr/models/inbound_email_attachment.rb +250 -0
  20. data/lib/zyphr/models/inbound_email_from.rb +230 -0
  21. data/lib/zyphr/models/inbound_email_list_response.rb +231 -0
  22. data/lib/zyphr/models/inbound_email_list_response_meta.rb +247 -0
  23. data/lib/zyphr/models/inbound_email_response.rb +229 -0
  24. data/lib/zyphr/models/set_domain_inbound_request.rb +220 -0
  25. data/lib/zyphr.rb +10 -0
  26. data/spec/api/domains_api_spec.rb +13 -0
  27. data/spec/api/inbound_email_api_spec.rb +76 -0
  28. data/spec/models/inbound_attachment_url_response_data_spec.rb +48 -0
  29. data/spec/models/inbound_attachment_url_response_spec.rb +42 -0
  30. data/spec/models/inbound_email_attachment_spec.rb +54 -0
  31. data/spec/models/inbound_email_from_spec.rb +42 -0
  32. data/spec/models/inbound_email_list_response_meta_spec.rb +54 -0
  33. data/spec/models/inbound_email_list_response_spec.rb +42 -0
  34. data/spec/models/inbound_email_response_spec.rb +42 -0
  35. data/spec/models/inbound_email_spec.rb +142 -0
  36. data/spec/models/set_domain_inbound_request_spec.rb +36 -0
  37. data/zyphr.gemspec +1 -1
  38. metadata +42 -2
@@ -0,0 +1,234 @@
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 InboundEmailApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get an attachment download URL
23
+ # Return a short-lived presigned S3 download URL for one attachment of a received email. `attachmentId` is the positional id from the email's `attachments` array.
24
+ # @param id [String]
25
+ # @param attachment_id [String]
26
+ # @param [Hash] opts the optional parameters
27
+ # @return [InboundAttachmentUrlResponse]
28
+ def get_inbound_attachment_url(id, attachment_id, opts = {})
29
+ data, _status_code, _headers = get_inbound_attachment_url_with_http_info(id, attachment_id, opts)
30
+ data
31
+ end
32
+
33
+ # Get an attachment download URL
34
+ # Return a short-lived presigned S3 download URL for one attachment of a received email. `attachmentId` is the positional id from the email's `attachments` array.
35
+ # @param id [String]
36
+ # @param attachment_id [String]
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [Array<(InboundAttachmentUrlResponse, Integer, Hash)>] InboundAttachmentUrlResponse data, response status code and response headers
39
+ def get_inbound_attachment_url_with_http_info(id, attachment_id, opts = {})
40
+ if @api_client.config.debugging
41
+ @api_client.config.logger.debug 'Calling API: InboundEmailApi.get_inbound_attachment_url ...'
42
+ end
43
+ # verify the required parameter 'id' is set
44
+ if @api_client.config.client_side_validation && id.nil?
45
+ fail ArgumentError, "Missing the required parameter 'id' when calling InboundEmailApi.get_inbound_attachment_url"
46
+ end
47
+ # verify the required parameter 'attachment_id' is set
48
+ if @api_client.config.client_side_validation && attachment_id.nil?
49
+ fail ArgumentError, "Missing the required parameter 'attachment_id' when calling InboundEmailApi.get_inbound_attachment_url"
50
+ end
51
+ # resource path
52
+ local_var_path = '/inbound-emails/{id}/attachments/{attachmentId}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'attachmentId' + '}', CGI.escape(attachment_id.to_s))
53
+
54
+ # query parameters
55
+ query_params = opts[:query_params] || {}
56
+
57
+ # header parameters
58
+ header_params = opts[:header_params] || {}
59
+ # HTTP header 'Accept' (if needed)
60
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
61
+
62
+ # form parameters
63
+ form_params = opts[:form_params] || {}
64
+
65
+ # http body (model)
66
+ post_body = opts[:debug_body]
67
+
68
+ # return_type
69
+ return_type = opts[:debug_return_type] || 'InboundAttachmentUrlResponse'
70
+
71
+ # auth_names
72
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
73
+
74
+ new_options = opts.merge(
75
+ :operation => :"InboundEmailApi.get_inbound_attachment_url",
76
+ :header_params => header_params,
77
+ :query_params => query_params,
78
+ :form_params => form_params,
79
+ :body => post_body,
80
+ :auth_names => auth_names,
81
+ :return_type => return_type
82
+ )
83
+
84
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
85
+ if @api_client.config.debugging
86
+ @api_client.config.logger.debug "API called: InboundEmailApi#get_inbound_attachment_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
87
+ end
88
+ return data, status_code, headers
89
+ end
90
+
91
+ # Get a received email
92
+ # Retrieve a single inbound email by id (scoped to the project).
93
+ # @param id [String]
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [InboundEmailResponse]
96
+ def get_inbound_email(id, opts = {})
97
+ data, _status_code, _headers = get_inbound_email_with_http_info(id, opts)
98
+ data
99
+ end
100
+
101
+ # Get a received email
102
+ # Retrieve a single inbound email by id (scoped to the project).
103
+ # @param id [String]
104
+ # @param [Hash] opts the optional parameters
105
+ # @return [Array<(InboundEmailResponse, Integer, Hash)>] InboundEmailResponse data, response status code and response headers
106
+ def get_inbound_email_with_http_info(id, opts = {})
107
+ if @api_client.config.debugging
108
+ @api_client.config.logger.debug 'Calling API: InboundEmailApi.get_inbound_email ...'
109
+ end
110
+ # verify the required parameter 'id' is set
111
+ if @api_client.config.client_side_validation && id.nil?
112
+ fail ArgumentError, "Missing the required parameter 'id' when calling InboundEmailApi.get_inbound_email"
113
+ end
114
+ # resource path
115
+ local_var_path = '/inbound-emails/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
116
+
117
+ # query parameters
118
+ query_params = opts[:query_params] || {}
119
+
120
+ # header parameters
121
+ header_params = opts[:header_params] || {}
122
+ # HTTP header 'Accept' (if needed)
123
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
124
+
125
+ # form parameters
126
+ form_params = opts[:form_params] || {}
127
+
128
+ # http body (model)
129
+ post_body = opts[:debug_body]
130
+
131
+ # return_type
132
+ return_type = opts[:debug_return_type] || 'InboundEmailResponse'
133
+
134
+ # auth_names
135
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
136
+
137
+ new_options = opts.merge(
138
+ :operation => :"InboundEmailApi.get_inbound_email",
139
+ :header_params => header_params,
140
+ :query_params => query_params,
141
+ :form_params => form_params,
142
+ :body => post_body,
143
+ :auth_names => auth_names,
144
+ :return_type => return_type
145
+ )
146
+
147
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
148
+ if @api_client.config.debugging
149
+ @api_client.config.logger.debug "API called: InboundEmailApi#get_inbound_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
150
+ end
151
+ return data, status_code, headers
152
+ end
153
+
154
+ # List received emails
155
+ # List inbound (received) emails for the project, newest first. By default only delivered mail (`received`/`processed`) is returned; pass `include_withheld=true` to also see quarantined/dropped.
156
+ # @param [Hash] opts the optional parameters
157
+ # @option opts [String] :status
158
+ # @option opts [String] :to Filter by receiving address
159
+ # @option opts [Boolean] :include_withheld Include quarantined/dropped mail
160
+ # @option opts [Integer] :limit (default to 50)
161
+ # @option opts [Integer] :offset (default to 0)
162
+ # @return [InboundEmailListResponse]
163
+ def list_inbound_emails(opts = {})
164
+ data, _status_code, _headers = list_inbound_emails_with_http_info(opts)
165
+ data
166
+ end
167
+
168
+ # List received emails
169
+ # List inbound (received) emails for the project, newest first. By default only delivered mail (&#x60;received&#x60;/&#x60;processed&#x60;) is returned; pass &#x60;include_withheld&#x3D;true&#x60; to also see quarantined/dropped.
170
+ # @param [Hash] opts the optional parameters
171
+ # @option opts [String] :status
172
+ # @option opts [String] :to Filter by receiving address
173
+ # @option opts [Boolean] :include_withheld Include quarantined/dropped mail
174
+ # @option opts [Integer] :limit (default to 50)
175
+ # @option opts [Integer] :offset (default to 0)
176
+ # @return [Array<(InboundEmailListResponse, Integer, Hash)>] InboundEmailListResponse data, response status code and response headers
177
+ def list_inbound_emails_with_http_info(opts = {})
178
+ if @api_client.config.debugging
179
+ @api_client.config.logger.debug 'Calling API: InboundEmailApi.list_inbound_emails ...'
180
+ end
181
+ allowable_values = ["received", "processed", "quarantined", "dropped", "failed"]
182
+ if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
183
+ fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
184
+ end
185
+ if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
186
+ fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling InboundEmailApi.list_inbound_emails, must be smaller than or equal to 100.'
187
+ end
188
+
189
+ # resource path
190
+ local_var_path = '/inbound-emails'
191
+
192
+ # query parameters
193
+ query_params = opts[:query_params] || {}
194
+ query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
195
+ query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
196
+ query_params[:'include_withheld'] = opts[:'include_withheld'] if !opts[:'include_withheld'].nil?
197
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
198
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
199
+
200
+ # header parameters
201
+ header_params = opts[:header_params] || {}
202
+ # HTTP header 'Accept' (if needed)
203
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
204
+
205
+ # form parameters
206
+ form_params = opts[:form_params] || {}
207
+
208
+ # http body (model)
209
+ post_body = opts[:debug_body]
210
+
211
+ # return_type
212
+ return_type = opts[:debug_return_type] || 'InboundEmailListResponse'
213
+
214
+ # auth_names
215
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
216
+
217
+ new_options = opts.merge(
218
+ :operation => :"InboundEmailApi.list_inbound_emails",
219
+ :header_params => header_params,
220
+ :query_params => query_params,
221
+ :form_params => form_params,
222
+ :body => post_body,
223
+ :auth_names => auth_names,
224
+ :return_type => return_type
225
+ )
226
+
227
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
228
+ if @api_client.config.debugging
229
+ @api_client.config.logger.debug "API called: InboundEmailApi#list_inbound_emails\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
230
+ end
231
+ return data, status_code, headers
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,229 @@
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 InboundAttachmentUrlResponse
18
+ attr_accessor :data
19
+
20
+ attr_accessor :meta
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'data' => :'data',
26
+ :'meta' => :'meta'
27
+ }
28
+ end
29
+
30
+ # Returns attribute mapping this model knows about
31
+ def self.acceptable_attribute_map
32
+ attribute_map
33
+ end
34
+
35
+ # Returns all the JSON keys this model knows about
36
+ def self.acceptable_attributes
37
+ acceptable_attribute_map.values
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'data' => :'InboundAttachmentUrlResponseData',
44
+ :'meta' => :'RequestMeta'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Zyphr::InboundAttachmentUrlResponse` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ acceptable_attribute_map = self.class.acceptable_attribute_map
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!acceptable_attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Zyphr::InboundAttachmentUrlResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'data')
71
+ self.data = attributes[:'data']
72
+ end
73
+
74
+ if attributes.key?(:'meta')
75
+ self.meta = attributes[:'meta']
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ warn '[DEPRECATED] the `valid?` method is obsolete'
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(o)
97
+ return true if self.equal?(o)
98
+ self.class == o.class &&
99
+ data == o.data &&
100
+ meta == o.meta
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 [Integer] Hash code
111
+ def hash
112
+ [data, meta].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 self.build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ attributes = attributes.transform_keys(&:to_sym)
121
+ transformed_hash = {}
122
+ openapi_types.each_pair do |key, type|
123
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = nil
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[attribute_map[key]].is_a?(Array)
129
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
130
+ end
131
+ elsif !attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
133
+ end
134
+ end
135
+ new(transformed_hash)
136
+ end
137
+
138
+ # Deserializes the data based on type
139
+ # @param string type Data type
140
+ # @param string value Value to be deserialized
141
+ # @return [Object] Deserialized data
142
+ def self._deserialize(type, value)
143
+ case type.to_sym
144
+ when :Time
145
+ Time.parse(value)
146
+ when :Date
147
+ Date.parse(value)
148
+ when :String
149
+ value.to_s
150
+ when :Integer
151
+ value.to_i
152
+ when :Float
153
+ value.to_f
154
+ when :Boolean
155
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
156
+ true
157
+ else
158
+ false
159
+ end
160
+ when :Object
161
+ # generic object (usually a Hash), return directly
162
+ value
163
+ when /\AArray<(?<inner_type>.+)>\z/
164
+ inner_type = Regexp.last_match[:inner_type]
165
+ value.map { |v| _deserialize(inner_type, v) }
166
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
167
+ k_type = Regexp.last_match[:k_type]
168
+ v_type = Regexp.last_match[:v_type]
169
+ {}.tap do |hash|
170
+ value.each do |k, v|
171
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
172
+ end
173
+ end
174
+ else # model
175
+ # models (e.g. Pet) or oneOf
176
+ klass = Zyphr.const_get(type)
177
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+
227
+ end
228
+
229
+ end