Class: Adapi::AdGroupCriterion

Inherits:
Api
  • Object
show all
Defined in:
lib/adapi/ad_group_criterion.rb

Overview

Direct Known Subclasses

Keyword

Constant Summary collapse

ATTRIBUTES =
[ :ad_group_id, :criterion_use ]

Constants inherited from Api

Adapi::Api::API_EXCEPTIONS, Adapi::Api::LOGGER

Instance Attribute Summary

Attributes inherited from Api

#adwords, #id, #params, #service, #status, #version, #xsi_type

Instance Method Summary collapse

Methods inherited from Api

#[], #[]=, #check_for_errors, create, #mutate, #new?, #persisted?, #store_errors, to_micro_units, #to_param, update

Constructor Details

#initialize(params = {}) ⇒ AdGroupCriterion

Returns a new instance of AdGroupCriterion.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/adapi/ad_group_criterion.rb', line 18

def initialize(params = {})
  params[:service_name] = :AdGroupCriterionService

  @xsi_type = 'AdGroupCriterion'

  ATTRIBUTES.each do |param_name|
    self.send "#{param_name}=", params[param_name]
  end

  super(params)
end

Instance Method Details

#attributesObject

FIXME why we don’t use :criterion_use parameter here?



14
15
16
# File 'lib/adapi/ad_group_criterion.rb', line 14

def attributes
  super.merge( ad_group_id: ad_group_id )
end

#delete(criterion_id) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/adapi/ad_group_criterion.rb', line 30

def delete(criterion_id)
  response = self.mutate(
    :operator => 'REMOVE',
    :operand => {
      :ad_group_id => self.ad_group_id,
      :criterion => { :id => criterion_id.to_i }
    }
  )

  (response and response[:value])
end