parlo-sdk 1.0.0

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 (46) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +132 -0
  3. data/lib/parlo-sdk/api/domains_api.rb +332 -0
  4. data/lib/parlo-sdk/api/emails_api.rb +156 -0
  5. data/lib/parlo-sdk/api_client.rb +397 -0
  6. data/lib/parlo-sdk/api_error.rb +58 -0
  7. data/lib/parlo-sdk/api_model_base.rb +88 -0
  8. data/lib/parlo-sdk/configuration.rb +308 -0
  9. data/lib/parlo-sdk/models/auth_health.rb +227 -0
  10. data/lib/parlo-sdk/models/auth_health_dkim.rb +188 -0
  11. data/lib/parlo-sdk/models/auth_health_dmarc.rb +174 -0
  12. data/lib/parlo-sdk/models/auth_health_spf.rb +164 -0
  13. data/lib/parlo-sdk/models/create_domain_request.rb +164 -0
  14. data/lib/parlo-sdk/models/delete_domain200_response.rb +214 -0
  15. data/lib/parlo-sdk/models/dns_record.rb +267 -0
  16. data/lib/parlo-sdk/models/domain.rb +319 -0
  17. data/lib/parlo-sdk/models/domain_summary.rb +260 -0
  18. data/lib/parlo-sdk/models/email.rb +340 -0
  19. data/lib/parlo-sdk/models/email_created.rb +214 -0
  20. data/lib/parlo-sdk/models/error.rb +190 -0
  21. data/lib/parlo-sdk/models/list_domains200_response.rb +166 -0
  22. data/lib/parlo-sdk/models/send_email_request.rb +288 -0
  23. data/lib/parlo-sdk/models/send_email_request_cc.rb +104 -0
  24. data/lib/parlo-sdk/models/send_email_request_to.rb +105 -0
  25. data/lib/parlo-sdk/version.rb +15 -0
  26. data/lib/parlo-sdk.rb +58 -0
  27. data/spec/api/domains_api_spec.rb +92 -0
  28. data/spec/api/emails_api_spec.rb +60 -0
  29. data/spec/models/auth_health_dkim_spec.rb +40 -0
  30. data/spec/models/auth_health_dmarc_spec.rb +42 -0
  31. data/spec/models/auth_health_spec.rb +54 -0
  32. data/spec/models/auth_health_spf_spec.rb +36 -0
  33. data/spec/models/create_domain_request_spec.rb +36 -0
  34. data/spec/models/delete_domain200_response_spec.rb +46 -0
  35. data/spec/models/dns_record_spec.rb +58 -0
  36. data/spec/models/domain_spec.rb +76 -0
  37. data/spec/models/domain_summary_spec.rb +64 -0
  38. data/spec/models/email_created_spec.rb +46 -0
  39. data/spec/models/email_spec.rb +82 -0
  40. data/spec/models/error_spec.rb +42 -0
  41. data/spec/models/list_domains200_response_spec.rb +36 -0
  42. data/spec/models/send_email_request_cc_spec.rb +32 -0
  43. data/spec/models/send_email_request_spec.rb +90 -0
  44. data/spec/models/send_email_request_to_spec.rb +32 -0
  45. data/spec/spec_helper.rb +111 -0
  46. metadata +153 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a86fcc7296426ee54eb2d2903e4d0112ba86f5ca602fdb02f3f02dc2e889003e
4
+ data.tar.gz: 99bafb1a2b9523052f897f5a4c48d797cab3dc35ee9f8f1ca2dda24557fff517
5
+ SHA512:
6
+ metadata.gz: f0f56669490d5fbd80059ca8f38ef01b4d076e5b5cec0dc510cd1fcc6643f6b6a941940718a9925a3d0cddf39277883f7ca4d449fb74276c1521694c72f68aeb
7
+ data.tar.gz: 278e1e48e27744b27451e75d8c3ed25a54b986aae2c5d7f57158ff1aa9290027b6bb3d828256cab9404fa68a929c7e2eb5c1d6e3743106e3686ad7b82ed41fad
data/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # parlo-sdk
2
+
3
+ Parlo - the Ruby gem for the Parlo API
4
+
5
+ The Parlo API sends transactional email and manages the sending domains it
6
+ authenticates from. Marketing campaigns (audiences, templates, broadcasts)
7
+ are designed and sent from the Parlo dashboard, not this API — the API is
8
+ transactional-only at launch.
9
+
10
+ All requests authenticate with a company API key as an HTTP bearer token:
11
+ `Authorization: Bearer parlo_live_xxx`. Errors return a JSON body of the
12
+ shape `{ \"message\": string, \"code\": string }`.
13
+
14
+
15
+ This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
16
+
17
+ - API version: 1.0.0
18
+ - Package version: 1.0.0
19
+ - Generator version: 7.24.0-SNAPSHOT
20
+ - Build package: org.openapitools.codegen.languages.RubyClientCodegen
21
+ For more information, please visit [https://getparlo.io](https://getparlo.io)
22
+
23
+ ## Installation
24
+
25
+ ### Build a gem
26
+
27
+ To build the Ruby code into a gem:
28
+
29
+ ```shell
30
+ gem build parlo-sdk.gemspec
31
+ ```
32
+
33
+ Then either install the gem locally:
34
+
35
+ ```shell
36
+ gem install ./parlo-sdk-1.0.0.gem
37
+ ```
38
+
39
+ (for development, run `gem install --dev ./parlo-sdk-1.0.0.gem` to install the development dependencies)
40
+
41
+ or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
42
+
43
+ Finally add this to the Gemfile:
44
+
45
+ gem 'parlo-sdk', '~> 1.0.0'
46
+
47
+ ### Install from Git
48
+
49
+ If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
50
+
51
+ gem 'parlo-sdk', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
52
+
53
+ ### Include the Ruby code directly
54
+
55
+ Include the Ruby code directly using `-I` as follows:
56
+
57
+ ```shell
58
+ ruby -Ilib script.rb
59
+ ```
60
+
61
+ ## Getting Started
62
+
63
+ Please follow the [installation](#installation) procedure and then run the following code:
64
+
65
+ ```ruby
66
+ # Load the gem
67
+ require 'parlo-sdk'
68
+
69
+ # Setup authorization
70
+ Parlo.configure do |config|
71
+ # Configure Bearer authorization: bearerAuth
72
+ config.access_token = 'YOUR_BEARER_TOKEN'
73
+ # Configure a proc to get access tokens in lieu of the static access_token configuration
74
+ config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' }
75
+ end
76
+
77
+ api_instance = Parlo::DomainsApi.new
78
+ create_domain_request = Parlo::CreateDomainRequest.new({name: 'yourdomain.com'}) # CreateDomainRequest |
79
+
80
+ begin
81
+ #Add a sending domain
82
+ result = api_instance.create_domain(create_domain_request)
83
+ p result
84
+ rescue Parlo::ApiError => e
85
+ puts "Exception when calling DomainsApi->create_domain: #{e}"
86
+ end
87
+
88
+ ```
89
+
90
+ ## Documentation for API Endpoints
91
+
92
+ All URIs are relative to *https://api.getparlo.io/v1*
93
+
94
+ Class | Method | HTTP request | Description
95
+ ------------ | ------------- | ------------- | -------------
96
+ *Parlo::DomainsApi* | [**create_domain**](docs/DomainsApi.md#create_domain) | **POST** /domains | Add a sending domain
97
+ *Parlo::DomainsApi* | [**delete_domain**](docs/DomainsApi.md#delete_domain) | **DELETE** /domains/{id} | Remove a domain
98
+ *Parlo::DomainsApi* | [**get_domain**](docs/DomainsApi.md#get_domain) | **GET** /domains/{id} | Retrieve a domain
99
+ *Parlo::DomainsApi* | [**list_domains**](docs/DomainsApi.md#list_domains) | **GET** /domains | List sending domains
100
+ *Parlo::DomainsApi* | [**verify_domain**](docs/DomainsApi.md#verify_domain) | **POST** /domains/{id}/verify | Re-check a domain's DNS
101
+ *Parlo::EmailsApi* | [**get_email**](docs/EmailsApi.md#get_email) | **GET** /emails/{id} | Retrieve an email
102
+ *Parlo::EmailsApi* | [**send_email**](docs/EmailsApi.md#send_email) | **POST** /emails | Send a transactional email
103
+
104
+
105
+ ## Documentation for Models
106
+
107
+ - [Parlo::AuthHealth](docs/AuthHealth.md)
108
+ - [Parlo::AuthHealthDkim](docs/AuthHealthDkim.md)
109
+ - [Parlo::AuthHealthDmarc](docs/AuthHealthDmarc.md)
110
+ - [Parlo::AuthHealthSpf](docs/AuthHealthSpf.md)
111
+ - [Parlo::CreateDomainRequest](docs/CreateDomainRequest.md)
112
+ - [Parlo::DeleteDomain200Response](docs/DeleteDomain200Response.md)
113
+ - [Parlo::DnsRecord](docs/DnsRecord.md)
114
+ - [Parlo::Domain](docs/Domain.md)
115
+ - [Parlo::DomainSummary](docs/DomainSummary.md)
116
+ - [Parlo::Email](docs/Email.md)
117
+ - [Parlo::EmailCreated](docs/EmailCreated.md)
118
+ - [Parlo::Error](docs/Error.md)
119
+ - [Parlo::ListDomains200Response](docs/ListDomains200Response.md)
120
+ - [Parlo::SendEmailRequest](docs/SendEmailRequest.md)
121
+ - [Parlo::SendEmailRequestCc](docs/SendEmailRequestCc.md)
122
+ - [Parlo::SendEmailRequestTo](docs/SendEmailRequestTo.md)
123
+
124
+
125
+ ## Documentation for Authorization
126
+
127
+
128
+ Authentication schemes defined for the API:
129
+ ### bearerAuth
130
+
131
+ - **Type**: Bearer authentication
132
+
@@ -0,0 +1,332 @@
1
+ =begin
2
+ #Parlo API
3
+
4
+ #The Parlo API sends transactional email and manages the sending domains it authenticates from. Marketing campaigns (audiences, templates, broadcasts) are designed and sent from the Parlo dashboard, not this API — the API is transactional-only at launch. All requests authenticate with a company API key as an HTTP bearer token: `Authorization: Bearer parlo_live_xxx`. Errors return a JSON body of the shape `{ \"message\": string, \"code\": string }`.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Parlo
16
+ class DomainsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Add a sending domain
23
+ # Registers a domain as a SES sending identity and returns the DNS records to add (three required DKIM CNAMEs plus recommended SPF and DMARC TXT records). Add the records at your DNS provider, then call the verify endpoint to check them.
24
+ # @param create_domain_request [CreateDomainRequest]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [Domain]
27
+ def create_domain(create_domain_request, opts = {})
28
+ data, _status_code, _headers = create_domain_with_http_info(create_domain_request, opts)
29
+ data
30
+ end
31
+
32
+ # Add a sending domain
33
+ # Registers a domain as a SES sending identity and returns the DNS records to add (three required DKIM CNAMEs plus recommended SPF and DMARC TXT records). Add the records at your DNS provider, then call the verify endpoint to check them.
34
+ # @param create_domain_request [CreateDomainRequest]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(Domain, Integer, Hash)>] Domain data, response status code and response headers
37
+ def create_domain_with_http_info(create_domain_request, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: DomainsApi.create_domain ...'
40
+ end
41
+ # verify the required parameter 'create_domain_request' is set
42
+ if @api_client.config.client_side_validation && create_domain_request.nil?
43
+ fail ArgumentError, "Missing the required parameter 'create_domain_request' when calling DomainsApi.create_domain"
44
+ end
45
+ # resource path
46
+ local_var_path = '/domains'
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
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_domain_request)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'Domain'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"DomainsApi.create_domain",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: DomainsApi#create_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Remove a domain
91
+ # @param id [String] The domain id (UUID).
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [DeleteDomain200Response]
94
+ def delete_domain(id, opts = {})
95
+ data, _status_code, _headers = delete_domain_with_http_info(id, opts)
96
+ data
97
+ end
98
+
99
+ # Remove a domain
100
+ # @param id [String] The domain id (UUID).
101
+ # @param [Hash] opts the optional parameters
102
+ # @return [Array<(DeleteDomain200Response, Integer, Hash)>] DeleteDomain200Response data, response status code and response headers
103
+ def delete_domain_with_http_info(id, opts = {})
104
+ if @api_client.config.debugging
105
+ @api_client.config.logger.debug 'Calling API: DomainsApi.delete_domain ...'
106
+ end
107
+ # verify the required parameter 'id' is set
108
+ if @api_client.config.client_side_validation && id.nil?
109
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.delete_domain"
110
+ end
111
+ # resource path
112
+ local_var_path = '/domains/{id}'.sub('{id}', CGI.escape(id.to_s))
113
+
114
+ # query parameters
115
+ query_params = opts[:query_params] || {}
116
+
117
+ # header parameters
118
+ header_params = opts[:header_params] || {}
119
+ # HTTP header 'Accept' (if needed)
120
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
121
+
122
+ # form parameters
123
+ form_params = opts[:form_params] || {}
124
+
125
+ # http body (model)
126
+ post_body = opts[:debug_body]
127
+
128
+ # return_type
129
+ return_type = opts[:debug_return_type] || 'DeleteDomain200Response'
130
+
131
+ # auth_names
132
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
133
+
134
+ new_options = opts.merge(
135
+ :operation => :"DomainsApi.delete_domain",
136
+ :header_params => header_params,
137
+ :query_params => query_params,
138
+ :form_params => form_params,
139
+ :body => post_body,
140
+ :auth_names => auth_names,
141
+ :return_type => return_type
142
+ )
143
+
144
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
145
+ if @api_client.config.debugging
146
+ @api_client.config.logger.debug "API called: DomainsApi#delete_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
147
+ end
148
+ return data, status_code, headers
149
+ end
150
+
151
+ # Retrieve a domain
152
+ # Returns the domain with its DNS records and advisory auth-health report.
153
+ # @param id [String] The domain id (UUID).
154
+ # @param [Hash] opts the optional parameters
155
+ # @return [Domain]
156
+ def get_domain(id, opts = {})
157
+ data, _status_code, _headers = get_domain_with_http_info(id, opts)
158
+ data
159
+ end
160
+
161
+ # Retrieve a domain
162
+ # Returns the domain with its DNS records and advisory auth-health report.
163
+ # @param id [String] The domain id (UUID).
164
+ # @param [Hash] opts the optional parameters
165
+ # @return [Array<(Domain, Integer, Hash)>] Domain data, response status code and response headers
166
+ def get_domain_with_http_info(id, opts = {})
167
+ if @api_client.config.debugging
168
+ @api_client.config.logger.debug 'Calling API: DomainsApi.get_domain ...'
169
+ end
170
+ # verify the required parameter 'id' is set
171
+ if @api_client.config.client_side_validation && id.nil?
172
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.get_domain"
173
+ end
174
+ # resource path
175
+ local_var_path = '/domains/{id}'.sub('{id}', CGI.escape(id.to_s))
176
+
177
+ # query parameters
178
+ query_params = opts[:query_params] || {}
179
+
180
+ # header parameters
181
+ header_params = opts[:header_params] || {}
182
+ # HTTP header 'Accept' (if needed)
183
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
184
+
185
+ # form parameters
186
+ form_params = opts[:form_params] || {}
187
+
188
+ # http body (model)
189
+ post_body = opts[:debug_body]
190
+
191
+ # return_type
192
+ return_type = opts[:debug_return_type] || 'Domain'
193
+
194
+ # auth_names
195
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
196
+
197
+ new_options = opts.merge(
198
+ :operation => :"DomainsApi.get_domain",
199
+ :header_params => header_params,
200
+ :query_params => query_params,
201
+ :form_params => form_params,
202
+ :body => post_body,
203
+ :auth_names => auth_names,
204
+ :return_type => return_type
205
+ )
206
+
207
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
208
+ if @api_client.config.debugging
209
+ @api_client.config.logger.debug "API called: DomainsApi#get_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
210
+ end
211
+ return data, status_code, headers
212
+ end
213
+
214
+ # List sending domains
215
+ # @param [Hash] opts the optional parameters
216
+ # @return [ListDomains200Response]
217
+ def list_domains(opts = {})
218
+ data, _status_code, _headers = list_domains_with_http_info(opts)
219
+ data
220
+ end
221
+
222
+ # List sending domains
223
+ # @param [Hash] opts the optional parameters
224
+ # @return [Array<(ListDomains200Response, Integer, Hash)>] ListDomains200Response data, response status code and response headers
225
+ def list_domains_with_http_info(opts = {})
226
+ if @api_client.config.debugging
227
+ @api_client.config.logger.debug 'Calling API: DomainsApi.list_domains ...'
228
+ end
229
+ # resource path
230
+ local_var_path = '/domains'
231
+
232
+ # query parameters
233
+ query_params = opts[:query_params] || {}
234
+
235
+ # header parameters
236
+ header_params = opts[:header_params] || {}
237
+ # HTTP header 'Accept' (if needed)
238
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
239
+
240
+ # form parameters
241
+ form_params = opts[:form_params] || {}
242
+
243
+ # http body (model)
244
+ post_body = opts[:debug_body]
245
+
246
+ # return_type
247
+ return_type = opts[:debug_return_type] || 'ListDomains200Response'
248
+
249
+ # auth_names
250
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
251
+
252
+ new_options = opts.merge(
253
+ :operation => :"DomainsApi.list_domains",
254
+ :header_params => header_params,
255
+ :query_params => query_params,
256
+ :form_params => form_params,
257
+ :body => post_body,
258
+ :auth_names => auth_names,
259
+ :return_type => return_type
260
+ )
261
+
262
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
263
+ if @api_client.config.debugging
264
+ @api_client.config.logger.debug "API called: DomainsApi#list_domains\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
265
+ end
266
+ return data, status_code, headers
267
+ end
268
+
269
+ # Re-check a domain's DNS
270
+ # Re-reads the domain's verification status from SES and refreshes the advisory SPF/DMARC auth-health checks. Returns the updated domain.
271
+ # @param id [String] The domain id (UUID).
272
+ # @param [Hash] opts the optional parameters
273
+ # @return [Domain]
274
+ def verify_domain(id, opts = {})
275
+ data, _status_code, _headers = verify_domain_with_http_info(id, opts)
276
+ data
277
+ end
278
+
279
+ # Re-check a domain&#39;s DNS
280
+ # Re-reads the domain&#39;s verification status from SES and refreshes the advisory SPF/DMARC auth-health checks. Returns the updated domain.
281
+ # @param id [String] The domain id (UUID).
282
+ # @param [Hash] opts the optional parameters
283
+ # @return [Array<(Domain, Integer, Hash)>] Domain data, response status code and response headers
284
+ def verify_domain_with_http_info(id, opts = {})
285
+ if @api_client.config.debugging
286
+ @api_client.config.logger.debug 'Calling API: DomainsApi.verify_domain ...'
287
+ end
288
+ # verify the required parameter 'id' is set
289
+ if @api_client.config.client_side_validation && id.nil?
290
+ fail ArgumentError, "Missing the required parameter 'id' when calling DomainsApi.verify_domain"
291
+ end
292
+ # resource path
293
+ local_var_path = '/domains/{id}/verify'.sub('{id}', CGI.escape(id.to_s))
294
+
295
+ # query parameters
296
+ query_params = opts[:query_params] || {}
297
+
298
+ # header parameters
299
+ header_params = opts[:header_params] || {}
300
+ # HTTP header 'Accept' (if needed)
301
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
302
+
303
+ # form parameters
304
+ form_params = opts[:form_params] || {}
305
+
306
+ # http body (model)
307
+ post_body = opts[:debug_body]
308
+
309
+ # return_type
310
+ return_type = opts[:debug_return_type] || 'Domain'
311
+
312
+ # auth_names
313
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
314
+
315
+ new_options = opts.merge(
316
+ :operation => :"DomainsApi.verify_domain",
317
+ :header_params => header_params,
318
+ :query_params => query_params,
319
+ :form_params => form_params,
320
+ :body => post_body,
321
+ :auth_names => auth_names,
322
+ :return_type => return_type
323
+ )
324
+
325
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
326
+ if @api_client.config.debugging
327
+ @api_client.config.logger.debug "API called: DomainsApi#verify_domain\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
328
+ end
329
+ return data, status_code, headers
330
+ end
331
+ end
332
+ end
@@ -0,0 +1,156 @@
1
+ =begin
2
+ #Parlo API
3
+
4
+ #The Parlo API sends transactional email and manages the sending domains it authenticates from. Marketing campaigns (audiences, templates, broadcasts) are designed and sent from the Parlo dashboard, not this API — the API is transactional-only at launch. All requests authenticate with a company API key as an HTTP bearer token: `Authorization: Bearer parlo_live_xxx`. Errors return a JSON body of the shape `{ \"message\": string, \"code\": string }`.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.24.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Parlo
16
+ class EmailsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Retrieve an email
23
+ # Returns the current status and engagement flags for a sent email.
24
+ # @param id [String] The email id (UUID).
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [Email]
27
+ def get_email(id, opts = {})
28
+ data, _status_code, _headers = get_email_with_http_info(id, opts)
29
+ data
30
+ end
31
+
32
+ # Retrieve an email
33
+ # Returns the current status and engagement flags for a sent email.
34
+ # @param id [String] The email id (UUID).
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(Email, Integer, Hash)>] Email data, response status code and response headers
37
+ def get_email_with_http_info(id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: EmailsApi.get_email ...'
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 EmailsApi.get_email"
44
+ end
45
+ # resource path
46
+ local_var_path = '/emails/{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] || 'Email'
64
+
65
+ # auth_names
66
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
67
+
68
+ new_options = opts.merge(
69
+ :operation => :"EmailsApi.get_email",
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: EmailsApi#get_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+
85
+ # Send a transactional email
86
+ # Queues a transactional email for delivery and returns immediately with a `queued` status. The actual send happens out of band; poll `GET /emails/{id}` (or consume webhook events) for the outcome. The `from` address must belong to a domain your company has verified (see the Domains endpoints). `data` fills `[placeholder]` tokens in `subject`, `html` and `text`. Provide at least one of `html` or `text`. Send an `Idempotency-Key` header to make retries safe — a repeated key returns the original email instead of sending again.
87
+ # @param send_email_request [SendEmailRequest]
88
+ # @param [Hash] opts the optional parameters
89
+ # @option opts [String] :idempotency_key Unique key that makes a repeated send return the original email instead of sending again.
90
+ # @return [EmailCreated]
91
+ def send_email(send_email_request, opts = {})
92
+ data, _status_code, _headers = send_email_with_http_info(send_email_request, opts)
93
+ data
94
+ end
95
+
96
+ # Send a transactional email
97
+ # Queues a transactional email for delivery and returns immediately with a &#x60;queued&#x60; status. The actual send happens out of band; poll &#x60;GET /emails/{id}&#x60; (or consume webhook events) for the outcome. The &#x60;from&#x60; address must belong to a domain your company has verified (see the Domains endpoints). &#x60;data&#x60; fills &#x60;[placeholder]&#x60; tokens in &#x60;subject&#x60;, &#x60;html&#x60; and &#x60;text&#x60;. Provide at least one of &#x60;html&#x60; or &#x60;text&#x60;. Send an &#x60;Idempotency-Key&#x60; header to make retries safe — a repeated key returns the original email instead of sending again.
98
+ # @param send_email_request [SendEmailRequest]
99
+ # @param [Hash] opts the optional parameters
100
+ # @option opts [String] :idempotency_key Unique key that makes a repeated send return the original email instead of sending again.
101
+ # @return [Array<(EmailCreated, Integer, Hash)>] EmailCreated data, response status code and response headers
102
+ def send_email_with_http_info(send_email_request, opts = {})
103
+ if @api_client.config.debugging
104
+ @api_client.config.logger.debug 'Calling API: EmailsApi.send_email ...'
105
+ end
106
+ # verify the required parameter 'send_email_request' is set
107
+ if @api_client.config.client_side_validation && send_email_request.nil?
108
+ fail ArgumentError, "Missing the required parameter 'send_email_request' when calling EmailsApi.send_email"
109
+ end
110
+ # resource path
111
+ local_var_path = '/emails'
112
+
113
+ # query parameters
114
+ query_params = opts[:query_params] || {}
115
+
116
+ # header parameters
117
+ header_params = opts[:header_params] || {}
118
+ # HTTP header 'Accept' (if needed)
119
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
120
+ # HTTP header 'Content-Type'
121
+ content_type = @api_client.select_header_content_type(['application/json'])
122
+ if !content_type.nil?
123
+ header_params['Content-Type'] = content_type
124
+ end
125
+ header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
126
+
127
+ # form parameters
128
+ form_params = opts[:form_params] || {}
129
+
130
+ # http body (model)
131
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(send_email_request)
132
+
133
+ # return_type
134
+ return_type = opts[:debug_return_type] || 'EmailCreated'
135
+
136
+ # auth_names
137
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
138
+
139
+ new_options = opts.merge(
140
+ :operation => :"EmailsApi.send_email",
141
+ :header_params => header_params,
142
+ :query_params => query_params,
143
+ :form_params => form_params,
144
+ :body => post_body,
145
+ :auth_names => auth_names,
146
+ :return_type => return_type
147
+ )
148
+
149
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
150
+ if @api_client.config.debugging
151
+ @api_client.config.logger.debug "API called: EmailsApi#send_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
152
+ end
153
+ return data, status_code, headers
154
+ end
155
+ end
156
+ end