Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

senders argument for TransactionalEmailsApi.get_transac_blocked_contacts not optional #99

Open
jgillmanjr opened this issue Dec 9, 2024 · 1 comment

Comments

@jgillmanjr
Copy link

The documentation for TransactionalEmailsApi.get_transac_blocked_contacts method indicates that the senders is optional.

However this doesn't appear to be the case.

@jgillmanjr
Copy link
Author

jgillmanjr commented Dec 20, 2024

So I did some further testing - it appears that things work when making the call without the API. Let me demonstrate.

Using the API

        try:
            response = email_api.get_transac_blocked_contacts()
            print(response)

        except ApiException as e:
            print(f"Exception when calling TransactionalEmailsApi->get_transac_blocked_contacts: {e}")

results in

  File "/lib/site-packages/sib_api_v3_sdk/api/transactional_emails_api.py", line 1543, in get_transac_blocked_contacts
    (data) = self.get_transac_blocked_contacts_with_http_info(**kwargs)  # noqa: E501
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api/transactional_emails_api.py", line 1622, in get_transac_blocked_contacts_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 327, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 171, in __call_api
    return_data = self.deserialize(response_data, response_type)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 243, in deserialize
    return self.__deserialize(data, response_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 282, in __deserialize
    return self.__deserialize_model(data, klass)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 626, in __deserialize_model
    kwargs[attr] = self.__deserialize(value, attr_type)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 259, in __deserialize
    return [self.__deserialize(sub_data, sub_kls)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 282, in __deserialize
    return self.__deserialize_model(data, klass)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/api_client.py", line 628, in __deserialize_model
    instance = klass(**kwargs)
               ^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/models/get_transac_blocked_contacts_contacts.py", line 57, in __init__
    self.sender_email = sender_email
    ^^^^^^^^^^^^^^^^^
  File "/lib/site-packages/sib_api_v3_sdk/models/get_transac_blocked_contacts_contacts.py", line 107, in sender_email
    raise ValueError("Invalid value for `sender_email`, must not be `None`")  # noqa: E501
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Invalid value for `sender_email`, must not be `None`

Using requests

        try:
            url = "https://api.brevo.com/v3/smtp/blockedContacts?limit=50&offset=0&sort=desc"
            headers = {
                "accept": "application/json",
                'api-key': settings.SENDINBLUE_API_KEY,
            }
            response = requests.get(url, headers=headers)
            rj = response.json()
            for contact in rj['contacts']:
                contact['email'] = '****@****.tld'
                if 'senderEmail' in contact:
                    contact['senderEmail'] = '****@****.tld'

            print(json.dumps(rj, indent=4))

        except ApiException as e:
            print(f"Exception when calling TransactionalEmailsApi->get_transac_blocked_contacts: {e}")

results in

{
    "contacts": [
        {
            "email": "****@****.tld",
            "reason": {
                "message": "Contact has flagged one of your emails as junk",
                "code": "contactFlaggedAsSpam"
            },
            "blockedAt": "2024-12-07T17:35:06.080Z",
            "senderEmail": "****@****.tld"
        },

       ///// SNIP /////

        {
            "email": "****@****.tld",
            "reason": {
                "message": "This contact's email address generated a hard bounce",
                "code": "hardBounce"
            },
            "blockedAt": "2022-11-28T12:50:15.000Z"
        }
    ],
    "count": 13
}

So it appears that the method needs to handle the lack of the parameter a little differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant