moltin / js-sdk

JavaScript & Node.js SDKs for the Elastic Path Commerce Cloud eCommerce API
http://documentation.elasticpath.com/
MIT License
173 stars 77 forks source link

Issues with Order and AddressBase types not matching the order data from get order response #615

Closed scernisevs closed 2 years ago

scernisevs commented 2 years ago

Issues with Order and CustomerAddress types not matching the order data from getOrder response

Here is an example of Order Data from GET https://api.moltin.com/v2/orders

  {
            "id": "33140290-780a-4cbd-8e78-ea5512d3c3d8",
            "type": "order",
            "consignment_id": "0",
            "shipping-provider": null,
            "status": "processing",
            "payment": "authorized",
            "shipping": "unfulfilled",
            "anonymized": false,
            "customer": {
                "name": "Padmanabhan M",
                "email": "padmanabhan.masilamani@borngroup.com"
            },
            "shipping_address": {
                "first_name": "Padmanabhan",
                "last_name": "Masilamani",
                "phone_number": "",
                "company_name": "",
                "line_1": "Lane2",
                "line_2": "Lane2",
                "city": "Chennai",
                "postcode": "100001",
                "county": "New York",
                "country": "AG",
                "instructions": ""
            },
            "billing_address": {
                "first_name": "Padmanabhan",
                "last_name": "Masilamani",
                "company_name": "",
                "line_1": "Lane2",
                "line_2": "Lane2",
                "city": "Chennai",
                "postcode": "100001",
                "county": "New York",
                "country": "AG"
            },
            "links": {},
            "meta": {
                "display_price": {
                    "with_tax": {
                        "amount": 52345,
                        "currency": "USD",
                        "formatted": "$523.45"
                    },
                    "without_tax": {
                        "amount": 52345,
                        "currency": "USD",
                        "formatted": "$523.45"
                    },
                    "tax": {
                        "amount": 0,
                        "currency": "USD",
                        "formatted": "$0.00"
                    },
                    "discount": {
                        "amount": 0,
                        "currency": "USD",
                        "formatted": "$0.00"
                    }
                },
                "timestamps": {
                    "created_at": "2022-04-22T12:05:40Z",
                    "updated_at": "2022-04-22T12:05:40Z"
                }
            },
            "relationships": {
                "items": {
                    "data": [
                        {
                            "type": "item",
                            "id": "1342ca3b-b18d-48b2-8c21-c737bc08a19d"
                        },
                        {
                            "type": "item",
                            "id": "f10f411f-6002-4faa-905c-3039e3b02ab5"
                        },
                        {
                            "type": "item",
                            "id": "f2ae96fc-1b1b-4b76-99f8-55debba501c1"
                        },
                        {
                            "type": "item",
                            "id": "31d6f2a3-b30f-43b9-98e9-0ad73440ed9b"
                        },
                        {
                            "type": "item",
                            "id": "b31c54db-cf78-4c3c-89a5-9ee3a21c22f2"
                        }
                    ]
                },
                "customer": {
                    "data": {
                        "type": "customer",
                        "id": "c75a5ba9-50c5-42ad-a788-46948511e6c4"
                    }
                }
            }
        }

Problems:

Order Types - https://github.com/moltin/js-sdk/blob/master/src/types/order.d.ts 1) Order --> shipping_address: AddressBase, billing_address: AddressBase AddressBase --> has mandatory fields "name", and "type", that are not present on the response 2) Order --> items?: RelationshipToMany<'product'> is incorrect and throws errors as it should be RelationshipToMany<'item'>

3) AddressBase has: phone_number, instructions fields as required, which are not present for billing_address

rjdmacedo commented 2 years ago

If I may pitch in, there are more types that aren't correct with what's coming from the API.

POST /getCatalogs and /getNodes should return a Catalog[] and a Node[] but there is a mismatch on some properties.

field123 commented 2 years ago

Hi @rjdmacedo

If you could create a issue with the sepcifics of the mismatched types then I'll be able to get them sorted 🙏. If you can make PR that would be even better. 😉