Update company retrieve to match http api
Why?
Why are you making this change?
Company retrieve doesn't match the api here which can return either a Company or a Company list depending on whether the company_id or name param are specified.
How?
Technical details on your change
Changed the output of retrieve to return either Company or CompanyList. Added an or to check which parameters were passed and return the correct type.
Thanks for the suggestion @cullen-ambience! Note that the SDK is generated from the OpenAPI spec sourced here.
In this case, there are two separate methods:
- client.companies.retrieve returns a
Intercom.CompanyList. - client.companies.find returns a single
Company.
With this, I'd argue the current design is better. The user doesn't need to determine whether or not there is a single element or a list - they can just use the right method for the job.
cc @Eclairemoy for any additional context on the design of the API (just in case that doesn't cover it).
Thanks for the suggestion @cullen-ambience! Note that the SDK is generated from the OpenAPI spec sourced here.
In this case, there are two separate methods:
- client.companies.retrieve returns a
Intercom.CompanyList.- client.companies.find returns a single
Company.With this, I'd argue the current design is better. The user doesn't need to determine whether or not there is a single element or a list - they can just use the right method for the job.
cc @Eclairemoy for any additional context on the design of the API (just in case that doesn't cover it).
Based on my understanding these Intercom APIs are doing two different things. Find uses intercom internal company id ("id" in the Company type) to retrieve a single company. Retrieve uses a number of params, one of which can be external company id ("company_id" in the Company type). It sounds like the issue may be with the underlying OpenAPI design.
Regardless, I'm seeing Company formatted data being returned from company.retrieve when company_id is specified in the params, which causes a type conflict in my app that expects CompanyList. I can recast the type and get around it for now, but thought it would be better to flag it for you all :).