View Source WhatsappElixir (whatsapp_elixir v0.1.1)

WhatsappElixir is an Elixir API wrapper for interacting with the WhatsApp API.

Installation

To use WhatsappElixir in your project, add it to your mix.exs dependencies:

defp deps do
  [
    {:whatsapp_elixir, git: "git@bitbucket.org:bitfactor/whatsapp_elixir.git"}
  ]
end

Then, run mix deps.get to fetch and install the dependency.

Configuration

Configure your WhatsApp credentials in config/config.exs:

config :whatsapp_elixir,
  token: System.get_env("WHATSAPP_TOKEN"),
  phone_number_id: System.get_env("WHATSAPP_PHONE_NUMBER_ID")

Link to this section Summary

Functions

Creates a new WhatsappElixir struct with the given token and phone number ID.

Verifies if the provided token matches the expected token.

Link to this section Functions

Link to this function

new(token, phone_number_id)

View Source

Creates a new WhatsappElixir struct with the given token and phone number ID.

Parameters

  • token: The token to be used for authentication.
  • phone_number_id: The phone number ID associated with the WhatsApp account.

Examples

iex> WhatsappElixir.new("your_token", "your_phone_number_id")
%WhatsappElixir{token: "your_token", phone_number_id: "your_phone_number_id"}
Link to this function

verify_token(expected_token, provided_token)

View Source

Verifies if the provided token matches the expected token.

Parameters

  • expected_token: The token expected.
  • provided_token: The token to be verified.

Examples

iex> WhatsappElixir.verify_token("expected_token", "provided_token")
true

iex> WhatsappElixir.verify_token("expected_token", "wrong_token")
false