Class: Sentdm::Resources::Profiles
- Inherits:
-
Object
- Object
- Sentdm::Resources::Profiles
- Defined in:
- lib/sentdm/resources/profiles.rb,
lib/sentdm/resources/profiles/campaigns.rb
Overview
Manage organization profiles
Defined Under Namespace
Classes: Campaigns
Instance Attribute Summary collapse
-
#campaigns ⇒ Sentdm::Resources::Profiles::Campaigns
readonly
Manage organization profiles.
Instance Method Summary collapse
-
#complete(profile_id, web_hook_url:, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Object
Some parameter documentations has been truncated, see Models::ProfileCompleteParams for more details.
-
#create(allow_contact_sharing: nil, allow_template_sharing: nil, billing_contact: nil, billing_model: nil, brand: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, payment_details: nil, sandbox: nil, short_name: nil, whatsapp_business_account: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail
Some parameter documentations has been truncated, see Models::ProfileCreateParams for more details.
-
#delete(profile_id, body:, x_profile_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ProfileDeleteParams for more details.
-
#initialize(client:) ⇒ Profiles
constructor
private
A new instance of Profiles.
-
#list(x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::ProfileListResponse
Some parameter documentations has been truncated, see Models::ProfileListParams for more details.
-
#retrieve(profile_id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail
Some parameter documentations has been truncated, see Models::ProfileRetrieveParams for more details.
-
#update(profile_id, allow_contact_sharing: nil, allow_number_change_during_onboarding: nil, allow_template_sharing: nil, billing_contact: nil, billing_model: nil, brand: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, payment_details: nil, sandbox: nil, sending_phone_number: nil, sending_phone_number_profile_id: nil, sending_whatsapp_number_profile_id: nil, short_name: nil, whatsapp_phone_number: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail
Some parameter documentations has been truncated, see Models::ProfileUpdateParams for more details.
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.
338 339 340 341 |
# File 'lib/sentdm/resources/profiles.rb', line 338 def initialize(client:) @client = client @campaigns = Sentdm::Resources::Profiles::Campaigns.new(client: client) end |
Instance Attribute Details
#campaigns ⇒ Sentdm::Resources::Profiles::Campaigns (readonly)
Manage organization profiles
9 10 11 |
# File 'lib/sentdm/resources/profiles.rb', line 9 def campaigns @campaigns end |
Instance Method Details
#complete(profile_id, web_hook_url:, sandbox: nil, idempotency_key: nil, x_profile_id: 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
322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/sentdm/resources/profiles.rb', line 322 def complete(profile_id, params) parsed, = Sentdm::ProfileCompleteParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"} @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: ) end |
#create(allow_contact_sharing: nil, allow_template_sharing: nil, billing_contact: nil, billing_model: nil, brand: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, payment_details: nil, sandbox: nil, short_name: nil, whatsapp_business_account: nil, idempotency_key: nil, x_profile_id: 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.
## WhatsApp Business Account
Every profile must be linked to a WhatsApp Business Account. There are two ways to do this:
**1. Inherit from organization (default)** — Omit the ‘whatsapp_business_account` field. The profile will share the organization’s WhatsApp Business Account, which must have been set up via WhatsApp Embedded Signup. This is the recommended path for most use cases.
**2. Direct credentials** — Provide a ‘whatsapp_business_account` object with `waba_id`, `phone_number_id`, and `access_token`. Use this when the profile needs its own independent WhatsApp Business Account. Obtain these from Meta Business Manager by creating a System User with `whatsapp_business_messaging` and `whatsapp_business_management` permissions.
If the ‘whatsapp_business_account` field is omitted and the organization has no WhatsApp Business Account configured, the request will be rejected with HTTP 422.
## Brand
Include the optional ‘brand` field to create the brand for this profile at the same time. Cannot be used when `inherit_tcr_brand` is `true`.
## Payment Details
When ‘billing_model` is `“profile”` or `“profile_and_organization”` you may include a `payment_details` object containing the card number, expiry (MM/YY), CVC, and billing ZIP code. Payment details are **never stored** on our servers and are forwarded directly to the payment processor. Providing `payment_details` when `billing_model` is `“organization”` is not allowed.
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/sentdm/resources/profiles.rb', line 94 def create(params = {}) parsed, = Sentdm::ProfileCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"} @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: ) end |
#delete(profile_id, body:, x_profile_id: 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.
271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/sentdm/resources/profiles.rb', line 271 def delete(profile_id, params) parsed, = Sentdm::ProfileDeleteParams.dump_request(params) @client.request( method: :delete, path: ["v3/profiles/%1$s", profile_id], headers: parsed.except(:body).transform_keys(x_profile_id: "x-profile-id"), body: parsed[:body], model: NilClass, options: ) end |
#list(x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::ProfileListResponse
Some parameter documentations has been truncated, see Models::ProfileListParams for more details.
Retrieves all sender profiles within an organization, including brand information for each profile. Profiles represent different brands, departments, or use cases within an organization, each with their own messaging configuration.
241 242 243 244 245 246 247 248 249 250 |
# File 'lib/sentdm/resources/profiles.rb', line 241 def list(params = {}) parsed, = Sentdm::ProfileListParams.dump_request(params) @client.request( method: :get, path: "v3/profiles", headers: parsed.transform_keys(x_profile_id: "x-profile-id"), model: Sentdm::Models::ProfileListResponse, options: ) end |
#retrieve(profile_id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseOfProfileDetail
Some parameter documentations has been truncated, see Models::ProfileRetrieveParams for more details.
Retrieves detailed information about a specific sender profile within an organization, including brand and KYC information if a brand has been configured.
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/sentdm/resources/profiles.rb', line 125 def retrieve(profile_id, params = {}) parsed, = Sentdm::ProfileRetrieveParams.dump_request(params) @client.request( method: :get, path: ["v3/profiles/%1$s", profile_id], headers: parsed.transform_keys(x_profile_id: "x-profile-id"), model: Sentdm::APIResponseOfProfileDetail, options: ) end |
#update(profile_id, allow_contact_sharing: nil, allow_number_change_during_onboarding: nil, allow_template_sharing: nil, billing_contact: nil, billing_model: nil, brand: nil, description: nil, icon: nil, inherit_contacts: nil, inherit_tcr_brand: nil, inherit_tcr_campaign: nil, inherit_templates: nil, name: nil, payment_details: nil, sandbox: nil, sending_phone_number: nil, sending_phone_number_profile_id: nil, sending_whatsapp_number_profile_id: nil, short_name: nil, whatsapp_phone_number: nil, idempotency_key: nil, x_profile_id: 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).
## Brand Management
Include the optional ‘brand` field to create or update the brand associated with this profile. The brand holds KYC and TCR compliance data (legal business info, contact details, messaging vertical). Once a brand has been submitted to TCR it cannot be modified. Setting `inherit_tcr_brand: true` and providing `brand` in the same request is not allowed.
## Payment Details
When ‘billing_model` is `“profile”` or `“profile_and_organization”` you may include a `payment_details` object containing the card number, expiry (MM/YY), CVC, and billing ZIP code. Payment details are **never stored** on our servers and are forwarded directly to the payment processor. Providing `payment_details` when `billing_model` is `“organization”` is not allowed.
211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/sentdm/resources/profiles.rb', line 211 def update(profile_id, params = {}) parsed, = Sentdm::ProfileUpdateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"} @client.request( method: :patch, path: ["v3/profiles/%1$s", profile_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Sentdm::APIResponseOfProfileDetail, options: ) end |