Class: Sendmux::Sending::Generated::EmailsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sendmux_sending_generated/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/sendmux_sending_generated/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/sendmux_sending_generated/api/emails_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#sending_send_email(email_send_request, opts = {}) ⇒ SendSuccessResponse

Send a single email Queue a single email for delivery. Requires email.send permission.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.

Returns:



28
29
30
31
# File 'lib/sendmux_sending_generated/api/emails_api.rb', line 28

def sending_send_email(email_send_request, opts = {})
  data, _status_code, _headers = sending_send_email_with_http_info(email_send_request, opts)
  data
end

#sending_send_email_batch(batch_send_request, opts = {}) ⇒ BatchSendSuccessResponse

Send a batch of emails Queue up to 100 emails for delivery in a single request. Uses partial success model — individual message failures do not fail the entire batch. Requires email.send permission.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.

Returns:



103
104
105
106
# File 'lib/sendmux_sending_generated/api/emails_api.rb', line 103

def sending_send_email_batch(batch_send_request, opts = {})
  data, _status_code, _headers = sending_send_email_batch_with_http_info(batch_send_request, opts)
  data
end

#sending_send_email_batch_with_http_info(batch_send_request, opts = {}) ⇒ Array<(BatchSendSuccessResponse, Integer, Hash)>

Send a batch of emails Queue up to 100 emails for delivery in a single request. Uses partial success model — individual message failures do not fail the entire batch. Requires `email.send` permission.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.

Returns:

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

    BatchSendSuccessResponse 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
# File 'lib/sendmux_sending_generated/api/emails_api.rb', line 114

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

  # resource path
  local_var_path = '/emails/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']) 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(batch_send_request)

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

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

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

#sending_send_email_with_http_info(email_send_request, opts = {}) ⇒ Array<(SendSuccessResponse, Integer, Hash)>

Send a single email Queue a single email for delivery. Requires `email.send` permission.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.

Returns:

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

    SendSuccessResponse data, response status code and response headers



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
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/sendmux_sending_generated/api/emails_api.rb', line 39

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

  # resource path
  local_var_path = '/emails/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']) 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(email_send_request)

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

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

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