Skip to content
Niels Liebisch edited this page Dec 7, 2016 · 25 revisions

Usage

Create a virtualQ client by instantiate a VirtualQ class as follows:

        var apiKey = "YOUR-API-KEY";
        using (IVirtualQ client = new VirtualQ(apiKey))
        {
            // Rest of the code ...
        }

You can provide additional information to set up a proxy or time out configuration using the VirtualQClientConfiguration class as folows:

        VirtualQClientConfiguration configuration = new VirtualQClientConfiguration
        {
            ApiBaseAddress = "https://api.example.com" // Overrides the default API base Url
            Timeout = TimeSpan.FromMilliseconds(1500), // Sets Timeout to 1.5 seconds
            ProxyConfiguration = new WebProxy()        // Sets proxy configuration using a WebProxy class
        };        
        var apiKey = "YOUR-API-KEY";
        using (IVirtualQ client = new VirtualQ(apiKey, configuration))
        {
            // Rest of the code ...
        }

All properties in VirtualQClientConfiguration class are optional.

For more information: TimeSpan, WebProxy

VirtualQ class inherits from IDisposable. If the VirtualQ client is not instantiated inside of a using block, the Dispose method must be called in order to release managed resources when the client is no longer used.

        client.Dispose();

IVirtualQ is the interface of the VirtualQ class and defines several properties that represent a handler that matches an end point in the API:

        ILinesHandler Lines { get; }
        ILineGroupsHandler LineGroups { get; }
        ICallerHandler Callers { get; }

All methods in the handler interfaces are asynchronous. Here are a couple of samples on how to use them.

ILinesHandler

ILinesHandler interface defines functionality that affects Lines API end point.

        Task<Result<bool>> IsVirtualQActive(long lineId);

Returns true if a line that matches the lineId parameter is active, otherwise returns false.

        bool isVirtualQActive;
        long lineId = 3;

        var result = async client.Lines.IsVirtualQActive(lineId);

        if(result.RequestWasSuccessful) 
        {
            // You can collect the value returned by the API
            isVirtualQActive = result.Value;
        }
        else
        {
            // Something went wrong, verify the error object assigned to the Error property
            YourCustomErrorHandling(result.Error);
        }

ILineGroupsHandler

ILineGroupsHandler interface defines functionality that affects Line Groups API end point.

        Task<Result> UpdateLineGroup(long lineGroupId, UpdateLineGroupParameters attributes);

Updates a Line Group that matches lineGroupId parameter with the information supplied in the attributes parameter. This method doesn't return an value from the API.

        long lineGroupIdToUpdate = 185;
        UpdateLineGroupParameters attributes = new UpdateLineGroupParameters
        {
            ServiceEwt = 300,
            ServiceCallersCount = 2,
            ServiceAverageTalkTime = 35,
            ServiceAgentsCount = 3,
            ServiceAgentList = new string[] { "A", "B", "C" }
        };

        Result result = async client.LineGroups.UpdateLineGroup(lineGroupIdToUpdate, attributes);

        if(!result.RequestWasSuccessful)
        {
            // Something went wrong, verify the error object assigned to the Error property
            YourCustomErrorHandling(result.Error);
        }
Clone this wiki locally