square / square-nodejs-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is a booking id really an optional property of a booking?

chris-miner opened this issue · comments

commented

The Booking interface declares its id property as optional:

export interface Booking {
    /** A unique ID of this object representing a booking. */
    id?: string;

Is this really optional? Don't all bookings have an id? Can't I expect that a booking fetched from square will have an id?

It's marked as optional because the same Booking type is used for both in the request and response. In the request you don't pass it, but it should always be returned in the response.

commented

Okay, sure that makes sense. A booking from square will have the id, but a new booking that I'm creating won't until it gets back to square. So I can see how this is optional.

The thing is, as a consumer of the info at square I have to do a lot of checking that attributes are not null or undefined as I'm making use of the returned data. Even though we know the info is there.

Maybe there is a work around for that. Or a restructuring of something that would allow me to consume data returned without doing a lot of checking for things that we can expect are present.

I suppose int the case of a Typescript client, I have some syntax that I can use to cover that case.

From that perspective you can consider this issue closed.