sendinblue / APIv3-python-library

SendinBlue's python library for API v3
MIT License
82 stars 40 forks source link

Issue calling `get_contact_info` for existing contact #13

Closed anthonyjb closed 6 years ago

anthonyjb commented 6 years ago

I'm working on a project with a client that allows visitors to subscribe to the websites mailing list. The client is using the sendinblue service and we've hooked up the form to call the sendinblue API via this library (we're using version sib-api-v3-sdk-2.0.1).

I have 2 issues with 2 different versions of your library:

Version 1.1.4

When trying to get contact information for an existing contact we are getting an error, see this trace: https://sentry.io/share/issue/daf5d4634d5d4fda85813fb31ca34de7/

It looks like internally the get_contact_info method is calling various API endpoints and that at some point it gets a version of the contact's details that doesn't contain any attributes data (see below). This data is then used with something that requires an attributes value other than None and a ValueError is raised.

{
    'email': '...@gmail.com', 
    'emailBlacklisted': False, 
    'id': 423471, 
    'listIds': [
        7, 
        9
    ], 
    'modifiedAt': '2018-02-28T15:01:58.782+00:00', 
    'smsBlacklisted': False, 
    'statistics': {
        'clicked': [
            {}
        ], 
            'messagesSent': [
            {}, 
            {}, 
            {}
        ]
    }
}

Version 2.0.1

Having had this issue with version 1.1.4 I updated to the latest version of the library and tried again only to get an entirely unrelated error message:

module 'sib_api_v3_sdk.configuration' has no attribute 'api_key'

My code looks like this:

sib_api_v3_sdk.configuration.api_key['api-key'] = \
               current_app.config['SENDINBLUE_API_KEY']

The example code on the README for this project looks like this:

sib_api_v3_sdk.configuration.api_key['api-key'] = 'YOUR_API_KEY'

So it looks like your documentation isn't up to date maybe or there's a fundamental issue with the new version of the library. I did check you release notes for the update to v2:

Mixed specification updates:

- Renaming of few methods
- Added new parameter smtpBlacklistSender in createContact & updateContact
- Added few extensions in attachments
- Removed tag from required properties in getReports
- Removed tag & reason from required properties in getSmsEventReport
- Modified date-time format description
- Modified getCampaignRecipients properties type to array of integers

But I can't see anything related to this change in them.

aakanksha-sib commented 6 years ago

Hi @anthonyjb , Please refer to the latest example for "get_contact_info" api from https://github.com/sendinblue/APIv3-python-library/blob/master/docs/ContactsApi.md#get_contact_info . However, the get-account api call example should be modified. We will be updating it in our next release. Thanks