-
Notifications
You must be signed in to change notification settings - Fork 21
fix(UXP-858): add offer_request_id inside Offers list operations #68
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
Conversation
src/booking/Offers/Offers.ts
Outdated
*/ | ||
public list = (options?: PaginationMeta): Promise<DuffelResponse<Offer[]>> => | ||
this.request({ method: 'GET', path: this.path, params: options }) | ||
public list = (offer_request_id: string, options?: ListOffersParams): Promise<DuffelResponse<Offer[]>> => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you thinking of putting offer_request_id
inside the params object instead?
The benefit of the current way is that it makes this argument "required". But it will make Offers.list
look inconsistent when compared to other list
functions, which only have an options
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of having it separate since we are separating a mandatory argument, which is offer_request_id
from the additional options (limit, sort, etc). Even so, it diverges from the others list
functions, most of the developers would understand that. Happy to hear other thoughts too! @igorp1 @mcdeguzman99 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes the library's API a little harder to reason about personally, and it will make it harder in the future for us to automatically generate code snippets in the API reference. But I'm happy for you guys to make the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would be to keep required fields explicit and separate, and to put all of the optional fields in options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should go inside options
to be consistent with the rest of the client library interface, but it should be a required argument.
When we have an id
as a separate argument (usually in get
functions), it's because it's the ID of the resource that we're referring to - e.g. if you do offers.get(id)
, you're passing in the offer's ID. In this case we're talking about the offer request ID. This is a different but related object. A similar example can be found in SeatMaps, where you get
a seatmap not by its own ID, but by the related offer's ID. Hence the offer ID is passed in as a required parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I thought I submitted this comment yesterday, but looks like it was stuck in pending...
src/booking/Offers/Offers.ts
Outdated
*/ | ||
public list = (options?: PaginationMeta): Promise<DuffelResponse<Offer[]>> => | ||
this.request({ method: 'GET', path: this.path, params: options }) | ||
public list = (offer_request_id: string, options?: ListOffersParams): Promise<DuffelResponse<Offer[]>> => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should go inside options
to be consistent with the rest of the client library interface, but it should be a required argument.
When we have an id
as a separate argument (usually in get
functions), it's because it's the ID of the resource that we're referring to - e.g. if you do offers.get(id)
, you're passing in the offer's ID. In this case we're talking about the offer request ID. This is a different but related object. A similar example can be found in SeatMaps, where you get
a seatmap not by its own ID, but by the related offer's ID. Hence the offer ID is passed in as a required parameter.
/** | ||
* Retrieves a generator of all offers. The results may be returned in any order. | ||
* @param {Object.<ListOffersParams>} params - Pagination options (optional: limit, after, before) | ||
* @param {string} params.offer_request_id - Duffel's unique identifier for the offer request, returned when it was created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} params.offer_request_id - Duffel's unique identifier for the offer request, returned when it was created | |
* @param {string} offer_request_id - Duffel's unique identifier for the offer request, returned when it was created |
Since it shouldn't actually be nested inside "params"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was reading about it and because it's nested inside params
we need to define the previous object since we are deconstructing the object. Makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aah ok, I read that as you need to have it as {params: {offer_request_id: ...}}
* Retrieves a page of offers. The results may be returned in any order. | ||
* @param {Object} [options] - Pagination options (optional: limit, after, before) | ||
* @param {Object.<ListOffersParams>} params - Pagination options (optional: limit, after, before) | ||
* @param {string} params.offer_request_id - Duffel's unique identifier for the offer request, returned when it was created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param {string} params.offer_request_id - Duffel's unique identifier for the offer request, returned when it was created | |
* @param {string} offer_request_id - Duffel's unique identifier for the offer request, returned when it was created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! And just to check... looks like there's enough consensus on this discussion, right?
What was done?
offer_request_id
argument since it's required in the API to retrieve the offers listmax_connections
andsort
to OfferRequest types