Exigo Developer Resources

This database contains the documentation for Exigo's OData API's, as well as C# sample code and fully-realized demo applications ready to be customized for your needs. Start building downline viewers, reporting tools and shopping carts on the Exigo platform today!


Create an account Sign In

Commissions

Overview

A multi-page report that shows both current and prior commissions earned by a distributor.

Namespaces

This sample requires the following namespaces:

using ExigoWebService;
using ExigoOData;
using System.Data.Services.Client;
using System.Text;
using System.Linq.Expressions;
using System.Reflection;
using System.ComponentModel;

Exigo API Authentication

This sample accesses the web service using the ExigoApi object:

    public ExigoApi Exigo
    {
        get
        {
            return new ExigoApi
            {
                ApiAuthenticationValue = new ApiAuthentication
                {
                    LoginName = exigoAPILoginName,
                    Password = exigoAPIPassword,
                    Company = exigoAPICompany
                }
            };
        }
    }
    

This sample also accesses OData using the ExigoContext object:

    public ExigoContext ExigoOData
    {
        get
        {
            var context = new ExigoOData.ExigoContext(new Uri("http://api.exigo.com/4.0/" + exigoAPICompany + "/model"));
            context.IgnoreMissingProperties = true;
            var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(exigoAPILoginName + ":" + exigoAPIPassword));
            context.SendingRequest +=
                (object s, SendingRequestEventArgs e) =>
                    e.RequestHeaders.Add("Authorization", "Basic " + credentials);
            return context;
        }
    }
    

Fetching All Real-Time Commissions

To fetch the customer's real-time commissions, we use the web service's GetRealTimeCommissions method.

        return Exigo.GetRealTimeCommissions(new GetRealTimeCommissionsRequest
        {
            CustomerID = customerID
        }).Commissions
            .Where(c => c.PeriodType == periodTypeID)
            .OrderByDescending(c => c.PeriodID).ToList();
        

Fetching All Prior Commissions

To fetch the customer's prior commissions, we use the Commissions OData query. We also expand the CommissionRun OData object so that we can easily access the commission's period details.

        return ExigoOData.Commissions.Expand("CommissionRun")
                .Where(c => c.CustomerID == customerID)
                .Where(c => c.CommissionRun.PeriodTypeID == periodTypeID)
                .OrderByDescending(c => c.CommissionRunID)
                .Select(c => c).ToList();
        

Fetching Period Details

To fetch a specific period's details, we use the Periods OData query, providing the desired period ID.

        return (from c in ExigoOData.Periods
                where c.PeriodID == PeriodID
                select new Period()
                {
                    StartDate = c.StartDate,
                    EndDate = c.EndDate
                }).FirstOrDefault();
        

Fetching the Current Period's Commission Run ID

In order to properly fetch a commission period's bonuses and details, we need the commission Run ID. This unique identifier is assigned to each commission run that is created in Exigo.

To fetch the current period's commission run ID, we use the CommissionRuns OData query, providing the desired period ID. We order the results by CommissionRunID to ensure we get the most recent results first.

        return (from c in ExigoOData.CommissionRuns
                where c.PeriodID == PeriodID
                orderby c.CommissionRunID descending
                select new
                {
                    c.CommissionRunID
                }).FirstOrDefault().CommissionRunID;
        

Fetching A Specific Commission

To fetch a specific commission's details, such as the earnings, previous balance, fee, total commission amount and paid rank, we use the Commissions OData query, providing the desired customer ID, the commission run ID and the currency code filter. We extend the CommissionRun OData query to allow us easy access to the commission's period details. To get the commission run ID, see the above section, "Fetching the Current Period's Commission Run ID".

        return (from c in ExigoOData.Commissions.Expand("CommissionRun")
                where c.CustomerID == customerID
                where c.CommissionRunID == CommissionRunID
                where c.CurrencyCode == currencyCode
                select c).FirstOrDefault();
        

Fetching A Specific Commission Run's Details

To fetch a specific commission run's details, such as the period ID and description, we use the CommissionRuns OData query, providing the desired commission run ID. We extend the Period OData query to allow us easy access to the commission's period details, such as the start and end date. To get the commission run ID, see the above section, "Fetching the Current Period's Commission Run ID".

        return (from c in ExigoOData.CommissionRuns.Expand("Period")
                where c.CommissionRunID == CommissionRunID
                select c).FirstOrDefault();
        

Fetching A Specific Commission's Earned Bonuses

To fetch a specific commission's earned bonuses, we use the CommissionBonuses OData query, providing the desired commission run ID. To get the commission run ID, see the above section, "Fetching the Current Period's Commission Run ID".

        return (from c in ExigoOData.CommissionBonuses
                where c.CustomerID == customerID
                where c.CommissionRunID == CommissionRunID
                select c).ToList();
        

Fetching A Specific Commission Bonus' Details

To fetch a specific commission bonus' details, we use the CommissionDetails OData query, providing the desired commission run ID, the bonus ID and the customer's ID. A bonus ID can be fetched from the CommissionBonuses OData query. To get the commission run ID, see the above section, "Fetching the Current Period's Commission Run ID".

        var query = ExigoOData.CommissionDetails
            .Where(c => c.CommissionRunID == CommissionRunID)
            .Where(c => c.BonusID == BonusID)
            .Where(c => c.CustomerID == customerID);