GithubHelp home page GithubHelp logo

isabella232 / ringcentral-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ringcentral/ringcentral-python

0.0 0.0 0.0 158 KB

RingCentral Connect Platform Python SDK

License: MIT License

Makefile 2.53% Python 97.47%

ringcentral-python's Introduction

RingCentral SDK for Python

Build Status Coverage Status Twitter

RingCentral Developers is a cloud communications platform which can be accessed via more than 70 APIs. The platform's main capabilities include technologies that enable: Voice, SMS/MMS, Fax, Glip Team Messaging, Data and Configurations.

API Reference and APIs Explorer.

Installation

This SDK is tested against Python 3.7 so we recommend installing using it with Python 3.7 or newer

Manual

$ git clone https://github.com/ringcentral/python-sdk.git ./ringcentral-python-sdk

Install dependencies:

PIP

$ pip3 install ringcentral

Setup

Rename credentials-sample.ini to credentials.ini.

Edit credentials.ini and update appropriate parameters. CLIENT_ID is synonymous with APP_KEY. CLIENT_SECRET is synonymous with APP_SECRET. In this repository, the latter convention is used that of APP_KEY and APP_SECRET.

Usage

Take a look at a sample code.

from ringcentral import SDK

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER')
platform = sdk.platform()
platform.login('USERNAME', 'EXTENSION', 'PASSWORD')

res = platform.get('/account/~/extension/~')
print('User loaded ' + res.json().name)

Subscribing for server events

from threading import Thread
from time import sleep
from ringcentral.subscription import Events

def on_message(msg):
    print(msg)

def pubnub():
    s = sdk.create_subscription()
    s.add_events(['/account/~/extension/~/message-store'])
    s.on(Events.notification, on_message)
    s.register()
    while True:
        sleep(0.1)

try:
    try:
        import Pubnub
        t = Thread(target=pubnub)
        t.start()
    except ImportError as e:
        print("No Pubnub SDK, skipping Pubnub test")

except KeyboardInterrupt:
    pass

Send sms

from ringcentral import SDK

database = []
database.append({"Customer":"Tyler","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Chen","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Anne","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Brown","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Peter","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"White","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Lisa","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Dan","Payment":"Paid","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Stephanie","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})
database.append({"Customer":"Lukas","Payment":"Due","PhoneNumber":"xxxxxxxxxxx"})

sdk = SDK('CLIENT_ID', 'CLIENT_SECRET', 'SERVER')
platform = sdk.platform()
platform.login('USERNAME', 'EXTENSION', 'PASSWORD')

def sendSMS(message, number):  
    params = {'from': {'phoneNumber': 'USERNAME'},'to': [{'phoneNumber': number}],'text': message}
    response = platform.post('/restapi/v1.0/account/~/extension/~/sms', params)
    print('Sent payment reminder to ' + number)

def main():
    for i in range(len(database)):
        customer = database[i]
        if customer['Payment'] is "Due":
            sendSMS("Hi " + customer['Customer'] + ". Your payment is due.", customer['PhoneNumber'])
        time.sleep(5)
    print("Send payment reminder done.")

if __name__ == '__main__':
    main()

ringcentral-python's People

Contributors

byrnereese avatar dassburger avatar grokify avatar kirill-konshin avatar krystiand avatar link89 avatar pacovu avatar suyashjoshi avatar tylerlong avatar vasmik avatar vyshakhbabji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.