Sha256: f9a8d3aebf05d369dbef649b55c9c9b97c3dc77ef3a8225ddbc21af1debcfccd

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

module TheTradeDeskAds
  # An ad belongs to an ad set. It is created using an ad creative.
  # https://developers.facebook.com/docs/marketing-api/reference/adgroup
  class AdPartner < Base
    FIELDS   = %w[PartnerId].freeze
    # Sorting Formats: name, display name
    SORTING_FIELDS = {"Name": "Name"}

    # facets = TheTradeDeskAds::AdPartner.facets

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

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





    # has_many advertisers
    # partner = TheTradeDeskAds::AdPartner.new(PartnerId: "ux50sgw")
    # partner_advertisers = partner.advertisers

    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
the_trade_desk_ads-0.0.1 lib/the_trade_desk_ads/ad_partner.rb