sendgrid / sendgrid-php

The Official Twilio SendGrid PHP API Library
https://sendgrid.com
MIT License
1.49k stars 624 forks source link

API using Fluent interface of library, return all times 200, and empty response body #1068

Closed abkrim closed 2 years ago

abkrim commented 2 years ago

Issue Summary

When I have gone to work with a part of the package, I have noticed that there is a strange behavior, not very suitable, in the whitelabel method, when it is used at least in fluent mode.

I always return 200

Steps to Reproduce

  1. This is the first step
  2. This is the second step
  3. Further steps, etc.

Code Snippet


$domain_whitelabeled = 'domain.tld';

// First test
$sg = new \SendGrid('mytoken'));
$query_params = json_decode('{"domain": $domain_whitelabeled);
$response = $sg->client->whitelabel()->domains()->get(null, $query_params);

// response dumped OK
array:3 [▼
  0 => SendGrid\Response {#2441 ▶}
  1 => 200
  2 => array:1 [▼
    0 => array:12 [▼
      "id" => 12753033
      "user_id" => 23123539
      "subdomain" => "em8774"
      "domain" => "domain.tld"
      "username" => "email@domain.com"
      "ips" => []
      "custom_spf" => false
      "default" => false
      "legacy" => false
      "automatic_security" => true
      "valid" => false
      "dns" => array:3 [▶]
    ]
  ]
]

// Not  in sendgrid 
$domain_not_whitelabeled='notlabeled.tld';
$sg = new \SendGrid('mytoken'));
$query_params = json_decode('{"domain": $domain_whitelabeled);
$response = $sg->client->whitelabel()->domains()->get(null, $query_params);

array:3 [▼
  0 => SendGrid\Response {#2441 ▼
    #statusCode: 200
    #body: "[]"
    #headers: array:24 [▶]
  }
  1 => 200
  2 => []
]

// Wrong $query_params
// return all domains whitelabeled

Technical details:

I think is not correct.

childish-sambino commented 2 years ago

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at support.sendgrid.com.