Conversation
src/IntercomCompanies.php
Outdated
| * @return stdClass | ||
| * @throws Exception | ||
| */ | ||
| public function attachContact($contactId, $options) |
There was a problem hiding this comment.
I have mixed feelings about something, so hope to get your view on this too 😄 On one hand, this API wrapper is super-lightweight and we generally just take one parameter for the id and other for the payload (options). In this case, this call requires the options to contain a specific parameter, so I think being more specific here would be helpful, ie
| public function attachContact($contactId, $options) | |
| public function attachContact(string $contactId, string $companyId) | |
| { | |
| $options = [ "id" => $companyId ]; | |
| ... | |
| } |
What do you think about that change? I'm happy with keeping it as you did for consistency, but also happy to move to what I proposed 😄
There was a problem hiding this comment.
You raise a good point, and I agree that the function should take a specific parameter for the $companyId. In order to provide as much flexibility as possible, I was thinking of keeping $options as a parameter and using array_merge like so:
| public function attachContact($contactId, $options) | |
| public function attachContact(string $contactId, string $companyId, $options) | |
| { | |
| $options = array_merge($options, ["id" => $companyId]); | |
| ... | |
| } |
What are your thoughts on this?
There was a problem hiding this comment.
Makes total sense! That would definitely make it more flexible in case we add additional parameters in the future 😄 Let's do that, but adding a default for $options:
| public function attachContact($contactId, $options) | |
| public function attachContact(string $contactId, string $companyId, array $options = []) | |
| { | |
| $options = array_merge($options, ["id" => $companyId]); | |
| ... | |
| } |
src/IntercomCompanies.php
Outdated
| public function detachContact($contactId, $companyId, $options = []) | ||
| { | ||
| $path = $this->companyAssociatePath($contactId); | ||
| return $this->client->delete($path . '/' . $companyId, $options); |
There was a problem hiding this comment.
Would be great to create a method to store the complexity of this path, ie $this->companyDetachPath($contactId, $companyId);
GabrielAnca
left a comment
There was a problem hiding this comment.
Thank you so much for your contribution @RaneLafraze 🚀 I've made a couple of comments and I think we'd be ready to merge into the main PR 😄
Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com>
|
Thank you @GabrielAnca ! I've made the changes discussed above. I'm on board in terms of merging into the main branch, but I'd greatly appreciate your advice and final review. Thanks again! |
GabrielAnca
left a comment
There was a problem hiding this comment.
Thanks for making the changes @RaneLafraze 🎉 I just found one more thing I didn't see before. Other than that, we are ready to merge this into @lloydliyu's branch
Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com>
|
Perfect, thanks again @GabrielAnca ! Please let me know if there is anything else I need to do on my end, or if there are any other ways I can help out! |
|
Looks great @RaneLafraze 🎉 Sorry I was out of the office for the last couple of days. Let's merge this one into the original PR and I'll have a look at it right now 😄 |
* Adds 2.0 contact methods * Adds contact methods to readme. * Corrects search for contacts * Removes customers endpoint as this is no longer available in the API * Adds conversation search * Adds conversation search to Readme. * Adds in search pagination for contacts and conversations, adds in cursor pagination for contacts. * Potential fix for tests * lint fixes * Dan.c/2.0 (#307) * Create dedicated attach and detach methods * Use post and get methods instead of sendRequest() * Add default value and update phpdocs * Lint fixes * Change string concatenation for consistency Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> * Add companyId parameter and add types * Add method to generate detach contact request path * Add typing for parameter Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> * Apply suggested docs changes Co-authored-by: Rane Lafraze <lafrazeRL@gmail.com> * Minor docs and method arguments fixes Co-authored-by: Rane Lafraze <lafrazeRL@gmail.com> Co-authored-by: Gabriel Anca Corral <GabrielAnca@users.noreply.github.com> Co-authored-by: Gabriel Anca <gabrielancacorral@gmail.com>
Why?
Fulfills many of the suggestions on the current PR #306
How?
IntercomCompaniesfor attaching and detaching contactssendRequest()calls with the respectivepost()andget()methods