Class: Sentdm::Resources::Profiles

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

Overview

Manage organization profiles

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Profiles

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 Profiles.

Parameters:



250
251
252
# File 'lib/sentdm/resources/profiles.rb', line 250

def initialize(client:)
  @client = client
end

Instance Method Details

#complete(profile_id, web_hook_url:, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Object

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

Final step in profile compliance workflow. Validates all prerequisites (general data, brand, campaigns), connects profile to Telnyx/WhatsApp, and sets status based on configuration. The process runs in the background and calls the provided webhook URL when finished.

Prerequisites:
- Profile must be completed
- If inheritTcrBrand=false: Profile must have existing brand
- If inheritTcrBrand=true: Parent must have existing brand
- If TCR application: Must have at least one campaign (own or inherited)
- If inheritTcrCampaign=false: Profile should have campaigns
- If inheritTcrCampaign=true: Parent must have campaigns

Status Logic:
- If both SMS and WhatsApp channels are missing → SUBMITTED
- If TCR application and not inheriting brand/campaigns → SUBMITTED
- If non-TCR with destination country (IsMain=true) → SUBMITTED
- Otherwise → COMPLETED

Parameters:

  • profile_id (String)

    Path param: Profile ID from route

  • web_hook_url (String)

    Body param: Webhook URL to call when profile completion finishes (success or fai

  • 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:

  • (Object)

See Also:



234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/sentdm/resources/profiles.rb', line 234

def complete(profile_id, params)
  parsed, options = Sentdm::ProfileCompleteParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: ["v3/profiles/%1$s/complete", profile_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Internal::Type::Unknown,
    options: options
  )
end

#create(allow_contact_sharing: nil, allow_template_sharing: nil, billing_model: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, short_name: nil, test_mode: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail

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

Creates a new sender profile within an organization. Profiles represent different brands, departments, or use cases, each with their own messaging configuration and settings. Requires admin role in the organization.

Parameters:

  • allow_contact_sharing (Boolean)

    Body param: Whether contacts are shared across profiles (default: false)

  • allow_template_sharing (Boolean)

    Body param: Whether templates are shared across profiles (default: false)

  • billing_model (String, nil)

    Body param: Billing model: profile, organization, or profile_and_organization (d

  • description (String, nil)

    Body param: Profile description (optional)

  • icon (String, nil)

    Body param: Profile icon URL (optional)

  • inherit_contacts (Boolean, nil)

    Body param: Whether this profile inherits contacts from organization (default: t

  • inherit_tcr_brand (Boolean, nil)

    Body param: Whether this profile inherits TCR brand from organization (default:

  • inherit_tcr_campaign (Boolean, nil)

    Body param: Whether this profile inherits TCR campaign from organization (defaul

  • inherit_templates (Boolean, nil)

    Body param: Whether this profile inherits templates from organization (default:

  • name (String)

    Body param: Profile name (required)

  • short_name (String, nil)

    Body param: Profile short name/abbreviation (optional)

  • 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:



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sentdm/resources/profiles.rb', line 47

def create(params = {})
  parsed, options = Sentdm::ProfileCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "v3/profiles",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseOfProfileDetail,
    options: options
  )
end

#delete(path_profile_id, body_profile_id: nil, test_mode: nil, request_options: {}) ⇒ nil

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

Soft deletes a sender profile. The profile will be marked as deleted but data is retained. Requires admin role in the organization.

Parameters:

  • path_profile_id (String)
  • body_profile_id (String)

    Profile ID from route parameter

  • test_mode (Boolean)

    Test mode flag - when true, the operation is simulated without side effects

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

Returns:

  • (nil)

See Also:



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/sentdm/resources/profiles.rb', line 185

def delete(path_profile_id, params = {})
  parsed, options = Sentdm::ProfileDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["v3/profiles/%1$s", path_profile_id],
    headers: {"content-type" => "*/*"},
    body: parsed,
    model: NilClass,
    options: options
  )
end

#list(request_options: {}) ⇒ Sentdm::Models::ProfileListResponse

Retrieves all sender profiles within an organization. Profiles represent different brands, departments, or use cases within an organization, each with their own messaging configuration.

Parameters:

Returns:

See Also:



157
158
159
160
161
162
163
164
# File 'lib/sentdm/resources/profiles.rb', line 157

def list(params = {})
  @client.request(
    method: :get,
    path: "v3/profiles",
    model: Sentdm::Models::ProfileListResponse,
    options: params[:request_options]
  )
end

#retrieve(profile_id, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail

Retrieves detailed information about a specific sender profile within an organization.

Parameters:

Returns:

See Also:



71
72
73
74
75
76
77
78
# File 'lib/sentdm/resources/profiles.rb', line 71

def retrieve(profile_id, params = {})
  @client.request(
    method: :get,
    path: ["v3/profiles/%1$s", profile_id],
    model: Sentdm::APIResponseOfProfileDetail,
    options: params[:request_options]
  )
end

#update(path_profile_id, allow_contact_sharing: nil, allow_number_change_during_onboarding: nil, allow_template_sharing: nil, billing_model: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, body_profile_id: nil, sending_phone_number: nil, sending_phone_number_profile_id: nil, sending_whatsapp_number_profile_id: nil, short_name: nil, test_mode: nil, whatsapp_phone_number: nil, idempotency_key: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail

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

Updates a profile’s configuration and settings. Requires admin role in the organization. Only provided fields will be updated (partial update).

Parameters:

  • path_profile_id (String)

    Path param

  • allow_contact_sharing (Boolean, nil)

    Body param: Whether contacts are shared across profiles (optional)

  • allow_number_change_during_onboarding (Boolean, nil)

    Body param: Whether number changes are allowed during onboarding (optional)

  • allow_template_sharing (Boolean, nil)

    Body param: Whether templates are shared across profiles (optional)

  • billing_model (String, nil)

    Body param: Billing model: profile, organization, or profile_and_organization (o

  • description (String, nil)

    Body param: Profile description (optional)

  • icon (String, nil)

    Body param: Profile icon URL (optional)

  • inherit_contacts (Boolean, nil)

    Body param: Whether this profile inherits contacts from organization (optional)

  • inherit_tcr_brand (Boolean, nil)

    Body param: Whether this profile inherits TCR brand from organization (optional)

  • inherit_tcr_campaign (Boolean, nil)

    Body param: Whether this profile inherits TCR campaign from organization (option

  • inherit_templates (Boolean, nil)

    Body param: Whether this profile inherits templates from organization (optional)

  • name (String, nil)

    Body param: Profile name (optional)

  • body_profile_id (String)

    Body param: Profile ID from route parameter

  • sending_phone_number (String, nil)

    Body param: Direct phone number for SMS sending (optional)

  • sending_phone_number_profile_id (String, nil)

    Body param: Reference to another profile to use for SMS/Telnyx configuration (op

  • sending_whatsapp_number_profile_id (String, nil)

    Body param: Reference to another profile to use for WhatsApp configuration (opti

  • short_name (String, nil)

    Body param: Profile short name/abbreviation (optional)

  • test_mode (Boolean)

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

  • whatsapp_phone_number (String, nil)

    Body param: Direct phone number for WhatsApp sending (optional)

  • 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:



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/sentdm/resources/profiles.rb', line 133

def update(path_profile_id, params = {})
  parsed, options = Sentdm::ProfileUpdateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :patch,
    path: ["v3/profiles/%1$s", path_profile_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseOfProfileDetail,
    options: options
  )
end