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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -1
  3. data.tar.gz.sig +0 -0
  4. data/bin/twitter-ads +3 -0
  5. data/lib/twitter-ads.rb +2 -4
  6. data/lib/twitter-ads/account.rb +25 -5
  7. data/lib/twitter-ads/audiences/tailored_audience.rb +47 -5
  8. data/lib/twitter-ads/campaign/app_list.rb +4 -2
  9. data/lib/twitter-ads/campaign/campaign.rb +11 -6
  10. data/lib/twitter-ads/campaign/funding_instrument.rb +4 -2
  11. data/lib/twitter-ads/campaign/iab_category.rb +1 -1
  12. data/lib/twitter-ads/campaign/line_item.rb +13 -7
  13. data/lib/twitter-ads/campaign/organic_tweet.rb +4 -1
  14. data/lib/twitter-ads/campaign/promotable_user.rb +4 -2
  15. data/lib/twitter-ads/campaign/targeting_criteria.rb +6 -3
  16. data/lib/twitter-ads/campaign/tweet.rb +16 -12
  17. data/lib/twitter-ads/client.rb +2 -0
  18. data/lib/twitter-ads/creative/account_media.rb +8 -6
  19. data/lib/twitter-ads/creative/image_app_download_card.rb +15 -9
  20. data/lib/twitter-ads/creative/image_conversation_card.rb +17 -9
  21. data/lib/twitter-ads/creative/media_creative.rb +9 -7
  22. data/lib/twitter-ads/creative/promoted_account.rb +8 -4
  23. data/lib/twitter-ads/creative/promoted_tweet.rb +10 -8
  24. data/lib/twitter-ads/creative/scheduled_tweet.rb +57 -0
  25. data/lib/twitter-ads/creative/video.rb +14 -8
  26. data/lib/twitter-ads/creative/video_app_download_card.rb +18 -12
  27. data/lib/twitter-ads/creative/video_conversation_card.rb +18 -9
  28. data/lib/twitter-ads/creative/video_website_card.rb +53 -0
  29. data/lib/twitter-ads/creative/website_card.rb +14 -16
  30. data/lib/twitter-ads/enum.rb +32 -13
  31. data/lib/twitter-ads/http/request.rb +2 -2
  32. data/lib/twitter-ads/http/ton_upload.rb +33 -17
  33. data/lib/twitter-ads/measurement/app_event_tag.rb +2 -1
  34. data/lib/twitter-ads/measurement/web_event_tag.rb +2 -1
  35. data/lib/twitter-ads/resources/analytics.rb +13 -8
  36. data/lib/twitter-ads/targeting/reach_estimate.rb +2 -2
  37. data/lib/twitter-ads/targeting_criteria/app_store_category.rb +2 -1
  38. data/lib/twitter-ads/targeting_criteria/behavior.rb +2 -1
  39. data/lib/twitter-ads/targeting_criteria/behavior_taxonomy.rb +2 -1
  40. data/lib/twitter-ads/targeting_criteria/device.rb +2 -1
  41. data/lib/twitter-ads/targeting_criteria/event.rb +2 -1
  42. data/lib/twitter-ads/targeting_criteria/interest.rb +2 -1
  43. data/lib/twitter-ads/targeting_criteria/language.rb +2 -1
  44. data/lib/twitter-ads/targeting_criteria/location.rb +2 -1
  45. data/lib/twitter-ads/targeting_criteria/network_operator.rb +2 -1
  46. data/lib/twitter-ads/targeting_criteria/platform.rb +2 -1
  47. data/lib/twitter-ads/targeting_criteria/platform_version.rb +2 -1
  48. data/lib/twitter-ads/targeting_criteria/tv_market.rb +2 -1
  49. data/lib/twitter-ads/targeting_criteria/tv_show.rb +2 -1
  50. data/lib/twitter-ads/utils.rb +3 -3
  51. data/lib/twitter-ads/version.rb +1 -1
  52. data/spec/fixtures/campaigns_all.json +10 -10
  53. data/spec/fixtures/line_items_all.json +10 -10
  54. data/spec/fixtures/line_items_load.json +1 -1
  55. data/spec/fixtures/no_content.json +0 -0
  56. data/spec/fixtures/promoted_tweets_all.json +20 -20
  57. data/spec/fixtures/promoted_tweets_load.json +1 -1
  58. data/spec/spec_helper.rb +1 -1
  59. data/spec/support/helpers.rb +2 -2
  60. data/spec/twitter-ads/campaign/app_list_spec.rb +1 -1
  61. data/spec/twitter-ads/campaign/line_item_spec.rb +1 -1
  62. data/spec/twitter-ads/campaign/reach_estimate_spec.rb +1 -1
  63. data/spec/twitter-ads/campaign/tweet_spec.rb +7 -7
  64. data/spec/twitter-ads/client_spec.rb +2 -1
  65. data/spec/twitter-ads/creative/promoted_tweet_spec.rb +2 -2
  66. data/spec/twitter-ads/creative/website_card_spec.rb +15 -9
  67. data/spec/twitter-ads/http/ton_upload_spec.rb +96 -0
  68. metadata +60 -62
  69. metadata.gz.sig +0 -0
  70. data/lib/twitter-ads/creative/app_download_card.rb +0 -44
  71. data/lib/twitter-ads/creative/lead_gen_card.rb +0 -46
  72. data/lib/twitter-ads/targeting_criteria/tv_channel.rb +0 -20
  73. data/lib/twitter-ads/targeting_criteria/tv_genre.rb +0 -20
  74. data/spec/twitter-ads/creative/app_download_card_spec.rb +0 -44
  75. 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: 515186149614e6ad01864e1c993d6d507b9b700a
4
- data.tar.gz: 35a9ccc5c1d33bfe13b46ea21841e9c1fe504e87
3
+ metadata.gz: 1831dee8de9255d8b7b9a5131ebd8a2f7960cca7
4
+ data.tar.gz: 180c8bb92cf67b4cf01fb662f6a39d9557cfae29
5
5
  SHA512:
6
- metadata.gz: eb3b164f846c1588f9a4f878c78b095c8c2d995023b5f198c464de95f71f7bc48f882adc2c5904aba04d3b4b17e84757335a5060b6b03208038e1e5dec76e12d
7
- data.tar.gz: fddb7139f5e4f6fe7d29eb672ce89e384fb37f3adccbdc8843dc5205e34cfb6ec736bd8a02668349263297933299617c9acbbf05e8d483d6fafa9d3969bd7df1
6
+ metadata.gz: 78279f2ea036bd2c39b5b603d0985d6d796f72a4cbfb8fe83355acd6ea4c3b0c9f6540c850d8c7ff15b82bec598e0b38c6f7457f11808151b9a8cb3e39929a5d
7
+ data.tar.gz: c3dd5a42d10352ac6c39fe9064c3e30535a0741f4a15a958547845b8acfdc2127f5b1404e1730d2a7d36b33e48bc7813694a3bee2310ccd1cedbc5316f475f40
@@ -1 +1,3 @@
1
- ��� B֡#�9#{�����[dgA@Y�/w�]��"�|���l��� �#.��Q:蹖|�T9�Ì���n��,�i(K��`{�/�� �w& \yjN�:,��\ӈ8�J�[�%��S���>)��$F��"ui�3i��m��=z�K���Ȯ��%�����:Z�,'I��.��\ �����k�.�A�m���K��eB�Z�j�����n3R1��a��i9y�|�6��=C�ɿ�k�v�z5��y�
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
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+
3
6
  begin
4
7
  require 'twitter'
5
8
  rescue LoadError
@@ -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
 
@@ -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 = '/1/accounts'.freeze # @api private
21
- RESOURCE = '/1/accounts/%{id}'.freeze # @api private
22
- FEATURES = '/1/accounts/%{id}/features'.freeze # @api private
23
- SCOPED_TIMELINE = '/1/accounts/%{id}/scoped_timeline'.freeze # @api private
24
- AUTHENTICATED_USER_ACCESS = '/1/accounts/%{id}/authenticated_user_access'.freeze # @api private
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 = '/1/accounts/%{account_id}/tailored_audiences'.freeze # @api private
29
- RESOURCE = '/1/accounts/%{account_id}/tailored_audiences/%{id}'.freeze # @api private
30
- RESOURCE_UPDATE = '/1/accounts/%{account_id}/tailored_audience_changes'.freeze # @api private
31
- GLOBAL_OPT_OUT =
32
- '/1/accounts/%{account_id}/tailored_audiences/global_opt_out'.freeze # @api private
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 = '/1/accounts/%{account_id}/app_lists'.freeze # @api private
17
- RESOURCE = '/1/accounts/%{account_id}/app_lists/%{id}'.freeze # @api private
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 :paused, type: :bool
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 = '/1/accounts/%{account_id}/campaigns'.freeze # @api private
36
- RESOURCE_STATS = '/1/stats/accounts/%{account_id}'.freeze # @api private
37
- RESOURCE_ASYNC_STATS = '/1/stats/jobs/accounts/%{account_id}'.freeze # @api private
38
- RESOURCE_BATCH = '/1/batch/accounts/%{account_id}/campaigns'.freeze # @api private
39
- RESOURCE = '/1/accounts/%{account_id}/campaigns/%{id}'.freeze # @api private
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 = '/1/accounts/%{account_id}/funding_instruments'.freeze # @api private
29
- RESOURCE = '/1/accounts/%{account_id}/funding_instruments/%{id}'.freeze # @api private
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 = '/1/iab_categories'.freeze # @api private
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 :paused, type: :bool
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 = '/1/accounts/%{account_id}/line_items'.freeze # @api private
47
- RESOURCE_STATS = '/1/stats/accounts/%{account_id}'.freeze # @api private
48
- RESOURCE_ASYNC_STATS = '/1/stats/jobs/accounts/%{account_id}'.freeze # @api private
49
- RESOURCE_BATCH = '/1/batch/accounts/%{account_id}/line_items'.freeze # @api private
50
- RESOURCE = '/1/accounts/%{account_id}/line_items/%{id}'.freeze # @api private
51
- RESOURCE_PLACEMENTS = '/1/line_items/placements'.freeze # @api private
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
- RESOURCE_ASYNC_STATS = '/1/stats/jobs/accounts/%{account_id}'.freeze # @api private
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 = '/1/accounts/%{account_id}/promotable_users'.freeze # @api private
20
- RESOURCE = '/1/accounts/%{account_id}/promotable_users/%{id}'.freeze # @api private
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 = '/1/accounts/%{account_id}/targeting_criteria'.freeze # @api private
32
- RESOURCE_BATCH = '/1/batch/accounts/%{account_id}/targeting_criteria'.freeze # @api private
33
- RESOURCE = '/1/accounts/%{account_id}/targeting_criteria/%{id}'.freeze # @api private
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 = '/1/accounts/%{account_id}/tweet/preview'.freeze # @api private
11
- RESOURCE_STATS = '/1/stats/accounts/%{account_id}'.freeze # @api private
12
- RESOURCE_ASYNC_STATS = '/1/stats/jobs/accounts/%{account_id}'.freeze # @api private
13
- RESOURCE = '/1/accounts/%{account_id}/tweet/preview/%{id}'.freeze # @api private
14
- RESOURCE_CREATE = '/1/accounts/%{account_id}/tweet'.freeze # @api private
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, status: 'potatoes can be deadly...')
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] :status The text of your status update, up to 140 characters.
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[:status] = URI.escape(opts[:status]) if opts.key?(:status)
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, status, opts = {})
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: params).perform
81
+ response = TwitterAds::Request.new(account.client, :post, resource, params: opts).perform
78
82
  response.body[:data]
79
83
  end
80
84
 
@@ -3,6 +3,8 @@
3
3
 
4
4
  module TwitterAds
5
5
 
6
+ API_VERSION = '2'.freeze
7
+
6
8
  # The Ads API Client class which functions as a
7
9
  # container for basic API consumer information.
8
10
  class Client
@@ -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 :updated_at, type: :time, read_only: true
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 = '/1/accounts/%{account_id}/account_media'.freeze # @api private
26
- RESOURCE = '/1/accounts/%{account_id}/account_media/%{id}'.freeze # @api private
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 :googleplay_app_id
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
- '/1/accounts/%{account_id}/cards/image_app_download'.freeze # @api private
34
- RESOURCE = '/1/accounts/%{account_id}/cards/image_app_download/%{id}'.freeze # @api private
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