-
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.
Add support for Tailored Audience Permissions (#202)
* Add support for Tailored Audience Permissions * bump version
- Loading branch information
Showing
3 changed files
with
145 additions
and
1 deletion.
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,49 @@ | ||
# frozen_string_literal: true | ||
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
require 'digest' | ||
require 'twitter-ads' | ||
include TwitterAds::Enum | ||
|
||
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) | ||
|
||
tailored_audience_id = '36n4f' | ||
|
||
# fetch all permissions | ||
permissions = TwitterAds::TailoredAudiencePermission.all(account, tailored_audience_id) | ||
|
||
permissions.each { |data| | ||
p data.id | ||
p data.permission_level | ||
p data.granted_account_id | ||
} | ||
|
||
# create instance | ||
permission = TwitterAds::TailoredAudiencePermission.new(account) | ||
|
||
# set required params | ||
permission.tailored_audience_id = tailored_audience_id | ||
permission.granted_account_id = '18ce54uvbwu' | ||
permission.permission_level = PermissionLevel::READ_ONLY | ||
|
||
# set permission | ||
response = permission.save | ||
|
||
# delete permission | ||
permission.id = response.id | ||
permission.delete! |
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
# Copyright (C) 2019 Twitter, Inc. | ||
|
||
module TwitterAds | ||
VERSION = '5.1.0' | ||
VERSION = '5.2.0' | ||
end |