class TwitterAds::TargetingCriteria

Constants

RESOURCE
RESOURCE_BATCH
RESOURCE_COLLECTION

Attributes

account[R]

Public Class Methods

all(account, line_item_ids, opts = {}) click to toggle source

Returns a Cursor instance for a given resource.

@param account [Account] The Account object instance. @param line_item_ids [String] A String or String array of Line Item IDs. @param opts [Hash] An optional Hash of extended options. @option opts [Boolean] :with_deleted Indicates if deleted items should be included. @option opts [String] :sort_by The object param to sort the API response by.

@return [Cursor] A Cusor object ready to iterate through the API response.

@since 0.3.1 @see Cursor @see dev.twitter.com/ads/basics/sorting Sorting

# File lib/twitter-ads/campaign/targeting_criteria.rb, line 58
def all(account, line_item_ids, opts = {})
  params = { line_item_ids: Array(line_item_ids).join(',') }.merge!(opts)
  resource = RESOURCE_COLLECTION % { account_id: account.id }
  request = Request.new(account.client, :get, resource, params: params)
  Cursor.new(self, request, init_with: [account])
end
load(account, id, opts = {}) click to toggle source

Returns an object instance for a given resource.

@param account [Account] The Account object instance. @param id [String] The ID of the specific object to be loaded. @param opts [Hash] An optional Hash of extended options. @option opts [Boolean] :with_deleted Indicates if deleted items should be included. @option opts [String] :sort_by The object param to sort the API response by.

@return [self] The object instance for the specified resource.

@since 0.3.1

# File lib/twitter-ads/campaign/targeting_criteria.rb, line 76
def load(account, id, opts = {})
  params   = { with_deleted: true }.merge!(opts)
  resource = RESOURCE % { account_id: account.id, id: id }
  response = Request.new(account.client, :get, resource, params: params).perform
  new(account).from_response(response.body[:data])
end
new(account) click to toggle source
# File lib/twitter-ads/campaign/targeting_criteria.rb, line 38
def initialize(account)
  @account = account
  self
end