Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues in twilio API docs #204

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
## Overview

The Twilio API provides capability to access its platform for communications. These APIs connects the software layer and
communications networks around the world to allow users to call and message anyone, globally.
The Twilio API provides the capability to access its platform for communications. These APIs connect the software layer and
communications networks around the world to allow users to call and message anyone globally.

This module supports [Twilio Basic API version 2010-04-01](https://www.twilio.com/docs/all).
This package supports [Twilio Basic API version 2010-04-01](https://www.twilio.com/docs/all).

## Prerequisites
Before using this connector in your Ballerina application, complete the following:

* Create a [Twilio account](https://www.twilio.com/).
* Obtain tokens as follows:
Before using this connector in your Ballerina application, complete the following:

1. Create a Twilio account.
1. Create a [Twilio account](https://www.twilio.com/).

2. Obtain a [Twilio phone number](https://support.twilio.com/hc/en-us/articles/223136107-How-does-Twilio-s-Free-Trial-work-).

!!! Tip

If you use a trail account, you may need to verify your recipient phone numbers before having any communication with them.
>**Tip:** If you use a trial account, you may need to verify your recipient's phone numbers before having any communication with them.

3. Obtain a [Twilio Account Auth Token](https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them).

Expand All @@ -27,38 +23,44 @@ If you use a trail account, you may need to verify your recipient phone numbers

# Quickstart

To use the Twilio connector in your Ballerina application, update the .bal file as follows:
To use the Twilio connector in your Ballerina application, update the `.bal` file as follows:

### Step 1 - Import connector
Import the Twilio module to your Ballerina program as follows. You can use [configurable variables](https://ballerina.io/learn/by-example/configurable.html) to provide the necessary credentials.
### Step 1 - Import the package

Import the Twilio package to your Ballerina program as follows. You can use [configurable variables](https://ballerina.io/learn/by-example/configurable.html) to provide the necessary credentials.

```ballerina
import ballerinax/twilio;
```

### Step 2 - Create a new connector instance

To create a new connector instance, add a configuration as follows:

```ballerina
configurable string accountSId = ?;
configurable string authToken = ?;

twilio:ConnectionConfig twilioConfig = {
auth: {
accountSId: accountSId,
authToken: authToken
accountSId,
authToken
}
};

twilio:Client twilioClient = new (twilioConfig);
twilio:Client twilio = new (twilioConfig);
```

### Step 3 - Invoke connector operation

1. Invoke the connector operation using the client as follows:

```ballerina
public function main() returns error? {
twilio:Account response = check twilioClient->getAccountDetails();
twilio:Account response = check twilio->getAccountDetails();
}
```

2. Use `bal run` command to compile and run the Ballerina program.

**[You can find more samples here](https://github.com/ballerina-platform/module-ballerinax-twilio/tree/master/twilio/samples)**