ringcentral-ruby
Ruby SDK for RingCentral.
Installation
gem install ringcentral-sdk
Documentation
https://developer.ringcentral.com/api-docs/latest/index.html
Usage
require 'ringcentral'
rc = RingCentral.new(ENV['appKey'], ENV['appSecret'], ENV['server'])
rc.(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
# get
r = rc.get('/restapi/v1.0/account/~/extension/~')
expect(r).not_to be_nil
expect('101').to eq(JSON.parse(r.body)['extensionNumber'])
Send SMS
r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
to: [{phoneNumber: ENV['receiver']}],
from: {phoneNumber: ENV['username']},
text: 'Hello world'
})
Send fax
rc.post('/restapi/v1.0/account/~/extension/~/fax',
payload: { to: [{ phoneNumber: ENV['receiver'] }] },
files: [
'spec/test.txt;type=text/plain',
'spec/test.png;type=image/png'
]
)
Send MMS
r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
payload: {
to: [{ phoneNumber: ENV['receiver'] }],
from: { phoneNumber: ENV['username'] },
text: 'hello world'
},
files: [
'spec/test.png;type=image/png'
]
)
PubNub subscription
def createSubscription(callback)
events = [
'/restapi/v1.0/account/~/extension/~/message-store',
]
subscription = rc.subscription(events, lambda { ||
callback.call()
})
subscription.subscribe()
return subscription
end
createSubscription(lambda { ||
puts
})
For more sample code, please refer to the test cases.
How to test
Create .env file with the following content:
production=false
server=https://platform.devtest.ringcentral.com
appKey=appKey
appSecret=appSecret
username=username
extension=extension
password=password
receiver=number-to-receiver-sms
Run rspec
License
MIT
Todo
- Batch requests