Class: BrevoRuby::TransactionalWhatsAppApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TransactionalWhatsAppApi

Returns a new instance of TransactionalWhatsAppApi.



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

def api_client
  @api_client
end

Instance Method Details

#get_whatsapp_event_report(opts = {}) ⇒ GetWhatsappEventReport

Get all your WhatsApp activity (unaggregated events) This endpoint will show the unaggregated statistics for WhatsApp activity (30 days by default if ‘startDate` and `endDate` or `days` is not passed. The date range can not exceed 90 days)

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number limitation for the result returned (default to 2500)

  • :offset (Integer)

    Beginning point in the list to retrieve from (default to 0)

  • :start_date (String)

    **Mandatory if endDate is used.** Starting date of the report (YYYY-MM-DD). Must be lower than equal to endDate

  • :end_date (String)

    **Mandatory if startDate is used.** Ending date of the report (YYYY-MM-DD). Must be greater than equal to startDate

  • :days (Integer)

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

  • :contact_number (String)

    Filter results for specific contact (WhatsApp Number with country code. Example, 85264318721)

  • :event (String)

    Filter the report for a specific event type

  • :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_whats_app_api.rb', line 44

def get_whatsapp_event_report(opts = {})
  data, _status_code, _headers = get_whatsapp_event_report_with_http_info(opts)
  data
end

#get_whatsapp_event_report_with_http_info(opts = {}) ⇒ Array<(GetWhatsappEventReport, Fixnum, Hash)>

Get all your WhatsApp activity (unaggregated events) This endpoint will show the unaggregated statistics for WhatsApp activity (30 days by default if &#x60;startDate&#x60; and &#x60;endDate&#x60; or &#x60;days&#x60; is not passed. The date range can not exceed 90 days)

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number limitation for the result returned

  • :offset (Integer)

    Beginning point in the list to retrieve from

  • :start_date (String)

    **Mandatory if endDate is used.** Starting date of the report (YYYY-MM-DD). Must be lower than equal to endDate

  • :end_date (String)

    **Mandatory if startDate is used.** Ending date of the report (YYYY-MM-DD). Must be greater than equal to startDate

  • :days (Integer)

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

  • :contact_number (String)

    Filter results for specific contact (WhatsApp Number with country code. Example, 85264318721)

  • :event (String)

    Filter the report for a specific event type

  • :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<(GetWhatsappEventReport, Fixnum, Hash)>)

    GetWhatsappEventReport 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
115
116
117
# File 'lib/brevo-ruby/api/transactional_whats_app_api.rb', line 61

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

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

  if @api_client.config.client_side_validation && opts[:'event'] && !['sent', 'delivered', 'read', 'error', 'unsubscribe', 'reply', 'soft-bounce'].include?(opts[:'event'])
    fail ArgumentError, 'invalid value for "event", must be one of sent, delivered, read, error, unsubscribe, reply, soft-bounce'
  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 = '/whatsapp/statistics/events'

  # query parameters
  query_params = {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].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[:'days'] = opts[:'days'] if !opts[:'days'].nil?
  query_params[:'contactNumber'] = opts[:'contact_number'] if !opts[:'contact_number'].nil?
  query_params[:'event'] = opts[:'event'] if !opts[:'event'].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 => 'GetWhatsappEventReport')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalWhatsAppApi#get_whatsapp_event_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_whatsapp_message(send_whatsapp_message, opts = {}) ⇒ InlineResponse2013

Send a WhatsApp message This endpoint is used to send a WhatsApp message. <br/>(**The first message you send using the API must contain a Template ID. You must create a template on WhatsApp on the Brevo platform to fetch the Template ID.**)

Parameters:

  • send_whatsapp_message

    Values to send WhatsApp message

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

    the optional parameters

Returns:



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

def send_whatsapp_message(send_whatsapp_message, opts = {})
  data, _status_code, _headers = send_whatsapp_message_with_http_info(send_whatsapp_message, opts)
  data
end

#send_whatsapp_message_with_http_info(send_whatsapp_message, opts = {}) ⇒ Array<(InlineResponse2013, Fixnum, Hash)>

Send a WhatsApp message This endpoint is used to send a WhatsApp message. &lt;br/&gt;(**The first message you send using the API must contain a Template ID. You must create a template on WhatsApp on the Brevo platform to fetch the Template ID.**)

Parameters:

  • send_whatsapp_message

    Values to send WhatsApp message

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

    the optional parameters

Returns:

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

    InlineResponse2013 data, response status code and response headers



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

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

  # 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_whatsapp_message)
  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 => 'InlineResponse2013')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TransactionalWhatsAppApi#send_whatsapp_message\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_whats_app_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