Skip to content

zabing/RingCentral.Net

 
 

Repository files navigation

RingCentral.Net

Build Status

This project is a complete rewrite of ringcentral/ringcentral-csharp-client.

Installation

Package is avaiable on NuGet: https://www.nuget.org/packages/RingCentral.Net

You can install it just like you install any other NuGet packages.

If you need PubNub feature, you also need to install one of the following packages:

Code samples

You can find sample code for all the endpoints.

There is also lots of useful code for your reference in our test cases.

Token auto refresh

By default this SDK doesn't do token refresh. You are responsible to design and implement your own token management strategy.

However, if you need a quick and dirty solution, you can try rc.AuthoRefresh(interval: 1000 * 60 * 30);. To disable it, use rc.StopAutoRefresh();.

API calls auto retry

By default there is no API calls auto retry. If an API call fails, an exception will be thrown and you are supposed to catch and handle it.

However, if you need a quick and dirty solution, you can try rc.AutoRetry(baseDelay: 10000, maxRetryTimes: 10, retryableHttpStatusCodes: new[]{429});.

Above it's a sample to deal with API rate limit. To disable it, use rc.StopAutoRetry();.

Binary content downloading

Some sample code for binary content downloading may not work.

Because RingCentral is gradually migrating binary content to CDN such as media.ringcentral.com.

For example, to download the attachment of a fax:

// `message` is the fax message object
var content = await rc.Get<byte[]>(message.attachments[0].uri);

The following does NOT work:

// `message` is the fax message object
var content = await rc.Restapi().Account().Extension().MessageStore(message.id).Content(message.attachments[0].id).Get();

Rule of thumb

But not all binary content has been migrated to CDN. If the resource to download provides you with a CDN uri, use that CDN uri. If there is no CDN uri provided, contruct the uri as the sample code shows.

How to access headers

By default, the SDK doesn't return headers:

var extInfo = await rc.Restapi().Account("~").Extension("~").Get();

If you need headers:

var httpResponseMessage = await rc.Get(rc.Restapi().Account("~").Extension("~").Path(true));
var headers = httpResponseMessage.Headers;
var responseBodyStr = await httpResponseMessage.Content.ReadAsStringAsync();
var extInfo = JsonConvert.DeserializeObject<GetExtensionInfoResponse>(responseBodyStr);

For maintainers

Release

Update version number in RingCentral.Net/RingCentral.Net.csproj & RingCentral.Net/RestClient.cs

cd RingCentral.Net
dotnet pack

Update version number in RingCentral.Net.PubnubPCL/RingCentral.Net.PubnubPCL.csproj

cd RingCentral.Net.PubnubPCL
dotnet pack

Update version number in RingCentral.Net.Pubnub\Properties\AssemblyInfo.cs

Rebuild solution

cd RingCentral.Net.Pubnub
nuget pack

Reference: Quickstart: Create and publish a package using Visual Studio (.NET Framework, Windows)

Todo

  • Write a script to generate swagger spec
  • Add batch get to auto generated sample code
  • How to handle deprecated endpoints?
  • Exception error message for binary data? Will it print a LOT?

About

RingCentral SDK for .NET

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 96.7%
  • JavaScript 3.3%