|
| 1 | +import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js'; |
| 2 | +import type { |
| 3 | + GetAllRetailCampaignCategoriesParams, |
| 4 | + GetAllRetailCampaignCategoriesResponse, |
| 5 | + GetAllRetailCampaignsParams, |
| 6 | + GetAllRetailCampaignsResponse, |
| 7 | + GetAllRetailConditionCategoriesParams, |
| 8 | + GetAllRetailConditionCategoriesResponse, |
| 9 | + GetAllRetailOfferAttributesParams, |
| 10 | + GetAllRetailOfferAttributesResponse, |
| 11 | + GetAllRetailOffersParams, |
| 12 | + GetAllRetailOffersResponse, |
| 13 | + GetAllRetailPricingRatesParams, |
| 14 | + GetAllRetailPricingRatesResponse, |
| 15 | + GetAllRetailPricingStrategiesParams, |
| 16 | + GetAllRetailPricingStrategiesResponse, |
| 17 | + GetAllRetailProductAttributesParams, |
| 18 | + GetAllRetailProductAttributesResponse, |
| 19 | + GetAllRetailProductsParams, |
| 20 | + GetAllRetailProductsResponse, |
| 21 | + GetRetailCampaignByIdParams, |
| 22 | + GetRetailCampaignByNameParams, |
| 23 | + GetRetailCampaignCategoryByIdParams, |
| 24 | + GetRetailOfferAttributeByIdParams, |
| 25 | + GetRetailOfferByIdParams, |
| 26 | + GetRetailPricingCycleParams, |
| 27 | + GetRetailPricingRateByIdParams, |
| 28 | + GetRetailPricingStrategyByIdParams, |
| 29 | + GetRetailProductAttributeByIdParams, |
| 30 | + GetRetailProductByIdParams, |
| 31 | + GetRetailProductByPriceCodeParams, |
| 32 | + GetRetailProductBySkuParams, |
| 33 | + RetailCampaign, |
| 34 | + RetailCampaignCategory, |
| 35 | + RetailOffer, |
| 36 | + RetailOfferAttribute, |
| 37 | + RetailPricingCycle, |
| 38 | + RetailPricingRate, |
| 39 | + RetailPricingStrategy, |
| 40 | + RetailProduct, |
| 41 | + RetailProductAttribute, |
| 42 | +} from './types.js'; |
| 43 | + |
| 44 | +export class ArcDeveloperRetail extends ArcAbstractAPI { |
| 45 | + constructor(options: ArcAPIOptions) { |
| 46 | + super({ ...options, apiPath: 'retail/api/v1' }); |
| 47 | + } |
| 48 | + |
| 49 | + // ============================================ |
| 50 | + // Product Methods |
| 51 | + // ============================================ |
| 52 | + |
| 53 | + async getProductById(id: number, params?: GetRetailProductByIdParams): Promise<RetailProduct> { |
| 54 | + const { data } = await this.client.get(`/product/${id}`, { params }); |
| 55 | + return data; |
| 56 | + } |
| 57 | + |
| 58 | + async getProductBySku(sku: string, params?: GetRetailProductBySkuParams): Promise<RetailProduct> { |
| 59 | + const { data } = await this.client.get(`/product/sku/${sku}`, { params }); |
| 60 | + return data; |
| 61 | + } |
| 62 | + |
| 63 | + async getProductByPriceCode(priceCode: number, params?: GetRetailProductByPriceCodeParams): Promise<RetailProduct> { |
| 64 | + const { data } = await this.client.get(`/product/pricecode/${priceCode}`, { params }); |
| 65 | + return data; |
| 66 | + } |
| 67 | + |
| 68 | + async getAllProducts(params?: GetAllRetailProductsParams): Promise<GetAllRetailProductsResponse> { |
| 69 | + const { data } = await this.client.get('/product', { params }); |
| 70 | + return data; |
| 71 | + } |
| 72 | + |
| 73 | + // ============================================ |
| 74 | + // Pricing Strategy Methods |
| 75 | + // ============================================ |
| 76 | + |
| 77 | + async getPricingStrategyById( |
| 78 | + id: number, |
| 79 | + params?: GetRetailPricingStrategyByIdParams |
| 80 | + ): Promise<RetailPricingStrategy> { |
| 81 | + const { data } = await this.client.get(`/pricing/strategy/${id}`, { params }); |
| 82 | + return data; |
| 83 | + } |
| 84 | + |
| 85 | + async getAllPricingStrategies( |
| 86 | + params?: GetAllRetailPricingStrategiesParams |
| 87 | + ): Promise<GetAllRetailPricingStrategiesResponse> { |
| 88 | + const { data } = await this.client.get('/pricing/strategy', { params }); |
| 89 | + return data; |
| 90 | + } |
| 91 | + |
| 92 | + // ============================================ |
| 93 | + // Pricing Rate Methods |
| 94 | + // ============================================ |
| 95 | + |
| 96 | + async getPricingRateById(id: number, params?: GetRetailPricingRateByIdParams): Promise<RetailPricingRate> { |
| 97 | + const { data } = await this.client.get(`/pricing/rate/${id}`, { params }); |
| 98 | + return data; |
| 99 | + } |
| 100 | + |
| 101 | + async getAllPricingRates(params?: GetAllRetailPricingRatesParams): Promise<GetAllRetailPricingRatesResponse> { |
| 102 | + const { data } = await this.client.get('/pricing/rate', { params }); |
| 103 | + return data; |
| 104 | + } |
| 105 | + |
| 106 | + // ============================================ |
| 107 | + // Pricing Cycle Methods |
| 108 | + // ============================================ |
| 109 | + |
| 110 | + async getPricingCycle( |
| 111 | + priceCode: number, |
| 112 | + cycleIndex: number, |
| 113 | + startDate: string, |
| 114 | + params?: GetRetailPricingCycleParams |
| 115 | + ): Promise<RetailPricingCycle> { |
| 116 | + const { data } = await this.client.get(`/pricing/cycle/${priceCode}/${cycleIndex}/${startDate}`, { |
| 117 | + params, |
| 118 | + }); |
| 119 | + return data; |
| 120 | + } |
| 121 | + |
| 122 | + // ============================================ |
| 123 | + // Campaign Methods |
| 124 | + // ============================================ |
| 125 | + |
| 126 | + async getCampaignById(id: number, params?: GetRetailCampaignByIdParams): Promise<RetailCampaign> { |
| 127 | + const { data } = await this.client.get(`/campaign/${id}`, { params }); |
| 128 | + return data; |
| 129 | + } |
| 130 | + |
| 131 | + async getCampaignByName(campaignName: string, params?: GetRetailCampaignByNameParams): Promise<RetailCampaign> { |
| 132 | + const { data } = await this.client.get(`/campaign/${campaignName}/get`, { params }); |
| 133 | + return data; |
| 134 | + } |
| 135 | + |
| 136 | + async getAllCampaigns(params?: GetAllRetailCampaignsParams): Promise<GetAllRetailCampaignsResponse> { |
| 137 | + const { data } = await this.client.get('/campaign', { params }); |
| 138 | + return data; |
| 139 | + } |
| 140 | + |
| 141 | + // ============================================ |
| 142 | + // Campaign Category Methods |
| 143 | + // ============================================ |
| 144 | + |
| 145 | + async getCampaignCategoryById( |
| 146 | + id: number, |
| 147 | + params?: GetRetailCampaignCategoryByIdParams |
| 148 | + ): Promise<RetailCampaignCategory> { |
| 149 | + const { data } = await this.client.get(`/campaign/category/${id}`, { params }); |
| 150 | + return data; |
| 151 | + } |
| 152 | + |
| 153 | + async getAllCampaignCategories( |
| 154 | + params?: GetAllRetailCampaignCategoriesParams |
| 155 | + ): Promise<GetAllRetailCampaignCategoriesResponse> { |
| 156 | + const { data } = await this.client.get('/campaign/category', { params }); |
| 157 | + return data; |
| 158 | + } |
| 159 | + |
| 160 | + // ============================================ |
| 161 | + // Offer Methods |
| 162 | + // ============================================ |
| 163 | + |
| 164 | + async getOfferById(id: number, params?: GetRetailOfferByIdParams): Promise<RetailOffer> { |
| 165 | + const { data } = await this.client.get(`/offer/${id}`, { params }); |
| 166 | + return data; |
| 167 | + } |
| 168 | + |
| 169 | + async getAllOffers(params?: GetAllRetailOffersParams): Promise<GetAllRetailOffersResponse> { |
| 170 | + const { data } = await this.client.get('/offer', { params }); |
| 171 | + return data; |
| 172 | + } |
| 173 | + |
| 174 | + // ============================================ |
| 175 | + // Offer Attribute Methods |
| 176 | + // ============================================ |
| 177 | + |
| 178 | + async getOfferAttributeById(id: number, params?: GetRetailOfferAttributeByIdParams): Promise<RetailOfferAttribute> { |
| 179 | + const { data } = await this.client.get(`/offer/attribute/${id}`, { params }); |
| 180 | + return data; |
| 181 | + } |
| 182 | + |
| 183 | + async getAllOfferAttributes( |
| 184 | + params?: GetAllRetailOfferAttributesParams |
| 185 | + ): Promise<GetAllRetailOfferAttributesResponse> { |
| 186 | + const { data } = await this.client.get('/offer/attribute', { params }); |
| 187 | + return data; |
| 188 | + } |
| 189 | + |
| 190 | + // ============================================ |
| 191 | + // Product Attribute Methods |
| 192 | + // ============================================ |
| 193 | + |
| 194 | + async getProductAttributeById( |
| 195 | + id: number, |
| 196 | + params?: GetRetailProductAttributeByIdParams |
| 197 | + ): Promise<RetailProductAttribute> { |
| 198 | + const { data } = await this.client.get(`/product/attribute/${id}`, { params }); |
| 199 | + return data; |
| 200 | + } |
| 201 | + |
| 202 | + async getAllProductAttributes( |
| 203 | + params?: GetAllRetailProductAttributesParams |
| 204 | + ): Promise<GetAllRetailProductAttributesResponse> { |
| 205 | + const { data } = await this.client.get('/product/attribute', { params }); |
| 206 | + return data; |
| 207 | + } |
| 208 | + |
| 209 | + // ============================================ |
| 210 | + // Condition Category Methods |
| 211 | + // ============================================ |
| 212 | + |
| 213 | + async getAllConditionCategories( |
| 214 | + params?: GetAllRetailConditionCategoriesParams |
| 215 | + ): Promise<GetAllRetailConditionCategoriesResponse> { |
| 216 | + const { data } = await this.client.get('/condition/categories', { params }); |
| 217 | + return data; |
| 218 | + } |
| 219 | +} |
0 commit comments