samcart-api
Version:
A typescript/javascript api for connecting to SamCart.
832 lines • 169 kB
JavaScript
"use strict";
/* tslint:disable */
/* eslint-disable */
/**
* SamCart Public API
* # Introduction Welcome to SamCart\'s Public API. This API is used for accessing the data inside your SamCart marketplace. ## Private Beta This API is currently in private beta. If you would like to be considered for our beta program, please contact support@samcart.com. ## OpenAPI Specification This API is documented in OpenAPI format and follows the practices of that specification. # Authentication This API offers one form of authentication: <ul> <li>API Key</lil> </ul> API keys can only be generated by the SamCart Support team. Please contact support@samcart.com if you would like to be included in the Beta program. ## Using the API Key To be successfully authenticated, you must pass the header parameter <span class=\'code\'>sc-api</span> with your provided API key. If your key is invalid or not supplied in the call, the API will return code <span class=\'code\'>401 Unauthorized</a> with an additional message explaining the specifics of why that code was returned. ## Security Scheme All of our responses are secure via HTTPS. This API will accept HTTPS or HTTP requests, but HTTP requests will result in a `301 Moved Permanently` response header to redirect the request to HTTPS. If you send an HTTP request, and your client supports automatic redirects, you will receive your payload back via HTTPS. If your client does not support automatic redirects, you will receive the response `301 Moved Permanently` and you will have to manually update your request to use HTTPS. # Rate Limiting All endpoints of this API are rate-limited. If any of the limits configured is reached, the service will return status code <span class=\'code\'>429 Too Many Requests</span> to the client. If a request is rate-limited, the response will include a header explaining the limits and how many seconds are remaining before additional requests can be made. # Pagination The following bulk endpoints include pagination: <ul class=\'list\'> <li><a href=\'https://developer.samcart.com/#operation/getCharges\'>Charges</a></li> <li><a href=\'https://developer.samcart.com/#operation/getCustomers\'>Customers</a></li> <li><a href=\'https://developer.samcart.com/#operation/getProducts\'>Products</a></li> </ul> When making a request to a paginated endpoint, the response will return a maximum of 100 results but can be adjusted using the <span class=\'code\'>limit</span> query parameter. Included in the body of the response are links to subsequent pages of results. Using these links you are able to use to iterate through the various pages of results. # Response Codes The following is a list of the response code that may be sent after an API request is made. Some response codes will provide additional messaging about why that response code was returned: <ul class=\'list\'> <li class=\'code\'>200 Success</li> <li class=\'code\'>301 Moved Permanently</li> <li class=\'code\'>404 Object could not be found</splian> <li class=\'code\'>401 Unauthorized</li> <li class=\'code\'>429 Too Many Requests</li> <li class=\'code\'>504 Timeout</li> </ul> # Versioning and compatibility We will try to maintain backward and future compatibility as much as we can. However, in case we need to introduce a backward-incompatible change, we will release a new version of the API. Currently, the API is on <span class=\'code\'>Version 1</span>. ## Changelog ### 2021-07-15 Fixed pagination URL protocol to match original request. ### 2021-07-13 Added bulk endpoint for our Subscriptions object. Calls made to this endpoint will return all Subscriptions within the specified parameters. ### 2021-06-22 Added bulk endpoint for our Orders object. Calls made to this endpoint will return all Orders within the specified parameters. ### 2021-06-09 Introduced the <span class=\'code\'>SKU</span> property to the Orders, Subscriptions, and Products endpoint. Added indexes to improve performance. ### 2021-06-02 Initial API specification published and began private beta. # Feedback We’d love your feedback! We’re committed to growing our API product and want to ensure it meets your needs. Click on the link below to give us feedback on our API. While you’re there, check out the other great initiatives on our roadmap. <a href=\'https://feedback.samcart.com/c/85-public-api\'>SamCart Public API Feedback</a>
*
* The version of the OpenAPI document: 1.0.0
* Contact: support@samcart.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionsApi = exports.SubscriptionsApiFactory = exports.SubscriptionsApiFp = exports.SubscriptionsApiAxiosParamCreator = exports.ProductsApi = exports.ProductsApiFactory = exports.ProductsApiFp = exports.ProductsApiAxiosParamCreator = exports.OrdersApi = exports.OrdersApiFactory = exports.OrdersApiFp = exports.OrdersApiAxiosParamCreator = exports.FailedChargesApi = exports.FailedChargesApiFactory = exports.FailedChargesApiFp = exports.FailedChargesApiAxiosParamCreator = exports.CustomersApi = exports.CustomersApiFactory = exports.CustomersApiFp = exports.CustomersApiAxiosParamCreator = exports.ChargesApi = exports.ChargesApiFactory = exports.ChargesApiFp = exports.ChargesApiAxiosParamCreator = exports.SubscriptionServiceCouponTypeEnum = exports.SubscriptionServiceCouponChargeInstanceEnum = exports.SubscriptionServiceProcessorNameEnum = exports.SubscriptionServiceTypeEnum = exports.SubscriptionServiceStatusEnum = exports.SubscriptionPlanServicePlanFrequencyEnum = exports.SubscriptionPlanServicePlanStatusEnum = exports.SubscriptionHistoryServiceNewStatusEnum = exports.RefundServiceChargeRefundStatusEnum = exports.ProductServiceStatusEnum = exports.ProductServicePricingTypeEnum = exports.ProductServiceProductCategoryEnum = exports.OrderServiceCouponTypeEnum = exports.OrderServiceCouponChargeInstanceEnum = exports.OrderServiceCartItemsStatusEnum = exports.OrderServiceCartItemsPricingTypeEnum = exports.OrderServiceProcessorNameEnum = exports.FailedChargeServiceProcessorNameEnum = exports.ChargeServiceChargeRefundStatusEnum = exports.ChargeServiceProcessorNameEnum = exports.AddressServiceTypeEnum = void 0;
const axios_1 = __importDefault(require("axios"));
// Some imports not used depending on template conditions
// @ts-ignore
const common_1 = require("./common");
// @ts-ignore
const base_1 = require("./base");
exports.AddressServiceTypeEnum = {
Shipping: 'shipping',
Billing: 'billing'
};
exports.ChargeServiceProcessorNameEnum = {
Stripe: 'Stripe',
Braintree: 'Braintree',
AuthorizeNet: 'Authorize.net',
PayPal: 'PayPal'
};
exports.ChargeServiceChargeRefundStatusEnum = {
Refunded: 'refunded',
PartiallyRefunded: 'partially_refunded'
};
exports.FailedChargeServiceProcessorNameEnum = {
Stripe: 'Stripe',
Braintree: 'Braintree',
AuthorizeNet: 'Authorize.net',
PayPal: 'PayPal'
};
exports.OrderServiceProcessorNameEnum = {
Stripe: 'Stripe',
Braintree: 'Braintree',
AuthorizeNet: 'Authorize.net',
PayPal: 'PayPal'
};
exports.OrderServiceCartItemsPricingTypeEnum = {
OneTime: 'one_time',
RecurringSubscription: 'recurring_subscription',
LimitedSubscription: 'limited_subscription',
PwywOnetime: 'pwyw_onetime',
PwywRecurringSubscription: 'pwyw_recurring_subscription',
PwywLimitedSubscription: 'pwyw_limited_subscription'
};
exports.OrderServiceCartItemsStatusEnum = {
Pending: 'pending',
Charged: 'charged',
Declined: 'declined',
Refunded: 'refunded',
Fulfilled: 'fulfilled',
Reversed: 'reversed',
PartiallyRefunded: 'partially_refunded'
};
exports.OrderServiceCouponChargeInstanceEnum = {
OneTime: 'one_time',
Recurring: 'recurring'
};
exports.OrderServiceCouponTypeEnum = {
FlatRate: 'flat_rate',
Percentage: 'percentage'
};
exports.ProductServiceProductCategoryEnum = {
Physical: 'physical',
Digital: 'digital'
};
exports.ProductServicePricingTypeEnum = {
OneTime: 'one_time',
Limited: 'limited',
Recurring: 'recurring',
Pwyw: 'pwyw'
};
exports.ProductServiceStatusEnum = {
Live: 'live',
Test: 'test',
Archived: 'archived'
};
exports.RefundServiceChargeRefundStatusEnum = {
Refunded: 'refunded',
PartiallyRefunded: 'partially_refunded'
};
exports.SubscriptionHistoryServiceNewStatusEnum = {
Active: 'active',
Canceled: 'canceled',
Delinquent: 'delinquent',
Completed: 'completed',
Paused: 'paused',
InvalidProcessor: 'invalid_processor',
ScaRequired: 'sca_required',
Deleted: 'deleted'
};
exports.SubscriptionPlanServicePlanStatusEnum = {
Active: 'active',
Archived: 'archived'
};
exports.SubscriptionPlanServicePlanFrequencyEnum = {
Days: 'days',
Weekly: 'weekly',
Monthly: 'monthly',
Quarterly: 'quarterly',
Yearly: 'yearly'
};
exports.SubscriptionServiceStatusEnum = {
Active: 'active',
Canceled: 'canceled',
Delinquent: 'delinquent',
Completed: 'completed',
Paused: 'paused',
InvalidProcessor: 'invalid_processor',
ScaRequired: 'sca_required',
Deleted: 'deleted'
};
exports.SubscriptionServiceTypeEnum = {
LimitedSubscription: 'limited_subscription',
RecurringSubscription: 'recurring_subscription'
};
exports.SubscriptionServiceProcessorNameEnum = {
Stripe: 'Stripe',
Braintree: 'Braintree',
AuthorizeNet: 'Authorize.net',
PayPal: 'PayPal'
};
exports.SubscriptionServiceCouponChargeInstanceEnum = {
OneTime: 'one_time',
Recurring: 'recurring'
};
exports.SubscriptionServiceCouponTypeEnum = {
FlatRate: 'flat_rate',
Percentage: 'percentage'
};
/**
* ChargesApi - axios parameter creator
* @export
*/
const ChargesApiAxiosParamCreator = function (configuration) {
return {
/**
* Retrieve a charge
* @param {number} id The SamCart ID for the charge
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getByChargeId: (id, createdAtMin, createdAtMax, testMode, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getByChargeId', 'id', id);
const localVarPath = `/charges/{id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (testMode !== undefined) {
localVarQueryParameter['test_mode'] = testMode;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all charges
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {number} [offset] The offset value used to paginate through a list of entries. If the dir query parameter is prev then the offset will be the id of the first record of the data set otherwise the offset will be the id of the last record
* @param {number} [limit] An optional limit for the number of entries on a page with a maximum value of 100. Default value is 100 if not provided.
* @param {'next' | 'prev'} [dir] The direction to paginate the next set of data. If dir is prev the page will return a data set before the offset otherwise the data set will be after the offset. Default value is next if not provided.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getCharges: (createdAtMin, createdAtMax, testMode, offset, limit, dir, options = {}) => __awaiter(this, void 0, void 0, function* () {
const localVarPath = `/charges`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (testMode !== undefined) {
localVarQueryParameter['test_mode'] = testMode;
}
if (offset !== undefined) {
localVarQueryParameter['offset'] = offset;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (dir !== undefined) {
localVarQueryParameter['dir'] = dir;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all refunds on a charge
* @param {number} id The SamCart ID for the charge
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMultipleRefundsByChargeId: (id, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getMultipleRefundsByChargeId', 'id', id);
const localVarPath = `/charges/{id}/refunds`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve a refund on a charge
* @param {number} id The SamCart ID for the charge
* @param {number} refundId The SamCart ID for the refund
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getRefundByChargeId: (id, refundId, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getRefundByChargeId', 'id', id);
// verify required parameter 'refundId' is not null or undefined
(0, common_1.assertParamExists)('getRefundByChargeId', 'refundId', refundId);
const localVarPath = `/charges/{id}/refunds/{refund_id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)))
.replace(`{${"refund_id"}}`, encodeURIComponent(String(refundId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
};
};
exports.ChargesApiAxiosParamCreator = ChargesApiAxiosParamCreator;
/**
* ChargesApi - functional programming interface
* @export
*/
const ChargesApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.ChargesApiAxiosParamCreator)(configuration);
return {
/**
* Retrieve a charge
* @param {number} id The SamCart ID for the charge
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getByChargeId(id, createdAtMin, createdAtMax, testMode, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield localVarAxiosParamCreator.getByChargeId(id, createdAtMin, createdAtMax, testMode, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
});
},
/**
* Retrieve all charges
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {number} [offset] The offset value used to paginate through a list of entries. If the dir query parameter is prev then the offset will be the id of the first record of the data set otherwise the offset will be the id of the last record
* @param {number} [limit] An optional limit for the number of entries on a page with a maximum value of 100. Default value is 100 if not provided.
* @param {'next' | 'prev'} [dir] The direction to paginate the next set of data. If dir is prev the page will return a data set before the offset otherwise the data set will be after the offset. Default value is next if not provided.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield localVarAxiosParamCreator.getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
});
},
/**
* Retrieve all refunds on a charge
* @param {number} id The SamCart ID for the charge
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMultipleRefundsByChargeId(id, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield localVarAxiosParamCreator.getMultipleRefundsByChargeId(id, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
});
},
/**
* Retrieve a refund on a charge
* @param {number} id The SamCart ID for the charge
* @param {number} refundId The SamCart ID for the refund
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getRefundByChargeId(id, refundId, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield localVarAxiosParamCreator.getRefundByChargeId(id, refundId, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
});
},
};
};
exports.ChargesApiFp = ChargesApiFp;
/**
* ChargesApi - factory interface
* @export
*/
const ChargesApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.ChargesApiFp)(configuration);
return {
/**
* Retrieve a charge
* @param {number} id The SamCart ID for the charge
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getByChargeId(id, createdAtMin, createdAtMax, testMode, options) {
return localVarFp.getByChargeId(id, createdAtMin, createdAtMax, testMode, options).then((request) => request(axios, basePath));
},
/**
* Retrieve all charges
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {number} [offset] The offset value used to paginate through a list of entries. If the dir query parameter is prev then the offset will be the id of the first record of the data set otherwise the offset will be the id of the last record
* @param {number} [limit] An optional limit for the number of entries on a page with a maximum value of 100. Default value is 100 if not provided.
* @param {'next' | 'prev'} [dir] The direction to paginate the next set of data. If dir is prev the page will return a data set before the offset otherwise the data set will be after the offset. Default value is next if not provided.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options) {
return localVarFp.getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options).then((request) => request(axios, basePath));
},
/**
* Retrieve all refunds on a charge
* @param {number} id The SamCart ID for the charge
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getMultipleRefundsByChargeId(id, options) {
return localVarFp.getMultipleRefundsByChargeId(id, options).then((request) => request(axios, basePath));
},
/**
* Retrieve a refund on a charge
* @param {number} id The SamCart ID for the charge
* @param {number} refundId The SamCart ID for the refund
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getRefundByChargeId(id, refundId, options) {
return localVarFp.getRefundByChargeId(id, refundId, options).then((request) => request(axios, basePath));
},
};
};
exports.ChargesApiFactory = ChargesApiFactory;
/**
* ChargesApi - object-oriented interface
* @export
* @class ChargesApi
* @extends {BaseAPI}
*/
class ChargesApi extends base_1.BaseAPI {
/**
* Retrieve a charge
* @param {number} id The SamCart ID for the charge
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChargesApi
*/
getByChargeId(id, createdAtMin, createdAtMax, testMode, options) {
return (0, exports.ChargesApiFp)(this.configuration).getByChargeId(id, createdAtMin, createdAtMax, testMode, options).then((request) => request(this.axios, this.basePath));
}
/**
* Retrieve all charges
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {number} [offset] The offset value used to paginate through a list of entries. If the dir query parameter is prev then the offset will be the id of the first record of the data set otherwise the offset will be the id of the last record
* @param {number} [limit] An optional limit for the number of entries on a page with a maximum value of 100. Default value is 100 if not provided.
* @param {'next' | 'prev'} [dir] The direction to paginate the next set of data. If dir is prev the page will return a data set before the offset otherwise the data set will be after the offset. Default value is next if not provided.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChargesApi
*/
getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options) {
return (0, exports.ChargesApiFp)(this.configuration).getCharges(createdAtMin, createdAtMax, testMode, offset, limit, dir, options).then((request) => request(this.axios, this.basePath));
}
/**
* Retrieve all refunds on a charge
* @param {number} id The SamCart ID for the charge
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChargesApi
*/
getMultipleRefundsByChargeId(id, options) {
return (0, exports.ChargesApiFp)(this.configuration).getMultipleRefundsByChargeId(id, options).then((request) => request(this.axios, this.basePath));
}
/**
* Retrieve a refund on a charge
* @param {number} id The SamCart ID for the charge
* @param {number} refundId The SamCart ID for the refund
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ChargesApi
*/
getRefundByChargeId(id, refundId, options) {
return (0, exports.ChargesApiFp)(this.configuration).getRefundByChargeId(id, refundId, options).then((request) => request(this.axios, this.basePath));
}
}
exports.ChargesApi = ChargesApi;
/**
* CustomersApi - axios parameter creator
* @export
*/
const CustomersApiAxiosParamCreator = function (configuration) {
return {
/**
* Retrieve all addresses for a customer
* @param {number} id The SamCart ID for the customer
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAddressesByCustomerId: (id, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getAddressesByCustomerId', 'id', id);
const localVarPath = `/customers/{id}/addresses`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve a customer
* @param {number} id The SamCart ID for the customer
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getByCustomerId: (id, createdAtMin, createdAtMax, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getByCustomerId', 'id', id);
const localVarPath = `/customers/{id}`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all charges for a customer
* @param {number} id The SamCart ID for the customer
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getChargesByCustomerId: (id, createdAtMin, createdAtMax, testMode, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getChargesByCustomerId', 'id', id);
const localVarPath = `/customers/{id}/charges`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (testMode !== undefined) {
localVarQueryParameter['test_mode'] = testMode;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all customers
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {number} [offset] The offset value used to paginate through a list of entries. If the dir query parameter is prev then the offset will be the id of the first record of the data set otherwise the offset will be the id of the last record
* @param {number} [limit] An optional limit for the number of entries on a page with a maximum value of 100. Default value is 100 if not provided.
* @param {'next' | 'prev'} [dir] The direction to paginate the next set of data. If dir is prev the page will return a data set before the offset otherwise the data set will be after the offset. Default value is next if not provided.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getCustomers: (createdAtMin, createdAtMax, offset, limit, dir, options = {}) => __awaiter(this, void 0, void 0, function* () {
const localVarPath = `/customers`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (offset !== undefined) {
localVarQueryParameter['offset'] = offset;
}
if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
if (dir !== undefined) {
localVarQueryParameter['dir'] = dir;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all orders for a customer
* @param {number} id The SamCart ID for the customer
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getOrdersByCustomerId: (id, createdAtMin, createdAtMax, testMode, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getOrdersByCustomerId', 'id', id);
const localVarPath = `/customers/{id}/orders`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (testMode !== undefined) {
localVarQueryParameter['test_mode'] = testMode;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
/**
* Retrieve all subscriptions for a customer
* @param {number} id The SamCart ID for the customer
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {string} [rebillingAtMin] Filter by UTC rebilling date at or after given date
* @param {string} [rebillingAtMax] Filter by UTC rebilling date at or before given date
* @param {string} [canceledAtMin] Filter by UTC canceled date at or after given date
* @param {string} [canceledAtMax] Filter by UTC canceled date at or before given date
* @param {'active' | 'canceled' | 'delinquent' | 'completed' | 'paused' | 'invalid_processor' | 'sca_required' | 'deleted'} [status] Filter subscriptions by status
* @param {'limited_subscription' | 'recurring_subscription'} [type] Filter subscriptions by type
* @param {boolean} [testMode] Filter by test mode
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getSubscriptionsByCustomerId: (id, createdAtMin, createdAtMax, rebillingAtMin, rebillingAtMax, canceledAtMin, canceledAtMax, status, type, testMode, options = {}) => __awaiter(this, void 0, void 0, function* () {
// verify required parameter 'id' is not null or undefined
(0, common_1.assertParamExists)('getSubscriptionsByCustomerId', 'id', id);
const localVarPath = `/customers/{id}/subscriptions`
.replace(`{${"id"}}`, encodeURIComponent(String(id)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication apiKeyAuth required
yield (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "sc-api", configuration);
if (createdAtMin !== undefined) {
localVarQueryParameter['created_at_min'] = (createdAtMin instanceof Date) ?
createdAtMin.toISOString().substr(0, 10) :
createdAtMin;
}
if (createdAtMax !== undefined) {
localVarQueryParameter['created_at_max'] = (createdAtMax instanceof Date) ?
createdAtMax.toISOString().substr(0, 10) :
createdAtMax;
}
if (rebillingAtMin !== undefined) {
localVarQueryParameter['rebilling_at_min'] = (rebillingAtMin instanceof Date) ?
rebillingAtMin.toISOString().substr(0, 10) :
rebillingAtMin;
}
if (rebillingAtMax !== undefined) {
localVarQueryParameter['rebilling_at_max'] = (rebillingAtMax instanceof Date) ?
rebillingAtMax.toISOString().substr(0, 10) :
rebillingAtMax;
}
if (canceledAtMin !== undefined) {
localVarQueryParameter['canceled_at_min'] = (canceledAtMin instanceof Date) ?
canceledAtMin.toISOString().substr(0, 10) :
canceledAtMin;
}
if (canceledAtMax !== undefined) {
localVarQueryParameter['canceled_at_max'] = (canceledAtMax instanceof Date) ?
canceledAtMax.toISOString().substr(0, 10) :
canceledAtMax;
}
if (status !== undefined) {
localVarQueryParameter['status'] = status;
}
if (type !== undefined) {
localVarQueryParameter['type'] = type;
}
if (testMode !== undefined) {
localVarQueryParameter['test_mode'] = testMode;
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
}),
};
};
exports.CustomersApiAxiosParamCreator = CustomersApiAxiosParamCreator;
/**
* CustomersApi - functional programming interface
* @export
*/
const CustomersApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.CustomersApiAxiosParamCreator)(configuration);
return {
/**
* Retrieve all addresses for a customer
* @param {number} id The SamCart ID for the customer
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
getAddressesByCustomerId(id, options) {
return __awaiter(this, void 0, void 0, function* () {
const localVarAxiosArgs = yield localVarAxiosParamCreator.getAddressesByCustomerId(id, options);
return (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration);
});
},
/**
* Retrieve a customer
* @param {number} id The SamCart ID for the customer
* @param {string} [createdAtMin] Filter by UTC created at date at or after given date
* @param {string} [createdAtMax] Filter by UTC created at date at or before given date
* @param {*} [options] Override