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

Commit

Permalink
feat: create confirmPreorder
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jul 13, 2020
1 parent e33a0cb commit a17ac2e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sections/fulfillment-inbound-shipment/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,16 @@ export const GetPreorderInfoResponse = Codec.interface({
GetPreorderInfoResult: GetPreorderInfo,
}),
})

const ConfirmPreorder = Codec.interface({
ConfirmedNeedByDate: string,
ConfirmedFulfillableDate: string,
})

export type ConfirmPreorder = GetInterface<typeof ConfirmPreorder>

export const ConfirmPreorderResponse = Codec.interface({
ConfirmPreorderResponse: Codec.interface({
ConfirmPreorderResult: ConfirmPreorder,
}),
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ParsingError } from '../../error'
import { HttpClient, RequestMeta, Resource } from '../../http'
import { getServiceStatusByResource } from '../shared'
import {
ConfirmPreorder,
ConfirmPreorderResponse,
CreateInboundShipment,
CreateInboundShipmentPlan,
CreateInboundShipmentPlanResponse,
Expand All @@ -19,6 +21,7 @@ import {
import {
canonicalizeParametersCreateInboUpdateundShipmentPlan,
canonicalizeParametersCreateUpdateInboundShipment,
ConfirmPreorderParameters,
CreateInboundShipmentParameters,
CreateInboundShipmentPlanParameters,
GetInboundGuidanceForASINParameters,
Expand All @@ -31,6 +34,27 @@ const FULFILLMENT_INBOUND_SHIPMENT_API_VERSION = '2010-10-01'
export class FulfillmentInboundShipment {
constructor(private httpClient: HttpClient) {}

async confirmPreorder(
parameters: ConfirmPreorderParameters,
): Promise<[ConfirmPreorder, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.FulfillmentInboundShipment,
version: FULFILLMENT_INBOUND_SHIPMENT_API_VERSION,
action: 'ConfirmPreorder',
parameters: {
ShipmentId: parameters.ShipmentId,
NeedByDate: parameters.NeedByDate.toISOString(),
},
})

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

async getPreorderInfo(
parameters: GetPreorderInfoParameters,
): Promise<[GetPreorderInfo, RequestMeta]> {
Expand Down
5 changes: 5 additions & 0 deletions src/sections/fulfillment-inbound-shipment/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,8 @@ export interface CreateInboundShipmentParameters {
export interface GetPreorderInfoParameters {
ShipmentId: string
}

export interface ConfirmPreorderParameters {
ShipmentId: string
NeedByDate: Date
}
16 changes: 16 additions & 0 deletions test/unit/__snapshots__/fulfillment-inbound-shipment.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`fulfillmentInboundShipment confirmPreorder returns confirmed dates if succesful 1`] = `
Array [
Object {
"ConfirmedFulfillableDate": "2015-12-31",
"ConfirmedNeedByDate": "2015-12-27",
},
Object {
"quotaMax": 1000,
"quotaRemaining": 999,
"quotaResetOn": 2020-04-06T10:22:23.582Z,
"requestId": "0",
"timestamp": 2020-05-06T09:22:23.582Z,
},
]
`;

exports[`fulfillmentInboundShipment createInboundShipment returns the shipment ID if succesful 1`] = `
Array [
Object {
Expand Down

0 comments on commit a17ac2e

Please sign in to comment.