trieb-work / schemabase

The schemabase Integration framework to build custom data movers between different cloud services. Using BullMQ, Webhooks, Prisma Database and more
https://schemabase.app
MIT License
5 stars 2 forks source link

RFC: adding Fedex tracking integration #430

Closed JannikZed closed 6 months ago

JannikZed commented 1 year ago

We have a fedex API account and need to add a Fedex pp in schemabase. Oauth token URL: https://apis.fedex.com/oauth/token grant_type client credentials, send client credentials in body.

For the tracking:

POST https://apis.fedex.com/track/v1/trackingnumbers
{
  "includeDetailedScans": true,
  "trackingInfo": [
    {
      "shipDateBegin": "",
      "shipDateEnd": "",
      "trackingNumberInfo": {
        "trackingNumber": "785609834778",
        "carrierCode": "FDXE",
        "trackingNumberUniqueId": ""
      }
    }
  ]
}

Response:

{
    "transactionId": "c93a745c-7ec5-4f05-ba91-8c1f0f4afb50",
    "output": {
        "completeTrackResults": [
            {
                "trackingNumber": "785609834778",
                "trackResults": [
                    {
                        "trackingNumberInfo": {
                            "trackingNumber": "785609834778",
                            "trackingNumberUniqueId": "12026~785609834778~FDEG",
                            "carrierCode": "FDXG"
                        },
                        "additionalTrackingInfo": {
                            "nickname": "",
                            "packageIdentifiers": [
                                {
                                    "type": "STANDARD_MPS",
                                    "values": [
                                        "785609834778"
                                    ],
                                    "trackingNumberUniqueId": "12026",
                                    "carrierCode": ""
                                },
                                {
                                    "type": "CUSTOMER_REFERENCE",
                                    "values": [
                                        "PA/OUT/73994"
                                    ],
                                    "trackingNumberUniqueId": "",
                                    "carrierCode": ""
                                },
                                {
                                    "type": "PURCHASE_ORDER",
                                    "values": [
                                        "7328902"
                                    ],
                                    "trackingNumberUniqueId": "",
                                    "carrierCode": ""
                                }
                            ],
                            "hasAssociatedShipments": true
                        },
                        "shipperInformation": {
                            "contact": {},
                            "address": {
                                "city": "BLAIRSVILLE",
                                "stateOrProvinceCode": "PA",
                                "countryCode": "US",
                                "residential": false,
                                "countryName": "United States"
                            }
                        },
                        "recipientInformation": {
                            "contact": {},
                            "address": {
                                "city": "CAVE IN ROCK",
                                "stateOrProvinceCode": "IL",
                                "countryCode": "US",
                                "residential": false,
                                "countryName": "United States"
                            }
                        },
                        "latestStatusDetail": {
                            "code": "OD",
                            "derivedCode": "OD",
                            "statusByLocale": "Out for delivery",
                            "description": "On FedEx vehicle for delivery",
                            "scanLocation": {
                                "city": "MARION",
                                "stateOrProvinceCode": "IL",
                                "countryCode": "US",
                                "residential": false,
                                "countryName": "United States"
                            }
                        },
                        "dateAndTimes": [
                            {
                                "type": "ESTIMATED_DELIVERY",
                                "dateTime": "2023-10-31T00:00:00-06:00"
                            },
                            {
                                "type": "COMMITMENT",
                                "dateTime": "2023-10-31T00:00:00-06:00"
                            },
                            {
                                "type": "ACTUAL_PICKUP",
                                "dateTime": "2023-10-27T00:00:00-06:00"
                            },
                            {
                                "type": "SHIP",
                                "dateTime": "2023-10-27T00:00:00-06:00"
                            },
                            {
                                "type": "ACTUAL_TENDER",
                                "dateTime": "2023-10-27T00:00:00-06:00"
                            },
                            {
                                "type": "ANTICIPATED_TENDER",
                                "dateTime": "2023-10-27T00:00:00-06:00"
                            }
                        ],
                        "availableImages": [],
                        "packageDetails": {
                            "packagingDescription": {
                                "type": "YOUR_PACKAGING",
                                "description": "Package"
                            },
                            "physicalPackagingType": "PACKAGE",
                            "sequenceNumber": "1",
                            "count": "2",
                            "weightAndDimensions": {
                                "weight": [
                                    {
                                        "value": "24.3",
                                        "unit": "LB"
                                    },
                                    {
                                        "value": "11.02",
                                        "unit": "KG"
                                    }
                                ],
                                "dimensions": [
                                    {
                                        "length": 22,
                                        "width": 22,
                                        "height": 7,
                                        "units": "IN"
                                    },
                                    {
                                        "length": 55,
                                        "width": 55,
                                        "height": 17,
                                        "units": "CM"
                                    }
                                ]
                            },
                            "packageContent": []
                        },
                        "shipmentDetails": {
                            "possessionStatus": true,
                            "weight": [
                                {
                                    "value": "45.8",
                                    "unit": "LB"
                                },
                                {
                                    "value": "20.77",
                                    "unit": "KG"
                                }
                            ]
                        },
                        "scanEvents": [
                            {
                                "date": "2023-10-31T06:04:00-05:00",
                                "eventType": "OD",
                                "eventDescription": "On FedEx vehicle for delivery",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "MARION",
                                    "stateOrProvinceCode": "IL",
                                    "postalCode": "62959",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0629",
                                "locationType": "VEHICLE",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-31T05:22:00-05:00",
                                "eventType": "AR",
                                "eventDescription": "At local FedEx facility",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "MARION",
                                    "stateOrProvinceCode": "IL",
                                    "postalCode": "62959",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0629",
                                "locationType": "DESTINATION_FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-30T19:25:02-05:00",
                                "eventType": "IT",
                                "eventDescription": "On the way",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "MARION",
                                    "stateOrProvinceCode": "IL",
                                    "postalCode": "62959",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationType": "VEHICLE",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-29T22:20:18-05:00",
                                "eventType": "DP",
                                "eventDescription": "Departed FedEx location",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "SAINT PETERS",
                                    "stateOrProvinceCode": "MO",
                                    "postalCode": "63376",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0633",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-28T23:28:34-05:00",
                                "eventType": "AO",
                                "eventDescription": "Shipment arriving On-Time",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "SAINT PETERS",
                                    "stateOrProvinceCode": "MO",
                                    "postalCode": "63376",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0633",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-28T23:27:00-05:00",
                                "eventType": "AR",
                                "eventDescription": "Arrived at FedEx location",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "SAINT PETERS",
                                    "stateOrProvinceCode": "MO",
                                    "postalCode": "63376",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0633",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-28T21:45:04-05:00",
                                "eventType": "IT",
                                "eventDescription": "On the way",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "ST PETERS",
                                    "stateOrProvinceCode": "MO",
                                    "postalCode": "63376",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationType": "VEHICLE",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-28T10:16:09-04:00",
                                "eventType": "DP",
                                "eventDescription": "Departed FedEx location",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "GROVEPORT",
                                    "stateOrProvinceCode": "OH",
                                    "postalCode": "43125",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0433",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-28T06:07:00-04:00",
                                "eventType": "AR",
                                "eventDescription": "Arrived at FedEx location",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "GROVEPORT",
                                    "stateOrProvinceCode": "OH",
                                    "postalCode": "43125",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0433",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-27T21:59:54-04:00",
                                "eventType": "DP",
                                "eventDescription": "Left FedEx origin facility",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "HUNKER",
                                    "stateOrProvinceCode": "PA",
                                    "postalCode": "15639",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0156",
                                "locationType": "ORIGIN_FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-27T18:08:14-04:00",
                                "eventType": "AE",
                                "eventDescription": "Shipment arriving early",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "HUNKER",
                                    "stateOrProvinceCode": "PA",
                                    "postalCode": "15639",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0156",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-27T18:06:00-04:00",
                                "eventType": "AR",
                                "eventDescription": "Arrived at FedEx location",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "HUNKER",
                                    "stateOrProvinceCode": "PA",
                                    "postalCode": "15639",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0156",
                                "locationType": "FEDEX_FACILITY",
                                "derivedStatusCode": "IT",
                                "derivedStatus": "In transit"
                            },
                            {
                                "date": "2023-10-27T15:44:00-04:00",
                                "eventType": "PU",
                                "eventDescription": "Picked up",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "city": "HUNKER",
                                    "stateOrProvinceCode": "PA",
                                    "postalCode": "15639",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationId": "0156",
                                "locationType": "PICKUP_LOCATION",
                                "derivedStatusCode": "PU",
                                "derivedStatus": "Picked up"
                            },
                            {
                                "date": "2023-10-27T08:25:00-04:00",
                                "eventType": "OC",
                                "eventDescription": "Shipment information sent to FedEx",
                                "exceptionCode": "",
                                "exceptionDescription": "",
                                "scanLocation": {
                                    "streetLines": [
                                        ""
                                    ],
                                    "postalCode": "15717",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                },
                                "locationType": "CUSTOMER",
                                "derivedStatusCode": "IN",
                                "derivedStatus": "Label created"
                            }
                        ],
                        "availableNotifications": [
                            "ON_DELIVERY",
                            "ON_EXCEPTION",
                            "ON_ESTIMATED_DELIVERY"
                        ],
                        "deliveryDetails": {
                            "deliveryAttempts": "0",
                            "deliveryOptionEligibilityDetails": [
                                {
                                    "option": "INDIRECT_SIGNATURE_RELEASE",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "REDIRECT_TO_HOLD_AT_LOCATION",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "REROUTE",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "RESCHEDULE",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "RETURN_TO_SHIPPER",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "DISPUTE_DELIVERY",
                                    "eligibility": "POSSIBLY_ELIGIBLE"
                                },
                                {
                                    "option": "SUPPLEMENT_ADDRESS",
                                    "eligibility": "INELIGIBLE"
                                }
                            ]
                        },
                        "originLocation": {
                            "locationContactAndAddress": {
                                "address": {
                                    "city": "HUNKER",
                                    "stateOrProvinceCode": "PA",
                                    "countryCode": "US",
                                    "residential": false,
                                    "countryName": "United States"
                                }
                            }
                        },
                        "lastUpdatedDestinationAddress": {
                            "city": "CAVE IN ROCK",
                            "stateOrProvinceCode": "IL",
                            "countryCode": "US",
                            "residential": false,
                            "countryName": "United States"
                        },
                        "serviceDetail": {
                            "type": "GROUND_HOME_DELIVERY",
                            "description": "FedEx Home Delivery",
                            "shortDescription": "HD"
                        },
                        "standardTransitTimeWindow": {
                            "window": {
                                "ends": "2023-10-31T00:00:00-06:00"
                            }
                        },
                        "estimatedDeliveryTimeWindow": {
                            "window": {
                                "begins": "2023-10-31T09:30:00-05:00",
                                "ends": "2023-10-31T13:30:00-05:00"
                            },
                            "type": "TYPICAL"
                        },
                        "goodsClassificationCode": "",
                        "returnDetail": {}
                    }
                ]
            }
        ]
    }
}
JannikZed commented 6 months ago

done