module TwitterAds::AudienceSummary

Constants

RESOURCE

Public Class Methods

fetch(account, params) click to toggle source

Get an audience summary for the specified targeting criteria.

@example

TwitterAds::AudienceSummary.fetch(
  account,
  params: {targeting_criteria:[{targeting_type:'LOCATION',
          targeting_value:'96683cc9126741d1'}]}
)

@param params [Hash] A hash of input targeting criteria values

@return [Hash] A hash containing the min and max audience size.

@since 7.0.0 @see developer.twitter.com/en/docs/ads/campaign-management/api-reference/audience-summary

# File lib/twitter-ads/targeting/audience_summary.rb, line 32
def fetch(account, params)
  resource = RESOURCE % { account_id: account.id }
  headers = { 'Content-Type' => 'application/json' }

  response = TwitterAds::Request.new(account.client,
                                     :post,
                                     resource,
                                     headers: headers,
                                     body: params.to_json).perform
  response.body[:data]
end