Class: Adapi::Ad
Overview
Ad == AdGroupAd wraps all types of ads: text ads, image ads…
Direct Known Subclasses
Defined Under Namespace
Classes: TextAd
Constant Summary
Constants inherited from Api
Adapi::Api::API_EXCEPTIONS, Adapi::Api::LOGGER
Instance Attribute Summary collapse
-
#ad_group_id ⇒ Object
REFACTOR attributes.
-
#approval_status ⇒ Object
REFACTOR attributes.
-
#disapproval_reasons ⇒ Object
REFACTOR attributes.
-
#display_url ⇒ Object
REFACTOR attributes.
-
#id ⇒ Object
REFACTOR attributes.
-
#trademark_disapproved ⇒ Object
REFACTOR attributes.
-
#url ⇒ Object
REFACTOR attributes.
Attributes inherited from Api
#adwords, #params, #service, #status, #version, #xsi_type
Instance Method Summary collapse
-
#attributes ⇒ Object
PS: create won’t work with id and ad_group_id ‘id’ => id, ‘ad_group_id’ => ad_group_id,.
-
#delete(params = {}) ⇒ Object
FIXME add validations.
-
#destroy ⇒ Object
deletes ad TODO call by delete method.
-
#initialize(params = {}) ⇒ Ad
constructor
A new instance of Ad.
Methods inherited from Api
#[], #[]=, #check_for_errors, create, #mutate, #new?, #persisted?, #store_errors, to_micro_units, #to_param, update
Constructor Details
#initialize(params = {}) ⇒ Ad
Returns a new instance of Ad.
22 23 24 25 26 27 28 29 30 |
# File 'lib/adapi/ad.rb', line 22 def initialize(params = {}) params[:service_name] = :AdGroupAdService %w{ id ad_group_id url display_url status }.each do |param_name| self.send "#{param_name}=", params[param_name.to_sym] end super(params) end |
Instance Attribute Details
#ad_group_id ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def ad_group_id @ad_group_id end |
#approval_status ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def approval_status @approval_status end |
#disapproval_reasons ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def disapproval_reasons @disapproval_reasons end |
#display_url ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def display_url @display_url end |
#id ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def id @id end |
#trademark_disapproved ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def trademark_disapproved @trademark_disapproved end |
#url ⇒ Object
REFACTOR attributes
11 12 13 |
# File 'lib/adapi/ad.rb', line 11 def url @url end |
Instance Method Details
#attributes ⇒ Object
PS: create won’t work with id and ad_group_id ‘id’ => id, ‘ad_group_id’ => ad_group_id,
18 19 20 |
# File 'lib/adapi/ad.rb', line 18 def attributes super.merge( id: id, ad_group_id: ad_group_id, url: url, display_url: display_url ) end |
#delete(params = {}) ⇒ Object
FIXME add validations
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/adapi/ad.rb', line 48 def delete(params = {}) operations = params[:ad_ids].map do |ad_id| { :operator => 'REMOVE', :operand => { :ad_group_id => params[:ad_group_id], :ad => { :id => ad_id, :xsi_type => 'Ad' } } } end response = self.mutate(operations) (response and response[:value]) ? true : false end |
#destroy ⇒ Object
deletes ad TODO call by delete method
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/adapi/ad.rb', line 35 def destroy response = self.mutate( :operator => 'REMOVE', :operand => { :ad_group_id => @ad_group_id, :ad => { :id => @id, :xsi_type => 'Ad' } } ) (response and response[:value]) ? true : false end |