Class: TheTradeDeskAds::AdPartner

Inherits:
Base
  • Object
show all
Defined in:
lib/the_trade_desk_ads/ad_partner.rb

Overview

An ad belongs to an ad set. It is created using an ad creative. developers.facebook.com/docs/marketing-api/reference/adgroup

Constant Summary collapse

FIELDS =
%w[PartnerId].freeze
SORTING_FIELDS =

Sorting Formats: name, display name

{"Name": "Name"}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

auth, delete, #destroy, get, paginate, post, #save, #update

Class Method Details

.facets(query = {}) ⇒ Object



12
13
14
# File 'lib/the_trade_desk_ads/ad_partner.rb', line 12

def facets(query = {})
  get('partner/query/facets', query: query, objectify: false)
end

.find(id) ⇒ Object

Not implemented in API

Raises:

  • (Exception)


17
18
19
# File 'lib/the_trade_desk_ads/ad_partner.rb', line 17

def find(id)
  raise Exception, "Not implemented in TheTradeDesk API"
end

Instance Method Details

#advertisers(availabilities: ['Available','Archived'], search_terms: nil, sort_fields: nil, page_start_index: 0, page_size: 10) ⇒ Object

has_many advertisers partner = TheTradeDeskAds::AdPartner.new(PartnerId: “ux50sgw”) partner_advertisers = partner.advertisers

Raises:

  • (Exception)


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/the_trade_desk_ads/ad_partner.rb', line 30

def advertisers(availabilities: ['Available','Archived'], search_terms: nil, sort_fields: nil, page_start_index: 0, page_size: 10)
  raise Exception, "Partner ID must be specified" unless self.PartnerId
  raise Exception, "Availabilities must be one of: #{TheTradeDeskAds::AdAdvertiser::AVAILABILITIES.join(', ')}" unless (availabilities - TheTradeDeskAds::AdAdvertiser::AVAILABILITIES).empty?
  query = { "PartnerId": self.PartnerId,
            "Availabilities": availabilities,
            "SearchTerms": search_terms,
            "SortFields": sort_fields,
            "PageStartIndex": page_start_index,
            "PageSize": page_size
           }
  query.delete_if { |_k, v| v.nil? }
  AdPartner.post('advertiser/query/partner', query: query, objectify: true)
end