Module: Madmen::Google
- Defined in:
- lib/madmen/google.rb,
lib/madmen/google/ad.rb,
lib/madmen/google/keyword.rb,
lib/madmen/google/ad_group.rb,
lib/madmen/google/campaign.rb
Overview
Defined Under Namespace
Classes: Ad, AdGroup, Campaign, Keyword
Constant Summary
collapse
- CLIENT =
Constants ====================================================================================
AdWords::API.new(AdWords::AdWordsCredentials.new(credentials))
Class Method Summary
collapse
Class Method Details
.ad_group_ad_service ⇒ Object
Services =====================================================================================
28
29
30
|
# File 'lib/madmen/google.rb', line 28
def self.ad_group_ad_service
@ad_group_ad_service ||= CLIENT.get_service('AdGroupAd', latest)
end
|
.ad_group_criterion_service ⇒ Object
32
33
34
|
# File 'lib/madmen/google.rb', line 32
def self.ad_group_criterion_service
@ad_group_criterion_service ||= CLIENT.get_service('AdGroupCriterion', latest)
end
|
.ad_group_service ⇒ Object
36
37
38
|
# File 'lib/madmen/google.rb', line 36
def self.ad_group_service
@ad_group_service ||= CLIENT.get_service('AdGroup', latest)
end
|
.call_service(service, method, args) ⇒ Object
Utility Methods ==============================================================================
.campaign_service ⇒ Object
40
41
42
|
# File 'lib/madmen/google.rb', line 40
def self.campaign_service
@campaign_service ||= CLIENT.get_service('Campaign', latest)
end
|
.campaign_target_service ⇒ Object
44
45
46
|
# File 'lib/madmen/google.rb', line 44
def self.campaign_target_service
@campaign_target_service ||= CLIENT.get_service('CampaignTarget', latest)
end
|
.credentials ⇒ Object
Credentials ==================================================================================
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/madmen/google.rb', line 14
def self.credentials
{
'developerToken' => PpcLogic.adwords_developer_token,
'useragent' => "SEO Logic",
'password' => PpcLogic.adwords_password,
'email' => PpcLogic.adwords_email,
'clientEmail' => PpcLogic.adwords_client_email,
'applicationToken' => PpcLogic.adwords_application_token
}
end
|
.latest ⇒ Object
48
49
50
|
# File 'lib/madmen/google.rb', line 48
def self.latest
@latest ||= AdWords::Service.latest_version
end
|
.report_api_usage ⇒ Object
71
72
73
|
# File 'lib/madmen/google.rb', line 71
def self.report_api_usage
Rails.logger.info 'MADMEN: %d API units consumed total (%d in last call).' % [CLIENT.total_units, CLIENT.last_units]
end
|
.rescue_from_api_error(error) ⇒ Object
75
76
77
78
79
|
# File 'lib/madmen/google.rb', line 75
def self.rescue_from_api_error(error)
Rails.logger.info 'MADMEN: SOAP Error: %s (code: %d)' % [error.soap_faultstring_ex, error.code_ex]
Rails.logger.info 'MADMEN: Trigger: %s' % error.trigger_ex unless error.trigger_ex.nil?
Rails.logger.info 'MADMEN: Source: %s' % error.backtrace.first
end
|
.rescue_from_connnection_error(error) ⇒ Object
81
82
83
84
|
# File 'lib/madmen/google.rb', line 81
def self.rescue_from_connnection_error(error)
Rails.logger.info "MADMEN: #{error}"
Rails.logger.info 'MADMEN: Source: %s' % error.backtrace.first
end
|
.rescue_from_unknown_api_call(error) ⇒ Object
86
87
88
89
|
# File 'lib/madmen/google.rb', line 86
def self.rescue_from_unknown_api_call(error)
Rails.logger.info "MADMEN: #{error}"
Rails.logger.info 'MADMEN: Source: %s' % error.backtrace.first
end
|