Skip to content

Commit a6af521

Browse files
authored
[Bug] Fix string concatenation (#201)
* Fix string concatenation * Remove TA old exapmle * Add new TA example * Fix typo * Disable Hound
1 parent f8d3cf9 commit a6af521

4 files changed

Lines changed: 25 additions & 19 deletions

File tree

.hound.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/active_entities.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
include TwitterAds::Enum
1515

16-
CCONSUMER_KEY = 'your consumer key'
16+
CONSUMER_KEY = 'your consumer key'
1717
CONSUMER_SECRET = 'your consumer secret'
1818
ACCESS_TOKEN = 'user access token'
1919
ACCESS_TOKEN_SECRET = 'user access token secret'

examples/tailored_audience.rb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22
# Copyright (C) 2019 Twitter, Inc.
33

4+
require 'digest'
45
require 'twitter-ads'
56
include TwitterAds::Enum
67

@@ -21,19 +22,26 @@
2122
# load up the account instance
2223
account = client.accounts(ADS_ACCOUNT)
2324

24-
# create a new tailored audience
25+
# create a new placeholder tailored audience
2526
audience =
26-
TwitterAds::TailoredAudience.create(account, '/path/to/file', 'my list', TAListTypes::Email)
27-
28-
# check the processing status
29-
audience.status
27+
TwitterAds::TailoredAudience.create(account, 'Test TA')
28+
29+
# sample user
30+
# all values musth be sha256 hashede except 'partner_user_id'
31+
email_hash = Digest::SHA256.hexdigest 'test-email@test.com'
32+
33+
# create payload
34+
user = [{
35+
operation_type: 'Update',
36+
params: {
37+
users: [{
38+
email: [
39+
email_hash
40+
]
41+
}]
42+
}
43+
}]
3044

3145
# update the tailored audience
32-
audience.update('/path/to/file', 'TWITTER_ID', TAOperations::REMOVE)
33-
audience.update('/path/to/file', 'PHONE_NUMBER', TAOperations::ADD)
34-
35-
# delete the tailored audience
36-
audience.delete!
37-
38-
# add users to the account's global opt-out list
39-
TwitterAds::TailoredAudience.opt_out(account, '/path/to/file', TAListTypes::HANDLE)
46+
success_count, total_count = audience.users(user)
47+
print "Successfully added #{total_count} users" if success_count == total_count

lib/twitter-ads/audiences/tailored_audience.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class TailoredAudience
2929
'accounts/%{account_id}/tailored_audiences' # @api private
3030
RESOURCE = "/#{TwitterAds::API_VERSION}/" \
3131
'accounts/%{account_id}/tailored_audiences/%{id}' # @api private
32-
RESOURCE_USERS = "/#{TwitterAds::API_VERSION}/ \
33-
accounts/%{account_id}/tailored_audiences/ \
34-
%{id}/users" # @api private
32+
RESOURCE_USERS = "/#{TwitterAds::API_VERSION}/" \
33+
'accounts/%{account_id}/tailored_audiences/' \
34+
'%{id}/users' # @api private
3535

3636
LIST_TYPES = %w(
3737
EMAIL

0 commit comments

Comments
 (0)