Class: Wavix::TenDlc::Campaigns::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/wavix/ten_dlc/campaigns/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



10
11
12
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::CreateCampaignsResponse

Registers a 10DLC Campaign under the 10DLC Brand identified by brand_id. The Brand must have a verified identity status.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)

Returns:



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
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 133

def create(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request_data = Wavix::TenDlc::Campaigns::Types::TenDlcCampaignCreateRequest.new(params).to_h
  non_body_param_names = %w[brand_id]
  body = request_data.except(*non_body_param_names)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::CreateCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::DeleteCampaignsResponse

Deletes a 10DLC Campaign. Associated phone numbers cannot be used as Sender IDs once the Campaign is deleted.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)
  • :campaign_id (String)

Returns:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 248

def delete(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns/#{URI.encode_uri_component(params[:campaign_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::DeleteCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::GetCampaignsResponse

Returns the 10DLC Campaign identified by campaign_id under the Brand identified by brand_id.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)
  • :campaign_id (String)

Returns:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 173

def get(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns/#{URI.encode_uri_component(params[:campaign_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::GetCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::ListCampaignsResponse

Returns a paginated list of 10DLC Campaigns for the authenticated account, filtered by date, status, and use case.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :name (String, nil)
  • :usecase (String, nil)
  • :status (String, nil)
  • :mock (Boolean, nil)
  • :created_before (String, nil)
  • :created_after (String, nil)
  • :page (Integer, nil)
  • :per_page (Integer, nil)

Returns:



34
35
36
37
38
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
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 34

def list(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["usecase"] = params[:usecase] if params.key?(:usecase)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["mock"] = params[:mock] if params.key?(:mock)
  query_params["created_before"] = params[:created_before] if params.key?(:created_before)
  query_params["created_after"] = params[:created_after] if params.key?(:created_after)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["per_page"] = params[:per_page] if params.key?(:per_page)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v3/10dlc/brands/campaigns",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::ListCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_by_brand(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::ListByBrandCampaignsResponse

Returns a paginated list of 10DLC Campaigns associated with the 10DLC Brand identified by brand_id.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)
  • :name (String, nil)
  • :usecase (String, nil)
  • :status (String, nil)
  • :mock (Boolean, nil)
  • :created_before (String, nil)
  • :created_after (String, nil)
  • :page (Integer, nil)
  • :per_page (Integer, nil)

Returns:



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
118
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 87

def list_by_brand(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["usecase"] = params[:usecase] if params.key?(:usecase)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["mock"] = params[:mock] if params.key?(:mock)
  query_params["created_before"] = params[:created_before] if params.key?(:created_before)
  query_params["created_after"] = params[:created_after] if params.key?(:created_after)
  query_params["page"] = params[:page] if params.key?(:page)
  query_params["per_page"] = params[:per_page] if params.key?(:per_page)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::ListByBrandCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#nudge(request_options: {}, **params) ⇒ Wavix::Types::SuccessResponse

Requests action on a pending or rejected 10DLC Campaign. Use nudge_intent to specify the action:

  • REVIEW: Request review for a pending Campaign. - APPEAL_REJECTION: Appeal a rejected Campaign. Note:
  • The Campaign must be at least 72 hours old.
  • Only one nudge request per Campaign is allowed every 24 hours.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)
  • :campaign_id (String)

Returns:



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 287

def nudge(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request_data = Wavix::TenDlc::Campaigns::Types::NudgeCampaignsRequest.new(params).to_h
  non_body_param_names = %w[brand_id campaign_id]
  body = request_data.except(*non_body_param_names)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns/#{URI.encode_uri_component(params[:campaign_id].to_s)}/nudge",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::Types::SuccessResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ Wavix::TenDlc::Campaigns::Types::UpdateCampaignsResponse

Updates the 10DLC Campaign identified by campaign_id. Only the provided fields are changed.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :brand_id (String)
  • :campaign_id (String)

Returns:



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
# File 'lib/wavix/ten_dlc/campaigns/client.rb', line 208

def update(request_options: {}, **params)
  params = Wavix::Internal::Types::Utils.normalize_keys(params)
  request_data = Wavix::TenDlc::Campaigns::Types::TenDlcCampaignUpdateRequest.new(params).to_h
  non_body_param_names = %w[brand_id campaign_id]
  body = request_data.except(*non_body_param_names)

  request = Wavix::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "v3/10dlc/brands/#{URI.encode_uri_component(params[:brand_id].to_s)}/campaigns/#{URI.encode_uri_component(params[:campaign_id].to_s)}",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Wavix::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Wavix::TenDlc::Campaigns::Types::UpdateCampaignsResponse.load(response.body)
  else
    error_class = Wavix::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end