Nexmo Elixir Client Library

Build Statuscodecov

This is a work in progress Elixir client library for Nexmo. Functionality will be added for each Nexmo API service. Currently, this library supports:

Installation

Hex

If available in Hex, the package can be installed by adding nexmo to your list of dependencies in mix.exs:

def deps do
[
{:nexmo, "~> 0.3.0"}
]
end

Environment Variables

The client library requires environment variables to be supplied in order to enable its functionality. You can find a sample .env file in the root directory of the project. You need to supply your API credentials and the host names for the API endpoints in the .env file.

Your Nexmo API credentials:

API host names:

Usage

Account API

Get Balance

Nexmo.Account.get_balance

Docs: https://developer.nexmo.com/api/account#getAccountBalance

Top Up Balance

Nexmo.Account.top_up(trx: "transaction_reference")

Docs: https://developer.nexmo.com/api/account#topUpAccountBalance

Change Account Settings

Nexmo.Account.update(moCallBackUrl: "https://example.com/inbound", drCallBackUrl: "https://example.com/delivery")

Docs: https://developer.nexmo.com/api/account#changeAccountSettings

Retrieve API Secrets

Nexmo.Account.list_secrets

Docs: https://developer.nexmo.com/api/account#retrieveAPISecrets

Create API Secret

Nexmo.Account.create_secret(secret: "example-4PI-Secret")

Docs: https://developer.nexmo.com/api/account#createAPISecret

Retrieve one API Secret

Nexmo.Account.get_secret(secret_id: "secret_id")

Docs: https://developer.nexmo.com/api/account#retrieveAPISecret

Revoke an API Secret

Nexmo.Account.delete_secret(secret_id: "secret_id")

Docs: https://developer.nexmo.com/api/account#revokeAPISecret

Number Insight API

Basic Number Insight

Nexmo.NumberInsight.basic(number: "447700900000")

Docs: https://developer.nexmo.com/api/number-insight#getNumberInsightBasic

Standard Number Insight

Nexmo.NumberInsight.standard(number: "447700900000")

Docs: https://developer.nexmo.com/api/number-insight#getNumberInsightStandard

Advanced Number Insight

Nexmo.NumberInsight.advanced(number: "447700900000")

Docs: https://developer.nexmo.com/api/number-insight#getNumberInsightAdvanced

Advanced Number Insight Async

Nexmo.NumberInsight.advanced_async(
number: "447700900000",
callback: "https://example.com/callback"
)

Docs: https://developer.nexmo.com/api/number-insight#getNumberInsightAsync

SMS API

Send an SMS

Nexmo.Sms.send(
from: YOUR_NUMBER,
to: RECIPIENT_NUMBER,
text: "Hello world
)

Docs: https://developer.nexmo.com/api/sms#send-an-sms

Testing

The tests for Nexmo Elixir can be found in /test/. Each API service has its own testing suite and can be found in /test/#{name_of_service}, for example the SMS tests can be found in /test/sms. To run the testing suite execute mix test from the command line.

Appreciation

This project is built utilizing the wisdom and experience of earlier Nexmo Elixir projects, including from KindyNowApp, cbetta and adamrobbie. Thank you all for your examples of interacting with Nexmo using Elixir!

License

This project is licensed under the MIT License.