twitter-ads 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/bin/twitter-ads +3 -0
- data/lib/twitter-ads.rb +2 -4
- data/lib/twitter-ads/account.rb +25 -5
- data/lib/twitter-ads/audiences/tailored_audience.rb +47 -5
- data/lib/twitter-ads/campaign/app_list.rb +4 -2
- data/lib/twitter-ads/campaign/campaign.rb +11 -6
- data/lib/twitter-ads/campaign/funding_instrument.rb +4 -2
- data/lib/twitter-ads/campaign/iab_category.rb +1 -1
- data/lib/twitter-ads/campaign/line_item.rb +13 -7
- data/lib/twitter-ads/campaign/organic_tweet.rb +4 -1
- data/lib/twitter-ads/campaign/promotable_user.rb +4 -2
- data/lib/twitter-ads/campaign/targeting_criteria.rb +6 -3
- data/lib/twitter-ads/campaign/tweet.rb +16 -12
- data/lib/twitter-ads/client.rb +2 -0
- data/lib/twitter-ads/creative/account_media.rb +8 -6
- data/lib/twitter-ads/creative/image_app_download_card.rb +15 -9
- data/lib/twitter-ads/creative/image_conversation_card.rb +17 -9
- data/lib/twitter-ads/creative/media_creative.rb +9 -7
- data/lib/twitter-ads/creative/promoted_account.rb +8 -4
- data/lib/twitter-ads/creative/promoted_tweet.rb +10 -8
- data/lib/twitter-ads/creative/scheduled_tweet.rb +57 -0
- data/lib/twitter-ads/creative/video.rb +14 -8
- data/lib/twitter-ads/creative/video_app_download_card.rb +18 -12
- data/lib/twitter-ads/creative/video_conversation_card.rb +18 -9
- data/lib/twitter-ads/creative/video_website_card.rb +53 -0
- data/lib/twitter-ads/creative/website_card.rb +14 -16
- data/lib/twitter-ads/enum.rb +32 -13
- data/lib/twitter-ads/http/request.rb +2 -2
- data/lib/twitter-ads/http/ton_upload.rb +33 -17
- data/lib/twitter-ads/measurement/app_event_tag.rb +2 -1
- data/lib/twitter-ads/measurement/web_event_tag.rb +2 -1
- data/lib/twitter-ads/resources/analytics.rb +13 -8
- data/lib/twitter-ads/targeting/reach_estimate.rb +2 -2
- data/lib/twitter-ads/targeting_criteria/app_store_category.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/behavior.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/behavior_taxonomy.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/device.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/event.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/interest.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/language.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/location.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/network_operator.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/platform.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/platform_version.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/tv_market.rb +2 -1
- data/lib/twitter-ads/targeting_criteria/tv_show.rb +2 -1
- data/lib/twitter-ads/utils.rb +3 -3
- data/lib/twitter-ads/version.rb +1 -1
- data/spec/fixtures/campaigns_all.json +10 -10
- data/spec/fixtures/line_items_all.json +10 -10
- data/spec/fixtures/line_items_load.json +1 -1
- data/spec/fixtures/no_content.json +0 -0
- data/spec/fixtures/promoted_tweets_all.json +20 -20
- data/spec/fixtures/promoted_tweets_load.json +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/helpers.rb +2 -2
- data/spec/twitter-ads/campaign/app_list_spec.rb +1 -1
- data/spec/twitter-ads/campaign/line_item_spec.rb +1 -1
- data/spec/twitter-ads/campaign/reach_estimate_spec.rb +1 -1
- data/spec/twitter-ads/campaign/tweet_spec.rb +7 -7
- data/spec/twitter-ads/client_spec.rb +2 -1
- data/spec/twitter-ads/creative/promoted_tweet_spec.rb +2 -2
- data/spec/twitter-ads/creative/website_card_spec.rb +15 -9
- data/spec/twitter-ads/http/ton_upload_spec.rb +96 -0
- metadata +60 -62
- metadata.gz.sig +0 -0
- data/lib/twitter-ads/creative/app_download_card.rb +0 -44
- data/lib/twitter-ads/creative/lead_gen_card.rb +0 -46
- data/lib/twitter-ads/targeting_criteria/tv_channel.rb +0 -20
- data/lib/twitter-ads/targeting_criteria/tv_genre.rb +0 -20
- data/spec/twitter-ads/creative/app_download_card_spec.rb +0 -44
- data/spec/twitter-ads/creative/lead_gen_card_spec.rb +0 -46
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1831dee8de9255d8b7b9a5131ebd8a2f7960cca7
|
|
4
|
+
data.tar.gz: 180c8bb92cf67b4cf01fb662f6a39d9557cfae29
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78279f2ea036bd2c39b5b603d0985d6d796f72a4cbfb8fe83355acd6ea4c3b0c9f6540c850d8c7ff15b82bec598e0b38c6f7457f11808151b9a8cb3e39929a5d
|
|
7
|
+
data.tar.gz: c3dd5a42d10352ac6c39fe9064c3e30535a0741f4a15a958547845b8acfdc2127f5b1404e1730d2a7d36b33e48bc7813694a3bee2310ccd1cedbc5316f475f40
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
6��
|
|
2
|
+
��� ,9����o�}��q��f�1�l7�\���~$�4Ή�Y�;vU�Řg��;C��E�����V��V��
|
|
3
|
+
3�%��};,�@u�Fh��U@s�Y� $��~�T��U��F�r1��N}������8���*��m�5.�ب���Z,��nt���v���ȋVc�lEheקKTjN i�i?`R�eh���~A�kC�9���Q�I*�"�G�b�Ȕ�N� �7�ߌ3�`z�C����dYx
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/bin/twitter-ads
CHANGED
data/lib/twitter-ads.rb
CHANGED
|
@@ -42,8 +42,6 @@ require 'twitter-ads/campaign/iab_category'
|
|
|
42
42
|
require 'twitter-ads/enum'
|
|
43
43
|
|
|
44
44
|
require 'twitter-ads/targeting_criteria/tv_market'
|
|
45
|
-
require 'twitter-ads/targeting_criteria/tv_channel'
|
|
46
|
-
require 'twitter-ads/targeting_criteria/tv_genre'
|
|
47
45
|
require 'twitter-ads/targeting_criteria/tv_show'
|
|
48
46
|
require 'twitter-ads/targeting_criteria/event'
|
|
49
47
|
require 'twitter-ads/targeting_criteria/device'
|
|
@@ -57,16 +55,16 @@ require 'twitter-ads/targeting_criteria/behavior'
|
|
|
57
55
|
require 'twitter-ads/targeting_criteria/behavior_taxonomy'
|
|
58
56
|
require 'twitter-ads/targeting_criteria/app_store_category'
|
|
59
57
|
|
|
60
|
-
require 'twitter-ads/creative/app_download_card'
|
|
61
58
|
require 'twitter-ads/creative/account_media'
|
|
62
59
|
require 'twitter-ads/creative/image_app_download_card'
|
|
63
60
|
require 'twitter-ads/creative/image_conversation_card'
|
|
64
|
-
require 'twitter-ads/creative/lead_gen_card'
|
|
65
61
|
require 'twitter-ads/creative/media_creative'
|
|
66
62
|
require 'twitter-ads/creative/promoted_account'
|
|
67
63
|
require 'twitter-ads/creative/promoted_tweet'
|
|
64
|
+
require 'twitter-ads/creative/scheduled_tweet'
|
|
68
65
|
require 'twitter-ads/creative/video_app_download_card'
|
|
69
66
|
require 'twitter-ads/creative/video_conversation_card'
|
|
67
|
+
require 'twitter-ads/creative/video_website_card'
|
|
70
68
|
require 'twitter-ads/creative/website_card'
|
|
71
69
|
require 'twitter-ads/creative/video'
|
|
72
70
|
|
data/lib/twitter-ads/account.rb
CHANGED
|
@@ -17,11 +17,16 @@ module TwitterAds
|
|
|
17
17
|
property :updated_at, type: :time, read_only: true
|
|
18
18
|
property :deleted, type: :bool, read_only: true
|
|
19
19
|
|
|
20
|
-
RESOURCE_COLLECTION =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
21
|
+
'accounts'.freeze # @api private
|
|
22
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
23
|
+
'accounts/%{id}'.freeze # @api private
|
|
24
|
+
FEATURES = "/#{TwitterAds::API_VERSION}/" +
|
|
25
|
+
'accounts/%{id}/features'.freeze # @api private
|
|
26
|
+
SCOPED_TIMELINE = "/#{TwitterAds::API_VERSION}/" +
|
|
27
|
+
'accounts/%{id}/scoped_timeline'.freeze # @api private
|
|
28
|
+
AUTHENTICATED_USER_ACCESS = "/#{TwitterAds::API_VERSION}/" +
|
|
29
|
+
'accounts/%{id}/authenticated_user_access'.freeze # @api private
|
|
25
30
|
|
|
26
31
|
def initialize(client)
|
|
27
32
|
@client = client
|
|
@@ -118,6 +123,21 @@ module TwitterAds
|
|
|
118
123
|
load_resource(Creative::PromotedTweet, id, opts)
|
|
119
124
|
end
|
|
120
125
|
|
|
126
|
+
# Returns a collection of promoted accounts available to the current account.
|
|
127
|
+
#
|
|
128
|
+
# @param id [String] The PromotedAccount ID value.
|
|
129
|
+
# @param opts [Hash] A Hash of extended options.
|
|
130
|
+
# @option opts [String] :line_item_ids Scope the result to collection of line item IDs.
|
|
131
|
+
# @option opts [Boolean] :with_deleted Indicates if deleted items should be included.
|
|
132
|
+
# @option opts [String] :sort_by The object param to sort the API response by.
|
|
133
|
+
#
|
|
134
|
+
# @return A Cursor or object instance.
|
|
135
|
+
#
|
|
136
|
+
# @since 1.0.0
|
|
137
|
+
def promotable_accounts(id = nil, opts = {})
|
|
138
|
+
load_resource(Creative::PromotedAccount, id, opts)
|
|
139
|
+
end
|
|
140
|
+
|
|
121
141
|
# Returns a collection of funding instruments available to the current account.
|
|
122
142
|
#
|
|
123
143
|
# @param id [String] The FundingInstrument ID value.
|
|
@@ -25,11 +25,17 @@ module TwitterAds
|
|
|
25
25
|
property :targetable, type: :bool, read_only: true
|
|
26
26
|
property :targetable_types, read_only: true
|
|
27
27
|
|
|
28
|
-
RESOURCE_COLLECTION
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
29
|
+
'accounts/%{account_id}/tailored_audiences'.freeze # @api private
|
|
30
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
31
|
+
'accounts/%{account_id}/tailored_audiences/%{id}'.freeze # @api private
|
|
32
|
+
RESOURCE_UPDATE = "/#{TwitterAds::API_VERSION}/" +
|
|
33
|
+
'accounts/%{account_id}/tailored_audience_changes'.freeze # @api private
|
|
34
|
+
RESOURCE_MEMBERSHIPS = "/#{TwitterAds::API_VERSION}/" +
|
|
35
|
+
'tailored_audience_memberships'.freeze # @api private
|
|
36
|
+
# @api private
|
|
37
|
+
GLOBAL_OPT_OUT = "/#{TwitterAds::API_VERSION}/" +
|
|
38
|
+
'accounts/%{account_id}/tailored_audiences/global_opt_out'.freeze
|
|
33
39
|
|
|
34
40
|
LIST_TYPES = %w(
|
|
35
41
|
EMAIL
|
|
@@ -152,6 +158,42 @@ module TwitterAds
|
|
|
152
158
|
Cursor.new(nil, request).to_a.select { |change| change[:tailored_audience_id] == id }
|
|
153
159
|
end
|
|
154
160
|
|
|
161
|
+
# This is a private API and requires whitelisting from Twitter.
|
|
162
|
+
#
|
|
163
|
+
# This real-time API will enable partners to upload batched tailored audience information
|
|
164
|
+
# to Twitter for processing in real-time
|
|
165
|
+
#
|
|
166
|
+
# @example
|
|
167
|
+
# TailoredAudience.memberships(
|
|
168
|
+
# account,
|
|
169
|
+
# [
|
|
170
|
+
# {
|
|
171
|
+
# "operation_type" => "Update",
|
|
172
|
+
# "params" => {
|
|
173
|
+
# "user_identifier" => "IUGKJHG-UGJHVHJ",
|
|
174
|
+
# "user_identifier_type" => "TAWEB_PARTNER_USER_ID",
|
|
175
|
+
# "audience_names" => "Recent Site Visitors, Recent Sign-ups",
|
|
176
|
+
# "advertiser_account_id" => "43853bhii879"
|
|
177
|
+
# }
|
|
178
|
+
# },
|
|
179
|
+
# ]
|
|
180
|
+
# )
|
|
181
|
+
#
|
|
182
|
+
# @return success_count, total_count
|
|
183
|
+
def self.memberships(account, params)
|
|
184
|
+
resource = RESOURCE_MEMBERSHIPS
|
|
185
|
+
headers = { 'Content-Type' => 'application/json' }
|
|
186
|
+
response = TwitterAds::Request.new(account.client,
|
|
187
|
+
:post,
|
|
188
|
+
resource,
|
|
189
|
+
headers: headers,
|
|
190
|
+
body: params.to_json).perform
|
|
191
|
+
success_count = response.body[:data][0][:success_count]
|
|
192
|
+
total_count = response.body[:request][0][:total_count]
|
|
193
|
+
|
|
194
|
+
[success_count, total_count]
|
|
195
|
+
end
|
|
196
|
+
|
|
155
197
|
private
|
|
156
198
|
|
|
157
199
|
def create_audience(name, list_type)
|
|
@@ -13,8 +13,10 @@ module TwitterAds
|
|
|
13
13
|
property :apps, read_only: true
|
|
14
14
|
property :name, read_only: true
|
|
15
15
|
|
|
16
|
-
RESOURCE_COLLECTION =
|
|
17
|
-
|
|
16
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
17
|
+
'accounts/%{account_id}/app_lists'.freeze # @api private
|
|
18
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
19
|
+
'accounts/%{account_id}/app_lists/%{id}'.freeze # @api private
|
|
18
20
|
|
|
19
21
|
def initialize(account)
|
|
20
22
|
@account = account
|
|
@@ -23,7 +23,7 @@ module TwitterAds
|
|
|
23
23
|
property :funding_instrument_id
|
|
24
24
|
property :end_time, type: :time
|
|
25
25
|
property :start_time, type: :time
|
|
26
|
-
property :
|
|
26
|
+
property :entity_status
|
|
27
27
|
property :currency
|
|
28
28
|
property :standard_delivery
|
|
29
29
|
property :daily_budget_amount_local_micro
|
|
@@ -32,11 +32,16 @@ module TwitterAds
|
|
|
32
32
|
# sdk only
|
|
33
33
|
property :to_delete, type: :bool
|
|
34
34
|
|
|
35
|
-
RESOURCE_COLLECTION
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
36
|
+
'accounts/%{account_id}/campaigns'.freeze # @api private
|
|
37
|
+
RESOURCE_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
38
|
+
'stats/accounts/%{account_id}'.freeze # @api private
|
|
39
|
+
RESOURCE_ASYNC_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
40
|
+
'stats/jobs/accounts/%{account_id}'.freeze # @api private
|
|
41
|
+
RESOURCE_BATCH = "/#{TwitterAds::API_VERSION}/" +
|
|
42
|
+
'batch/accounts/%{account_id}/campaigns'.freeze # @api private
|
|
43
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
44
|
+
'accounts/%{account_id}/campaigns/%{id}'.freeze # @api private
|
|
40
45
|
|
|
41
46
|
def initialize(account)
|
|
42
47
|
@account = account
|
|
@@ -25,8 +25,10 @@ module TwitterAds
|
|
|
25
25
|
property :io_header, read_only: true
|
|
26
26
|
property :reasons_not_able_to_fund, read_only: true
|
|
27
27
|
|
|
28
|
-
RESOURCE_COLLECTION =
|
|
29
|
-
|
|
28
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
29
|
+
'accounts/%{account_id}/funding_instruments'.freeze # @api private
|
|
30
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
31
|
+
'accounts/%{account_id}/funding_instruments/%{id}'.freeze # @api private
|
|
30
32
|
|
|
31
33
|
def initialize(account)
|
|
32
34
|
@account = account
|
|
@@ -13,7 +13,7 @@ module TwitterAds
|
|
|
13
13
|
property :name, read_only: true
|
|
14
14
|
property :parent_id, read_only: true
|
|
15
15
|
|
|
16
|
-
RESOURCE_COLLECTION =
|
|
16
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/iab_categories".freeze # @api private
|
|
17
17
|
|
|
18
18
|
def initialize(account)
|
|
19
19
|
@account = account
|
|
@@ -25,7 +25,7 @@ module TwitterAds
|
|
|
25
25
|
property :include_sentiment
|
|
26
26
|
property :objective
|
|
27
27
|
property :optimization
|
|
28
|
-
property :
|
|
28
|
+
property :entity_status
|
|
29
29
|
property :primary_web_event_tag
|
|
30
30
|
property :product_type
|
|
31
31
|
property :placements
|
|
@@ -43,12 +43,18 @@ module TwitterAds
|
|
|
43
43
|
# sdk only
|
|
44
44
|
property :to_delete, type: :bool
|
|
45
45
|
|
|
46
|
-
RESOURCE_COLLECTION
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
47
|
+
'accounts/%{account_id}/line_items'.freeze # @api private
|
|
48
|
+
RESOURCE_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
49
|
+
'stats/accounts/%{account_id}'.freeze # @api private
|
|
50
|
+
RESOURCE_ASYNC_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
51
|
+
'stats/jobs/accounts/%{account_id}'.freeze # @api private
|
|
52
|
+
RESOURCE_BATCH = "/#{TwitterAds::API_VERSION}/" +
|
|
53
|
+
'batch/accounts/%{account_id}/line_items'.freeze # @api private
|
|
54
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
55
|
+
'accounts/%{account_id}/line_items/%{id}'.freeze # @api private
|
|
56
|
+
RESOURCE_PLACEMENTS = "/#{TwitterAds::API_VERSION}/" +
|
|
57
|
+
'line_items/placements'.freeze # @api private
|
|
52
58
|
|
|
53
59
|
def initialize(account)
|
|
54
60
|
@account = account
|
|
@@ -7,6 +7,9 @@ module TwitterAds
|
|
|
7
7
|
|
|
8
8
|
include TwitterAds::Analytics
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
RESOURCE_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
11
|
+
'stats/accounts/%{account_id}'.freeze # @api private
|
|
12
|
+
RESOURCE_ASYNC_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
13
|
+
'stats/jobs/accounts/%{account_id}'.freeze # @api private
|
|
11
14
|
end
|
|
12
15
|
end
|
|
@@ -16,8 +16,10 @@ module TwitterAds
|
|
|
16
16
|
property :updated_at, type: :time, read_only: true
|
|
17
17
|
property :deleted, type: :bool, read_only: true
|
|
18
18
|
|
|
19
|
-
RESOURCE_COLLECTION =
|
|
20
|
-
|
|
19
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
20
|
+
'accounts/%{account_id}/promotable_users'.freeze # @api private
|
|
21
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
22
|
+
'accounts/%{account_id}/promotable_users/%{id}'.freeze # @api private
|
|
21
23
|
|
|
22
24
|
def initialize(account)
|
|
23
25
|
@account = account
|
|
@@ -28,9 +28,12 @@ module TwitterAds
|
|
|
28
28
|
# sdk only
|
|
29
29
|
property :to_delete, type: :bool
|
|
30
30
|
|
|
31
|
-
RESOURCE_COLLECTION =
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
32
|
+
'accounts/%{account_id}/targeting_criteria'.freeze # @api private
|
|
33
|
+
RESOURCE_BATCH = "/#{TwitterAds::API_VERSION}/" +
|
|
34
|
+
'batch/accounts/%{account_id}/targeting_criteria'.freeze # @api private
|
|
35
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
36
|
+
'accounts/%{account_id}/targeting_criteria/%{id}'.freeze # @api private
|
|
34
37
|
|
|
35
38
|
def initialize(account)
|
|
36
39
|
@account = account
|
|
@@ -7,18 +7,23 @@ module TwitterAds
|
|
|
7
7
|
# cannot instaniate Tweet, only including class methods for stats
|
|
8
8
|
extend TwitterAds::Analytics::ClassMethods
|
|
9
9
|
|
|
10
|
-
RESOURCE_COLLECTION
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
11
|
+
'accounts/%{account_id}/tweet/preview'.freeze # @api private
|
|
12
|
+
RESOURCE_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
13
|
+
'stats/accounts/%{account_id}'.freeze # @api private
|
|
14
|
+
RESOURCE_ASYNC_STATS = "/#{TwitterAds::API_VERSION}/" +
|
|
15
|
+
'stats/jobs/accounts/%{account_id}'.freeze # @api private
|
|
16
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
17
|
+
'accounts/%{account_id}/tweet/preview/%{id}'.freeze # @api private
|
|
18
|
+
RESOURCE_CREATE = "/#{TwitterAds::API_VERSION}/" +
|
|
19
|
+
'accounts/%{account_id}/tweet'.freeze # @api private
|
|
15
20
|
|
|
16
21
|
class << self
|
|
17
22
|
|
|
18
23
|
# Returns an HTML preview of a tweet, either new or existing
|
|
19
24
|
#
|
|
20
25
|
# @example
|
|
21
|
-
# Tweet.preview(account,
|
|
26
|
+
# Tweet.preview(account, text: 'potatoes can be deadly...')
|
|
22
27
|
# Tweet.preview(account, id: 634798319504617472)
|
|
23
28
|
#
|
|
24
29
|
# @param client [Client] The Client object instance.
|
|
@@ -26,7 +31,7 @@ module TwitterAds
|
|
|
26
31
|
# @param opts [Hash] A hash of options.
|
|
27
32
|
#
|
|
28
33
|
# @option opts [Integer] :id The ID of an existing Tweet you want to preview.
|
|
29
|
-
# @option opts [String] :
|
|
34
|
+
# @option opts [String] :text The text of your status update.
|
|
30
35
|
# @option opts [Array] :media_ids A list of up to four media IDs to associate with the Tweet.
|
|
31
36
|
# @option opts [String] :card_id The base-36 ID of a revenue card to be embedded in the Tweet.
|
|
32
37
|
# @option opts [String] :preview_target The target to render the Tweet preview
|
|
@@ -41,7 +46,7 @@ module TwitterAds
|
|
|
41
46
|
resource = resource % { account_id: account.id, id: opts.delete(:id) }
|
|
42
47
|
|
|
43
48
|
# url encodes status message if present
|
|
44
|
-
opts[:
|
|
49
|
+
opts[:text] = URI.escape(opts[:text]) if opts.key?(:text)
|
|
45
50
|
|
|
46
51
|
# handles array to string conversion for media IDs
|
|
47
52
|
if opts.key?(:media_ids) && opts[:media_ids].respond_to?(:join)
|
|
@@ -54,9 +59,9 @@ module TwitterAds
|
|
|
54
59
|
|
|
55
60
|
# Creates a "Promoted-Only" Tweet using the specialized Ads API end point.
|
|
56
61
|
#
|
|
57
|
-
# @param status [String] The main Tweet body (max: 140 characters).
|
|
58
62
|
# @param opts [Hash] A hash of options.
|
|
59
63
|
#
|
|
64
|
+
# @option opts [String] :text The main Tweet body.
|
|
60
65
|
# @option opts [Array] :media_ids A list of up to four media IDs to associate with the Tweet.
|
|
61
66
|
# @option opts [Integer] :as_user_id The user ID whom you are posting the Tweet on behalf of.
|
|
62
67
|
# @option opts [Boolean] :trim_user Excludes the user object from the hydrated Tweet response.
|
|
@@ -71,10 +76,9 @@ module TwitterAds
|
|
|
71
76
|
# @see https://dev.twitter.com/ads/reference/post/accounts/%3Aaccount_id/tweet
|
|
72
77
|
#
|
|
73
78
|
# @return [Hash] A hash containing the newly created Tweet object.
|
|
74
|
-
def create(account,
|
|
75
|
-
params = { status: status }.merge!(opts)
|
|
79
|
+
def create(account, opts = {})
|
|
76
80
|
resource = RESOURCE_CREATE % { account_id: account.id }
|
|
77
|
-
response = TwitterAds::Request.new(account.client, :post, resource, params:
|
|
81
|
+
response = TwitterAds::Request.new(account.client, :post, resource, params: opts).perform
|
|
78
82
|
response.body[:data]
|
|
79
83
|
end
|
|
80
84
|
|
data/lib/twitter-ads/client.rb
CHANGED
|
@@ -12,18 +12,20 @@ module TwitterAds
|
|
|
12
12
|
|
|
13
13
|
attr_reader :account
|
|
14
14
|
|
|
15
|
-
property :id, read_only: true
|
|
16
|
-
property :deleted, type: :bool, read_only: true
|
|
17
15
|
property :created_at, type: :time, read_only: true
|
|
18
|
-
property :
|
|
16
|
+
property :deleted, type: :bool, read_only: true
|
|
17
|
+
property :id, read_only: true
|
|
19
18
|
property :media_url, read_only: true
|
|
19
|
+
property :updated_at, type: :time, read_only: true
|
|
20
20
|
|
|
21
|
-
property :media_id
|
|
22
21
|
property :creative_type
|
|
22
|
+
property :media_id
|
|
23
23
|
property :video_id
|
|
24
24
|
|
|
25
|
-
RESOURCE_COLLECTION =
|
|
26
|
-
|
|
25
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
26
|
+
'accounts/%{account_id}/account_media'.freeze # @api private
|
|
27
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
28
|
+
'accounts/%{account_id}/account_media/%{id}'.freeze # @api private
|
|
27
29
|
|
|
28
30
|
def initialize(account)
|
|
29
31
|
@account = account
|
|
@@ -12,26 +12,32 @@ module TwitterAds
|
|
|
12
12
|
|
|
13
13
|
attr_reader :account
|
|
14
14
|
|
|
15
|
+
property :card_type, read_only: true
|
|
16
|
+
property :card_uri, read_only: true
|
|
17
|
+
property :created_at, type: :time, read_only: true
|
|
18
|
+
property :deleted, type: :bool, read_only: true
|
|
15
19
|
property :id, read_only: true
|
|
20
|
+
property :image_display_height, read_only: true
|
|
21
|
+
property :image_display_width, read_only: true
|
|
16
22
|
property :preview_url, read_only: true
|
|
17
|
-
property :deleted, type: :bool, read_only: true
|
|
18
|
-
property :created_at, type: :time, read_only: true
|
|
19
23
|
property :updated_at, type: :time, read_only: true
|
|
24
|
+
property :wide_app_image, read_only: true
|
|
20
25
|
|
|
21
|
-
property :name
|
|
22
26
|
property :app_country_code
|
|
27
|
+
property :app_cta
|
|
28
|
+
property :googleplay_app_id
|
|
29
|
+
property :googleplay_deep_link
|
|
23
30
|
property :iphone_app_id
|
|
24
31
|
property :iphone_deep_link
|
|
25
32
|
property :ipad_app_id
|
|
26
33
|
property :ipad_deep_link
|
|
27
|
-
property :
|
|
28
|
-
property :googleplay_deep_link
|
|
29
|
-
property :app_cta
|
|
34
|
+
property :name
|
|
30
35
|
property :wide_app_image_media_id
|
|
31
36
|
|
|
32
|
-
RESOURCE_COLLECTION =
|
|
33
|
-
|
|
34
|
-
RESOURCE =
|
|
37
|
+
RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
|
|
38
|
+
'accounts/%{account_id}/cards/image_app_download'.freeze # @api private
|
|
39
|
+
RESOURCE = "/#{TwitterAds::API_VERSION}/" +
|
|
40
|
+
'accounts/%{account_id}/cards/image_app_download/%{id}'.freeze # @api private
|
|
35
41
|
|
|
36
42
|
def initialize(account)
|
|
37
43
|
@account = account
|