An open API service indexing awesome lists of open source software.

https://github.com/grokify/ringcentral-sdk-go

RingCentral SDK in Go (https://developers.ringcentral.com). Need help? Post your questions to http://stackoverflow.com/ or send email to [email protected].
https://github.com/grokify/ringcentral-sdk-go

Last synced: 2 months ago
JSON representation

RingCentral SDK in Go (https://developers.ringcentral.com). Need help? Post your questions to http://stackoverflow.com/ or send email to [email protected].

Awesome Lists containing this project

README

        

# RingCentral SDK in Go

[![Build Status][build-status-svg]][build-status-url]
[![Lint Status][lint-status-svg]][lint-status-url]
[![Go Report Card][goreport-svg]][goreport-url]
[![Docs][docs-godoc-svg]][docs-godoc-url]
[![SLOC][loc-svg]][repo-url]
[![License][license-svg]][license-url]

[used-by-svg]: https://sourcegraph.com/github.com/grokify/ringcentral-sdk-go/-/badge.svg
[used-by-url]: https://sourcegraph.com/github.com/grokify/ringcentral-sdk-go?badge
[build-status-svg]: https://github.com/grokify/ringcentral-sdk-go/actions/workflows/ci.yaml/badge.svg?branch=master
[build-status-url]: https://github.com/grokify/ringcentral-sdk-go/actions/workflows/ci.yaml
[lint-status-svg]: https://github.com/grokify/ringcentral-sdk-go/actions/workflows/lint.yaml/badge.svg?branch=master
[lint-status-url]: https://github.com/grokify/ringcentral-sdk-go/actions/workflows/lint.yaml
[goreport-svg]: https://goreportcard.com/badge/github.com/grokify/ringcentral-sdk-go
[goreport-url]: https://goreportcard.com/report/github.com/grokify/ringcentral-sdk-go
[codeclimate-status-svg]: https://codeclimate.com/github/grokify/ringcentral-sdk-go/badges/gpa.svg
[codeclimate-status-url]: https://codeclimate.com/github/grokify/ringcentral-sdk-go
[docs-godoc-svg]: https://pkg.go.dev/badge/github.com/grokify/ringcentral-sdk-go
[docs-godoc-url]: https://pkg.go.dev/github.com/grokify/ringcentral-sdk-go
[license-svg]: https://img.shields.io/badge/license-MIT-rcsdkgo.svg
[license-url]: https://github.com/grokify/ringcentral-sdk-go/blob/master/LICENSE
[loc-svg]: https://tokei.rs/b1/github/grokify/ringcentral-sdk-go
[repo-url]: https://github.com/grokify/ringcentral-sdk-go

:warning: Please use [`grokify/go-ringcentral`](https://github.com/grokify/go-ringcentral) instead :warning:

[![Docs][docs-godoc-svg]][docs-godoc-link]
[![License][license-svg]][license-link]

## Table of contents

1. [Overview](#overview)
1. [Included](#included)
2. [To Do](#to-do)
2. [Installation](#installation)
2. [Usage](#usage)
1. [Instantiation](#instantiation)
1. [Authorization](#authorization)
1. [API Requests](#api-requests)
1. [SMS Example](#sms-example)
2. [Fax Example](#fax-example)
6. [Links](#links)
7. [Contributions](#contributions)
8. [License](#license)

***

## Overview

This is an unofficial Go SDK for the RingCentral for Developers Platform REST API (https://developers.ringcentral.com).

The core SDK objects follow the general design of the official RingCentral SDKs. Additional functionality is provided for ease of use including request helpers.

This SDK is an early stage library and subject to breaking changes.

Examples using `*http.Client` and the `oauth2` package can be found here:

### Included

* OAuth2 authorization
* Generic API requests
* Fax request helper to create multipart/mixed messages

### To Do

The following are not yet included in this SDK:

* OAuth2 token refresh
* Subscriptions
* Tests

This SDK is an experimental SDK and will likely see a major rewrite to be more idiomatic Go. Recent work has been in using `http.Client` with `oauth2` directly (which does handle token refresh) and with Swagger Codegen project (with autogenerated model classes). Information on these efforts can be found here:

* OAuth2 Helpers: [grokify/oauth2more/ringcentral](https://github.com/grokify/oauth2more/tree/master/ringcentral)
* example: [ringcentral_get_account.go](https://github.com/grokify/oauth2util-go/blob/master/examples/ringcentral_get_account/ringcentral_get_account.go)
* Auth Code example: [grokify/beego-oauth2-demo](https://github.com/grokify/beego-oauth2-demo)
* Swagger Codegen SDK: [grokify/ringcentral-sdk-go-scg](https://github.com/grokify/ringcentral-sdk-go-scg)

## Installation

```bash
$ go get github.com/grokify/ringcentral-sdk-go
```

## Usage

### Instantation

The SDK is represented by the global RCSDK constructor. Your application must create an instance of this object.

```go
import(
"github.com/grokify/ringcentral-sdk-go/rcsdk"
)

// For Production use: rcsdk.RC_SERVER_PRODUCTION or "https://platform.ringcentral.com"
// For Sandbox use: rcsdk.RC_SERVER_SANDBOX or "https://platform.devtest.ringcentral.com"

sdk := rcsdk.NewSdk("yourAppKey", "yourAppSecret", rcsdk.RC_SERVER_SANDBOX)

// Get the Platform Singleton

platform := sdk.GetPlatform();
```

### Authorization

Login is accomplished by calling the `platform.Authorize()` method of the Platform singleton with username, extension
(optional), and password as parameters. A `Promise` instance is returned, resolved with an AJAX `Response` object.

The `username` should be a phone number in E.164 format without the leading `+`.

```go
platform.Authorize("16505551212", "101", "yourPassword")
```

### API Requests

General API requests can be made via the `platform` object's `Get`, `Post`, `Put`, and `Delete` methods.
Individual API calls are documented on the [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html).

The below SMS example shows how this can be used.

#### SMS Example

In order to send an SMS using the API, make a POST request to `/account/~/extension/~/sms`:

```go
import(
"net/http"
"net/url"
)

resp, err := platform.Post("/account/~/extension/~/sms", url.Values{}, []byte(`{
"to" : [{"phoneNumber": "14155551212"}],
"from" : {"phoneNumber": "16505551212"},
"text" : "Test from Go"
}`), http.Header{})

```

#### Fax Example

Request helpers are provided for more complicated requests. The below shows usage of the
fax request helper which is used to help create the `multipart/mixed` HTTP request.

More information on usage is available in `./rcsdk/helpers/faxrequest/README.md`.

```go
import(
"github.com/grokify/ringcentral-sdk-go/rcsdk/helpers/faxrequest"
"github.com/grokify/ringcentral-sdk-go/rcsdk/helpers/info"
)

fax, err := faxrequest.NewRequestHelper(faxrequest.Metadata{
To: []info.Caller{info.Caller{PhoneNumber: "+16505626570"}},
CoverPageText: "RingCentral fax example in Go!"})
err = fax.AddText([]byte("Hello World!"), "text/plain")
err = fax.AddFile("/path/to/myfile1.pdf")
err = fax.AddFile("/path/to/myfile2.tif")
err = fax.Finalize()

resp, err := platform.Post("/account/~/extension/~/fax", url.Values{}, fax.GetBody(), fax.GetHeaders())
```

## Links

Project Repo

* https://github.com/grokify/ringcentral-sdk-go

RingCentral API Docs

* https://developers.ringcentral.com/library.html

RingCentral API Explorer

* http://ringcentral.github.io/api-explorer

RingCentral Official SDKs

* https://github.com/ringcentral

## Contributions

Any reports of problems, comments or suggestions are most welcome.

Please report these on [Github](https://github.com/grokify/ringcentral-sdk-go)

## License

RingCentral SDK is available under an MIT-style license. See {file:LICENSE.txt} for details.

RingCentral SDK © 2015 by John Wang

[docs-godoc-svg]: https://img.shields.io/badge/docs-godoc-blue.svg
[docs-godoc-link]: https://godoc.org/github.com/grokify/ringcentral-sdk-go
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
[license-link]: https://github.com/grokify/ringcentral-sdk-go/blob/master/LICENSE.txt