Skip to content

ingrammicro-xvantage/xi-sdk-resellers-csharp

Repository files navigation

xi.sdk.resellers - the C# library for the XI Sdk Resellers

For resellers seeking to innovate with Ingram Micro's API solutions, automate your eCommerce experience with our array of APIs and webhooks to craft a seamless journey for your customers.

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 Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

Installation

From NuGet:

dotnet add package xi.sdk.resellers

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 xi.sdk.resellers.Api;
using xi.sdk.resellers.Client;
using xi.sdk.resellers.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 xi.sdk.resellers.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;

Connections

Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method.

To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see here for details). To use your own HttpClient instance just pass it to the ApiClass constructor.

HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);

If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory.

HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient);

You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available.

Here an example of DI setup in a sample web project:

services.AddHttpClient<YourApiClass>(httpClient =>
   new PetApi(httpClient));

Getting Started

Quickstart on creating an application can be found here

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using xi.sdk.resellers.Api;
using xi.sdk.resellers.Client;
using xi.sdk.resellers.Model;

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

            Configuration config = new Configuration();
            config.BasePath = "https://api.ingrammicro.com:443";
            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new AccesstokenApi(httpClient, config, httpClientHandler);
            var grantType = client_credentials;  // string | Keep grant_type as client_credentials only.
            var clientId = "clientId_example";  // string | 
            var clientSecret = "clientSecret_example";  // string | 

            try
            {
                // Accesstoken
                AccesstokenResponse result = apiInstance.GetAccesstoken(grantType, clientId, clientSecret);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling AccesstokenApi.GetAccesstoken: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.ingrammicro.com:443

Class Method HTTP request Description
AccesstokenApi GetAccesstoken GET /oauth/oauth20/token Accesstoken
DealsApi GetResellersV6Dealsdetails GET /resellers/v6/deals/{dealId} Deals Details
DealsApi GetResellersV6Dealssearch GET /resellers/v6/deals/search Deals Search
FreightEstimateApi PostFreightestimate POST /resellers/v6/freightestimate Freight Estimate
InvoicesApi GetInvoicedetailsV61 GET /resellers/v6.1/invoices/{invoiceNumber} Get Invoice Details v6.1
InvoicesApi GetResellersV6Invoicesearch GET /resellers/v6/invoices Search your invoice
OrderStatusApi ResellersV1WebhooksOrderstatuseventPost POST /resellers/v1/webhooks/orderstatusevent Order Status
OrdersApi DeleteOrdercancel DELETE /resellers/v6/orders/{OrderNumber} Cancel your Order
OrdersApi GetOrderdetailsV61 GET /resellers/v6.1/orders/{ordernumber} Get Order Details v6.1
OrdersApi GetResellersV6Ordersearch GET /resellers/v6/orders/search Search your Orders
OrdersApi PostCreateorderV6 POST /resellers/v6/orders Create your Order
OrdersApi PutOrdermodify PUT /resellers/v6/orders/{orderNumber} Modify your Order
ProductCatalogApi GetResellerV6Productdetail GET /resellers/v6/catalog/details/{ingramPartNumber} Product Details
ProductCatalogApi GetResellerV6Productsearch GET /resellers/v6/catalog Search Products
ProductCatalogApi PostPriceandavailability POST /resellers/v6/catalog/priceandavailability Price and Availability
QuoteToOrderApi PostQuoteToOrderV6 POST /resellers/v6/q2o/orders Quote To Order
QuotesApi GetQuotessearchV6 GET /resellers/v6/quotes/search Quote Search
QuotesApi GetResellerV6ValidateQuote GET /resellers/v6/q2o/validatequote Validate Quote
QuotesApi GetResellersV6Quotes GET /resellers/v6/quotes/{quoteNumber} Get Quote Details
RenewalsApi GetResellersV6Renewalsdetails GET /resellers/v6/renewals/{renewalId} Renewals Details
RenewalsApi PostRenewalssearch POST /resellers/v6/renewals/search Renewals Search
ReturnsApi GetResellersV6Returnsdetails GET /resellers/v6/returns/{caseRequestNumber} Returns Details
ReturnsApi GetResellersV6Returnssearch GET /resellers/v6/returns/search Returns Search
ReturnsApi PostReturnscreate POST /resellers/v6/returns/create Returns Create
StockUpdateApi ResellersV1WebhooksAvailabilityupdatePost POST /resellers/v1/webhooks/availabilityupdate Stock Update

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

application

Author

-Ingram Micro Xvantage

Contact

For any inquiries or support, please feel free to contact us at: