Class: ZanoxPublisher::ProgramApplication

Inherits:
Base
  • Object
show all
Defined in:
lib/zanox_publisher/program_application.rb

Overview

Program Applications

Apply to advertiser programs, get your applications, end partnerships.

Constant Summary collapse

RESOURCE_PATH =
'/programapplications'
PROGRAM_APPLICATION_STATUS_ENUM =
%w(open confirmed rejected deferred waiting blocked terminated canceled called declined deleted)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

maximum_per_page, per_page, per_page=, total, total=

Constructor Details

#initialize(data = {}) ⇒ ProgramApplication



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/zanox_publisher/program_application.rb', line 113

def initialize(data = {})
  @id                 = data.fetch('@id').to_i
  @program            = Program.new(data.fetch('program'))
  @adspace            = AdSpace.new(data.fetch('adspace'))
  @status             = data.fetch('status')
  @created_at         = data.fetch('createDate')
  @allow_tpv          = data.fetch('allowTpv')
  @approved_date      = data.fetch('approvedDate', nil)
  @publisher_comment  = data.fetch('publisherComment', nil)
  @advertiser_comment = data.fetch('advertiserComment', nil)
end

Instance Attribute Details

#adspaceAdSpace

The ad space for which the application is made

Returns:

  • (AdSpace)

    the current value of adspace



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def adspace
  @adspace
end

#advertiser_commentString Also known as: advertiserComment

The advertisers’ comment on the application

Returns:

  • (String)

    the current value of advertiser_comment



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def advertiser_comment
  @advertiser_comment
end

#allow_tpvBoolean Also known as: allowTpv

States if the application allows for tpv tracking links

Returns:

  • (Boolean)

    the current value of allow_tpv



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def allow_tpv
  @allow_tpv
end

#approved_dateDateTime Also known as: approvedDate

The date on which the application was approved

Returns:

  • (DateTime)

    the current value of approved_date



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def approved_date
  @approved_date
end

#created_atDateTime Also known as: createDate

The date on which the application was created at

Returns:

  • (DateTime)

    the current value of created_at



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def created_at
  @created_at
end

#idInteger

The programApplicationItems’s identifer from Zanox

Returns:

  • (Integer)

    the current value of id



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def id
  @id
end

#programProgram

The program for which the application is made

Returns:

  • (Program)

    the current value of program



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def program
  @program
end

#publisher_commentString Also known as: publisherComment

The publishers’ comment on the application

Returns:

  • (String)

    the current value of publisher_comment



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def publisher_comment
  @publisher_comment
end

#statusString

The status of the application

Returns:

  • (String)

    the current value of status



15
16
17
# File 'lib/zanox_publisher/program_application.rb', line 15

def status
  @status
end

Class Method Details

.all(options = {}) ⇒ Array<ProgramApplication>

Retrieves all program applications dependent on search parameters.

NOTE: Program applications are still returned even after the advertiser program has been paused discontinued. The attribute “active” in the “program” element, indicates whether the program is still active.

This is equivalent to the Zanox API method GetProgramApplications. The method documentation can be found under https://developer.zanox.com/web/guest/publisher-api-2011/get-programapplications.

Authentication: Requires signature.

This can require multiple requests, as internally every page is pulled. The ZanoxPublisher::ProgramApplication.page function can be used to better control the requests made.

Parameters:

  • program (Program, Integer)

    Limits results to a particular program.

  • adspace (AdSpace, Integer)

    Limits results to incentives that have tracking links associated with this ad space.

  • status (String)

    Restrict results to program applications with certain status.

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/zanox_publisher/program_application.rb', line 39

def all(options = {})
  retval = []
  current_page = 0
  options.merge!({ per_page: maximum_per_page })

  begin
    retval       += self.page(current_page, options)
    current_page += 1
  end while ProgramApplication.total > retval.size

  retval
end

.connectionConnection

A connection instance with Program Applications’ relative_path

Returns:



106
107
108
# File 'lib/zanox_publisher/program_application.rb', line 106

def connection
  @connection ||= Connection.new(RESOURCE_PATH)
end

.page(page = 0, options = {}) ⇒ Array<ProgramApplication>

Returns a list of programApplicationItems

This is equivalent to the Zanox API method GetProgramApplications. The method documentation can be found under https://developer.zanox.com/web/guest/publisher-api-2011/get-programapplications.

Authentication: Requires signature.

Parameters:

  • page (Integer) (defaults to: 0)

    the page position

  • per_page (Integer)

    number of items in the result set (API equivalent is items)

  • items (Integer)

    number of items in the result set (API name)

  • program (Program, Integer)

    Limits results to a particular program.

  • adspace (AdSpace, Integer)

    Limits results to incentives that have tracking links associated with this ad space.

  • status (String)

    Restrict results to program applications with certain status.

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/zanox_publisher/program_application.rb', line 67

def page(page = 0, options = {})
  params = { query: { page: page } }

  per_page = nil
  per_page = options[:per_page] if per_page.nil?
  per_page = options[:items]    if per_page.nil?
  per_page = Program.per_page   if per_page.nil?
  params[:query].merge!({ items: per_page })

  program = options[:program]
  program = program.to_i      unless program.nil?

  adspace = options[:adspace]
  adspace = adspace.to_i      unless adspace.nil?

  status  = options[:status]
  status  = nil               unless PROGRAM_APPLICATION_STATUS_ENUM.include? status

  params[:query].merge!({ program: program })  unless program.nil?
  params[:query].merge!({ adspace: adspace })  unless adspace.nil?
  params[:query].merge!({ status:  status  })  unless status.nil?

  retval = []

  response = self.connection.signature_get(RESOURCE_PATH, params)

  ProgramApplication.total = response.fetch('total')
  program_applications = response.fetch('programApplicationItems', {}).fetch('programApplicationItem', [])

  program_applications.each do |application|
    retval << ProgramApplication.new(application)
  end

  retval
end