Class: Sendpost::MessageApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sendpost_ruby_sdk/api/message_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ MessageApi

Returns a new instance of MessageApi.



19
20
21
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 19

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

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



17
18
19
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_all_messages(from, to, opts = {}) ⇒ Array<Message>

List Messages Retrieve a paginated list of all email messages sent through your account. Each message includes delivery status, timestamps, and metadata. Message Information Includes: - Sender and recipient details - Subject line and message ID - Delivery status (delivered, bounced, opened, etc.) - Timestamps for each event - IP address and pool used for sending Use Cases: - Search for specific emails sent to customers - Debug delivery issues for specific recipients - Audit email delivery for compliance - Export message logs for analysis - Customer support - lookup specific email by recipient Example: Find all emails to a specific domain in the last week: GET /account/message?from=2024-01-01T00:00:00Z&to=2024-01-07T23:59:59Z Note: Maximum date range is 60 days.

Parameters:

  • from (Time) —

    Start timestamp for message retrieval. ISO 8601 format.

  • to (Time) —

    End timestamp for message retrieval. Max 60 days from `from`.

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer) —

    Number of records to return per request. Default 50, max 100. (default to 50)

  • :offset (Integer) —

    Number of initial records to skip for pagination. (default to 0)

Returns:



30
31
32
33
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 30

def get_all_messages(from, to, opts = {})
  data, _status_code, _headers = get_all_messages_with_http_info(from, to, opts)
  data
end

#get_all_messages_with_http_info(from, to, opts = {}) ⇒ Array<(Array<Message>, Integer, Hash)>

List Messages Retrieve a paginated list of all email messages sent through your account. Each message includes delivery status, timestamps, and metadata. Message Information Includes: - Sender and recipient details - Subject line and message ID - Delivery status (delivered, bounced, opened, etc.) - Timestamps for each event - IP address and pool used for sending Use Cases: - Search for specific emails sent to customers - Debug delivery issues for specific recipients - Audit email delivery for compliance - Export message logs for analysis - Customer support - lookup specific email by recipient Example: Find all emails to a specific domain in the last week: ``` GET /account/message?from=2024-01-01T00:00:00Z&to=2024-01-07T23:59:59Z ``` Note: Maximum date range is 60 days.

Parameters:

  • from (Time) —

    Start timestamp for message retrieval. ISO 8601 format.

  • to (Time) —

    End timestamp for message retrieval. Max 60 days from `from`.

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer) —

    Number of records to return per request. Default 50, max 100. (default to 50)

  • :offset (Integer) —

    Number of initial records to skip for pagination. (default to 0)

Returns:

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

    Array data, response status code and response headers



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
96
97
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 43

def get_all_messages_with_http_info(from, to, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessageApi.get_all_messages ...'
  end
  # verify the required parameter 'from' is set
  if @api_client.config.client_side_validation && from.nil?
    fail ArgumentError, "Missing the required parameter 'from' when calling MessageApi.get_all_messages"
  end
  # verify the required parameter 'to' is set
  if @api_client.config.client_side_validation && to.nil?
    fail ArgumentError, "Missing the required parameter 'to' when calling MessageApi.get_all_messages"
  end
  # resource path
  local_var_path = '/account/message'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from'] = from
  query_params[:'to'] = to
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].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] || 'Array<Message>'

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

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

#get_message_by_id(message_id, opts = {}) ⇒ Message

Get Message Retrieve complete details about a specific email message, including full event timeline and metadata. Response Includes: - Full message details (sender, recipients, subject) - Complete event timeline (submitted, sent, delivered, opened, clicked) - Bounce/drop information with reasons - IP and pool used for sending - Click and open tracking data Use Cases: - Debug why a specific email wasn't delivered - Customer support - provide delivery proof - Audit trail for compliance requirements - Analyze engagement for specific messages

Parameters:

  • message_id (String) —

    The unique message ID returned when the email was sent.

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

    the optional parameters

Returns:



104
105
106
107
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 104

def get_message_by_id(message_id, opts = {})
  data, _status_code, _headers = get_message_by_id_with_http_info(message_id, opts)
  data
end

#get_message_by_id_with_http_info(message_id, opts = {}) ⇒ Array<(Message, Integer, Hash)>

Get Message Retrieve complete details about a specific email message, including full event timeline and metadata. Response Includes: - Full message details (sender, recipients, subject) - Complete event timeline (submitted, sent, delivered, opened, clicked) - Bounce/drop information with reasons - IP and pool used for sending - Click and open tracking data Use Cases: - Debug why a specific email wasn't delivered - Customer support - provide delivery proof - Audit trail for compliance requirements - Analyze engagement for specific messages

Parameters:

  • message_id (String) —

    The unique message ID returned when the email was sent.

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

    the optional parameters

Returns:

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

    Message 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
# File 'lib/sendpost_ruby_sdk/api/message_api.rb', line 114

def get_message_by_id_with_http_info(message_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MessageApi.get_message_by_id ...'
  end
  # verify the required parameter 'message_id' is set
  if @api_client.config.client_side_validation && message_id.nil?
    fail ArgumentError, "Missing the required parameter 'message_id' when calling MessageApi.get_message_by_id"
  end
  # resource path
  local_var_path = '/account/message/{message_id}'.sub('{' + 'message_id' + '}', CGI.escape(message_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] || 'Message'

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

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