module YahooGeminiClient

Constants

VERSION

Public Class Methods

new(*args) click to toggle source
# File lib/yahoo_gemini_client.rb, line 35
def self.new(*args)
  Client.new(*args)
end

Public Instance Methods

ad_groups() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 85
def ad_groups
  AdGroups.new(client: self)
end
advertisers() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 65
def advertisers
  Advertisers.new(client: self)
end
api_request_headers() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 54
def api_request_headers
  {
    "Authorization" => "Bearer #{token.token}",
    "User-Agent" => user_agent,
  }
end
authorization_url() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 27
def authorization_url
  oauth2_client.auth_code.authorize_url(
    :redirect_uri => "oob",
    :response_type => "code",
    :language => "en-us",
  )
end
campaigns() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 69
def campaigns
  Campaigns.new(client: self)
end
custom_report() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 73
def custom_report
  CustomReport.new(client: self)
end
encoded_creds() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 35
def encoded_creds
  Base64.encode64("#{consumer_key}:#{consumer_secret}").gsub(/\n/,"").strip
end
get_token(authorization_code) click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 39
def get_token(authorization_code)
  self.token = oauth2_client.auth_code.get_token(authorization_code, {
    :redirect_uri => 'oob',
    :headers => oauth2_headers,
  })
end
oauth2_headers() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 46
def oauth2_headers
  {
    'Authorization' => "Basic #{encoded_creds}",
    'Content-Type' => 'application/x-www-form-urlencoded',
    'User-Agent' => user_agent,
  }
end
token_refresh!() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 77
def token_refresh!
  # TODO: handle when there's no token
  self.token = self.token.refresh!({
    :redirect_uri => 'oob',
    :headers => oauth2_headers
  })
end
user_agent() click to toggle source
# File lib/yahoo_gemini_client/client.rb, line 61
def user_agent
  @user_agent ||= "YahooGeminiClientRubyGem/#{YahooGeminiClient::VERSION}"
end