Skip to content

FreeClimbAPI/csharp-sdk

Repository files navigation

freeclimb - the C# library for the FreeClimb API

FreeClimb is a cloud-based application programming interface (API) that puts the power of the Vail platform in your hands. FreeClimb simplifies the process of creating applications that can use a full range of telephony features without requiring specialized or on-site telephony equipment. Using the FreeClimb REST API to write applications is easy! You have the option to use the language of your choice or hit the API directly. Your application can execute a command by issuing a RESTful request to the FreeClimb API. The base URL to send HTTP requests to the FreeClimb REST API is: /apiserver. FreeClimb authenticates and processes your request.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • SDK version: 4.9.0
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://www.freeclimb.com/support/

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using freeclimb.Api;
using freeclimb.Client;
using freeclimb.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out freeclimb.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using freeclimb.Api;
using freeclimb.Client;
using freeclimb.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://www.freeclimb.com/apiserver";
            // Configure HTTP basic authorization: fc
            config.Username = "YOUR_ACCOUNT_ID";
            config.Password = "YOUR_API_KEY";

            var apiInstance = new DefaultApi(config);
            
            var buyIncomingNumberRequest = new BuyIncomingNumberRequest(); // BuyIncomingNumberRequest | Incoming Number transaction details

            try
            {
                // Buy a Phone Number
                IncomingNumberResult result = apiInstance.BuyAPhoneNumber(buyIncomingNumberRequest);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling DefaultApi.BuyAPhoneNumber: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://www.freeclimb.com/apiserver

Class Method HTTP request Description
DefaultApi BuyAPhoneNumber POST /Accounts/{accountId}/IncomingPhoneNumbers Buy a Phone Number
DefaultApi CreateAConference POST /Accounts/{accountId}/Conferences Create a Conference
DefaultApi CreateAQueue POST /Accounts/{accountId}/Queues Create a Queue
DefaultApi CreateAnApplication POST /Accounts/{accountId}/Applications Create an application
DefaultApi CreateKnowledgeBaseCompletion POST /Accounts/{accountId}/KnowledgeBases/{knowledgeBaseId}/Completion Query the knowledge base
DefaultApi DeleteARecording DELETE /Accounts/{accountId}/Recordings/{recordingId} Delete a Recording
DefaultApi DeleteAnApplication DELETE /Accounts/{accountId}/Applications/{applicationId} Delete an application
DefaultApi DeleteAnIncomingNumber DELETE /Accounts/{accountId}/IncomingPhoneNumbers/{phoneNumberId} Delete an Incoming Number
DefaultApi DequeueAMember POST /Accounts/{accountId}/Queues/{queueId}/Members/{callId} Dequeue a Member
DefaultApi DequeueHeadMember POST /Accounts/{accountId}/Queues/{queueId}/Members/Front Dequeue Head Member
DefaultApi DownloadARecordingFile GET /Accounts/{accountId}/Recordings/{recordingId}/Download Download a Recording File
DefaultApi FilterLogs POST /Accounts/{accountId}/Logs Filter Logs
DefaultApi GetACall GET /Accounts/{accountId}/Calls/{callId} Get a Call
DefaultApi GetAConference GET /Accounts/{accountId}/Conferences/{conferenceId} Get a Conference
DefaultApi GetAMember GET /Accounts/{accountId}/Queues/{queueId}/Members/{callId} Get a Member
DefaultApi GetAParticipant GET /Accounts/{accountId}/Conferences/{conferenceId}/Participants/{callId} Get a Participant
DefaultApi GetAQueue GET /Accounts/{accountId}/Queues/{queueId} Get a Queue
DefaultApi GetARecording GET /Accounts/{accountId}/Recordings/{recordingId} Get a Recording
DefaultApi GetAnAccount GET /Accounts/{accountId} Get an Account
DefaultApi GetAnApplication GET /Accounts/{accountId}/Applications/{applicationId} Get an Application
DefaultApi GetAnIncomingNumber GET /Accounts/{accountId}/IncomingPhoneNumbers/{phoneNumberId} Get an Incoming Number
DefaultApi GetAnSmsMessage GET /Accounts/{accountId}/Messages/{messageId} Get an SMS Message
DefaultApi GetHeadMember GET /Accounts/{accountId}/Queues/{queueId}/Members/Front Get Head Member
DefaultApi GetTenDLCSmsBrand GET /Accounts/{accountId}/Messages/10DLC/Brands/{brandId} Get a 10DLC SMS Brand
DefaultApi GetTenDLCSmsBrands GET /Accounts/{accountId}/Messages/10DLC/Brands Get list of SMS 10DLC Brands
DefaultApi GetTenDLCSmsCampaign GET /Accounts/{accountId}/Messages/10DLC/Campaigns/{campaignId} Get a 10DLC SMS Campaign
DefaultApi GetTenDLCSmsCampaigns GET /Accounts/{accountId}/Messages/10DLC/Campaigns Get list of SMS 10DLC Campaigns
DefaultApi GetTenDLCSmsPartnerCampaign GET /Accounts/{accountId}/Messages/10DLC/PartnerCampaigns/{campaignId} Get a 10DLC SMS Partner Campaign
DefaultApi GetTenDLCSmsPartnerCampaigns GET /Accounts/{accountId}/Messages/10DLC/PartnerCampaigns Get list of SMS 10DLC Partner Campaigns
DefaultApi GetTollFreeSmsCampaign GET /Accounts/{accountId}/Messages/TollFree/Campaigns/{campaignId} Get a TollFree SMS Campaign
DefaultApi GetTollFreeSmsCampaigns GET /Accounts/{accountId}/Messages/TollFree/Campaigns Get list of TollFree Campaigns
DefaultApi ListActiveQueues GET /Accounts/{accountId}/Queues List Active Queues
DefaultApi ListAllAccountLogs GET /Accounts/{accountId}/Logs List All Account Logs
DefaultApi ListApplications GET /Accounts/{accountId}/Applications List applications
DefaultApi ListAvailableNumbers GET /AvailablePhoneNumbers List available numbers
DefaultApi ListCallLogs GET /Accounts/{accountId}/Calls/{callId}/Logs List Call Logs
DefaultApi ListCallRecordings GET /Accounts/{accountId}/Calls/{callId}/Recordings List Call Recordings
DefaultApi ListCalls GET /Accounts/{accountId}/Calls List Calls
DefaultApi ListConferenceRecordings GET /Accounts/{accountId}/Conferences/{conferenceId}/Recordings List Conference Recordings
DefaultApi ListConferences GET /Accounts/{accountId}/Conferences List Conferences
DefaultApi ListIncomingNumbers GET /Accounts/{accountId}/IncomingPhoneNumbers List Incoming Numbers
DefaultApi ListMembers GET /Accounts/{accountId}/Queues/{queueId}/Members List Members
DefaultApi ListParticipants GET /Accounts/{accountId}/Conferences/{conferenceId}/Participants List Participants
DefaultApi ListRecordings GET /Accounts/{accountId}/Recordings List Recordings
DefaultApi ListSmsMessages GET /Accounts/{accountId}/Messages List SMS Messages
DefaultApi MakeACall POST /Accounts/{accountId}/Calls Make a Call
DefaultApi MakeAWebrtcJwt POST /Accounts/{accountId}/Calls/WebRTC/Token Make a JWT for WebRTC calling
DefaultApi RemoveAParticipant DELETE /Accounts/{accountId}/Conferences/{conferenceId}/Participants/{callId} Remove a Participant
DefaultApi SendAnSmsMessage POST /Accounts/{accountId}/Messages Send an SMS Message
DefaultApi StreamARecordingFile GET /Accounts/{accountId}/Recordings/{recordingId}/Stream Stream a Recording File
DefaultApi UpdateAConference POST /Accounts/{accountId}/Conferences/{conferenceId} Update a Conference
DefaultApi UpdateALiveCall POST /Accounts/{accountId}/Calls/{callId} Update a Live Call
DefaultApi UpdateAParticipant POST /Accounts/{accountId}/Conferences/{conferenceId}/Participants/{callId} Update a Participant
DefaultApi UpdateAQueue POST /Accounts/{accountId}/Queues/{queueId} Update a Queue
DefaultApi UpdateAnAccount POST /Accounts/{accountId} Manage an account
DefaultApi UpdateAnApplication POST /Accounts/{accountId}/Applications/{applicationId} Update an application
DefaultApi UpdateAnIncomingNumber POST /Accounts/{accountId}/IncomingPhoneNumbers/{phoneNumberId} Update an Incoming Number
DefaultApi GetNextPage GET Get next page of paginated resource

Documentation for Models

Documentation for Enums

Documentation for Authorization

fc

  • Type: HTTP basic authentication

Documentation for Serialization/Deserialization for Enums

These methods are not required unless being used for debugging/logging purposes

  • To serialize (turn value into enum), we would need to use the reflection method GetEnumByValue where you pass the enum as a type and value into the method to get the associated enum.

    GetMemberValue

    This is an extension method, so you can turn an enum directly into a value

    Get a value from an enum

      using System.Collections.Generic;
      using System.Diagnostics;
      using System;
      using System.Linq;
      using System.IO;
      using freeclimb.Api;
      using freeclimb.Client;
      using freeclimb.Model;
      using System.Reflection;
      using Newtonsoft.Json;
    
      using freeclimb.Enums;
    
      namespace Example
      {
      public class GetMemberValueExample
      {
          public static void Main()
          {
              AccountStatus status = AccountStatus.ACTIVE;
              string expectedValue = StringValueAccountStatusTestValue();
              string calculatedValue = status.GetMemberValue();
              Assert.Equal(expectedValue, calculatedValue);
          }
          private string StringValueAccountStatusTestValue()
          {
              return "active";
          }
      }
    
      }
  • To deserialize a value (turn enum into value), we would need to use the extension method GetMemberValue where you pass the enum as a parameter into the method to get the associated value.

    GetEnumByValue

    Reflection.GetEnumByValue(expectedValue)

    Get an Enum value from string

      using System.Collections.Generic;
      using System.Diagnostics;
      using System;
      using System.Linq;
      using System.IO;
      using freeclimb.Api;
      using freeclimb.Client;
      using freeclimb.Model;
      using System.Reflection;
      using Newtonsoft.Json;
    
      using freeclimb.Enums;
    
      namespace Example
      {
      public class GetEnumByValueExample
      {
          public static void Main()
          {
              string stringToConvertToEnum = "active";
              AccountStatus calculatedEnumValue = Reflection.GetEnumByValue<AccountStatus>(expectedValue);
              AccountStatus expectedValue = AccountStatus.ACTIVE;
              Assert.Equal(expectedValue, calculatedEnumValue);
          }
      }
    
      }

Documentation for verifying request signature

  • To verify the request signature, we will need to use the verifyRequestSignature method within the Request Verifier class

    RequestVerifier.verifyRequestSignature(requestBody, requestHeader, signingSecret, tolerance)

    This is a method that you can call directly from the request verifier class, it will throw exceptions depending on whether all parts of the request signature is valid otherwise it will throw a specific error message depending on which request signature part is causing issues

    This method requires a requestBody of type string, a requestHeader of type string, a signingSecret of type string, and a tolerance value of type int

    Example code down below

      using freeclimb.Utils;
      using System;
    
    
      namespace Example
      {
      	public class verifySignatureRequestExample
      	{
              public static void Main()
              {
                      string requestBody = "{\"accountId\":\"AC1334ffb694cd8d969f51cddf5f7c9b478546d50c\",\"callId\":\"CAccb0b00506553cda09b51c5477f672a49e0b2213\",\"callStatus\":\"ringing\",\"conferenceId\":null,\"direction\":\"inbound\",\"from\":\"+13121000109\",\"parentCallId\":null,\"queueId\":null,\"requestType\":\"inboundCall\",\"to\":\"+13121000096\"}";
    
                      string signingSecret = "sigsec_ead6d3b6904196c60835d039e91b3341c77a7793";
    
                      string requestHeader = "t=1679944186,v1=c3957749baf61df4b1506802579cc69a74c77a1ae21447b930e5a704f9ec4120,v1=1ba18712726898fbbe48cd862dd096a709f7ad761a5bab14bda9ac24d963a6a8";
                      int tolerance = 5 * 60;
    
                      RequestVerifier.verifyRequestSignature(requestBody, requestHeader, signingSecret, tolerance)
              }
         }
    
      }