Skip to content

Updated SDK to 1.8 #2

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: validate-pr
on: pull_request

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: "Checkout Project"
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: "Docker run test"
env: # Or as an environment variable
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PHONE_NO: ${{ secrets.PHONE_NO }}
FROM_ALIAS: ${{ secrets.FROM_ALIAS }}
run: docker-compose up --build --exit-code-from telstradev
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
AllCops:
TargetRubyVersion: 2.2
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Expand Down Expand Up @@ -46,7 +46,7 @@ Layout/EmptyLinesAroundMethodBody:
Layout/EmptyLinesAroundModuleBody:
Enabled: true

Layout/FirstParameterIndentation:
Layout/IndentFirstArgument:
Enabled: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Expand Down
14 changes: 14 additions & 0 deletions DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ruby:2.7.0

WORKDIR /app
COPY . .

RUN bundle install --verbose

RUN rake

RUN gem build Telstra_Messaging.gemspec

RUN gem install ./Telstra_Messaging-1.0.8.gem

CMD ["ruby", "backward-compat-test.rb"]
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ gemspec

group :development, :test do
gem 'rake', '~> 12.0.0'
gem 'pry-byebug'
gem 'rubocop', '~> 0.66.0'
end
176 changes: 27 additions & 149 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,149 +2,13 @@

Telstra_Messaging - the Ruby gem for the Telstra Messaging API

The Telstra Messaging API specification

# Introduction


# Features

The Telstra Messaging API provides the features below.
| Feature | Description |
| --- | --- |
| `Dedicated Number` | Provision a mobile number for your account to be used as `from` address in the API |
| `Send Messages` | Sending SMS or MMS messages |
| `Receive Messages` | Telstra will deliver messages sent to a dedicated number or to the `notifyURL` defined by you |
| `Broadcast Messages` | Invoke a single API call to send a message to a list of numbers provided in `to` |
| `Delivery Status` | Query the delivery status of your messages |
| `Callbacks` | Provide a notification URL and Telstra will notify your app when a message status changes |
| `Alphanumeric Identifier` | Differentiate yourself by providing an alphanumeric string in `from`. This feature is only available on paid plans |
| `Concatenation` | Send messages up to 1900 characters long and Telstra will automaticaly segment and reassemble them |
| `Reply Request` | Create a chat session by associating `messageId` and `to` number to track responses received from a mobile number. We will store this association for 8 days |
| `Character set` | Accepts all Unicode characters as part of UTF-8 |
| `Bounce-back response` | See if your SMS hits an unreachable or unallocated number (Australia Only) |
| `Queuing` | Messaging API will automatically queue and deliver each message at a compliant rate. |
| `Emoji Encoding` | The API supports the encoding of the full range of emojis. Emojis in the reply messages will be in their UTF-8 format. |

## Delivery Notification or Callbacks

The API provides several methods for notifying when a message has been delivered to the destination.

1. When you send a message there is an opportunity to specify a `notifyURL`. Once the message has been delivered the API will make a call to this URL to advise of the message status.
2. If you do not specify a URL you can always call the `GET /status` API to get the status of the message.

# Getting Access to the API

1. Register at [https://dev.telstra.com](https://dev.telstra.com).
2. After registration, login to [https://dev.telstra.com](https://dev.telstra.com) and navigate to the **My apps** page.
3. Create your application by clicking the **Add new app** button
4. Select **API Free Trial** Product when configuring your application. This Product includes the Telstra Messaging API as well as other free trial APIs. Your application will be approved automatically.
5. There is a maximum of 1000 free messages per developer. Additional messages and features can be purchased from [https://dev.telstra.com](https://dev.telstra.com).
6. Note your `Client key` and `Client secret` as these will be needed to provision a number for your application and for authentication.

Now head over to **Getting Started** where you can find a postman collection as well as some links to sample apps and SDKs to get you started.

Happy Messaging!

# Frequently Asked Questions

**Q: Is creating a subscription via the Provisioning call a required step?**

A. Yes. You will only be able to start sending messages if you have a provisioned dedicated number. Use Provisioning to create a dedicated number subscription, or renew your dedicated number if it has expired.

**Q: When trying to send an SMS I receive a `400 Bad Request` response. How can I fix this?**

A. You need to make sure you have a provisioned dedicated number before you can send an SMS.
If you do not have a provisioned dedicated number and you try to send a message via the API, you will get the error below in the response:

<pre><code class=\"language-sh\">{
\"status\":\"400\",
\"code\":\"DELIVERY-IMPOSSIBLE\",
\"message\":\"Invalid \\'from\\' address specified\"
}</code></pre>

Use Provisioning to create a dedicated number subscription, or renew your dedicated number if it has expired.

**Q: How long does my dedicated number stay active for?**

A. When you provision a dedicated number, by default it will be active for 30 days.
You can use the `activeDays` parameter during the provisioning call to increment or decrement the number of days your dedicated number will remain active.

Note that Free Trial apps will have 30 days as the maximum `activeDays` they can add to their provisioned number. If the Provisioning call is made several times within that 30-Day period, it will return the `expiryDate` in the Unix format and will not add any activeDays until after that `expiryDate`.

**Q: Can I send a broadcast message using the Telstra Messaging API?**

A. Yes. Recipient numbers can be in the form of an array of strings if a broadcast message needs to be sent, allowing you to send to multiple mobile numbers in one API call.
A sample request body for this will be: `{\"to\":[\"+61412345678\",\"+61487654321\"],\"body\":\"Test Message\"}`

**Q: Can I send SMS and MMS to all countries?**

A. You can send SMS and MMS to all countries EXCEPT to countries which are subject to global sanctions namely: Burma, Côte d'Ivoire, Cuba, Iran, North Korea, Syria.

**Q: Can I use `Alphanumeric Identifier` from my paid plan via credit card?**

A. `Alphanumeric Identifier` is only available on Telstra Account paid plans, not through credit card paid plans.

**Q: What is the maximum sized MMS that I can send?**

A. This will depend on the carrier that will receive the MMS. For Telstra it's up to 2MB, Optus up to 1.5MB and Vodafone only allows up to 500kB. You will need to check with international carriers for thier MMS size limits.

**Q: How is the size of an MMS calculated?**

A. Images are scaled up to approximately 4/3 when base64 encoded.
Additionally, there is approximately 200 bytes of overhead on each MMS.
Assuming the maximum MMS that can be sent on Telstra’s network is 2MB, then the maximum image size that can be sent will be approximately 1.378MB (1.378 x 1.34 + 200, without SOAP encapsulation).

**Q: How is an MMS classified as Small or Large?**

A. MMSes with size below 600kB are classed as Small whereas those that are bigger than 600kB are classed as Large. They will be charged accordingly.

**Q: Are SMILs supported by the Messaging API?**

A. While there will be no error if you send an MMS with a SMIL presentation, the actual layout or sequence defined in the SMIL may not display as expected because most of the new smartphone devices ignore the SMIL presentation layer. SMIL was used in feature phones which had limited capability and SMIL allowed a *powerpoint type* presentation to be provided. Smartphones now have the capability to display video which is the better option for presentations. It is recommended that MMS messages should just drop the SMIL.

**Q: How do I assign a delivery notification or callback URL?**

A. You can assign a delivery notification or callback URL by adding the `notifyURL` parameter in the body of the request when you send a message. Once the message has been delivered, a notification will then be posted to this callback URL.

**Q: What is the difference between the `notifyURL` parameter in the Provisoning call versus the `notifyURL` parameter in the Send Message call?**

A. The `notifyURL` in the Provisoning call will be the URL where replies to the provisioned number will be posted.
On the other hand, the `notifyURL` in the Send Message call will be the URL where the delivery notification will be posted, e.g. when an SMS has already been delivered to the recipient.

# Getting Started

Below are the steps to get started with the Telstra Messaging API.
1. Generate an OAuth2 token using your `Client key` and `Client secret`.
2. Use the Provisioning call to create a subscription and receive a dedicated number.
3. Send a message to a specific mobile number.

## Run in Postman
<a
href=\"https://app.getpostman.com/run-collection/ded00578f69a9deba256#?env%5BMessaging%20API%20Environments%5D=W3siZW5hYmxlZCI6dHJ1ZSwia2V5IjoiY2xpZW50X2lkIiwidmFsdWUiOiIiLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoiY2xpZW50X3NlY3JldCIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6ImFjY2Vzc190b2tlbiIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6Imhvc3QiLCJ2YWx1ZSI6InRhcGkudGVsc3RyYS5jb20iLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoiQXV0aG9yaXphdGlvbiIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6Im9hdXRoX2hvc3QiLCJ2YWx1ZSI6InNhcGkudGVsc3RyYS5jb20iLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoibWVzc2FnZV9pZCIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifV0=\"><img
src=\"https://run.pstmn.io/button.svg\" alt=\"Run in Postman\"/></a>

## Sample Apps
- [Perl Sample App](https://github.com/telstra/MessagingAPI-perl-sample-app)
- [Happy Chat App](https://github.com/telstra/messaging-sample-code-happy-chat)
- [PHP Sample App](https://github.com/developersteve/telstra-messaging-php)

## SDK Repos
- [Messaging API - PHP SDK](https://github.com/telstra/MessagingAPI-SDK-php)
- [Messaging API - Python SDK](https://github.com/telstra/MessagingAPI-SDK-python)
- [Messaging API - Ruby SDK](https://github.com/telstra/MessagingAPI-SDK-ruby)
- [Messaging API - NodeJS SDK](https://github.com/telstra/MessagingAPI-SDK-node)
- [Messaging API - .Net2 SDK](https://github.com/telstra/MessagingAPI-SDK-dotnet)
- [Messaging API - Java SDK](https://github.com/telstra/MessagingAPI-SDK-Java)

## Blog Posts
For more information on the Messaging API, you can read these blog posts:
- [Callbacks Part 1](https://dev.telstra.com/content/understanding-messaging-api-callbacks-part-1)
- [Callbacks Part 2](https://dev.telstra.com/content/understanding-messaging-api-callbacks-part-2)


This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 2.2.9
- Package version: 1.0.6
- Package version: 1.0.8
- Build package: org.openapitools.codegen.languages.RubyClientCodegen

## Installation

Expand All @@ -159,15 +23,16 @@ gem build Telstra_Messaging.gemspec
Then either install the gem locally:

```shell
gem install ./Telstra_Messaging-1.0.6.gem
gem install ./Telstra_Messaging-1.0.8.gem
```
(for development, run `gem install --dev ./Telstra_Messaging-1.0.6.gem` to install the development dependencies)

(for development, run `gem install --dev ./Telstra_Messaging-1.0.8.gem` to install the development dependencies)

or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).

Finally add this to the Gemfile:

gem 'Telstra_Messaging', '~> 1.0.6'
gem 'Telstra_Messaging', '~> 1.0.8'

### Install from Git

Expand All @@ -186,6 +51,7 @@ ruby -Ilib script.rb
## Getting Started

Please follow the [installation](#installation) procedure and then run the following code:

```ruby
# Load the gem
require 'Telstra_Messaging'
Expand All @@ -194,10 +60,13 @@ api_instance = Telstra_Messaging::AuthenticationApi.new
client_id = 'client_id_example' # String |
client_secret = 'client_secret_example' # String |
grant_type = 'client_credentials' # String |
opts = {
scope: 'scope_example' # String | NSMS
}

begin
#Generate OAuth2 token
result = api_instance.auth_token(client_id, client_secret, grant_type)
result = api_instance.auth_token(client_id, client_secret, grant_type, opts)
p result
rescue Telstra_Messaging::ApiError => e
puts "Exception when calling AuthenticationApi->auth_token: #{e}"
Expand All @@ -214,8 +83,11 @@ Class | Method | HTTP request | Description
*Telstra_Messaging::AuthenticationApi* | [**auth_token**](docs/AuthenticationApi.md#auth_token) | **POST** /oauth/token | Generate OAuth2 token
*Telstra_Messaging::MessagingApi* | [**get_mms_status**](docs/MessagingApi.md#get_mms_status) | **GET** /messages/mms/{messageid}/status | Get MMS Status
*Telstra_Messaging::MessagingApi* | [**get_sms_status**](docs/MessagingApi.md#get_sms_status) | **GET** /messages/sms/{messageId}/status | Get SMS Status
*Telstra_Messaging::MessagingApi* | [**retrieve_mms_responses**](docs/MessagingApi.md#retrieve_mms_responses) | **GET** /messages/mms | Retrieve MMS Responses
*Telstra_Messaging::MessagingApi* | [**retrieve_sms_responses**](docs/MessagingApi.md#retrieve_sms_responses) | **GET** /messages/sms | Retrieve SMS Responses
*Telstra_Messaging::MessagingApi* | [**m_ms_health_check**](docs/MessagingApi.md#m_ms_health_check) | **GET** /messages/mms/healthcheck | MMS Health Check
*Telstra_Messaging::MessagingApi* | [**retrieve_mms_replies**](docs/MessagingApi.md#retrieve_mms_replies) | **GET** /messages/mms | Retrieve MMS Replies
*Telstra_Messaging::MessagingApi* | [**retrieve_sms_replies**](docs/MessagingApi.md#retrieve_sms_replies) | **GET** /messages/sms | Retrieve SMS Replies
*Telstra_Messaging::MessagingApi* | [**s_ms_health_check**](docs/MessagingApi.md#s_ms_health_check) | **GET** /messages/sms/healthcheck | SMS Health Check
*Telstra_Messaging::MessagingApi* | [**s_ms_multi**](docs/MessagingApi.md#s_ms_multi) | **POST** /messages/sms/multi | Send Multiple SMS
*Telstra_Messaging::MessagingApi* | [**send_mms**](docs/MessagingApi.md#send_mms) | **POST** /messages/mms | Send MMS
*Telstra_Messaging::MessagingApi* | [**send_sms**](docs/MessagingApi.md#send_sms) | **POST** /messages/sms | Send SMS
*Telstra_Messaging::ProvisioningApi* | [**create_subscription**](docs/ProvisioningApi.md#create_subscription) | **POST** /messages/provisioning/subscriptions | Create Subscription
Expand All @@ -226,28 +98,34 @@ Class | Method | HTTP request | Description
## Documentation for Models

- [Telstra_Messaging::DeleteNumberRequest](docs/DeleteNumberRequest.md)
- [Telstra_Messaging::GetMmsResponse](docs/GetMmsResponse.md)
- [Telstra_Messaging::GetSubscriptionResponse](docs/GetSubscriptionResponse.md)
- [Telstra_Messaging::HealthCheckResponse](docs/HealthCheckResponse.md)
- [Telstra_Messaging::InboundPollResponse](docs/InboundPollResponse.md)
- [Telstra_Messaging::MMSContent](docs/MMSContent.md)
- [Telstra_Messaging::Message](docs/Message.md)
- [Telstra_Messaging::MessageSentResponse](docs/MessageSentResponse.md)
- [Telstra_Messaging::MessageMulti](docs/MessageMulti.md)
- [Telstra_Messaging::MessageSentResponseMms](docs/MessageSentResponseMms.md)
- [Telstra_Messaging::MessageSentResponseSms](docs/MessageSentResponseSms.md)
- [Telstra_Messaging::OAuthResponse](docs/OAuthResponse.md)
- [Telstra_Messaging::OutboundPollResponse](docs/OutboundPollResponse.md)
- [Telstra_Messaging::ProvisionNumberRequest](docs/ProvisionNumberRequest.md)
- [Telstra_Messaging::ProvisionNumberResponse](docs/ProvisionNumberResponse.md)
- [Telstra_Messaging::SendMmsRequest](docs/SendMmsRequest.md)
- [Telstra_Messaging::SendSMSRequest](docs/SendSMSRequest.md)
- [Telstra_Messaging::SendSmsMultiRequest](docs/SendSmsMultiRequest.md)
- [Telstra_Messaging::Status](docs/Status.md)


## Documentation for Authorisation
## Documentation for Authorization


### auth


- **Type**: OAuth
- **Flow**: application
- **Authorisation URL**:
- **Authorization URL**:
- **Scopes**:
- NSMS: NSMS

Loading