pinterest / pinterest-python-sdk

An SDK that makes it quick and easy to build applications with Pinterest API.
Apache License 2.0
43 stars 28 forks source link

BUG - Inconsistent usage of client in cls._create method for Audience and CustomerList objects #111

Closed SinhB closed 1 year ago

SinhB commented 1 year ago

Hello,

I'm experiencing an issue while using the Python SDK for ads. I typically instantiate a client using the create_client_with_refresh_token method without relying on config.json or environment variables. Most methods of the Audience and CustomerList objects work fine using this approach, except for the create method.

The problem arises from the fact that the cls._create method within the create method doesn't utilize the client passed to the Audience object. Instead, it searches for a default client elsewhere. The same issue occurs with the CustomerList object. :

response = cls._create(
            params={
                "ad_account_id": str(ad_account_id),
                "audience_create_request": AudienceCreateRequest(
                    ad_account_id=str(ad_account_id),
                    name=name,
                    rule=rule,
                    audience_type=audience_type,
                    description=description if description else '',
                    **kwargs
                ),
            },
            api=AudiencesApi,
            create_fn=AudiencesApi.audiences_create
        )

My question is whether this behavior is intended. Is it mandatory to use config.json or environment variables in order to use these methods effectively?

I would appreciate any insights or suggestions to resolve this issue. Thank you!

rushabhvaria commented 1 year ago

@SinhB Thank you for bringing this issue up. The team is looking into getting this fixed and we will post it in the next release, soon.

tonyluo7 commented 2 weeks ago

@rushabhvaria Hello, could you please release a new version of SDK to include the fix? We are using the latest version pinterest-api-sdk 0.2.1. Thanks.