import axios from "axios"; import { APIOptions } from "./APIOptions"; import { APIResponse } from "./APIResponse"; import { BrandsListResponse } from "./BrandsListResponse"; import { DenominationsListResponse } from "./DenominationsListResponse"; import { BrandsListRequest } from "./BrandsListRequest"; import { BrandStoresResponse } from "./BrandStoresResponse"; import { BaseAPI } from "./BaseAPI"; // tslint:disable: no-console export class CatalogAPI extends BaseAPI { constructor(options: APIOptions) { super(options); } async getBrandsList( brandsListRequest: BrandsListRequest ): Promise> { const req = this.getAxiosInstance().get(`/brands`, { params: { ...brandsListRequest } }); return await this.executeRequest(req); } async getDenominationsList( hash: string ): Promise> { const req = this.getAxiosInstance().get( `/brand/denominations?hash=${hash}` ); return await this.executeRequest(req); } async getBrandStores( hash: string ): Promise> { const req = this.getAxiosInstance().get(`/brand/stores?hash=${hash}`); return await this.executeRequest(req); } } async function testIt() { const api = new CatalogAPI({ apiKey: "726bb9ac3f79f6402b1084c55bf5c67c", secretKey: "2c81f317d15bc1b4cf81ad4db20be9fde95c5d53636d8f1a1e9d66ab62e27ffc", baseUrl: "http://sandbox2.api.giftcardsindia.in" }); await api.initialize(); const res = await api.getBrandsList({ countryIsoCode3: "USA" // categoryName: 'Luxury', }); const { response: brandsListResponse } = res; console.log(brandsListResponse); const response = await api.getDenominationsList( "11cf86710589d54468f2d9795be9c4ff" ); console.log(JSON.stringify(response as DenominationsListResponse, null, 2)); const response2 = await api.getBrandStores( "11cf86710589d54468f2d9795be9c4ff" ); console.log(JSON.stringify(response2 as BrandStoresResponse, null, 2)); console.log(JSON.stringify(response2, null, 2)); } // testIt()