RingCentral SDK for Ruby

Gem Version Build Status Coverage Status Code Climate Scrutinizer Code Quality Docs Docs License

Stack Overflow Chat

Table of contents

  1. Overview
  2. Documentation
  3. Installation
  4. Usage
    1. Synopsis
    2. API Requests
    3. Generic HTTP Requests
    4. SMS and MMS Examples
    5. Fax Examples
    6. Advanced Use Cases
  5. Supported Ruby Versions
  6. Releases
    1. Versioning
    2. Change Log
  7. Links
  8. Contributions
  9. License

Overview

A Ruby SDK for the RingCentral REST API.

Important Notes

Version 2.0.0 introduces the following backward breaking changes:

  • SDK instantiation by moving to a block-based configuration
  • Removal of RingCentralSdk::REST::Config class
  • Removal of RingCentralSdk::REST::Client.authorize_user method

Documentation

Full documentation and resources are available at:

  1. Ruby SDK Developer Guide - Read the Docs
  2. Ruby SDK Reference Guide - RubyDoc.info

For API information, see the official RingCentral resources:

  1. API Developer and Reference Guide
  2. API Explorer
  3. CTI Tutorial

Installation

Via Bundler

Add 'ringcentral_sdk' to Gemfile and then run bundle:

$ echo "gem 'ringcentral_sdk'" >> Gemfile
$ bundle

Via RubyGems

$ gem install ringcentral_sdk

Usage

Synopsis

require 'ringcentral_sdk'

client = RingCentralSdk::REST::Client.new do |config|
  # App info (mandatory)
  config.client_id = 'myAppClientID'
  config.client_secret = 'myAppClientSecret'
  config.server_url = RingCentralSdk::RC_SERVER_SANDBOX

  # User info for password grant (optional)
  config.username = 'myUsername'
  config.extension = 'myExtension'
  config.password = 'myPassword'

  # Set a custom logger (optional)
  config.logger = Logger.new(STDOUT)

  # Enable HTTP retries for 429, 503, and 504 errors
  # Set custom codes and retry after using retry_options
  config.retry = true
end

# Send SMS
res = client.messages.sms.create(
  from: '+16505551212',
  to: '+14155551212',
  text: 'Hi there!'
)

More information on the authorization code flow:

  1. Full documentation
  2. Sinatra example

API Requests

API requests can be made via the included Faraday client or RingCentralSdk::Helpers::Request subclasses. These are described below.

Generic HTTP Requests

To make generic API requests, use included Faraday client which can be accessed via client.http. The client automatically adds the correct access token to the HTTP request and handles OAuth token refresh using the OAuth gem.

This is useful to access many API endpoints which do not have custom wrappers and for debugging purposes.

http = client.http

SMS and MMS Examples

SMS:

client.messages.sms.create(
  from: '+16505551212',
  to: '+14155551212',
  text: 'Hi there!'
)

MMS with media file:

client.messages.sms.create(
  from: '+16505551212',
  to: '+14155551212',
  text: 'Hi there!',
  media: '/filepath/to/file.ext'
)

Fax Examples

Fax files:

client.messages.fax.create(
  to: '+14155551212',
  coverPageText: 'Hi there!',
  files: ['/path/to/myfile.pdf']
)

Fax text:

client.messages.fax.create(
  to: '+14155551212',
  coverPageText: 'Hi there!',
  text: 'Hi there!'
)

Subscription Example

To make subscriptions with RingCentral, use the SDK object to create subscription Observer object and then add observers to it.

# Create an observer object
class MyObserver
  def update(message)
    puts 'Subscription Message Received'
    puts JSON.dump(message)
  end
end

# Create an observable subscription and add your observer
sub = client.create_subscription
sub.add_observer MyObserver.new

# Subscribe to an arbitrary number of event filters
sub.subscribe ['/restapi/v1.0/account/~/extension/~/presence']

# End the subscription
sub.destroy

Advanced Use Cases

  1. Subscribing to All Extensions
  2. Managing Call Queue Member Status

Supported Ruby Versions

This library is tested against this list of Ruby implementations.

Releases

Releases with release notes are availabe on GitHub releases. Release notes include a high level description of the release as well as lists of non-breaking and breaking changes.

Versioning

  • Versions 1.0.0 and above follow semantic versioning. Breaking changes will be indicated by a change in major version.
  • Versions below 1.0.0 are in active development. During initial development (Version 0.x.x), minor version changes will indicate either substantial feature inclusion or breaking changes.

Change Log

See CHANGELOG.md

Project Repo

RingCentral API Docs

RingCentral API Explorer

RingCentral Official SDKs

Contributing

  1. Fork it ( http://github.com/grokify/ringcentral-sdk-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

RingCentral SDK is available under an MIT-style license. See LICENSE.md for details.

RingCentral SDK © 2015-2023 by John Wang