RingCentral v0.1.0 RingCentral View Source

A thin RingCentral API wrapper in Elixir.

Usage

client =
  RingCentral.Client.new(
    client_id: "CLIENT_ID",
    client_secret: "CLIENT_SECRET",
    redirect_uri: "https://ringcentral-elixir.test",
    server_url: "https://platform.devtest.ringcentral.com"
  )

authorize_url = RingCentral.OAuth.authorize_url!(client, ui_options: "hide_logo")

client = RingCentral.OAuth.get_token!(client, code: "AUTH_CODE")

case RingCentral.API.get(client, "/") do
  {:ok, %OAuth2.Response{body: resp}} ->
    resp
    |> IO.inspect()

  {:error, %OAuth2.Response{status_code: 401, body: body}} ->
    Logger.error("Unauthorized token")

  {:error, %OAuth2.Error{reason: reason}} ->
    Logger.error("Error: reason")
end