@apihawk/billia-sdk
Version:
The ApiHawk Billia SDK
151 lines • 5.98 kB
TypeScript
import { ApiHawkConnectorService, IApihawkSession } from '@apihawk/connector';
import { BilliaSDKServiceBase } from '../lib/billia-sdk-service-base';
import { IHashTable, IRestPaginatedResource, IRestPaginationQuery } from '../types/common';
import { ICustomerProduct, ICustomerProductNote, IExpiringProductsPeriod } from './billia-sdk-customer-product.types';
export declare class BilliaSDKCustomerProduct extends BilliaSDKServiceBase {
private billiaSDKCatalog;
constructor(api: ApiHawkConnectorService);
/**
* Get all customer products
* @param {IApihawkSession} session
* @param {IRestPaginationQuery} pagination
* @returns {Promise<IRestPaginatedResource<ICustomerProduct>>}
*/
getAll(session: IApihawkSession, pagination: IRestPaginationQuery): Promise<IRestPaginatedResource<ICustomerProduct>>;
/**
* Get products by cateogry_id
* @param {number} categoryId
* @param {IApihawkSession} session
* @param {IRestPaginationQuery} pagination
* @returns {Promise<IRestPaginatedResource<ICustomerProduct>>}
*/
getProductsByCategoryId(categoryId: number, session: IApihawkSession, pagination: IRestPaginationQuery): Promise<IRestPaginatedResource<ICustomerProduct>>;
/**
* Get expiring customer products
* @param {IApihawkSession} session user session
* @param {IExpiringProductsPeriod} period filter only products expiring this week/month/quarter
*/
getExpiringProducts(session: IApihawkSession, period?: IExpiringProductsPeriod): Promise<ICustomerProduct[]>;
/**
* Get customer product by ID
* @param {IApihawkSession} session
* @param {number} customerProductId
* @param {{}} query
* @returns {Promise<ICustomerProduct>}
*/
getCustomerProductById(session: IApihawkSession, customerProductId: number, query?: {}): Promise<ICustomerProduct>;
/**
* Gets customer product notes
* @param {IApihawkSession} session
* @param {number} customerProductId
*/
getCustomerProductNotes(session: IApihawkSession, customerProductId: number): Promise<IRestPaginatedResource<ICustomerProductNote>>;
/**
* Edits a customer product.
*
* There are three types of editing:
*
* 1. Renew
* { 'renew': { 'quantity': 12 } }
*
* 2. Edit
* { 'edit': { 'auto_renew': 'disabled', options: [{ 'option_id': 42, value: 'new value' }] } }
*
* 3. Upgrade
* { 'upgrade': { product_id: 1 } }
*
* @param {Object} session - session
* @param {number} productId - customer product ID
* @param {Object} data - request body
* @param {boolean} dryRun - calculate prices without altering the product
*/
edit(session: IApihawkSession, productId: number, data?: any, dryRun?: boolean): Promise<any>;
/**
* Get products count per category.
*
* @param {IApihawkSession} session
* @returns hash-table (category ID -> count)
*/
getProductsCountPerCategory(session: IApihawkSession): Promise<IHashTable<number>>;
/**
* Toggle auto-renew
* @param {IApihawkSession} session
* @param {number} productId
* @param {boolean} autoRenew
* @returns {Promise<ICustomerProduct>}
*/
toggleAutoRenew(session: IApihawkSession, productId: number, autoRenew: string): Promise<ICustomerProduct>;
/**
* Check if product can be temporary unsuspended
* @param {IApihawkSession} session
* @param {number} customerProductId
* @returns {Promise<boolean>}
*/
checkIsCustomerProductTemporaryUnsuspendActive(session: IApihawkSession, customerProductId: number): Promise<boolean>;
/**
* Temporary unsuspend customer product
* @param {IApihawkSession} session
* @param {number} customerProductId
* @returns {Promise<boolean>}
*/
customerProductTemporaryUnsuspend(session: IApihawkSession, customerProductId: number): Promise<boolean>;
/**
* Delete customer product option
* @param {IApihawkSession} session
* @param {number} customerProductOptionId
* @returns {Promise<boolean>}
*/
deleteCustomerProductOption(session: IApihawkSession, customerProductOptionId: number): Promise<boolean>;
/**
* Get catalog product
* @param {} session
* @param {number} productId
* @returns {Promise<ICatalogProduct>}
*/
private getCatalogProduct;
/**
* Hash customer product options
* @param {ICustomerProductOption[]} options
* @param {ICatalogOption[]} catalogProductOptions
* @returns {ICustomerProductOption[]}
*/
private hashOptions;
/**
* Calculates the current option's value in order to be
* data-bound to the front-end form controls.
*
* @param {Object} option - product option
*
* @returns {String | number | boolean} - primitive value
*/
private getCurrentOptionValue;
/**
* Maps a catalog option (not attached to a product)
* to a product option (attached to a product).
*
* @param {ICustomerProduct} product
* @param {ICustomerProductOption} productOption
* @param {ICatalogOption} catalogOption
*
* @returns {ICustomerProductOption} - product option
*/
private catalogOptionToProductOption;
/**
* Moves option group children options inside the parent option group.
*
* @param {ICustomerProductOption} optionGroup - product option of type "group"
* @param {ICustomerProductOption[]} allOptions - list of all product options
*
* @returns {ICustomerProductOption} - option group with attached children options
*/
private attachGroupChildren;
/**
* Filters visible options according to a given criteria.
*
* @param {Object} query - HTTP query hash
*
* @returns {Function} - predicate function
*/
private filterVisibleOptions;
}
//# sourceMappingURL=billia-sdk-customer-product.d.ts.map