Skip to content

senders argument for TransactionalEmailsApi.get_transac_blocked_contacts not optional #99

Open

Description

@jgillmanjr

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

However this doesn't appear to be the case.

Activity

  1. jgillmanjr commented on Dec 20, 2024

    @jgillmanjr
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions