Class: Sentdm::Resources::Brands::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/sentdm/resources/brands/campaigns.rb

Overview

Register and manage 10DLC brands for SMS compliance

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Campaigns

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Campaigns.

Parameters:



139
140
141
# File 'lib/sentdm/resources/brands/campaigns.rb', line 139

def initialize(client:)
  @client = client
end

Instance Method Details

#create(brand_id, campaign:, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::Brands::APIResponseTcrCampaignWithUseCases

Some parameter documentations has been truncated, see Models::Brands::CampaignCreateParams for more details.

Creates a new campaign scoped under a specific brand. The campaign is linked to the specified brand. Each campaign must include at least one use case with sample messages.

Parameters:

  • brand_id (String)

    Path param: Brand ID from route

  • campaign (Sentdm::Models::Brands::CampaignData)

    Body param: Campaign data

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sentdm/resources/brands/campaigns.rb', line 30

def create(brand_id, params)
  parsed, options = Sentdm::Brands::CampaignCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: ["v3/brands/%1$s/campaigns", brand_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Brands::APIResponseTcrCampaignWithUseCases,
    options: options
  )
end

#delete(campaign_id, brand_id:, body:, request_options: {}) ⇒ nil

Deletes a campaign by ID within a specific brand. The brand must belong to the authenticated customer.

Parameters:

Returns:

  • (nil)

See Also:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/sentdm/resources/brands/campaigns.rb', line 120

def delete(campaign_id, params)
  parsed, options = Sentdm::Brands::CampaignDeleteParams.dump_request(params)
  brand_id =
    parsed.delete(:brand_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v3/brands/%1$s/campaigns/%2$s", brand_id, campaign_id],
    headers: {"content-type" => "*/*"},
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#list(brand_id, request_options: {}) ⇒ Sentdm::Models::Brands::CampaignListResponse

Retrieves all campaigns linked to a specific brand, including their use cases and sample messages.

Parameters:

  • brand_id (String)

    Brand ID from route

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



95
96
97
98
99
100
101
102
# File 'lib/sentdm/resources/brands/campaigns.rb', line 95

def list(brand_id, params = {})
  @client.request(
    method: :get,
    path: ["v3/brands/%1$s/campaigns", brand_id],
    model: Sentdm::Models::Brands::CampaignListResponse,
    options: params[:request_options]
  )
end

#update(campaign_id, brand_id:, campaign:, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::Brands::APIResponseTcrCampaignWithUseCases

Some parameter documentations has been truncated, see Models::Brands::CampaignUpdateParams for more details.

Updates an existing campaign scoped under a specific brand. Cannot update campaigns that have already been submitted to TCR.

Parameters:

  • campaign_id (String)

    Path param: Campaign ID from route

  • brand_id (String)

    Path param: Brand ID from route

  • campaign (Sentdm::Models::Brands::CampaignData)

    Body param: Campaign data

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sentdm/resources/brands/campaigns.rb', line 66

def update(campaign_id, params)
  parsed, options = Sentdm::Brands::CampaignUpdateParams.dump_request(params)
  brand_id =
    parsed.delete(:brand_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :put,
    path: ["v3/brands/%1$s/campaigns/%2$s", brand_id, campaign_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Brands::APIResponseTcrCampaignWithUseCases,
    options: options
  )
end