UNPKG

samcart-api

Version:

A typescript/javascript api for connecting to SamCart.

153 lines 9.88 kB
"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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0; const base_1 = require("./base"); /** * * @export */ exports.DUMMY_BASE_URL = 'https://example.com'; /** * * @throws {RequiredError} * @export */ const assertParamExists = function (functionName, paramName, paramValue) { if (paramValue === null || paramValue === undefined) { throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); } }; exports.assertParamExists = assertParamExists; /** * * @export */ const setApiKeyToObject = function (object, keyParamName, configuration) { return __awaiter(this, void 0, void 0, function* () { if (configuration && configuration.apiKey) { const localVarApiKeyValue = typeof configuration.apiKey === 'function' ? yield configuration.apiKey(keyParamName) : yield configuration.apiKey; object[keyParamName] = localVarApiKeyValue; } }); }; exports.setApiKeyToObject = setApiKeyToObject; /** * * @export */ const setBasicAuthToObject = function (object, configuration) { if (configuration && (configuration.username || configuration.password)) { object["auth"] = { username: configuration.username, password: configuration.password }; } }; exports.setBasicAuthToObject = setBasicAuthToObject; /** * * @export */ const setBearerAuthToObject = function (object, configuration) { return __awaiter(this, void 0, void 0, function* () { if (configuration && configuration.accessToken) { const accessToken = typeof configuration.accessToken === 'function' ? yield configuration.accessToken() : yield configuration.accessToken; object["Authorization"] = "Bearer " + accessToken; } }); }; exports.setBearerAuthToObject = setBearerAuthToObject; /** * * @export */ const setOAuthToObject = function (object, name, scopes, configuration) { return __awaiter(this, void 0, void 0, function* () { if (configuration && configuration.accessToken) { const localVarAccessTokenValue = typeof configuration.accessToken === 'function' ? yield configuration.accessToken(name, scopes) : yield configuration.accessToken; object["Authorization"] = "Bearer " + localVarAccessTokenValue; } }); }; exports.setOAuthToObject = setOAuthToObject; /** * * @export */ const setSearchParams = function (url, ...objects) { const searchParams = new URLSearchParams(url.search); for (const object of objects) { for (const key in object) { if (Array.isArray(object[key])) { searchParams.delete(key); for (const item of object[key]) { searchParams.append(key, item); } } else { searchParams.set(key, object[key]); } } } url.search = searchParams.toString(); }; exports.setSearchParams = setSearchParams; /** * * @export */ const serializeDataIfNeeded = function (value, requestOptions, configuration) { const nonString = typeof value !== 'string'; const needsSerialization = nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); }; exports.serializeDataIfNeeded = serializeDataIfNeeded; /** * * @export */ const toPathString = function (url) { return url.pathname + url.search + url.hash; }; exports.toPathString = toPathString; /** * * @export */ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) { return (axios = globalAxios, basePath = BASE_PATH) => { const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url }); return axios.request(axiosRequestArgs); }; }; exports.createRequestFunction = createRequestFunction; //# sourceMappingURL=common.js.map