Class: BrevoRuby::TransactionalSMSApi

Inherits:
Object
  • Object
show all
Defined in:
lib/brevo-ruby/api/transactional_sms_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TransactionalSMSApi

Returns a new instance of TransactionalSMSApi.



19
20
21
# File 'lib/brevo-ruby/api/transactional_sms_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/brevo-ruby/api/transactional_sms_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_sms_events(opts = {}) ⇒ GetSmsEventReport

Get all your SMS activity (unaggregated events)

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents per page (default to 50)

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :offset (Integer)

    Index of the first document of the page (default to 0)

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with 'startDate' and 'endDate'

  • :phone_number (String)

    Filter the report for a specific phone number

  • :event (String)

    Filter the report for specific events

  • :tags (String)

    Filter the report for specific tags passed as a serialized urlencoded array

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if `sort` is not passed (default to desc)

Returns:



44
45
46
47
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 44

def get_sms_events(opts = {})
  data, _status_code, _headers = get_sms_events_with_http_info(opts)
  data
end

#get_sms_events_with_http_info(opts = {}) ⇒ Array<(GetSmsEventReport, Fixnum, Hash)>

Get all your SMS activity (unaggregated events)

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents per page

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :offset (Integer)

    Index of the first document of the page

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with &#39;startDate&#39; and &#39;endDate&#39;

  • :phone_number (String)

    Filter the report for a specific phone number

  • :event (String)

    Filter the report for specific events

  • :tags (String)

    Filter the report for specific tags passed as a serialized urlencoded array

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed

Returns:

  • (Array<(GetSmsEventReport, Fixnum, Hash)>)

    GetSmsEventReport data, response status code and response headers



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
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 61

def get_sms_events_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionalSMSApi.get_sms_events ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling TransactionalSMSApi.get_sms_events, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && opts[:'event'] && !['bounces', 'hardBounces', 'softBounces', 'delivered', 'sent', 'accepted', 'unsubscription', 'replies', 'blocked', 'rejected'].include?(opts[:'event'])
    fail ArgumentError, 'invalid value for "event", must be one of bounces, hardBounces, softBounces, delivered, sent, accepted, unsubscription, replies, blocked, rejected'
  end
  if @api_client.config.client_side_validation && opts[:'sort'] && !['asc', 'desc'].include?(opts[:'sort'])
    fail ArgumentError, 'invalid value for "sort", must be one of asc, desc'
  end
  # resource path
  local_var_path = '/transactionalSMS/statistics/events'

  # query parameters
  query_params = {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?
  query_params[:'phoneNumber'] = opts[:'phone_number'] if !opts[:'phone_number'].nil?
  query_params[:'event'] = opts[:'event'] if !opts[:'event'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetSmsEventReport')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalSMSApi#get_sms_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_transac_aggregated_sms_report(opts = {}) ⇒ GetTransacAggregatedSmsReport

Get your SMS activity aggregated over a period of time

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with startDate and endDate

  • :tag (String)

    Filter on a tag

Returns:



122
123
124
125
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 122

def get_transac_aggregated_sms_report(opts = {})
  data, _status_code, _headers = get_transac_aggregated_sms_report_with_http_info(opts)
  data
end

#get_transac_aggregated_sms_report_with_http_info(opts = {}) ⇒ Array<(GetTransacAggregatedSmsReport, Fixnum, Hash)>

Get your SMS activity aggregated over a period of time

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with startDate and endDate

  • :tag (String)

    Filter on a tag

Returns:



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
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 134

def get_transac_aggregated_sms_report_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionalSMSApi.get_transac_aggregated_sms_report ...'
  end
  # resource path
  local_var_path = '/transactionalSMS/statistics/aggregatedReport'

  # query parameters
  query_params = {}
  query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetTransacAggregatedSmsReport')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalSMSApi#get_transac_aggregated_sms_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_transac_sms_report(opts = {}) ⇒ GetTransacSmsReport

Get your SMS activity aggregated per day

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with &#39;startDate&#39; and &#39;endDate&#39;

  • :tag (String)

    Filter on a tag

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed (default to desc)

Returns:



181
182
183
184
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 181

def get_transac_sms_report(opts = {})
  data, _status_code, _headers = get_transac_sms_report_with_http_info(opts)
  data
end

#get_transac_sms_report_with_http_info(opts = {}) ⇒ Array<(GetTransacSmsReport, Fixnum, Hash)>

Get your SMS activity aggregated per day

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :start_date (String)

    Mandatory if endDate is used. Starting date (YYYY-MM-DD) of the report

  • :end_date (String)

    Mandatory if startDate is used. Ending date (YYYY-MM-DD) of the report

  • :days (Integer)

    Number of days in the past including today (positive integer). Not compatible with &#39;startDate&#39; and &#39;endDate&#39;

  • :tag (String)

    Filter on a tag

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed

Returns:

  • (Array<(GetTransacSmsReport, Fixnum, Hash)>)

    GetTransacSmsReport data, response status code and response headers



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
228
229
230
231
232
233
234
235
236
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 194

def get_transac_sms_report_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TransactionalSMSApi.get_transac_sms_report ...'
  end
  if @api_client.config.client_side_validation && opts[:'sort'] && !['asc', 'desc'].include?(opts[:'sort'])
    fail ArgumentError, 'invalid value for "sort", must be one of asc, desc'
  end
  # resource path
  local_var_path = '/transactionalSMS/statistics/reports'

  # query parameters
  query_params = {}
  query_params[:'startDate'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'endDate'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'GetTransacSmsReport')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalSMSApi#get_transac_sms_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_transac_sms(send_transac_sms, opts = {}) ⇒ SendSms

Send SMS message to a mobile number

Parameters:

  • send_transac_sms

    Values to send a transactional SMS

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

    the optional parameters

Returns:



241
242
243
244
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 241

def send_transac_sms(send_transac_sms, opts = {})
  data, _status_code, _headers = send_transac_sms_with_http_info(send_transac_sms, opts)
  data
end

#send_transac_sms_with_http_info(send_transac_sms, opts = {}) ⇒ Array<(SendSms, Fixnum, Hash)>

Send SMS message to a mobile number

Parameters:

  • send_transac_sms

    Values to send a transactional SMS

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

    the optional parameters

Returns:

  • (Array<(SendSms, Fixnum, Hash)>)

    SendSms data, response status code and response headers



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
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 250

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

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(send_transac_sms)
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SendSms')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalSMSApi#send_transac_sms\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#setUserAgent(user_agent) ⇒ Object

Set custom user_agent if explicitly passed in api default will still remain Swagger-Codegen/#VERSION/ruby



25
26
27
28
29
30
# File 'lib/brevo-ruby/api/transactional_sms_api.rb', line 25

def setUserAgent(user_agent)
  @user_agent = user_agent
  if user_agent.is_a?(String) && user_agent.downcase.start_with?('brevo_')
    @api_client.default_headers['User-Agent'] = @user_agent
  end
end