xdevplatform/twitter-ruby-ads-sdk

Posting a line item that was received from the API causes an error

Opened this issue · 1 comments

Issue Type: Bug

Description:
When handling a line item, receiving data from the API and then attempting to save that item back to the API causes errors.

Expected Result:
An example of a requested line item:

id: 5fmcj
deleted: false
created_at: 2016-06-14 15:36:09.000000000 Z
updated_at: 2016-06-14 15:36:10.000000000 Z
name: Untitled
campaign_id: 58ctu
advertiser_domain:
categories: []
charge_by: ENGAGEMENT
include_sentiment: POSITIVE_ONLY
objective: TWEET_ENGAGEMENTS
optimization: DEFAULT
paused: true
primary_web_event_tag:
product_type: PROMOTED_TWEETS
placements:
- ALL_ON_TWITTER
bid_unit: ENGAGEMENT
automatically_select_bid: true
bid_amount_local_micro:
total_budget_amount_local_micro:
advertiser_user_id: 1115726696
bid_type: AUTO
tracking_tags: []

I'd expect that sending this data back to the API would not cause an error.

Actual Result:
When a line item is requested, I receive data that causes errors went saved back to the API.
But when saving the line item, two items cause errors:

  • Sending both automatically_set_bid and bid_type produces the error "automatically_select_bid and bid_type are exclusive parameters".
  • Sending advertiser_user_id produces the error "setting advertiser_user_id is not allowed".

Steps to Reproduce:
This line of Ruby code should reproduce the error when populated with the appropriate variables:

TwitterAds::Account.load(client, account_id).line_items(line_item_id).save

I've implemented a workaround in my private fork that simply excludes these parameters from being sent. I don't see an automated way to know whether the advertiser_user_id parameter is allowed, so I universally excluded it. But I think the real fix lies inside the actual API, to allow a bid_type of AUTO when automatically_set_bid is true, and to only allow the advertiser_user_id sent by the API (which appears to be implicitly set to the user_id of the account being used.

👍