duffelhq / duffel-api-javascript

JavaScript client library for the Duffel API
https://duffel.com/docs
MIT License
36 stars 12 forks source link

The docs are a bit out of date #902

Closed randomprogramming closed 8 months ago

randomprogramming commented 8 months ago

I started reading the documentation here: https://duffel.com/docs/guides/getting-started-with-flights

Looked at the code:

duffel.offerRequests.create({
  slices : [
    {
      origin: "NYC",
      destination: "ATL",
      departure_date: "2021-06-21"
    },
    {
      origin: "ATL",
      destination: "NYC",
      departure_date: "2021-07-21"
    }
  ],
  passengers: [{ type: "adult" }, { type: "adult" }, { age: 1 }],
  cabin_class: "business",
})

But it seems that this way of searching for flights is not available anymore, now you need to pass in a Place for the origin and destination objects.

igorp1 commented 8 months ago

Hi @randomprogramming, thanks for reaching out. Where did you learn "now you need to pass in a Place for the origin and destination objects"? Please let me know if you've seen that in our documentation so we can correct it. You will find that on the api reference of the create offer request endpoint slice's origin and destination must be a 3 letter string of the iata code for a city or airport:

Screenshot 2024-04-02 at 09 02 29

The getting started guide seems to agree with that. Please do let me know if there's a mistake on the docs though, so we can correct asap. Thanks!

randomprogramming commented 8 months ago

Maybe I am misunderstanding something, but:

image

Typescript gives me the error Type 'string' is not assignable to type 'Place'.ts(2322) typings.d.ts(1652, 13): The expected type comes from property 'origin' which is declared here on type 'Omit<OfferRequestSlice, "origin_type" | "destination_type">' for all of these.

igorp1 commented 8 months ago

Ah I see, you are not misunderstanding it. The types for origin and destination are incorrect. I just opened a PR to correct that. Thanks for letting me know and sorry for the trouble!

igorp1 commented 8 months ago

PR was just merged @randomprogramming. If you have any trouble please reach out!