Skip to content

BUG - Cannot Update Ad with Custom Pinterest SDK Client #152

@jburg-pmg

Description

@jburg-pmg

Describe the bug

When using a custom Pinterest SDK Client, I am unable to make updates to an ad, ad group, or campaign

To Reproduce

Currently, I am using a custom Pinterest SDK Client to authenticate, meaning the default client is unauthenticated. The client is initialized successfully, and I am able to fetch an ad successfully using ad = Ad(account_id, ad_id, client=self.client). However, once I run ad.update_fields(status=new_status) this operation fails saying I am not authenticated.

I then attempted to use ad.update_fields(status=new_status, client=self.client), however this results in a type error. After doing some digging, this error seems to originate from this code block

def update_fields(self, **kwargs) -> bool:
    """
    Update Ad fields suing any arguments

    Returns:
        bool: If Ad fields were updated successfully
    """
    if "creative_type" in kwargs:
        kwargs["creative_type"] = CreativeType(kwargs["creative_type"])
    if "status" in kwargs:
        kwargs["status"] = EntityStatus(kwargs["status"])
    return self._update(
        params={
            "ad_account_id": self._ad_account_id,
            "ad_update_request": [
                AdUpdateRequest(
                    id=self._id,
                    **kwargs
                )
            ]
        },
        api=AdsApi,
        update_fn=AdsApi.ads_update,
        **kwargs
    )

as passing a client object in here causes it to be passed into both AdUpdateRequest and self._update due to the use of **kwargs. After cloning the repo and making a change to include client=None in the update_fields function definition and client=client in the self._update function parameters, the function works as expected.

Expected behavior

I should be able to update ad status with a custom Pinterest SDK Client

Screenshots

Image
Image

Additional Details (please complete the following information):

  • OS and Version: MacOS Sequoia Version 15.4.1
  • SDK Version: 0.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions