Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: get lowest priced offers for sku
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed May 28, 2020
1 parent 6f35973 commit be46b5e
Show file tree
Hide file tree
Showing 4 changed files with 378 additions and 256 deletions.
20 changes: 20 additions & 0 deletions src/sections/products/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ export const GetLowestOfferListingsForASINResponse = Codec.interface({
GetLowestOfferListingsForASINResponse: GetLowestOfferListingsForASINResult,
})

/**
* @todo - complete definitions
*/

const GetLowestPricedOffersForSKU = Codec.interface({
Identifier: unknown,
Summary: unknown,
Offers: unknown,
})

export const GetLowestPricedOffersForSKUResponse = Codec.interface({
GetLowestPricedOffersForSKUResponse: Codec.interface({
GetLowestPricedOffersForSKUResult: GetLowestPricedOffersForSKU,
}),
})
/**
* Types derived from codecs
*/

export type GetMatchingProductForIdResponse = GetInterface<typeof GetMatchingProductForIdResponse>
export type GetMyFeesEstimate = GetInterface<typeof GetMyFeesEstimate>
export type ListMatchingProducts = GetInterface<typeof ListMatchingProducts>
Expand All @@ -183,3 +202,4 @@ export type GetLowestOfferListingsForSKUResult = GetInterface<
export type GetLowestOfferListingsForASINResult = GetInterface<
typeof GetLowestOfferListingsForASINResult
>
export type GetLowestPricedOffersForSKU = GetInterface<typeof GetLowestPricedOffersForSKU>
21 changes: 21 additions & 0 deletions src/sections/products/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
GetLowestOfferListingsForASINResult,
GetLowestOfferListingsForSKUResponse,
GetLowestOfferListingsForSKUResult,
GetLowestPricedOffersForSKU,
GetLowestPricedOffersForSKUResponse,
GetMatchingProductForIdResponse,
GetMatchingProductForIdResponseCodec,
GetMatchingProductResponse,
Expand All @@ -23,6 +25,7 @@ import {
GetCompetitivePricingForSkuParameters,
GetLowestOfferListingsForAsinParameters,
GetLowestOfferListingsForSkuParameters,
GetLowestPricedOffersForSkuParameters,
GetMatchingProductForIdParameters,
GetMatchingProductParameters,
GetMyFeesEstimateParameters,
Expand Down Expand Up @@ -198,4 +201,22 @@ export class Products {
},
})
}

async getLowestPricedOffersForSku(
parameters: GetLowestPricedOffersForSkuParameters,
): Promise<[GetLowestPricedOffersForSKU, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.Products,
version: PRODUCTS_API_VERSION,
action: 'GetLowestPricedOffersForSKU',
parameters,
})

return GetLowestPricedOffersForSKUResponse.decode(response).caseOf({
Right: (x) => [x.GetLowestPricedOffersForSKUResponse.GetLowestPricedOffersForSKUResult, meta],
Left: (error) => {
throw new ParsingError(error)
},
})
}
}
9 changes: 8 additions & 1 deletion src/sections/products/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface GetCompetitivePricingForAsinParameters {
[key: string]: string | string[]
}

type ItemCondition = 'Any' | 'New' | 'Used' | 'Collectible' | 'Refurbished' | 'Club'
export type ItemCondition = 'Any' | 'New' | 'Used' | 'Collectible' | 'Refurbished' | 'Club'

export interface GetLowestOfferListingsForSkuParameters {
SellerSKUList: string[]
Expand All @@ -107,3 +107,10 @@ export interface GetLowestOfferListingsForAsinParameters {
MarketplaceId: string
ItemCondition?: ItemCondition
}

export interface GetLowestPricedOffersForSkuParameters {
MarketplaceId: string
SellerSKU: string
ItemCondition: ItemCondition
[key: string]: string
}

0 comments on commit be46b5e

Please sign in to comment.