class ZanoxPublisher::ProgramApplication
Program
Applications
Apply to advertiser programs, get your applications, end partnerships.
@attr [Integer] id The programApplicationItems's identifer from Zanox @attr [Program] program The program for which the application is made @attr [AdSpace] adspace The ad space for which the application is made @attr [String] status The status of the application @attr [DateTime] created_at
The date on which the application was created at @attr [Boolean] allow_tpv
States if the application allows for tpv tracking links @attr [DateTime] approved_date
The date on which the application was approved @attr [String] publisher_comment
The publishers' comment on the application @attr [String] advertiser_comment
The advertisers' comment on the application
Constants
- PROGRAM_APPLICATION_STATUS_ENUM
- RESOURCE_PATH
Attributes
Public Class Methods
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 {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.
@param program [Program, Integer] Limits results to a particular program. @param adspace [AdSpace, Integer] Limits results to incentives that have tracking links associated with this ad space. @param status [String] Restrict results to program applications with certain status.
@return [Array<ProgramApplication>]
# File lib/zanox_publisher/program_application.rb, line 39 def all(options = {}) retval = [] current_page = 0 options.merge!({ per_page: maximum_per_page }) loop do response = self.page(current_page, options) # This break is required as some give 0 elements, but set total value break if response.nil? or response.empty? retval += response # This is the normal break when all pages have been processed break unless ProgramApplication.total > retval.size current_page += 1 end retval end
A connection instance with Program
Applications' relative_path
@return [Connection]
# File lib/zanox_publisher/program_application.rb, line 115 def connection @connection ||= Connection.new(RESOURCE_PATH) end
TODO: {developer.zanox.com/web/guest/publisher-api-2011/post-programapplications-program-adspace} TODO: {developer.zanox.com/web/guest/publisher-api-2011/delete-programapplications-program-adspace}
# File lib/zanox_publisher/program_application.rb, line 122 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
Returns a list of programApplicationItems
This is equivalent to the Zanox API method GetProgramApplications. The method documentation can be found under {developer.zanox.com/web/guest/publisher-api-2011/get-programapplications}.
Authentication: Requires signature.
@param page [Integer] the page position @param per_page [Integer] number of items in the result set (API equivalent is items) @param items [Integer] number of items in the result set (API name) @param program [Program, Integer] Limits results to a particular program. @param adspace [AdSpace, Integer] Limits results to incentives that have tracking links associated with this ad space. @param status [String] Restrict results to program applications with certain status.
@return [Array<ProgramApplication>]
# File lib/zanox_publisher/program_application.rb, line 76 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