RingCentral SDK for Ruby
Table of contents
- Overview
- Documentation
- Installation
- Usage
- Synopsis
- API Requests 1. Generic HTTP Requests 2. SMS and MMS Examples 3. Fax Examples
- Advanced Use Cases
- Supported Ruby Versions
- Releases
- Versioning
- Change Log
- Links
- Contributions
- 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:
- Ruby SDK Developer Guide - Read the Docs
- Ruby SDK Reference Guide - RubyDoc.info
For API information, see the official RingCentral resources:
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:
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
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
Links
Project Repo
RingCentral API Docs
RingCentral API Explorer
RingCentral Official SDKs
Contributing
- Fork it ( http://github.com/grokify/ringcentral-sdk-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - 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