Class: Lockally::SendApi

Inherits:
Object
  • Object
show all
Defined in:
lib/lockally/api/send_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SendApi

Returns a new instance of SendApi.



19
20
21
# File 'lib/lockally/api/send_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/lockally/api/send_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#v1_messages_get(opts = {}) ⇒ V1MessagesGet200Response

List outbound messages Returns recent outbound messages for the calling tenant, sorted newest first. Backs the send-status pill in the SvelteKit /sends view and the outbound search box.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :status (String)
  • :sender (String)

    Exact match against the `from` mailbox.

  • :q (String)

    Free-text search across subject + sender.

  • :since (Time)

    Only messages queued at or after this RFC 3339 instant.

  • :cursor (String)

    queued_at of the prior page boundary. Pass back the `next_cursor` returned by the previous call.

  • :limit (Integer) — default: default to 50

Returns:



32
33
34
35
# File 'lib/lockally/api/send_api.rb', line 32

def v1_messages_get(opts = {})
  data, _status_code, _headers = v1_messages_get_with_http_info(opts)
  data
end

#v1_messages_get_with_http_info(opts = {}) ⇒ Array<(V1MessagesGet200Response, Integer, Hash)>

List outbound messages Returns recent outbound messages for the calling tenant, sorted newest first. Backs the send-status pill in the SvelteKit /sends view and the outbound search box.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :status (String)
  • :sender (String)

    Exact match against the `from` mailbox.

  • :q (String)

    Free-text search across subject + sender.

  • :since (Time)

    Only messages queued at or after this RFC 3339 instant.

  • :cursor (String)

    queued_at of the prior page boundary. Pass back the `next_cursor` returned by the previous call.

  • :limit (Integer) — default: default to 50

Returns:

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

    V1MessagesGet200Response data, response status code and response headers



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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/lockally/api/send_api.rb', line 47

def v1_messages_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_messages_get ...'
  end
  allowable_values = ["queued", "sending", "delivered", "bounced", "deferred", "complaint"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 200
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SendApi.v1_messages_get, must be smaller than or equal to 200.'
  end

  # resource path
  local_var_path = '/v1/messages'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'sender'] = opts[:'sender'] if !opts[:'sender'].nil?
  query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+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] || 'V1MessagesGet200Response'

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_messages_get",
    :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: SendApi#v1_messages_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#v1_messages_id_delete(id, opts = {}) ⇒ nil

Cancel a scheduled send Cancels a still-scheduled message (future queued_at). Already sending/sent → 409.

Parameters:

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

    the optional parameters

Returns:

  • (nil)


110
111
112
113
# File 'lib/lockally/api/send_api.rb', line 110

def v1_messages_id_delete(id, opts = {})
  v1_messages_id_delete_with_http_info(id, opts)
  nil
end

#v1_messages_id_delete_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Cancel a scheduled send Cancels a still-scheduled message (future queued_at). Already sending/sent → 409.

Parameters:

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
# File 'lib/lockally/api/send_api.rb', line 120

def v1_messages_id_delete_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_messages_id_delete ...'
  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 SendApi.v1_messages_id_delete"
  end
  # resource path
  local_var_path = '/v1/messages/{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/problem+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]

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_messages_id_delete",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SendApi#v1_messages_id_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#v1_messages_id_get(id, opts = {}) ⇒ Message

Get message status

Parameters:

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

    the optional parameters

Returns:



172
173
174
175
# File 'lib/lockally/api/send_api.rb', line 172

def v1_messages_id_get(id, opts = {})
  data, _status_code, _headers = v1_messages_id_get_with_http_info(id, opts)
  data
end

#v1_messages_id_get_with_http_info(id, opts = {}) ⇒ Array<(Message, Integer, Hash)>

Get message status

Parameters:

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

    the optional parameters

Returns:

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

    Message data, response status code and response headers



181
182
183
184
185
186
187
188
189
190
191
192
193
194
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
# File 'lib/lockally/api/send_api.rb', line 181

def v1_messages_id_get_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_messages_id_get ...'
  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 SendApi.v1_messages_id_get"
  end
  # resource path
  local_var_path = '/v1/messages/{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', 'application/problem+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] || 'Message'

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_messages_id_get",
    :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: SendApi#v1_messages_id_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#v1_messages_stats_get(opts = {}) ⇒ MessageStats

Aggregate delivery stats Counts by delivery outcome (delivered/bounced/deferred/complaint) plus rates over a window, from the delivery-event store. Privacy-first: this reflects what receiving servers reported, NOT whether a human opened the mail — Lockally does no open/click tracking.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :from (Time)

    Window start (default 7 days ago).

  • :to (Time)

    Window end (default now).

  • :domain (String)

    Filter by sender domain.

Returns:



236
237
238
239
# File 'lib/lockally/api/send_api.rb', line 236

def v1_messages_stats_get(opts = {})
  data, _status_code, _headers = v1_messages_stats_get_with_http_info(opts)
  data
end

#v1_messages_stats_get_with_http_info(opts = {}) ⇒ Array<(MessageStats, Integer, Hash)>

Aggregate delivery stats Counts by delivery outcome (delivered/bounced/deferred/complaint) plus rates over a window, from the delivery-event store. Privacy-first: this reflects what receiving servers reported, NOT whether a human opened the mail — Lockally does no open/click tracking.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :from (Time)

    Window start (default 7 days ago).

  • :to (Time)

    Window end (default now).

  • :domain (String)

    Filter by sender domain.

Returns:

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

    MessageStats data, response status code and response headers



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/lockally/api/send_api.rb', line 248

def v1_messages_stats_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_messages_stats_get ...'
  end
  # resource path
  local_var_path = '/v1/messages/stats'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/problem+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] || 'MessageStats'

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_messages_stats_get",
    :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: SendApi#v1_messages_stats_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#v1_send_batch_post(idempotency_key, v1_send_batch_post_request, opts = {}) ⇒ V1SendBatchPost200Response

Send a batch of emails Sends up to 500 messages in one call. Each is validated and enqueued independently — a bad message fails only its own slot (partial success, HTTP 200). One Idempotency-Key header covers the batch; per-message keys are derived as <key>:<index>.

Parameters:

  • idempotency_key (String)
  • v1_send_batch_post_request (V1SendBatchPostRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



301
302
303
304
# File 'lib/lockally/api/send_api.rb', line 301

def v1_send_batch_post(idempotency_key, v1_send_batch_post_request, opts = {})
  data, _status_code, _headers = v1_send_batch_post_with_http_info(idempotency_key, v1_send_batch_post_request, opts)
  data
end

#v1_send_batch_post_with_http_info(idempotency_key, v1_send_batch_post_request, opts = {}) ⇒ Array<(V1SendBatchPost200Response, Integer, Hash)>

Send a batch of emails Sends up to 500 messages in one call. Each is validated and enqueued independently — a bad message fails only its own slot (partial success, HTTP 200). One `Idempotency-Key` header covers the batch; per-message keys are derived as `<key>:<index>`.

Parameters:

  • idempotency_key (String)
  • v1_send_batch_post_request (V1SendBatchPostRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    V1SendBatchPost200Response data, response status code and response headers



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/lockally/api/send_api.rb', line 312

def v1_send_batch_post_with_http_info(idempotency_key, v1_send_batch_post_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_send_batch_post ...'
  end
  # verify the required parameter 'idempotency_key' is set
  if @api_client.config.client_side_validation && idempotency_key.nil?
    fail ArgumentError, "Missing the required parameter 'idempotency_key' when calling SendApi.v1_send_batch_post"
  end
  if @api_client.config.client_side_validation && idempotency_key.to_s.length > 200
    fail ArgumentError, 'invalid value for "idempotency_key" when calling SendApi.v1_send_batch_post, the character length must be smaller than or equal to 200.'
  end

  # verify the required parameter 'v1_send_batch_post_request' is set
  if @api_client.config.client_side_validation && v1_send_batch_post_request.nil?
    fail ArgumentError, "Missing the required parameter 'v1_send_batch_post_request' when calling SendApi.v1_send_batch_post"
  end
  # resource path
  local_var_path = '/v1/send/batch'

  # 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', 'application/problem+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'] = idempotency_key

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

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

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

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_send_batch_post",
    :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: SendApi#v1_send_batch_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#v1_send_post(idempotency_key, v1_send_post_request, opts = {}) ⇒ V1SendPost202Response

Send an email Submits an email for delivery via lockally. Returns 202 immediately once the message is accepted into lockally's queue; the actual SMTP submission to the recipient is async. Track delivery via GET /v1/messages/{id} or webhook subscriptions for delivery.delivered / delivery.bounced / delivery.complaint. Idempotency-Key required. Per design L7 — any unique string per send, 24-hour dedupe window. Repeated calls with the same key return byte-exact the original response and do NOT create a duplicate message. Sender authorisation. from must be a non-disabled mailbox owned by the calling tenant on a verified domain. Sending from aliases is not yet supported. Rate cap. Per-tenant rate_cap_per_min (returned on /v1/tenant) is enforced — 429 with Retry-After: 60 once tripped. Recipient warning. Over 25 total recipients (To+Cc+Bcc) sets a warning field in the response — large fan-outs queue noticeably at scale. Hard cap is 100/send.

Parameters:

  • idempotency_key (String)
  • v1_send_post_request (V1SendPostRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



380
381
382
383
# File 'lib/lockally/api/send_api.rb', line 380

def v1_send_post(idempotency_key, v1_send_post_request, opts = {})
  data, _status_code, _headers = v1_send_post_with_http_info(idempotency_key, v1_send_post_request, opts)
  data
end

#v1_send_post_with_http_info(idempotency_key, v1_send_post_request, opts = {}) ⇒ Array<(V1SendPost202Response, Integer, Hash)>

Send an email Submits an email for delivery via lockally. Returns 202 immediately once the message is accepted into lockally's queue; the actual SMTP submission to the recipient is async. Track delivery via `GET /v1/messages/id` or webhook subscriptions for `delivery.delivered` / `delivery.bounced` / `delivery.complaint`. Idempotency-Key required. Per design L7 — any unique string per send, 24-hour dedupe window. Repeated calls with the same key return byte-exact the original response and do NOT create a duplicate message. Sender authorisation. `from` must be a non-disabled mailbox owned by the calling tenant on a verified domain. Sending from aliases is not yet supported. Rate cap. Per-tenant `rate_cap_per_min` (returned on `/v1/tenant`) is enforced — 429 with `Retry-After: 60` once tripped. Recipient warning. Over 25 total recipients (To+Cc+Bcc) sets a `warning` field in the response — large fan-outs queue noticeably at scale. Hard cap is 100/send.

Parameters:

  • idempotency_key (String)
  • v1_send_post_request (V1SendPostRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    V1SendPost202Response data, response status code and response headers



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/lockally/api/send_api.rb', line 391

def v1_send_post_with_http_info(idempotency_key, v1_send_post_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SendApi.v1_send_post ...'
  end
  # verify the required parameter 'idempotency_key' is set
  if @api_client.config.client_side_validation && idempotency_key.nil?
    fail ArgumentError, "Missing the required parameter 'idempotency_key' when calling SendApi.v1_send_post"
  end
  if @api_client.config.client_side_validation && idempotency_key.to_s.length > 255
    fail ArgumentError, 'invalid value for "idempotency_key" when calling SendApi.v1_send_post, the character length must be smaller than or equal to 255.'
  end

  # verify the required parameter 'v1_send_post_request' is set
  if @api_client.config.client_side_validation && v1_send_post_request.nil?
    fail ArgumentError, "Missing the required parameter 'v1_send_post_request' when calling SendApi.v1_send_post"
  end
  # resource path
  local_var_path = '/v1/send'

  # 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', 'application/problem+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'] = idempotency_key

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

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

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

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

  new_options = opts.merge(
    :operation => :"SendApi.v1_send_post",
    :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: SendApi#v1_send_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end