Class: ZanoxPublisher::ProgramApplication
- 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
-
#adspace ⇒ AdSpace
The ad space for which the application is made.
-
#advertiser_comment ⇒ String
(also: #advertiserComment)
The advertisers’ comment on the application.
-
#allow_tpv ⇒ Boolean
(also: #allowTpv)
States if the application allows for tpv tracking links.
-
#approved_date ⇒ DateTime
(also: #approvedDate)
The date on which the application was approved.
-
#created_at ⇒ DateTime
(also: #createDate)
The date on which the application was created at.
-
#id ⇒ Integer
The programApplicationItems’s identifer from Zanox.
-
#program ⇒ Program
The program for which the application is made.
-
#publisher_comment ⇒ String
(also: #publisherComment)
The publishers’ comment on the application.
-
#status ⇒ String
The status of the application.
Class Method Summary collapse
-
.all(options = {}) ⇒ Array<ProgramApplication>
Retrieves all program applications dependent on search parameters.
-
.connection ⇒ Connection
A connection instance with Program Applications’ relative_path.
-
.page(page = 0, options = {}) ⇒ Array<ProgramApplication>
Returns a list of programApplicationItems.
Instance Method Summary collapse
- #initialize(data = {}) ⇒ ProgramApplication constructor
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
#adspace ⇒ AdSpace
The ad space for which the application is made
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def adspace @adspace end |
#advertiser_comment ⇒ String Also known as: advertiserComment
The advertisers’ comment on the application
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def advertiser_comment @advertiser_comment end |
#allow_tpv ⇒ Boolean Also known as: allowTpv
States if the application allows for tpv tracking links
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def allow_tpv @allow_tpv end |
#approved_date ⇒ DateTime Also known as: approvedDate
The date on which the application was approved
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def approved_date @approved_date end |
#created_at ⇒ DateTime Also known as: createDate
The date on which the application was created at
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def created_at @created_at end |
#id ⇒ Integer
The programApplicationItems’s identifer from Zanox
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def id @id end |
#program ⇒ Program
The program for which the application is made
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def program @program end |
#publisher_comment ⇒ String Also known as: publisherComment
The publishers’ comment on the application
15 16 17 |
# File 'lib/zanox_publisher/program_application.rb', line 15 def publisher_comment @publisher_comment end |
#status ⇒ String
The status of the application
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.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zanox_publisher/program_application.rb', line 39 def all( = {}) retval = [] current_page = 0 .merge!({ per_page: maximum_per_page }) begin retval += self.page(current_page, ) current_page += 1 end while ProgramApplication.total > retval.size retval end |
.connection ⇒ Connection
A connection instance with Program Applications’ relative_path
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.
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, = {}) params = { query: { page: page } } per_page = nil per_page = [:per_page] if per_page.nil? per_page = [:items] if per_page.nil? per_page = Program.per_page if per_page.nil? params[:query].merge!({ items: per_page }) program = [:program] program = program.to_i unless program.nil? adspace = [:adspace] adspace = adspace.to_i unless adspace.nil? status = [: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 |