Class: Adzerk::Publisher

Inherits:
ApiEndpoint show all
Defined in:
lib/adzerk/publisher.rb

Instance Attribute Summary

Attributes inherited from ApiEndpoint

#client, #datakey, #endpoint, #subendpoint

Instance Method Summary collapse

Methods inherited from ApiEndpoint

#delete, #get, #initialize, #list

Methods included from Util

#camelize_data, #parse_response, #uncamelize_data

Constructor Details

This class inherits a constructor from Adzerk::ApiEndpoint

Instance Method Details

#create(opts = {}, subid = nil) ⇒ Object



16
17
18
19
20
21
# File 'lib/adzerk/publisher.rb', line 16

def create(opts={}, subid=nil)
  e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint
  data = { datakey => camelize_data(opts).to_json }
  response = @client.post_request(e, data)
  parse_response(response)
end

#earnings(data = {}) ⇒ Object



4
5
6
7
8
# File 'lib/adzerk/publisher.rb', line 4

def earnings(data={})
  data = { 'earnings' => camelize_data(data).to_json }
  response = @client.post_request('/earnings', data)
  parse_response(response)
end

#payments(data = {}) ⇒ Object



10
11
12
13
14
# File 'lib/adzerk/publisher.rb', line 10

def payments(data={})
  data = { 'payments' => camelize_data(data).to_json }
  response = @client.post_request('/payments', data)
  parse_response(response)
end

#update(opts = {}) ⇒ Object



23
24
25
26
27
28
# File 'lib/adzerk/publisher.rb', line 23

def update(opts={})
  id = opts[:id].to_s
  data = { datakey => camelize_data(opts).to_json }
  response = @client.put_request("#{endpoint}/#{id}", data)
  parse_response(response)
end