Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.
/ ruby-client-sdk Public archive

The Releans Ruby SDK allow you to get up an running with Releans API quickly in your project. # What you can do with Releans Services? 1- Send emails 2- On-time SMS 3- Automation for reminders and appointments

License

Notifications You must be signed in to change notification settings

Releans/ruby-client-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started

The Releans SDK enables developers to use Releans Services in their code. You can get started in minutes.

How to Build

This client library is a Ruby gem which can be compiled and used in your Ruby and Ruby on Rails project. This library requires a few gems from the RubyGems repository.

  1. Open the command line interface or the terminal and navigate to the folder containing the source code.
  2. Run gem build releans_api.gemspec to build the gem.
  3. Once built, the gem can be installed on the current work environment using gem install releans_api-1.1.0.gem

Building Gem

How to Use

The following section explains how to use the ReleansApi Ruby Gem in a new Rails project using RubyMine™. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

1. Starting a new project

Close any existing projects in RubyMine™ by selecting File -> Close Project. Next, click on Create New Project to create a new project from scratch.

Create a new project in RubyMine

Next, provide TestApp as the project name, choose Rails Application as the project type, and click OK.

Create a new Rails Application in RubyMine - step 1

In the next dialog make sure that correct Ruby SDK is being used (minimum 2.0.0) and click OK.

Create a new Rails Application in RubyMine - step 2

This will create a new Rails Application project with an existing set of files and folder.

2. Add reference of the gem

In order to use the ReleansApi gem in the new project we must add a gem reference. Locate the Gemfile in the Project Explorer window under the TestApp project node. The file contains references to all gems being used in the project. Here, add the reference to the library gem by adding the following line: gem 'releans_api', '~> 1.1.0'

Add references of the Gemfile

3. Adding a new Rails Controller

Once the TestApp project is created, a folder named controllers will be visible in the Project Explorer under the following path: TestApp > app > controllers. Right click on this folder and select New -> Run Rails Generator....

Run Rails Generator on Controllers Folder

Selecting the said option will popup a small window where the generator names are displayed. Here, select the controller template.

Create a new Controller

Next, a popup window will ask you for a Controller name and included Actions. For controller name provide Hello and include an action named Index and click OK.

Add a new Controller

A new controller class anmed HelloController will be created in a file named hello_controller.rb containing a method named Index. In this method, add code for initialization and a sample for its usage.

Initialize the library

How to Test

You can test the generated SDK and the server with automatically generated test cases as follows:

  1. From terminal/cmd navigate to the root directory of the SDK.
  2. Invoke: bundle exec rake

Initialization

Authentication

In order to setup authentication and initialization of the API client, you need the following information.

Parameter Description
o_auth_access_token OAuth 2.0 Access Token

API client can be initialized as following.

# Configuration parameters and credentials
o_auth_access_token = 'o_auth_access_token' # OAuth 2.0 Access Token

client = ReleansApi::ReleansApiClient.new(
  o_auth_access_token: o_auth_access_token
)

The added initlization code can be debugged by putting a breakpoint in the Index method and running the project in debug mode by selecting Run -> Debug 'Development: TestApp'.

Debug the TestApp

Class Reference

List of Controllers

Class: MessageController

Get singleton instance

The singleton instance of the MessageController class can be accessed from the API Client.

message_controller = client.message

Method: get_all_messages

List all messages sent by the account.

def get_all_messages(accept); end

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

accept = '*/*'

result = message_controller.get_all_messages(accept)

Method: get_view_message

Return the details of the message.

def get_view_message(id,
                         accept); end

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

id = 'id'
accept = '*/*'

result = message_controller.get_view_message(id, accept)

Method: create_send_sms_message

Send a single message.

def create_send_sms_message(accept,
                                sender_id,
                                mobile_number,
                                message); end

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
sender_id Required Sender id to send the message from.
mobile_number Required The mobile number supposed to receive the message.
message Required Message text.

Example Usage

accept = 'Accept'
sender_id = 'senderId'
mobile_number = 'mobileNumber'
message = 'message'

result = message_controller.create_send_sms_message(accept, sender_id, mobile_number, message)

Back to List of Controllers

Class: SenderController

Get singleton instance

The singleton instance of the SenderController class can be accessed from the API Client.

sender_controller = client.sender

Method: get_sender_name_details

Return the details of the sender name.

def get_sender_name_details(id,
                                accept); end

Parameters

Parameter Tags Description
id Required TODO: Add a parameter description
accept Required TODO: Add a parameter description

Example Usage

id = 'sender-id'
accept = '*/*'

result = sender_controller.get_sender_name_details(id, accept)

Method: create_sender_name

Create a new sender id to send messages using it

def create_sender_name(accept,
                           content_type,
                           body); end

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description
content_type Required TODO: Add a parameter description
body Required TODO: Add a parameter description

Example Usage

accept = 'text/plain'
content_type = 'text/plain'
body = 'Your sender name'

result = sender_controller.create_sender_name(accept, content_type, body)

Method: get_all_senders

List all senders names associated with the account

def get_all_senders(accept); end

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

accept = '*/*'

result = sender_controller.get_all_senders(accept)

Back to List of Controllers

Class: BalanceController

Get singleton instance

The singleton instance of the BalanceController class can be accessed from the API Client.

balance_controller = client.balance

Method: get_balance

Get your available balance

def get_balance(accept); end

Parameters

Parameter Tags Description
accept Required TODO: Add a parameter description

Example Usage

accept = 'text/plain'

result = balance_controller.get_balance(accept)

Back to List of Controllers

About

The Releans Ruby SDK allow you to get up an running with Releans API quickly in your project. # What you can do with Releans Services? 1- Send emails 2- On-time SMS 3- Automation for reminders and appointments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages