twitter-ads 9.0.0 → 11.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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/twitter-ads/account.rb +17 -1
  4. data/lib/twitter-ads/campaign/campaign.rb +2 -2
  5. data/lib/twitter-ads/campaign/line_item.rb +4 -4
  6. data/lib/twitter-ads/campaign/tracking_tags.rb +97 -0
  7. data/lib/twitter-ads/client.rb +1 -1
  8. data/lib/twitter-ads/creative/cards.rb +31 -22
  9. data/lib/twitter-ads/creative/cards_fetch.rb +2 -4
  10. data/lib/twitter-ads/creative/draft_tweet.rb +0 -1
  11. data/lib/twitter-ads/cursor.rb +2 -2
  12. data/lib/twitter-ads/enum.rb +5 -0
  13. data/lib/twitter-ads/resources/analytics.rb +1 -2
  14. data/lib/twitter-ads/targeting/{audience_summary.rb → audience_estimate.rb} +3 -3
  15. data/lib/twitter-ads/version.rb +1 -1
  16. data/lib/twitter-ads.rb +2 -5
  17. data/spec/fixtures/accounts_all.json +0 -5
  18. data/spec/fixtures/accounts_load.json +0 -1
  19. data/spec/fixtures/{audience_summary.json → audience_estimate.json} +0 -0
  20. data/spec/fixtures/cards_all.json +836 -0
  21. data/spec/fixtures/cards_load.json +42 -0
  22. data/spec/fixtures/line_items_all.json +0 -10
  23. data/spec/fixtures/line_items_load.json +0 -1
  24. data/spec/fixtures/tracking_tags_load.json +17 -0
  25. data/spec/twitter-ads/campaign/line_item_spec.rb +1 -1
  26. data/spec/twitter-ads/campaign/tracking_tag_spec.rb +58 -0
  27. data/spec/twitter-ads/creative/cards_spec.rb +52 -0
  28. data/spec/twitter-ads/targeting/{audience_summary_spec.rb → audience_estimate_spec.rb} +2 -2
  29. metadata +48 -41
  30. data/lib/twitter-ads/creative/image_app_download_card.rb +0 -49
  31. data/lib/twitter-ads/creative/video_app_download_card.rb +0 -50
  32. data/lib/twitter-ads/creative/video_website_card.rb +0 -50
  33. data/lib/twitter-ads/creative/website_card.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ab4c35b2b3ff9a24fb3475717b923563c484d80b2ac7e981c18570ddbaebdbc
4
- data.tar.gz: e5f228604a745b96a063c59d80248bd976f27a4cc43243cd34a0f45a55548cb0
3
+ metadata.gz: 67928f3af10643b8b98513d2411b0f560103f8a6491d816fa25e99ffdd8362d9
4
+ data.tar.gz: '044490baf9cfab6e87b46a6d03a4b6b15bf44b3b5aa2e307bd9cd9137fdb72a9'
5
5
  SHA512:
6
- metadata.gz: d17c433739bebd2d74a7c62c20e58819f5f4ea29e241b3dd53ec4baeba4e55213761a27f40833d497b356638a8057770ab7a16f73578df96732555f511ddd43c
7
- data.tar.gz: 2aff371a6a36636f82adce64fa00766bcd6e5257a6c288ea58f06740df3bb879008bc1e2afe8b286c8b0b1e431ce5bf413a011562cae9e5594f65133f5d63752
6
+ metadata.gz: 395df768253f0f424c7d13c12004711aaae69c3b55f2c8a4f992b778b4fb7656dc41b2a79df9e00c3c31ec38851cc9a7059129c4b88b4717b86a8ba08bc7f5cd
7
+ data.tar.gz: 27d317c21e27631d3b09187c20c52934055f585a45e2e91af073abdfdf0c62c77d7ac9fe9b598a9583aad581dea944dd66eb265fddf7902c11dd701c539cc080
data/README.md CHANGED
@@ -52,7 +52,7 @@ This project is designed to work with Ruby 2.4.0 or greater. While it may work o
52
52
 
53
53
  Platform | Versions
54
54
  -------- | --------
55
- MRI | 2.4.x, 2.5.x, 2.6.x
55
+ MRI | 2.4.x, 2.5.x, 2.6.x, 2.7, 3.0
56
56
  Rubinius | 2.4.x, 2.5.x
57
57
 
58
58
  All releases adhere to strict [semantic versioning](http://semver.org). For Example, major.minor.patch-pre (aka. stick.carrot.oops-peek).
@@ -89,7 +89,7 @@ Like the [Response](https://github.com/twitterdev/twitter-ruby-ads-sdk/blob/mast
89
89
 
90
90
  The MIT License (MIT)
91
91
 
92
- Copyright (C) 2019 Twitter, Inc.
92
+ Copyright (C) 2021 Twitter, Inc.
93
93
 
94
94
  Permission is hereby granted, free of charge, to any person obtaining a copy
95
95
  of this software and associated documentation files (the "Software"), to deal
@@ -10,7 +10,6 @@ module TwitterAds
10
10
 
11
11
  property :id, read_only: true
12
12
  property :name, read_only: true
13
- property :salt, read_only: true
14
13
  property :timezone, read_only: true
15
14
  property :timezone_switch_at, type: :time, read_only: true
16
15
  property :created_at, type: :time, read_only: true
@@ -218,6 +217,23 @@ module TwitterAds
218
217
  load_resource(LineItem, id, opts)
219
218
  end
220
219
 
220
+ # Returns a collection of tracking tags available to the
221
+ # current account.
222
+ #
223
+ # @param id [String] The LineItem ID value.
224
+ # @param opts [Hash] A Hash of extended options.
225
+ # @option opts [Boolean] :with_deleted Indicates if deleted items should be included.
226
+ # @option opts [String] :sort_by The object param to sort the API response by.
227
+ # @option opts [String] :line_item_ids The object param to sort the API response by.
228
+ # @option opts [String] :tracking_tag_ids The object param to sort the API response by.
229
+ #
230
+ # @return A Cursor or object instance.
231
+ #
232
+ # @since 10.0.0
233
+ def tracking_tags(id = nil, opts = {})
234
+ load_resource(TrackingTag, id, opts)
235
+ end
236
+
221
237
  # Returns a collection of app lists available to the current account.
222
238
  #
223
239
  # @param id [String] The AppList ID value.
@@ -20,13 +20,13 @@ module TwitterAds
20
20
 
21
21
  property :name
22
22
  property :funding_instrument_id
23
- property :end_time, type: :time
24
- property :start_time, type: :time
25
23
  property :entity_status
24
+ property :effective_status
26
25
  property :currency
27
26
  property :standard_delivery
28
27
  property :daily_budget_amount_local_micro
29
28
  property :total_budget_amount_local_micro
29
+ property :budget_optimization
30
30
 
31
31
  # sdk only
32
32
  property :to_delete, type: :bool
@@ -19,7 +19,6 @@ module TwitterAds
19
19
  property :advertiser_domain
20
20
  property :android_app_store_identifier
21
21
  property :audience_expansion
22
- property :automatically_select_bid
23
22
  property :bid_amount_local_micro
24
23
  property :bid_strategy
25
24
  property :campaign_id
@@ -35,11 +34,9 @@ module TwitterAds
35
34
  property :primary_web_event_tag
36
35
  property :product_type
37
36
  property :start_time, type: :time
37
+ property :standard_delivery, type: :bool
38
38
  property :total_budget_amount_local_micro
39
-
40
- # beta (not yet generally available)
41
39
  property :advertiser_user_id
42
- property :tracking_tags
43
40
 
44
41
  # sdk only
45
42
  property :to_delete, type: :bool
@@ -94,5 +91,8 @@ module TwitterAds
94
91
  id ? TargetingCriteria.load(account, id, opts) : TargetingCriteria.all(account, @id, opts)
95
92
  end
96
93
 
94
+ def tracking_tags(id = nil, opts = {})
95
+ id ? TrackingTag.load(account, id, opts) : TrackingTag.all(account, @id, opts)
96
+ end
97
97
  end
98
98
  end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+ # Copyright (C) 2019 Twitter, Inc.
3
+
4
+ module TwitterAds
5
+ class TrackingTag
6
+
7
+ include TwitterAds::DSL
8
+ include TwitterAds::Resource
9
+ include TwitterAds::Persistence
10
+
11
+ attr_reader :account
12
+
13
+ property :id, read_only: true
14
+ property :deleted, type: :bool, read_only: true
15
+ property :created_at, type: :time, read_only: true
16
+ property :updated_at, type: :time, read_only: true
17
+
18
+ property :line_item_id
19
+ property :tracking_tag_type
20
+ property :tracking_tag_url
21
+
22
+ # sdk only
23
+ property :to_delete, type: :bool
24
+
25
+ RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
26
+ 'accounts/%{account_id}/tracking_tags' # @api private
27
+ RESOURCE = "/#{TwitterAds::API_VERSION}/" \
28
+ 'accounts/%{account_id}/tracking_tags/%{id}' # @api private
29
+
30
+ def initialize(account)
31
+ @account = account
32
+ self
33
+ end
34
+
35
+ # Creates a new Tracking Tag
36
+ #
37
+ # @param line_item_id [String] The line item id to create tags for.
38
+ # @param tracking_tag_url [String] tracking tag URL.
39
+ #
40
+ # @return [self] Returns the instance refreshed from the API
41
+ def create(line_item_id, tracking_tag_url)
42
+ resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
43
+ params = to_params.merge!(
44
+ line_item_id: line_item_id,
45
+ tracking_tag_url: tracking_tag_url,
46
+ tracking_tag_type: 'IMPRESSION_TAG'
47
+ )
48
+ response = Request.new(account.client, :post, resource, params: params).perform
49
+ from_response(response.body[:data])
50
+ end
51
+
52
+ class << self
53
+
54
+ # Returns a Cursor instance for a given resource.
55
+ #
56
+ # @param account [Account] The Account object instance.
57
+ # @param line_item_ids [String] A String or String array of Line Item IDs.
58
+ # @param opts [Hash] An optional Hash of extended options.
59
+ # @option opts [Boolean] :with_deleted Indicates if deleted items should be included.
60
+ # @option opts [String] :sort_by The object param to sort the API response by.
61
+ #
62
+ # @return [Cursor] A Cusor object ready to iterate through the API response.
63
+ #
64
+ # @since 0.3.1
65
+ # @see Cursor
66
+ # @see https://dev.twitter.com/ads/basics/sorting Sorting
67
+ def all(account, line_item_ids, opts = {})
68
+ if !line_item_ids.empty?
69
+ params = { line_item_ids: Array(line_item_ids).join(',') }.merge!(opts)
70
+ end
71
+ resource = RESOURCE_COLLECTION % { account_id: account.id }
72
+ request = Request.new(account.client, :get, resource, params: params)
73
+ Cursor.new(self, request, init_with: [account])
74
+ end
75
+
76
+ # Returns an object instance for a given resource.
77
+ #
78
+ # @param account [Account] The Account object instance.
79
+ # @param id [String] The ID of the specific object to be loaded.
80
+ # @param opts [Hash] An optional Hash of extended options.
81
+ # @option opts [Boolean] :with_deleted Indicates if deleted items should be included.
82
+ # @option opts [String] :sort_by The object param to sort the API response by.
83
+ #
84
+ # @return [self] The object instance for the specified resource.
85
+ #
86
+ # @since 0.3.1
87
+ def load(account, id, opts = {})
88
+ params = { with_deleted: true }.merge!(opts)
89
+ resource = RESOURCE % { account_id: account.id, id: id }
90
+ response = Request.new(account.client, :get, resource, params: params).perform
91
+ new(account).from_response(response.body[:data])
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module TwitterAds
5
5
 
6
- API_VERSION = '9'
6
+ API_VERSION = '11'
7
7
 
8
8
  # The Ads API Client class which functions as a
9
9
  # container for basic API consumer information.
@@ -12,36 +12,46 @@ module TwitterAds
12
12
 
13
13
  attr_reader :account
14
14
 
15
+ property :id, read_only: true
16
+ property :card_type, read_only: true
15
17
  property :card_uri, read_only: true
16
18
  property :created_at, type: :time, read_only: true
17
19
  property :deleted, type: :bool, read_only: true
18
20
  property :updated_at, type: :time, read_only: true
19
21
  # these are writable, but not in the sense that they can be set on an object and then saved
20
- property :name, read_only: true
21
- property :components, read_only: true
22
+ property :name
23
+ property :components
22
24
 
23
25
  RESOURCE = "/#{TwitterAds::API_VERSION}/" +
24
- 'accounts/%{account_id}/cards' # @api private
26
+ 'accounts/%{account_id}/cards/%{id}' # @api private
27
+ RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" +
28
+ 'accounts/%{account_id}/cards' # @api private
25
29
 
26
- def load(*)
27
- raise ArgumentError.new(
28
- "'Cards' object has no attribute 'load'")
29
- end
30
-
31
- def reload(*)
32
- raise ArgumentError.new(
33
- "'Cards' object has no attribute 'reload'")
34
- end
35
-
36
- def create(account, name, components)
37
- resource = RESOURCE % { account_id: account.id }
38
- params = { 'name': name, 'components': components }
30
+ def save
39
31
  headers = { 'Content-Type' => 'application/json' }
40
- response = Request.new(account.client,
41
- :post,
42
- resource,
43
- headers: headers,
44
- body: params.to_json).perform
32
+ params = { 'name': name, 'components': components }
33
+ if @id
34
+ resource = RESOURCE % {
35
+ account_id: account.id,
36
+ id: id
37
+ }
38
+ request = Request.new(account.client,
39
+ :put,
40
+ resource,
41
+ headers: headers,
42
+ body: params.to_json)
43
+ else
44
+ resource = RESOURCE_COLLECTION % {
45
+ account_id: account.id
46
+ }
47
+ request = Request.new(account.client,
48
+ :post,
49
+ resource,
50
+ headers: headers,
51
+ body: params.to_json)
52
+ end
53
+
54
+ response = request.perform
45
55
  from_response(response.body[:data])
46
56
  end
47
57
 
@@ -49,7 +59,6 @@ module TwitterAds
49
59
  @account = account
50
60
  self
51
61
  end
52
-
53
62
  end
54
63
 
55
64
  end
@@ -35,10 +35,8 @@ module TwitterAds
35
35
  property :image, read_only: true
36
36
  property :image_display_height, read_only: true
37
37
  property :image_display_width, read_only: true
38
- property :ipad_app_id, read_only: true
39
- property :ipad_deep_link, read_only: true
40
- property :iphone_app_id, read_only: true
41
- property :iphone_deep_link, read_only: true
38
+ property :ios_app_store_identifier, read_only: true
39
+ property :ios_deep_link, read_only: true
42
40
  property :name, read_only: true
43
41
  property :recipient_user_id, read_only: true
44
42
  property :second_choice, read_only: true
@@ -14,7 +14,6 @@ module TwitterAds
14
14
 
15
15
  # read-only
16
16
  property :id, read_only: true
17
- property :id_str, read_only: true
18
17
  property :created_at, type: :time, read_only: true
19
18
  property :updated_at, type: :time, read_only: true
20
19
  property :user_id, read_only: true
@@ -56,13 +56,13 @@ module TwitterAds
56
56
  # @return [Cursor] The current Cursor instance.
57
57
  #
58
58
  # @since 0.1.0
59
- def each(offset = 0)
59
+ def each(offset = 0, &block)
60
60
  return to_enum(:each, offset) unless block_given?
61
61
  @collection[offset..-1].each { |element| yield(element) }
62
62
  unless exhausted?
63
63
  offset = [@collection.size, offset].max
64
64
  fetch_next
65
- each(offset, &Proc.new)
65
+ each(offset, &block)
66
66
  end
67
67
  self
68
68
  end
@@ -84,6 +84,7 @@ module TwitterAds
84
84
 
85
85
  module PayBy
86
86
  APP_CLICK = 'APP_CLICK'
87
+ IMPRESSION = 'IMPRESSION'
87
88
  end
88
89
 
89
90
  module MetricGroup
@@ -233,5 +234,9 @@ module TwitterAds
233
234
  NULLCAST = 'NULLCAST'
234
235
  ORGANIC = 'ORGANIC'
235
236
  end
237
+
238
+ module BudgetOptimization
239
+ CAMPAIGN = 'CAMPAIGN'
240
+ end
236
241
  end
237
242
  end
@@ -14,7 +14,6 @@ module TwitterAds
14
14
  attr_reader :account
15
15
 
16
16
  property :id, read_only: true
17
- property :id_str, read_only: true
18
17
  property :status, read_only: true
19
18
  property :url, read_only: true
20
19
  property :created_at, type: :time, read_only: true
@@ -211,7 +210,7 @@ module TwitterAds
211
210
  tries = 0
212
211
  begin
213
212
  tries += 1
214
- raw_file = open(data_url)
213
+ raw_file = URI.open(data_url)
215
214
  unzipped_file = Zlib::GzipReader.new(raw_file)
216
215
  response_data = unzipped_file.read
217
216
  response = JSON.parse(response_data)
@@ -2,13 +2,13 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- module AudienceSummary
5
+ module AudienceEstimate
6
6
 
7
7
  include TwitterAds::DSL
8
8
  include TwitterAds::Resource
9
9
 
10
10
  RESOURCE = "/#{TwitterAds::API_VERSION}/" \
11
- 'accounts/%{account_id}/audience_summary'
11
+ 'accounts/%{account_id}/audience_estimate'
12
12
 
13
13
  property :audience_size, read_only: true
14
14
 
@@ -17,7 +17,7 @@ module TwitterAds
17
17
  # Get an audience summary for the specified targeting criteria.
18
18
  #
19
19
  # @example
20
- # TwitterAds::AudienceSummary.fetch(
20
+ # TwitterAds::AudienceEstimate.fetch(
21
21
  # account,
22
22
  # params: {targeting_criteria:[{targeting_type:'LOCATION',
23
23
  # targeting_value:'96683cc9126741d1'}]}
@@ -2,5 +2,5 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- VERSION = '9.0.0'
5
+ VERSION = '11.0.0'
6
6
  end
data/lib/twitter-ads.rb CHANGED
@@ -37,6 +37,7 @@ require 'twitter-ads/campaign/funding_instrument'
37
37
  require 'twitter-ads/campaign/line_item'
38
38
  require 'twitter-ads/campaign/promotable_user'
39
39
  require 'twitter-ads/campaign/targeting_criteria'
40
+ require 'twitter-ads/campaign/tracking_tags'
40
41
  require 'twitter-ads/campaign/tweet'
41
42
  require 'twitter-ads/campaign/organic_tweet'
42
43
  require 'twitter-ads/campaign/iab_category'
@@ -59,7 +60,6 @@ require 'twitter-ads/targeting_criteria/app_store_category'
59
60
  require 'twitter-ads/creative/account_media'
60
61
  require 'twitter-ads/creative/cards_fetch'
61
62
  require 'twitter-ads/creative/cards'
62
- require 'twitter-ads/creative/image_app_download_card'
63
63
  require 'twitter-ads/creative/image_conversation_card'
64
64
  require 'twitter-ads/creative/media_creative'
65
65
  require 'twitter-ads/creative/media_library'
@@ -67,15 +67,12 @@ require 'twitter-ads/creative/promoted_account'
67
67
  require 'twitter-ads/creative/promoted_tweet'
68
68
  require 'twitter-ads/creative/scheduled_tweet'
69
69
  require 'twitter-ads/creative/draft_tweet'
70
- require 'twitter-ads/creative/video_app_download_card'
71
70
  require 'twitter-ads/creative/video_conversation_card'
72
- require 'twitter-ads/creative/video_website_card'
73
- require 'twitter-ads/creative/website_card'
74
71
  require 'twitter-ads/creative/poll_cards'
75
72
  require 'twitter-ads/creative/tweet_previews'
76
73
  require 'twitter-ads/creative/tweets'
77
74
 
78
- require 'twitter-ads/targeting/audience_summary'
75
+ require 'twitter-ads/targeting/audience_estimate'
79
76
 
80
77
  require 'twitter-ads/measurement/web_event_tag'
81
78
  require 'twitter-ads/measurement/app_event_tag'
@@ -9,7 +9,6 @@
9
9
  "timezone_switch_at": "2014-11-17T08:00:00Z",
10
10
  "id": "2iqph",
11
11
  "created_at": "2015-03-04T10:50:42Z",
12
- "salt": "5ab2pizq7qxjjqrx3z67f4wbko61o7xs",
13
12
  "updated_at": "2015-04-11T05:20:08Z",
14
13
  "approval_status": "ACCEPTED",
15
14
  "deleted": false
@@ -20,7 +19,6 @@
20
19
  "timezone_switch_at": "2014-11-17T08:00:00Z",
21
20
  "id": "pz6ec",
22
21
  "created_at": "2015-05-29T00:52:16Z",
23
- "salt": "39ku32xvhdt0jax8thps2c70e2fv3yok",
24
22
  "updated_at": "2015-05-29T00:52:16Z",
25
23
  "approval_status": "ACCEPTED",
26
24
  "deleted": false
@@ -31,7 +29,6 @@
31
29
  "timezone_switch_at": "2014-11-17T08:00:00Z",
32
30
  "id": "j9ozo",
33
31
  "created_at": "2015-05-01T12:08:10Z",
34
- "salt": "winwfne3y6oyikl4tm84bj9r50waxj37",
35
32
  "updated_at": "2015-05-01T12:08:10Z",
36
33
  "approval_status": "ACCEPTED",
37
34
  "deleted": false
@@ -42,7 +39,6 @@
42
39
  "timezone_switch_at": "2014-11-17T08:00:00Z",
43
40
  "id": "9ttgd",
44
41
  "created_at": "2015-06-24T18:51:20Z",
45
- "salt": "tj9hmt5xylm5zztrq05w7hwh4mkpkg5r",
46
42
  "updated_at": "2015-06-26T06:13:24Z",
47
43
  "approval_status": "ACCEPTED",
48
44
  "deleted": false
@@ -53,7 +49,6 @@
53
49
  "timezone_switch_at": "2013-05-22T07:00:00Z",
54
50
  "id": "47d0v",
55
51
  "created_at": "2015-05-28T05:42:03Z",
56
- "salt": "1ms1mq1nww7zl7169865gwqt89s9127m",
57
52
  "updated_at": "2015-05-28T05:42:03Z",
58
53
  "approval_status": "ACCEPTED",
59
54
  "deleted": false
@@ -6,7 +6,6 @@
6
6
  "timezone_switch_at": "2014-11-17T08:00:00Z",
7
7
  "id": "2iqph",
8
8
  "created_at": "2015-03-04T10:50:42Z",
9
- "salt": "5ab2pizq7qxjjqrx3z67f4wbko61o7xs",
10
9
  "updated_at": "2015-04-11T05:20:08Z",
11
10
  "approval_status": "ACCEPTED",
12
11
  "deleted": false