WhatsappElixir.Recipient (whatsapp_elixir v0.1.10)
View SourceHelpers for addressing a message to either a phone number or a business-scoped user ID (BSUID).
WhatsApp users who adopt a username may be identified only by a BSUID, such as
"KE.984051547420197". Parent BSUIDs look like "US.ENT.11815799212886844830".
Meta's Messages API takes a phone number in "to" and a BSUID or parent BSUID
in "recipient". If a request has both, "to" takes precedence.
All senders in this library accept either form. Anything that doesn't look like
a BSUID goes in "to" exactly as it did before.
See https://developers.facebook.com/documentation/business-messaging/whatsapp/business-scoped-user-ids/
Summary
Functions
Returns true when value looks like a BSUID or parent BSUID.
Returns the addressing fields for a message payload.
Functions
Returns true when value looks like a BSUID or parent BSUID.
Examples
iex> WhatsappElixir.Recipient.bsuid?("KE.984051547420197")
true
iex> WhatsappElixir.Recipient.bsuid?("US.ENT.11815799212886844830")
true
iex> WhatsappElixir.Recipient.bsuid?("+254700000000")
false
iex> WhatsappElixir.Recipient.bsuid?(nil)
false
Returns the addressing fields for a message payload.
A BSUID becomes %{"recipient" => bsuid}. Anything else (a phone number with or
without a leading +, or any other value) becomes %{"to" => value}, unchanged.
Examples
iex> WhatsappElixir.Recipient.fields("254700000000")
%{"to" => "254700000000"}
iex> WhatsappElixir.Recipient.fields("+254700000000")
%{"to" => "+254700000000"}
iex> WhatsappElixir.Recipient.fields("KE.984051547420197")
%{"recipient" => "KE.984051547420197"}