Swift MWS Inbound: Get Preorder Info

Back to Index

Returns pre-order information, including dates, that a seller needs before confirming a shipment for pre-order. Also indicates if a shipment has already been confirmed for pre-order.

Documentation: http://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_GetPreorderInfo.html

CURL Command

curl -X POST https://mws.amazonaws.com/FulfillmentInboundShipment/2010-10-01 \
  -d "AWSAccessKeyId=AWS_ACCESS_KEY_ID" \
  -d "Action=GetPreorderInfo" \
  -d "MWSAuthToken=MWS_AUTH_TOKEN" \
  -d "SellerId=MWS_SELLER_ID" \
  -d "SignatureVersion=2" \
  -d "Timestamp=CURRENT_DATE_TIME" \
  -d "Version=2010-10-01" \
  -d "Signature=MWS_SIGNATURE" \
  -d "SignatureMethod=HmacSHA256" \
  -d "ShipmentId=FBA2F3KCQF"

Swift Example


func chilkatTest() {
    let rest = CkoRest()
    var success: Bool

    //  URL: https://mws.amazonaws.com/FulfillmentInboundShipment/2010-10-01
    var bTls: Bool = true
    var port: Int = 443
    var bAutoReconnect: Bool = true
    success = rest.Connect("mws.amazonaws.com", port: port, tls: bTls, autoReconnect: bAutoReconnect)
    if success != true {
        print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
        print("\(rest.LastErrorText)")
        return
    }

    rest.AddQueryParam("AWSAccessKeyId", value: "AWS_ACCESS_KEY_ID")
    rest.AddQueryParam("Action", value: "GetPreorderInfo")
    rest.AddQueryParam("MWSAuthToken", value: "MWS_AUTH_TOKEN")
    rest.AddQueryParam("SellerId", value: "MWS_SELLER_ID")
    rest.AddQueryParam("SignatureVersion", value: "2")
    rest.AddQueryParam("Version", value: "2010-10-01")
    rest.AddQueryParam("SignatureMethod", value: "HmacSHA256")
    rest.AddQueryParam("ShipmentId", value: "FBA2F3KCQF")

    rest.Host = "mws.amazonaws.com"
    //  The AddMwsSignature method adds the Timestamp and Signature query params.
    rest.AddMwsSignature("POST", uriPath: "/FulfillmentInboundShipment/2010-10-01", domain: "mws.amazonaws.com", mwsSecretKey: "MWS_SECRET_KEY")

    var strResponseBody: String? = rest.FullRequestFormUrlEncoded("POST", uriPath: "/FulfillmentInboundShipment/2010-10-01")
    if rest.LastMethodSuccess != true {
        print("\(rest.LastErrorText)")
        return
    }

    let xmlResponse = CkoXml()
    xmlResponse.LoadXml(strResponseBody)

    var GetPreorderInfoResponse_xmlns: String?
    var tagPath: String?
    var ShipmentContainsPreorderableItems: String?
    var NeedByDate: String?
    var ConfirmedFulfillableDate: String?
    var ShipmentConfirmedForPreorder: String?
    var RequestId: String?

    GetPreorderInfoResponse_xmlns = xmlResponse.GetAttrValue("xmlns")
    ShipmentContainsPreorderableItems = xmlResponse.GetChildContent("GetPreorderInfoResult|ShipmentContainsPreorderableItems")
    NeedByDate = xmlResponse.GetChildContent("GetPreorderInfoResult|NeedByDate")
    ConfirmedFulfillableDate = xmlResponse.GetChildContent("GetPreorderInfoResult|ConfirmedFulfillableDate")
    ShipmentConfirmedForPreorder = xmlResponse.GetChildContent("GetPreorderInfoResult|ShipmentConfirmedForPreorder")
    RequestId = xmlResponse.GetChildContent("ResponseMetadata|RequestId")

}

Sample XML Response Body

<?xml version="1.0" encoding="utf-8" ?>
<GetPreorderInfoResponse xmlns="http://mws.amazonaws.com/FulfillmentInboundShipment/2010-10-01/">
    <GetPreorderInfoResult>
        <ShipmentContainsPreorderableItems>true</ShipmentContainsPreorderableItems>
        <NeedByDate>2015-12-27</NeedByDate>
        <ConfirmedFulfillableDate>2015-12-31</ConfirmedFulfillableDate>
        <ShipmentConfirmedForPreorder>true</ShipmentConfirmedForPreorder>
    </GetPreorderInfoResult>
    <ResponseMetadata>
        <RequestId>4a1a7029-462b-4a27-a04c-4cbe0fd107e3</RequestId>
    </ResponseMetadata>
</GetPreorderInfoResponse>