class TwitterAds::Client

Attributes

access_token[R]
config[R]
ops[R]

Public Class Methods

new(params) click to toggle source
# File lib/twitter_ads/client.rb, line 15
def initialize(params)
  @config = params
  @ops = { get: [:bidding_rules, :iab_categories] }
  @attributes={}
  consumer = OAuth::Consumer.new(params[:consumer_key], params[:consumer_secret], site: "https://#{ADS_API_ENDPOINT}")
  consumer.http.use_ssl = true
  consumer.http.set_debug_output(STDERR)
  consumer.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  @client = self # To manage rest resource
  @access_token = OAuth::AccessToken.new(consumer, params[:access_token], params[:access_secret])
end

Public Instance Methods

account(account_id) click to toggle source

Create an account based on his id

# File lib/twitter_ads/client.rb, line 34
def account(account_id)
  TwitterAds::Account.new(self, {'id' => account_id})
end
accounts() click to toggle source

return the list of available accounts

# File lib/twitter_ads/client.rb, line 28
def accounts
  @cached_accounts = get('accounts').map { |account| Account.new(self, account) } unless @cached_accounts
  @cached_accounts
end