twitter-ads 5.1.0 → 5.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66b5f0101e9a3bb56a76274588cc25949cd5427a6993cf545934472013c019c1
4
- data.tar.gz: 74f5b1183e980d2793ba90af482b70fdfdd8c6b47dfbd80a99c0208c77f42289
3
+ metadata.gz: 3cd47b38d08667bf292088700123342cf46e6576a3cb9a315ae9011517f85db4
4
+ data.tar.gz: d8d0de8d946a946c483373d0a01cfbd716a0c43e2c48932e3dc77a091d4bdfeb
5
5
  SHA512:
6
- metadata.gz: 627d24d41572df3ecbd8078ab336da7008d3e9ffed57a3af1ac03d41c7c44014eee2d9da920b50505e2b24c866a80049825574cff377532c5146a5515857214b
7
- data.tar.gz: 03e79e1ce3c97d62a7bc9aae41b94bfd0709fc7899e4c248f403e652e6d7bd51c060d32466f392162ed5bd62853c61ff2e1ca4c39a2debe19cecef0fc80e218b
6
+ metadata.gz: 5e9298f7816c6a34f72d57ec64a36ca867bd226601486a41de01716283139ac3142788a7b4506567f097e143ebd39ff54bddd34db64bd84599815dd98a4a3a81
7
+ data.tar.gz: fb148af4796eaad730508ea7a4b3e63d5bcb36f56270e305707df52c36b96dbb485093bf2998684dcaaa8550e3a3ef8cf80294f1dee740ebc4c931b16d27b31d
@@ -256,9 +256,8 @@ module TwitterAds
256
256
  # @return [Array] An Array of Tweet objects.
257
257
  #
258
258
  # @since 0.2.3
259
- def scoped_timeline(ids, opts = {})
260
- ids = ids.join(',') if ids.is_a?(Array)
261
- params = { user_ids: ids }.merge!(opts)
259
+ def scoped_timeline(id, opts = {})
260
+ params = { user_id: id }.merge!(opts)
262
261
  resource = SCOPED_TIMELINE % { id: @id }
263
262
  request = Request.new(client, :get, resource, params: params)
264
263
  response = request.perform
@@ -29,9 +29,9 @@ module TwitterAds
29
29
  'accounts/%{account_id}/tailored_audiences' # @api private
30
30
  RESOURCE = "/#{TwitterAds::API_VERSION}/" \
31
31
  '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
35
35
 
36
36
  LIST_TYPES = %w(
37
37
  EMAIL
@@ -138,4 +138,99 @@ module TwitterAds
138
138
  end
139
139
 
140
140
  end
141
+
142
+ class TailoredAudiencePermission
143
+
144
+ include TwitterAds::DSL
145
+ include TwitterAds::Resource
146
+
147
+ attr_reader :account
148
+
149
+ # read-only
150
+ property :created_at, type: :time, read_only: true
151
+ property :updated_at, type: :time, read_only: true
152
+ property :deleted, type: :bool, read_only: true
153
+
154
+ property :id
155
+ property :tailored_audience_id
156
+ property :granted_account_id
157
+ property :permission_level
158
+
159
+ RESOURCE_COLLECTION = "/#{TwitterAds::API_VERSION}/" \
160
+ 'accounts/%{account_id}/tailored_audiences/' \
161
+ '%{tailored_audience_id}/permissions' # @api private
162
+ RESOURCE = "/#{TwitterAds::API_VERSION}/" \
163
+ 'accounts/%{account_id}/tailored_audiences/' \
164
+ '%{tailored_audience_id}/permissions/%{id}' # @api private
165
+
166
+ def initialize(account)
167
+ @account = account
168
+ self
169
+ end
170
+
171
+ class << self
172
+
173
+ # Retrieve details for some or
174
+ # all permissions associated with the specified tailored audience.
175
+ #
176
+ # @exapmle
177
+ # permissions = TailoredAudiencePermission.all(account, '36n4f')
178
+ #
179
+ # @param account [Account] The account object instance.
180
+ # @param tailored_audience_id [String] The tailored audience id.
181
+ #
182
+ # @since 5.2.0
183
+ #
184
+ # @return [TailoredAudiencePermission] The tailored audience permission instance.
185
+ def all(account, tailored_audience_id, opts = {})
186
+ params = {}.merge!(opts)
187
+ resource = RESOURCE_COLLECTION % {
188
+ account_id: account.id,
189
+ tailored_audience_id: tailored_audience_id
190
+ }
191
+ request = Request.new(account.client, :get, resource, params: params)
192
+ Cursor.new(self, request, init_with: [account])
193
+ end
194
+
195
+ end
196
+
197
+ # Saves or updates the current object instance
198
+ # depending on the presence of `object.tailored_audience_id`.
199
+ #
200
+ # @exapmle
201
+ # object.save
202
+ #
203
+ # @since 5.2.0
204
+ #
205
+ # @return [self] Returns the instance refreshed from the API.
206
+ def save
207
+ resource = RESOURCE_COLLECTION % {
208
+ account_id: account.id,
209
+ tailored_audience_id: tailored_audience_id
210
+ }
211
+ params = to_params
212
+ response = Request.new(account.client, :post, resource, params: params).perform
213
+ from_response(response.body[:data])
214
+ end
215
+
216
+ # Deletes the current or specified tailored audience permission.
217
+ #
218
+ # @example
219
+ # object.delete!
220
+ #
221
+ # Note: calls to this method are destructive and irreverisble.
222
+ #
223
+ # @since 5.2.0
224
+ #
225
+ # @return [self] Returns the instance refreshed from the API.
226
+ def delete!
227
+ resource = RESOURCE % {
228
+ account_id: account.id,
229
+ tailored_audience_id: tailored_audience_id,
230
+ id: @id
231
+ }
232
+ response = Request.new(account.client, :delete, resource).perform
233
+ from_response(response.body[:data])
234
+ end
235
+ end
141
236
  end
@@ -2,5 +2,5 @@
2
2
  # Copyright (C) 2019 Twitter, Inc.
3
3
 
4
4
  module TwitterAds
5
- VERSION = '5.1.0'
5
+ VERSION = '5.2.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-ads
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Babich
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2019-06-14 00:00:00.000000000 Z
15
+ date: 2019-06-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json