Ruby Library v2

View Repo

The Flowroute Ruby Library v2 provides methods for interacting with Messages v2 of the Flowroute API.

Requirements


Installation

  1. First, start a shell session and clone the SDK:

    via HTTPS:

    git clone https://github.com/flowroute/flowroute-messaging-ruby.git
                        

    via SSH:

    git@github.com:flowroute/flowroute-messaging-ruby.git
                        
  2. Switch to the newly-created flowroute-messaging-ruby directory and run the following to build the Flowroute gem:

    gem build flowroute_messaging.gemspec
                        

    This version of the library has been tested with Ruby 2.5.0 for Mac OS X. To see which version of ruby is installed on your machine, run the following:

    ruby --version
    
  3. Once built, run the following to install the gem in the current directory:

    gem install flowroute_messaging-1.0.gem
    


Usage

In Flowroute's approach to building the Messaging (v2) API wrapper, HTTP requests are handled by the APIController, which contains the functions used to perform tasks with the Ruby SDK.

APIController

The following shows how you can import and instantiate the APIController:

#Require Flowroute Messaging
require 'flowroute_messaging'

#Pass your API credentials
ctl = FlowrouteMessaging::MessagesController.new('YOUR_API_KEY', 'YOUR_API_SECRET_KEY')   

            

Credentials

In your Ruby file, replace accessKey:secretKey with your API credentials from the Flowroute Manager.

<
#Pass your API credentials
ctl = FlowrouteMessaging::MessagesController.new('YOUR_API_KEY', 'YOUR_API_SECRET_KEY')

            

Methods

create_message()

The method accepts the msg, to, from, and body parameters which you can learn more about in the API reference.

#Create and send the message
msg = FlowrouteMessaging::Message.new(to='15305557784', from='18444205700', content='You're obviously not a golfer.')
ctl.create_message(msg)
print ctl.create_message(msg)

            
Example Response
{
"data": {
    "id": "mdr1-fab29a740129404a8ca794efc1359e12'
    }
}

            
get_message_lookup()

The method accepts the record_id parameter which you can learn more about in the API reference.

#Get the MDR
recID = 'fab29a740129404a8ca794efc1359e12'
print ctl.get_message_lookup(recID)

            
Example Response
{
"data": {
  "attributes": {
      "body": "Gee, nice marmot!",
      "direction": "outbound",
      "amount_nanodollars": 4000000,
      "message_encoding": 0,
      "timestamp": "2016-05-03T17:41:00.478893+00:00",
      "has_mms": false,
      "to": "15305557784",
      "amount_display": "$0.0040",
      "from": "18444205700",
      "callback_url": None,
      "message_type": "long-code"
                },
  "type": "message",
  "id": "mdr1-cfab29a740129404a8ca794efc1359e12"
         }
}

            

©2004 - 2018 West Corporation. All Rights Reserved. Legal & Privacy | Diversity | Tariffs | Blog & Corporate News | Investor News | Contact