-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump version to 7 * changed serving_status to entity_status for media creatives * added granular tap placements * removed deprecated behavior targeting * added advertiser business categories endpoint * added missing content categories endpoint * added audience summary and tests * removed scoped timeline endpoint
- Loading branch information
Showing
16 changed files
with
192 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
# Copyright (C) 2019 Twitter, Inc. | ||
require 'twitter-ads' | ||
|
||
CONSUMER_KEY = 'your consumer key' | ||
CONSUMER_SECRET = 'your consumer secret' | ||
ACCESS_TOKEN = 'user access token' | ||
ACCESS_TOKEN_SECRET = 'user access token secret' | ||
ADS_ACCOUNT = 'ads account id' | ||
|
||
# initialize the twitter ads api client | ||
client = TwitterAds::Client.new( | ||
CONSUMER_KEY, | ||
CONSUMER_SECRET, | ||
ACCESS_TOKEN, | ||
ACCESS_TOKEN_SECRET | ||
) | ||
|
||
# load up the account instance | ||
account = client.accounts(ADS_ACCOUNT) | ||
|
||
# targeting criteria params | ||
params = { | ||
targeting_criteria: [ | ||
{ | ||
targeting_type: 'LOCATION', | ||
targeting_value: '96683cc9126741d1' | ||
}, | ||
{ | ||
targeting_type: 'BROAD_KEYWORD', | ||
targeting_value: 'cats' | ||
}, | ||
{ | ||
targeting_type: 'SIMILAR_TO_FOLLOWERS_OF_USER', | ||
targeting_value: '14230524' | ||
}, | ||
{ | ||
targeting_type: 'SIMILAR_TO_FOLLOWERS_OF_USER', | ||
targeting_value: '90420314' | ||
} | ||
] | ||
} | ||
|
||
audience_summary = TwitterAds::AudienceSummary.fetch(account, params) | ||
puts audience_summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
module TwitterAds | ||
class ContentCategories | ||
|
||
include TwitterAds::DSL | ||
include TwitterAds::Resource | ||
|
||
attr_reader :account | ||
|
||
property :id, read_only: true | ||
property :name, read_only: true | ||
property :iab_categories, read_only: true | ||
|
||
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/content_categories" # @api private | ||
|
||
def initialize(account) | ||
@account = account | ||
self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
module TwitterAds | ||
module AudienceSummary | ||
|
||
include TwitterAds::DSL | ||
include TwitterAds::Resource | ||
|
||
RESOURCE = "/#{TwitterAds::API_VERSION}/" \ | ||
'accounts/%{account_id}/audience_summary' | ||
|
||
property :audience_size, read_only: true | ||
|
||
class << self | ||
|
||
# Get an audience summary for the specified targeting criteria. | ||
# | ||
# @example | ||
# TwitterAds::AudienceSummary.fetch( | ||
# account, | ||
# params: {targeting_criteria:[{targeting_type:'LOCATION', | ||
# targeting_value:'96683cc9126741d1'}]} | ||
# ) | ||
# | ||
# @param params [Hash] A hash of input targeting criteria values | ||
# | ||
# @return [Hash] A hash containing the min and max audience size. | ||
# | ||
# @since 7.0.0 | ||
# @see https://developer.twitter.com/en/docs/ads/campaign-management/api-reference/audience-summary | ||
def fetch(account, params) | ||
resource = RESOURCE % { account_id: account.id } | ||
headers = { 'Content-Type' => 'application/json' } | ||
|
||
response = TwitterAds::Request.new(account.client, | ||
:post, | ||
resource, | ||
headers: headers, | ||
body: params.to_json).perform | ||
response.body[:data] | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
module TwitterAds | ||
VERSION = '6.0.1' | ||
VERSION = '7.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"request": { | ||
"params": { | ||
"targeting_criteria": null, | ||
"account_id": "2iqph" | ||
} | ||
}, | ||
"data": { | ||
"audience_size": { | ||
"min": 41133600, | ||
"max": 50274400 | ||
} | ||
} | ||
} |
Oops, something went wrong.