# carts

Carts - JavaScript client for carts
### Cart Allows for a cart to be created using BigCommerce cart logic. The existing BigCommerce front end cart can be bypassed.  Notes: - A **cart** `id` is the same as a **checkout** `id`. - A cart can be created by adding an existing **catalog item** or a **custom item**. - Carts are valid for 30 days from the last modification. This can include creating the cart or editing the cart. - Redirect URLs can be generated only from carts created using the Server to Server Cart API. To restore a cart that was created on the storefront, either by a shopper or the Storefront Cart API, first recreate the cart using the Server to Server Cart API.
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: 3.0
- Package version: 3.0
- Build package: io.swagger.codegen.v3.generators.javascript.JavaScriptClientCodegen

## Installation

### For [Node.js](https://nodejs.org/)

#### npm

To publish the library as a [npm](https://www.npmjs.com/),
please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).

Then install it via:

```shell
npm install carts --save
```

#### git
#
If the library is hosted at a git repository, e.g.
https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:

```shell
    npm install GIT_USER_ID/GIT_REPO_ID --save
```

### For browser

The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file):

```shell
browserify main.js > bundle.js
```

Then include *bundle.js* in the HTML pages.

### Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:

```javascript
module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}
```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following JS code:

```javascript
var Carts = require('carts');
var defaultClient = Carts.ApiClient.instance;

// Configure API key authorization: X-Auth-Client
var X-Auth-Client = defaultClient.authentications['X-Auth-Client'];
X-Auth-Client.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-Auth-Client.apiKeyPrefix['X-Auth-Client'] = "Token"

// Configure API key authorization: X-Auth-Token
var X-Auth-Token = defaultClient.authentications['X-Auth-Token'];
X-Auth-Token.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//X-Auth-Token.apiKeyPrefix['X-Auth-Token'] = "Token"

var api = new Carts.CartApi()
var body = new Carts.CartCreatePostData(); // {CartCreatePostData} **Examples:**

1. Creating a cart by adding a simple product (a product without option selections).
2. Creating a cart with a variant. This works when a product can be specified purely by a variant, without any other required options.
3. Creating a cart with a variant, a checkbox, and a picklist modifier added.
4. Creating a cart using a custom item.
var accept = "application/json"; // {String} 
var contentType = "application/json"; // {String} 
var opts = { 
  'include': "include_example" // {String} * `redirect_urls`: Create a direct link to a Cart. This can be used during the /POST request for Carts. * `line_items.physical_items.options`: The Cart returns an abbreviated result. Use this to return physical items product options. Can also be used in a /POST to have the extended Cart object return. * `line_items.digital_items.options`: The Cart returns an abbreviated result. Use this to return digital items product options.  Can also be used in a /POST to have the extended Cart object return.
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.createACart(body, accept, contentType, opts, callback);
```

## Documentation for API Endpoints

All URIs are relative to *https://api.bigcommerce.com/stores/{$$.env.store_hash}/v3*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Carts.CartApi* | [**createACart**](docs/CartApi.md#createACart) | **POST** /carts | Create a Cart
*Carts.CartApi* | [**deleteACart**](docs/CartApi.md#deleteACart) | **DELETE** /carts/{cartId} | Delete a Cart
*Carts.CartApi* | [**getACart**](docs/CartApi.md#getACart) | **GET** /carts/{cartId} | Get a Cart
*Carts.CartApi* | [**updateACart**](docs/CartApi.md#updateACart) | **PUT** /carts/{cartId} | Update Customer ID
*Carts.CartItemsApi* | [**addCartLineItem**](docs/CartItemsApi.md#addCartLineItem) | **POST** /carts/{cartId}/items | Add Cart Line Items
*Carts.CartItemsApi* | [**deleteCartLineItem**](docs/CartItemsApi.md#deleteCartLineItem) | **DELETE** /carts/{cartId}/items/{itemId} | Delete Cart Line Item
*Carts.CartItemsApi* | [**updateCartLineItem**](docs/CartItemsApi.md#updateCartLineItem) | **PUT** /carts/{cartId}/items/{itemId} | Update Cart Line Item
*Carts.CartRedirectURLsApi* | [**createCartRedirectURL**](docs/CartRedirectURLsApi.md#createCartRedirectURL) | **POST** /carts/{cartId}/redirect_urls | Create Cart Redirect URL

## Documentation for Models

 - [Carts.AllOfLineItemDigitalItemsItems](docs/AllOfLineItemDigitalItemsItems.md)
 - [Carts.AllOfLineItemPhysicalItemsItems](docs/AllOfLineItemPhysicalItemsItems.md)
 - [Carts.AppliedCoupon](docs/AppliedCoupon.md)
 - [Carts.AppliedCoupon1](docs/AppliedCoupon1.md)
 - [Carts.AppliedDiscount](docs/AppliedDiscount.md)
 - [Carts.AppliedDiscount1](docs/AppliedDiscount1.md)
 - [Carts.BaseItem](docs/BaseItem.md)
 - [Carts.CartCreatePostData](docs/CartCreatePostData.md)
 - [Carts.CartFull](docs/CartFull.md)
 - [Carts.CartFull1](docs/CartFull1.md)
 - [Carts.CartLineItemUpdatePost](docs/CartLineItemUpdatePost.md)
 - [Carts.CartLineItemUpdatePost1](docs/CartLineItemUpdatePost1.md)
 - [Carts.CartLineItemUpdatePost2](docs/CartLineItemUpdatePost2.md)
 - [Carts.CartPostCustomItem](docs/CartPostCustomItem.md)
 - [Carts.CartPostModifier](docs/CartPostModifier.md)
 - [Carts.CartPostModifierInner](docs/CartPostModifierInner.md)
 - [Carts.CartPostVariant](docs/CartPostVariant.md)
 - [Carts.CartPostVariantInner](docs/CartPostVariantInner.md)
 - [Carts.CartRequestData](docs/CartRequestData.md)
 - [Carts.CartUpdatePutRequestData](docs/CartUpdatePutRequestData.md)
 - [Carts.CartUpdateRequest](docs/CartUpdateRequest.md)
 - [Carts.CartsCurrency](docs/CartsCurrency.md)
 - [Carts.CartsCustomItems](docs/CartsCustomItems.md)
 - [Carts.ContactEntity](docs/ContactEntity.md)
 - [Carts.Currency](docs/Currency.md)
 - [Carts.Currency1](docs/Currency1.md)
 - [Carts.GiftWrapping](docs/GiftWrapping.md)
 - [Carts.InlineResponse201](docs/InlineResponse201.md)
 - [Carts.ItemCustom](docs/ItemCustom.md)
 - [Carts.ItemCustom1](docs/ItemCustom1.md)
 - [Carts.ItemDigital](docs/ItemDigital.md)
 - [Carts.ItemDigitalCoupons](docs/ItemDigitalCoupons.md)
 - [Carts.ItemDigitalCouponsCouponCode](docs/ItemDigitalCouponsCouponCode.md)
 - [Carts.ItemGiftCertificate](docs/ItemGiftCertificate.md)
 - [Carts.ItemPhysical](docs/ItemPhysical.md)
 - [Carts.LineItem](docs/LineItem.md)
 - [Carts.LineItemGiftCertificateRequestData](docs/LineItemGiftCertificateRequestData.md)
 - [Carts.LineItemRequestData](docs/LineItemRequestData.md)
 - [Carts.ProductOption](docs/ProductOption.md)
 - [Carts.ProductOptionSelection](docs/ProductOptionSelection.md)

## Documentation for Authorization


### X-Auth-Client

- **Type**: API key
- **API key parameter name**: X-Auth-Client
- **Location**: HTTP header

### X-Auth-Token

- **Type**: API key
- **API key parameter name**: X-Auth-Token
- **Location**: HTTP header

