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

Commit

Permalink
feat: make getPalletLabels
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jul 15, 2020
1 parent e5f542c commit 6dffe69
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/sections/fulfillment-inbound-shipment/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,15 @@ export const GetUniquePackageLabelsResponse = Codec.interface({
GetUniquePackageLabelsResult: GetUniquePackageLabels,
}),
})

const GetPalletLabels = Codec.interface({
TransportDocument,
})

export type GetPalletLabels = GetInterface<typeof GetPalletLabels>

export const GetPalletLabelsResponse = Codec.interface({
GetPalletLabelsResponse: Codec.interface({
GetPalletLabelsResult: GetPalletLabels,
}),
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
GetInboundGuidanceForSKUResponse,
GetPackageLabels,
GetPackageLabelsResponse,
GetPalletLabels,
GetPalletLabelsResponse,
GetPreorderInfo,
GetPreorderInfoResponse,
GetPrepInstructionsForASIN,
Expand Down Expand Up @@ -48,6 +50,7 @@ import {
GetInboundGuidanceForASINParameters,
GetInboundGuidanceForSKUParameters,
GetPackageLabelsParameters,
GetPalletLabelsParameters,
GetPreorderInfoParameters,
GetPrepInstructionsForASINParameters,
GetPrepInstructionsForSKUParameters,
Expand All @@ -62,6 +65,28 @@ const FULFILLMENT_INBOUND_SHIPMENT_API_VERSION = '2010-10-01'
export class FulfillmentInboundShipment {
constructor(private httpClient: HttpClient) {}

async getPalletLabels(
parameters: GetPalletLabelsParameters,
): Promise<[GetPalletLabels, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.FulfillmentInboundShipment,
version: FULFILLMENT_INBOUND_SHIPMENT_API_VERSION,
action: 'GetPalletLabels',
parameters: {
ShipmentId: parameters.ShipmentId,
PageType: parameters.PageType,
NumberOfPallets: parameters.NumberOfPallets,
},
})

return GetPalletLabelsResponse.decode(response).caseOf({
Right: (x) => [x.GetPalletLabelsResponse.GetPalletLabelsResult, meta],
Left: (error) => {
throw new ParsingError(error)
},
})
}

async getUniquePackageLabels(
parameters: GetUniquePackageLabelsParameters,
): Promise<[GetUniquePackageLabels, RequestMeta]> {
Expand Down
8 changes: 7 additions & 1 deletion src/sections/fulfillment-inbound-shipment/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ enum PageTypeEnum {
'PackageLabel_Plain_Paper',
}

type PageType = keyof typeof PageTypeEnum
export type PageType = keyof typeof PageTypeEnum

export interface GetPackageLabelsParameters {
ShipmentId: string
Expand All @@ -393,3 +393,9 @@ export interface GetUniquePackageLabelsParameters {
PageType: PageType
PackageLabelsToPrint: string[]
}

export interface GetPalletLabelsParameters {
ShipmentId: string
PageType: PageType
NumberOfPallets: number
}
18 changes: 18 additions & 0 deletions test/unit/__snapshots__/fulfillment-inbound-shipment.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ Array [
]
`;

exports[`fulfillmentInboundShipment getPalletLabels returns PDF document data if succesful 1`] = `
Array [
Object {
"TransportDocument": Object {
"Checksum": "WGQwqA+NlzMVL1plHc/7ZA==",
"PdfDocument": "ABEAAAAAAlbHMucGRmUEsFBgAAAAABAAEAPwAAALQXAQAAAA==",
},
},
Object {
"quotaMax": 1000,
"quotaRemaining": 999,
"quotaResetOn": 2020-04-06T10:22:23.582Z,
"requestId": "0",
"timestamp": 2020-05-06T09:22:23.582Z,
},
]
`;

exports[`fulfillmentInboundShipment getPreorderInfo returns preorderinfo if succesful 1`] = `
Array [
Object {
Expand Down

0 comments on commit 6dffe69

Please sign in to comment.