UltraCart REST API V2 SDK for C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swagger-codegen
docs
src
.gitignore
.swagger-codegen-ignore
.travis.yml
LICENSE
README.md
build.bat
build.sh
com.ultracart.admin.v2.sln
git_push.sh
mono_nunit_test.sh

README.md

UltraCart C# SDK - the C# library for the UltraCart Rest API V2

UltraCart REST API Version 2

This C# SDK is automatically generated by the Swagger Codegen project:

  • API version: 2.0.0
  • SDK version: 1.0.7
  • Build package: io.swagger.codegen.languages.CSharpClientCodegen

For more information, please visit http://www.ultracart.com

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742

Installation

The UltraCart REST SDK is available on nuget.org. The offical name of the nuget package is com.ultracart.admin.v2. We recommend installing and using the nuget package.

You may also 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 com.ultracart.admin.v2.Api;
using com.ultracart.admin.v2.Client;
using com.ultracart.admin.v2.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 com.ultracart.admin.v2.csproj

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

Getting Started

// You must create your own Simple API key for this example to work.
// See the comments below.

using System;
using System.Collections.Generic;
using com.ultracart.admin.v2.Api;
using com.ultracart.admin.v2.Client;
using com.ultracart.admin.v2.Model;

namespace SDKSample {
  public class GettingStarted {

    /// <summary>
    /// Helper method to loop through a large customer record set and return back a chunk of it.
    /// See the Main method for its usage.
    /// See https://www.ultracart.com/api/#resource_customer.html
    /// See https://www.ultracart.com/api/#Operation1 for the /customer/customers REST call.
    /// </summary>
    /// <param name="api">CustomerApi reference</param>
    /// <param name="offset">The record offset.  First execution this will be zero, and then increment
    /// by the number of records returned each iteration.</param>
    /// <param name="limit">Default and maximum is 200 records.  The example below uses 100.</param>
    /// <returns>
    /// A list of UltraCart customer profiles.  These are NOT records.  They are customer profiles.
    /// If a customer places an order and does not create a customer profile, they will not appear in this list.
    /// </returns>
    private static List<Customer> GetCustomerChunk(CustomerApi api, int offset = 0, int limit = 200) {

      // string expand = null; // no expansion.  bare bones.  you will rarely want this.
      const string expand = "shipping,billing"; // shipping and billing addresses
      // string expand = "shipping,billing,cards,pricing_tiers"; // everything.

      var customerResponse = api.GetCustomers(offset: offset, limit: limit, expand: expand);
      // TODO if the response is not success, handle errors here.
      return customerResponse.Success == true ? customerResponse.Customers : new List<Customer>();

    }



    private static int Main() {

      // API Simple Keys Documentation
      // https://ultracart.atlassian.net/wiki/display/ucdoc/API+Simple+Key
      //
      // This is the backend screen where API keys are created.
      // See https://secure.ultracart.com/merchant/configuration/apiManagementApp.do
      const string simpleKey = "508052342b482a015d85c69048030a0005a9da7cea5afe015d85c69048030a00";
      Configuration.Default.ApiKey.Add("x-ultracart-simple-key", simpleKey);

      // This is required.  Search for 'Versioning' on this page:
      // https://www.ultracart.com/api/#topics.html
      Configuration.Default.DefaultHeader.Add("X-UltraCart-Api-Version", "2017-03-01");

      var api = new CustomerApi();
      var offset = 0;
      const int limit = 100; // why 100?  Just to show more looping.  200 is the max and a better choice.
      var stillMoreRecords = true;
      var customers = new List<Customer>();

      while (stillMoreRecords) {
        var chunkOfCustomers = GetCustomerChunk(api, offset, limit);
        Console.WriteLine($"{chunkOfCustomers.Count} customers retrieved.");
        customers.AddRange(chunkOfCustomers);
        offset += limit;
        stillMoreRecords = chunkOfCustomers.Count == limit;

      }

      Console.WriteLine($"{customers.Count} total customers retrieved.");

      return 0;
    }

  }
}

Documentation for API Endpoints

All URIs are relative to https://secure.ultracart.com/rest/v2

Class Method HTTP request Description
AffiliateApi GetClicksByQuery POST /affiliate/clicks/query Retrieve clicks
AffiliateApi GetLedgersByQuery POST /affiliate/ledgers/query Retrieve ledger entries
AutoOrderApi GetAutoOrder GET /auto_order/auto_orders/{auto_order_oid} Retrieve an auto order
AutoOrderApi GetAutoOrderByCode GET /auto_order/auto_orders/code/{auto_order_code} Retrieve an auto order
AutoOrderApi GetAutoOrderByReferenceOrderId GET /auto_order/auto_orders/reference_order_id/{reference_order_id} Retrieve an auto order
AutoOrderApi GetAutoOrders GET /auto_order/auto_orders Retrieve auto orders
AutoOrderApi UpdateAutoOrder PUT /auto_order/auto_orders/{auto_order_oid} Update an auto order
ChargebackApi DeleteChargeback DELETE /chargeback/chargebacks/{chargeback_dispute_oid} Delete a chargeback
ChargebackApi GetChargebackDispute GET /chargeback/chargebacks/{chargeback_dispute_oid} Retrieve a chargeback
ChargebackApi GetChargebackDisputes GET /chargeback/chargebacks Retrieve chargebacks
ChargebackApi InsertChargeback POST /chargeback/chargebacks Insert a chargeback
ChargebackApi UpdateChargeback PUT /chargeback/chargebacks/{chargeback_dispute_oid} Update a chargeback
CheckoutApi CityState POST /checkout/city_state City/State for Zip
CheckoutApi FinalizeOrder POST /checkout/cart/finalizeOrder Finalize Order
CheckoutApi GetCart GET /checkout/cart Get cart
CheckoutApi GetCartByCartId GET /checkout/cart/{cart_id} Get cart (by cart id)
CheckoutApi GetCartByReturnCode GET /checkout/return/{return_code} Get cart (by return code)
CheckoutApi HandoffCart POST /checkout/cart/handoff Handoff cart
CheckoutApi Login POST /checkout/cart/profile/login Profile login
CheckoutApi Logout POST /checkout/cart/profile/logout Profile logout
CheckoutApi Register POST /checkout/cart/profile/register Profile registration
CheckoutApi RelatedItemsForCart POST /checkout/related_items Related items
CheckoutApi RelatedItemsForItem POST /checkout/relatedItems/{item_id} Related items (specific item)
CheckoutApi SetupBrowserKey PUT /checkout/browser_key Setup Browser Application
CheckoutApi UpdateCart PUT /checkout/cart Update cart
CheckoutApi ValidateCart POST /checkout/cart/validate Validate
CouponApi DeleteCoupon DELETE /coupon/coupons/{coupon_oid} Delete a coupon
CouponApi GenerateCouponCodes POST /coupon/coupons/{coupon_oid}/generate_codes Generates one time codes for a coupon
CouponApi GenerateOneTimeCodesByMerchantCode POST /coupon/coupons/merchant_code/{merchant_code}/generate_codes Generates one time codes by merchant code
CouponApi GetCoupon GET /coupon/coupons/{coupon_oid} Retrieve a coupon
CouponApi GetCouponByMerchantCode GET /coupon/coupons/merchant_code/{merchant_code} Retrieve a coupon by merchant code
CouponApi GetCoupons GET /coupon/coupons Retrieve coupons
CouponApi GetCouponsByQuery GET /coupon/coupons/query Retrieve coupons by query
CouponApi GetEditorValues GET /coupon/editor_values Retrieve values needed for a coupon editor
CouponApi InsertCoupon POST /coupon/coupons Insert a coupon
CouponApi UpdateCoupon PUT /coupon/coupons/{coupon_oid} Update a coupon
CustomerApi DeleteCustomer DELETE /customer/customers/{customer_profile_oid} Delete a customer
CustomerApi GetCustomer GET /customer/customers/{customer_profile_oid} Retrieve a customer
CustomerApi GetCustomers GET /customer/customers Retrieve customers
CustomerApi GetCustomersByQuery GET /customer/customers/query Retrieve customers by query
CustomerApi GetCustomersForDataTables POST /customer/customers/dataTables Retrieve customers for DataTables plugin
CustomerApi GetEditorValues GET /customer/editor_values Retrieve values needed for a customer profile editor
CustomerApi InsertCustomer POST /customer/customers Insert a customer
CustomerApi UpdateCustomer PUT /customer/customers/{customer_profile_oid} Update a customer
FulfillmentApi AcknowledgeOrders PUT /fulfillment/distribution_centers/{distribution_center_code}/acknowledgements Acknowledge receipt of orders.
FulfillmentApi GetDistributionCenterOrders GET /fulfillment/distribution_centers/{distribution_center_code}/orders Retrieve orders queued up for this distribution center.
FulfillmentApi GetDistributionCenters GET /fulfillment/distribution_centers Retrieve distribution centers
FulfillmentApi ShipOrders POST /fulfillment/distribution_centers/{distribution_center_code}/shipments Mark orders as shipped
FulfillmentApi UpdateInventory POST /fulfillment/distribution_centers/{distribution_center_code}/inventory Update inventory
ItemApi DeleteItem DELETE /item/items/{merchant_item_oid} Delete an item
ItemApi GetItem GET /item/items/{merchant_item_oid} Retrieve an item
ItemApi GetItemByMerchantItemId GET /item/items/merchant_item_id/{merchant_item_id} Retrieve an item by item id
ItemApi GetItems GET /item/items Retrieve items
ItemApi GetPricingTiers GET /item/pricing_tiers Retrieve pricing tiers
ItemApi InsertItem POST /item/items Create an item
ItemApi UpdateItem PUT /item/items/{merchant_item_oid} Update an item
ItemApi UpdateItems PUT /item/items/batch Update multiple items
ItemApi UploadTemporaryMultimedia POST /item/temp_multimedia Upload an image to the temporary multimedia.
OauthApi OauthAccessToken POST /oauth/token Exchange authorization code for access token.
OauthApi OauthRevoke POST /oauth/revoke Revoke this OAuth application.
OrderApi CancelOrder POST /order/orders/{order_id}/cancel Cancel an order
OrderApi DeleteOrder DELETE /order/orders/{order_id} Delete an order
OrderApi Format POST /order/orders/{order_id}/format Format order
OrderApi GetOrder GET /order/orders/{order_id} Retrieve an order
OrderApi GetOrders GET /order/orders Retrieve orders
OrderApi GetOrdersByQuery POST /order/orders/query Retrieve orders
OrderApi RefundOrder PUT /order/orders/{order_id}/refund Refund an order
OrderApi ResendReceipt POST /order/orders/{order_id}/resend_receipt Resend receipt
OrderApi ResendShipmentConfirmation POST /order/orders/{order_id}/resend_shipment_confirmation Resend shipment confirmation
OrderApi UpdateOrder PUT /order/orders/{order_id} Update an order
WebhookApi DeleteWebhook DELETE /webhook/webhooks/{webhookOid} Delete a webhook
WebhookApi GetWebhookLog GET /webhook/webhooks/{webhookOid}/logs/{requestId} Retrieve an individual log
WebhookApi GetWebhookLogSummaries GET /webhook/webhooks/{webhookOid}/logs Retrieve the log summaries
WebhookApi GetWebhooks GET /webhook/webhooks Retrieve webhooks
WebhookApi InsertWebhook POST /webhook/webhooks Add a webhook
WebhookApi ResendEvent POST /webhook/webhooks/{webhookOid}/reflow/{eventName} Resend events to the webhook endpoint.
WebhookApi UpdateWebhook PUT /webhook/webhooks/{webhookOid} Update a webhook

Documentation for Models

Documentation for Authorization

ultraCartBrowserApiKey

  • Type: API key
  • API key parameter name: x-ultracart-browser-key
  • Location: HTTP header

ultraCartOauth

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://secure.ultracart.com/rest/v2/oauth/authorize
  • Scopes:
    • affiliate_read: Allows you to read affiliate information.
    • affiliate_write: Allows you to write affiliate information.
    • auto_order_read: Allows you to read auto order information.
    • auto_order_write: Allows you to write auto order information.
    • chargeback_read: Allows you to read chargeback information.
    • chargeback_write: Allows you to write chargeback information.
    • checkout_read: Allows you to read checkout information.
    • checkout_write: Allows you to write checkout information.
    • coupon_read: Allows you to read coupon information.
    • coupon_write: Allows you to write coupon information.
    • customer_read: Allows you to read customer information.
    • customer_write: Allows you to write customer information.
    • fulfillment_read: Allows you to read fulfillment information.
    • fulfillment_write: Allows you to write fulfillment information.
    • order_read: Allows you to read order information.
    • order_write: Allows you to write order information.
    • item_read: Allows you to read item information.
    • item_write: Allows you to write item information.
    • webhook_read: Allows you to read webhook information.
    • webhook_write: Allows you to write webhook information.
    • ultrabooks_read: 1 of 2 required to use UltraBooks
    • ultrabooks_write: 2 of 2 required to use UltraBooks

ultraCartSimpleApiKey

  • Type: API key
  • API key parameter name: x-ultracart-simple-key
  • Location: HTTP header