Class: Parlo::EmailsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/parlo-sdk/api/emails_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ EmailsApi

Returns a new instance of EmailsApi.



19
20
21
# File 'lib/parlo-sdk/api/emails_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/parlo-sdk/api/emails_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_email(id, opts = {}) ⇒ Email

Retrieve an email Returns the current status and engagement flags for a sent email.

Parameters:

  • id (String)

    The email id (UUID).

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



27
28
29
30
# File 'lib/parlo-sdk/api/emails_api.rb', line 27

def get_email(id, opts = {})
  data, _status_code, _headers = get_email_with_http_info(id, opts)
  data
end

#get_email_with_http_info(id, opts = {}) ⇒ Array<(Email, Integer, Hash)>

Retrieve an email Returns the current status and engagement flags for a sent email.

Parameters:

  • id (String)

    The email id (UUID).

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Email, Integer, Hash)>)

    Email data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/parlo-sdk/api/emails_api.rb', line 37

def get_email_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailsApi.get_email ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling EmailsApi.get_email"
  end
  # resource path
  local_var_path = '/emails/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Email'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailsApi.get_email",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EmailsApi#get_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_emails(opts = {}) ⇒ EmailList

List transactional emails Returns this company's transactional emails, newest first, with pagination metadata. Use it to build a delivery log or to reconcile a batch of sends without polling each message by id. Filters combine with AND. A malformed filter is rejected with a 422 rather than ignored, so a narrowing filter can never silently return the unfiltered set. Transactional message bodies are never stored and never returned.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :status (String)

    Filter by delivery status. Accepts a comma-separated list to match any of several, e.g. `bounced,failed`.

  • :to (String)

    Filter by recipient. Matches any recipient of the message, case-insensitively, on a partial string — `example.com` matches every recipient at that domain.

  • :since (String)

    Only emails created at or after this time. Strict ISO 8601: either a date (`2026-08-01`) or a timestamp (`2026-08-01T10:00:00Z`).

  • :_until (String)

    Only emails created at or before this time. Same format as `since`. A date with no time covers that whole day.

  • :tags (Hash<String, String>)

    Filter by the tags set at send time. Supply several keys to require all of them: `?tags=receipt&tags=prod`. Maximum 10 keys.

  • :search_term (String)

    Case-insensitive substring match on the subject.

  • :page (Integer)

    1-based page number. (default to 1)

  • :per_page (Integer)

    Results per page. (default to 25)

Returns:



97
98
99
100
# File 'lib/parlo-sdk/api/emails_api.rb', line 97

def list_emails(opts = {})
  data, _status_code, _headers = list_emails_with_http_info(opts)
  data
end

#list_emails_with_http_info(opts = {}) ⇒ Array<(EmailList, Integer, Hash)>

List transactional emails Returns this company's transactional emails, newest first, with pagination metadata. Use it to build a delivery log or to reconcile a batch of sends without polling each message by id. Filters combine with AND. A malformed filter is rejected with a 422 rather than ignored, so a narrowing filter can never silently return the unfiltered set. Transactional message bodies are never stored and never returned.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :status (String)

    Filter by delivery status. Accepts a comma-separated list to match any of several, e.g. `bounced,failed`.

  • :to (String)

    Filter by recipient. Matches any recipient of the message, case-insensitively, on a partial string — `example.com` matches every recipient at that domain.

  • :since (String)

    Only emails created at or after this time. Strict ISO 8601: either a date (`2026-08-01`) or a timestamp (`2026-08-01T10:00:00Z`).

  • :_until (String)

    Only emails created at or before this time. Same format as `since`. A date with no time covers that whole day.

  • :tags (Hash<String, String>)

    Filter by the tags set at send time. Supply several keys to require all of them: `?tags=receipt&tags=prod`. Maximum 10 keys.

  • :search_term (String)

    Case-insensitive substring match on the subject.

  • :page (Integer)

    1-based page number. (default to 1)

  • :per_page (Integer)

    Results per page. (default to 25)

Returns:

  • (Array<(EmailList, Integer, Hash)>)

    EmailList data, response status code and response headers



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/parlo-sdk/api/emails_api.rb', line 114

def list_emails_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailsApi.list_emails ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling EmailsApi.list_emails, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100
    fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling EmailsApi.list_emails, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling EmailsApi.list_emails, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/emails'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'search_term'] = opts[:'search_term'] if !opts[:'search_term'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EmailList'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailsApi.list_emails",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EmailsApi#list_emails\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_email(send_email_request, opts = {}) ⇒ EmailCreated

Send a transactional email 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.

Parameters:

  • send_email_request (SendEmailRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key that makes a repeated send return the original email instead of sending again.

Returns:



184
185
186
187
# File 'lib/parlo-sdk/api/emails_api.rb', line 184

def send_email(send_email_request, opts = {})
  data, _status_code, _headers = send_email_with_http_info(send_email_request, opts)
  data
end

#send_email_with_http_info(send_email_request, opts = {}) ⇒ Array<(EmailCreated, Integer, Hash)>

Send a transactional email 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.

Parameters:

  • send_email_request (SendEmailRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Unique key that makes a repeated send return the original email instead of sending again.

Returns:

  • (Array<(EmailCreated, Integer, Hash)>)

    EmailCreated data, response status code and response headers



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/parlo-sdk/api/emails_api.rb', line 195

def send_email_with_http_info(send_email_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EmailsApi.send_email ...'
  end
  # verify the required parameter 'send_email_request' is set
  if @api_client.config.client_side_validation && send_email_request.nil?
    fail ArgumentError, "Missing the required parameter 'send_email_request' when calling EmailsApi.send_email"
  end
  # resource path
  local_var_path = '/emails'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(send_email_request)

  # return_type
  return_type = opts[:debug_return_type] || 'EmailCreated'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"EmailsApi.send_email",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EmailsApi#send_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end