Class: Zanox::TrackingCategory

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hashable

#to_hash

Constructor Details

#initialize(data) ⇒ TrackingCategory

  • pid (Integer) AdSpace ID

  • name (String) The name of the tracking category

  • program (Hash) The program in input

  • adspace (Hash) The adspace in input

  • transaction_type (String) The type of the transaction (leads, sales)

  • sale_fixed (Float) The fixed value of the sale

  • sale_percent (Float) The percent value of the sale


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zanox/resources/tracking_category.rb', line 38

def initialize(data)
  @pid           = data['@id'].to_i
  @name          = data['name']
  @program       = {
    id:   data['program']['@id'].to_i,
    name: data['program']['$']
  }
  @adspace        = {
    id:   data['adspace']['@id'].to_i,
    name: data['adspace']['$']
  }
  @transaction_type = data['transactionType']
  @sale_fixed       = data['saleFixed']
  @sale_percent     = data['salePercent']
end

Instance Attribute Details

#adspaceObject (readonly)

Returns the value of attribute adspace.


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

def adspace
  @adspace
end

#nameObject (readonly)

Returns the value of attribute name.


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

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.


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

def pid
  @pid
end

#programObject (readonly)

Returns the value of attribute program.


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

def program
  @program
end

#sale_fixedObject (readonly)

Returns the value of attribute sale_fixed.


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

def sale_fixed
  @sale_fixed
end

#sale_percentObject (readonly)

Returns the value of attribute sale_percent.


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

def sale_percent
  @sale_percent
end

#transaction_typeObject (readonly)

Returns the value of attribute transaction_type.


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

def transaction_type
  @transaction_type
end

Class Method Details

.find(program_id, adspace_id) ⇒ Object


55
56
57
58
# File 'lib/zanox/resources/tracking_category.rb', line 55

def find(program_id, adspace_id)
  response = API.request("programapplications/program/#{program_id}/adspace/#{adspace_id}/trackingcategories")
  [response.tracking_category_item].flatten.map { |tracking_category| new(tracking_category) }
end