baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
136 lines (135 loc) • 7.15 kB
TypeScript
/**
* @module commerceClient
* @description Commerce Client provides an easy way to consume Commerce REST API end-points. In order to obtain a needed routes `commerceClient` uses `commerceRoute`.
*/
import { IQueryModel, IGetRequestOptions, IOptions } from '../../common/contracts';
import { ApiClient, IHttpResponse } from '../../httpApi';
import { CommerceRoute, CommerceCustomerClient, CommerceInvoiceClient, CommerceProductClient, CommercePaymentTransactionClient, Lookups, CommerceProductFilesClient, CommerceProductSettingsClient, CommerceCouponClient, CommerceCouponUseClient } from './';
export declare class CommerceClient {
protected commerceCustomerClient: CommerceCustomerClient;
protected commerceInvoiceClient: CommerceInvoiceClient;
protected commerceProductClient: CommerceProductClient;
protected commerceProductFilesClient: CommerceProductFilesClient;
protected commerceProductSettingsClient: CommerceProductSettingsClient;
protected commercePaymentTransactionClient: CommercePaymentTransactionClient;
protected commerceCouponClient: CommerceCouponClient;
protected commerceCouponUseClient: CommerceCouponUseClient;
protected lookup: Lookups;
protected commerceRoute: CommerceRoute;
protected apiClient: ApiClient;
readonly customers: CommerceCustomerClient;
readonly invoices: CommerceInvoiceClient;
readonly products: CommerceProductClient;
readonly files: CommerceProductFilesClient;
readonly settings: CommerceProductSettingsClient;
readonly paymentTransactions: CommercePaymentTransactionClient;
readonly coupons: CommerceCouponClient;
readonly couponUses: CommerceCouponUseClient;
readonly lookups: Lookups;
readonly routeDefinition: CommerceRoute;
constructor(commerceCustomerClient: CommerceCustomerClient, commerceInvoiceClient: CommerceInvoiceClient, commerceProductClient: CommerceProductClient, commerceProductFilesClient: CommerceProductFilesClient, commerceProductSettingsClient: CommerceProductSettingsClient, commercePaymentTransactionClient: CommercePaymentTransactionClient, commerceCouponClient: CommerceCouponClient, commerceCouponUseClient: CommerceCouponUseClient, lookup: Lookups, commerceRoute: CommerceRoute, apiClient: ApiClient);
/**
* Returns a promise that is resolved once the find action has been performed. Success response returns a list of commerce resources matching the given criteria.
* @method
* @example commerceClient.find({
pageNumber : 1,
pageSize : 10,
orderBy : '<field>',
orderDirection : '<asc|desc>',
customerId: '<customer-id>'
})
.then(function (collection) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
find(options?: IOptions): PromiseLike<IHttpResponse<IQueryModel<any>>>;
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the commerce resource.
* @method
* @example commerceClient.get('<id>', {})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
get(id: string, options?: IGetRequestOptions): PromiseLike<IHttpResponse<any>>;
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns the commerce resource.
* @method
* @example commerceClient.validateVAT({ countryCode: 'DE', vatId: 'DE999999999' })
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
validateVAT(countryCode: string, vatId: string): PromiseLike<IHttpResponse<any>>;
/**
* Returns a promise that is resolved once the subscribe pre-process commerce action has been performed; this action performes pre-subscribe operations such as getting client tokens etc.
* @method
* @example commerceClient.preprocess({
systemName : '<system-name>',
productId : '<product-id>',
customerId: '<id>'
})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
preprocess(data: any): PromiseLike<IHttpResponse<any>>;
/**
* Returns a promise that is resolved once the subscribe commerce action has been performed; this action creates a new commerce subscription resource.
* @method
* @example commerceClient.subscribe({
systemName : '<system-name>',
productId : '<product-id>',
customer: {
id: '<id>',
firstName: '<first-name>',
lastName: '<last-name>'
}
})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
subscribe(data: any): PromiseLike<IHttpResponse<any>>;
/**
* Returns a promise that is resolved once the cancel subscription action has been performed. This action will remove a commerce subscription resource from the system if successfully completed. This route obtain routes from `commerceRoute` route template. Here is an example of how execute this action:
* @method
* @example commerceClient.cancel({
systemName: '<system-name>',
id: '<subscription-id>',
requestRefund: <true/false>,
refundAmount: <refund-amount>
})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
cancel(data: any): PromiseLike<IHttpResponse<void>>;
}
/**
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @overview
***Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/