php-http-client icon indicating copy to clipboard operation
php-http-client copied to clipboard

feat: add support for "Get Contacts by Emails" endpoint

Open trane77 opened this issue 2 years ago • 4 comments

Fixes

Makes the Get contacts by emails endpoint usable by adding the relative phpDoc method.

Checklist

  • [x] I acknowledge that all my contributions will be made under the project's license
  • [x] I have made a material change to the repo (functionality, testing, spelling, grammar)
  • [x] I have read the Contribution Guidelines and my PR follows them
  • [x] I have titled the PR appropriately
  • [x] I have updated my branch with the main branch
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added the necessary documentation about the functionality in the appropriate .md file
  • [x] I have added inline documentation to the code I modified

trane77 avatar Oct 27 '23 10:10 trane77

@twilio-dx any news about this PR? Thanks

trane77 avatar Oct 30 '23 23:10 trane77

Hi @funder7! We have added this to our list and looking into it. Thanks!

tiwarishubham635 avatar Nov 09 '23 07:11 tiwarishubham635

Hi @funder7! I just check this one. The endpoint is already accessible if you have your contacts added. It throws 404 when there are no contacts previously added. I firstly created a contact with my sendgrid account with some email id say - [email protected]. Then I executed this script and it wokred for me giving a 200 response and fetched the required contact.

`<?php // Uncomment next line if you're not using a dependency loader (such as Composer) // require_once '<PATH TO>/sendgrid-php.php';

$apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey); $request_body = json_decode('{ "emails": [ "[email protected]" ] }');

try { $response = $sg->client->marketing()->contacts()->search()->emails()->post($request_body); print $response->statusCode() . "\n"; print_r($response->headers()); print $response->body() . "\n"; } catch (Exception $ex) { echo 'Caught exception: '. $ex->getMessage(); }` So I don't think this change is required. Can you check?

tiwarishubham635 avatar Dec 04 '23 06:12 tiwarishubham635

Hi @tiwarishubham635, some time passed since my PR :-) As far as I can remember, I only added the emails() method into Client.php, which enables correct autocompletion while writing code. I was implementing what is written in Sendgrid's documentation and realized that emails was present there, but not in the code, so I added it.

Being something related to phpDoc only, and not an actual implementation, the update is totally transparent regarding how the API works, the only purpose is to help during development.

Cheers

trane77 avatar Sep 20 '24 09:09 trane77