Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for type: SHIPMENT #361

Open
2020Deception opened this issue Dec 4, 2022 · 0 comments
Open

Example for type: SHIPMENT #361

2020Deception opened this issue Dec 4, 2022 · 0 comments

Comments

@2020Deception
Copy link

2020Deception commented Dec 4, 2022

I am trying to figure it out, but an example may help more. I am seeing the following issue:

function getOrderRequest(key, locationId, body) {
    const date = new Date();
    return {
        idempotencyKey: key,
        order: {
            locationId: locationId,
            lineItems: [{
                name: body.name,
                quantity: body.quantity,
                basePriceMoney: {
                    amount: body.amount,
                    currency: "USD"
                }
            }],
            "fulfillments": [{
                "type": "SHIPMENT",
                "state": "PROPOSED",
                "placed_at": date.toISOString(),
                "line_item_application": "ALL",
                "shipment_details": {
                    "carrier": body.shipment_details.carrier,
                    "recipient": {
                        "display_name": body.shipment_details.recipient.display_name,
                        "email_address": body.shipment_details.recipient.email_address,
                        "phone_number": body.shipment_details.recipient.phone_number,
                        "address": {
                            "address_line_1": body.shipment_details.recipient.address.address_line_1,
                            "administrative_district_level_1": body.shipment_details.recipient.address.administrative_district_level_1, //state
                            "country": body.shipment_details.recipient.address.country,
                            "locality": body.shipment_details.recipient.address.locality, //city
                            "postal_code": body.shipment_details.recipient.address.postal_code,
                        }
                    }
                }
            }]
        }
    }
}

exports.zeedy = async (req, res) => {
    const requestBody = req.body;
    console.log('start body')
    console.log(requestBody)
    console.log('end body')
    const bytes = randomBytes(12).toString('hex')
    try {
        const locationId = process.env.locationId;
        console.log(locationId)
        const createOrderRequest = getOrderRequest(bytes, locationId, requestBody);
        console.log('createOrderRequest created')
        console.log(createOrderRequest.order.fulfillments[0].shipment_details)
        console.log('end details')
        const createOrderResponse = await ordersApi.createOrder(createOrderRequest);

It failed on createOrder with:
"detail": "Fulfillments of type SHIPMENT must have shipment_details supplied.",
"field": "order.fulfillments[0].shipment_details",

but the values are there when logged. An example would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant