Class: Zanox::AdSpace

Inherits:
Item
  • Object
show all
Defined in:
lib/zanox/resources/adspace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hashable

#to_hash

Constructor Details

#initialize(data) ⇒ AdSpace

  • pid (Integer) AdSpace ID

  • name (String) The name of the adspace

  • url (String) The URL to the adspace

  • description (String) The description of the adspace

  • type (String) The type of the adspace (website, email, searchengine)

  • visitors (Integer) How many visitors Zanox tracked for you

  • impressions (Integer) The number of impressions of the adspace

  • scope (String) The scope of the adspace (private, bussiness)

  • regions (String[]) The regions where the adspace works

  • categories (String[]) The categories of the adspace

  • language (String) The language used inside the adspace

  • check_number (Integer)



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/zanox/resources/adspace.rb', line 44

def initialize(data)
  @pid           = data['@id'].to_i
  @name          = data['name']
  @url           = data['url']
  @description   = data['description']
  @type          = data['adspaceType']
  @visitors      = data['visitors'].to_i
  @impressions   = data['impressions'].to_i
  @scope         = data['scope']
  @regions       = [data['regions'].try { |r| r.map(&:values) }].flatten.compact
  @categories     = [].tap do |categories|
    categories_ = data['categories'].try { |p| p[0]['category'] }
    data['categories'].try { |p| p[0]['category'] }.each do |category|
      categories << {
        id:   category[0],
        name: category[1],
      }
    end
  end
  @language      = data['language']
  @check_number  = data['checkNumber']
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def categories
  @categories
end

#check_numberObject (readonly)

Returns the value of attribute check_number.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def check_number
  @check_number
end

#descriptionObject (readonly)

Returns the value of attribute description.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def description
  @description
end

#impressionsObject (readonly)

Returns the value of attribute impressions.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def impressions
  @impressions
end

#languageObject (readonly)

Returns the value of attribute language.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def pid
  @pid
end

#regionsObject (readonly)

Returns the value of attribute regions.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def regions
  @regions
end

#scopeObject (readonly)

Returns the value of attribute scope.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def scope
  @scope
end

#typeObject (readonly)

Returns the value of attribute type.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def url
  @url
end

#visitorsObject (readonly)

Returns the value of attribute visitors.



27
28
29
# File 'lib/zanox/resources/adspace.rb', line 27

def visitors
  @visitors
end

Class Method Details

.find(args = {}) ⇒ Object



68
69
70
71
# File 'lib/zanox/resources/adspace.rb', line 68

def find(args = {})
  response = API.request(:adspaces, args)
  response.adspace_items.map { |adspace| new(adspace) }
end