Class: Adzerk::ApiEndpoint
- Inherits:
-
Object
- Object
- Adzerk::ApiEndpoint
- Includes:
- Util
- Defined in:
- lib/adzerk/api_endpoint.rb
Direct Known Subclasses
Advertiser, Campaign, Channel, Creative, DayParting, DistanceTargeting, Flight, Priority, Publisher, ScheduledReporting, Site
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#datakey ⇒ Object
readonly
Returns the value of attribute datakey.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#subendpoint ⇒ Object
readonly
Returns the value of attribute subendpoint.
Instance Method Summary collapse
- #create(opts = {}, subid = nil) ⇒ Object
- #delete(id, subid = nil) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(args = {}) ⇒ ApiEndpoint
constructor
A new instance of ApiEndpoint.
- #list(subid = nil, page: 1, pageSize: 500) ⇒ Object
- #update(opts = {}) ⇒ Object
Methods included from Util
#camelize_data, #parse_response, #uncamelize_data
Constructor Details
#initialize(args = {}) ⇒ ApiEndpoint
Returns a new instance of ApiEndpoint.
8 9 10 11 12 13 |
# File 'lib/adzerk/api_endpoint.rb', line 8 def initialize(args= {}) @client = args[:client] @endpoint = args[:endpoint] @subendpoint = args[:subendpoint] @datakey = args[:datakey] ? args[:datakey] : args[:endpoint] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/adzerk/api_endpoint.rb', line 6 def client @client end |
#datakey ⇒ Object (readonly)
Returns the value of attribute datakey.
6 7 8 |
# File 'lib/adzerk/api_endpoint.rb', line 6 def datakey @datakey end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/adzerk/api_endpoint.rb', line 6 def endpoint @endpoint end |
#subendpoint ⇒ Object (readonly)
Returns the value of attribute subendpoint.
6 7 8 |
# File 'lib/adzerk/api_endpoint.rb', line 6 def subendpoint @subendpoint end |
Instance Method Details
#create(opts = {}, subid = nil) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/adzerk/api_endpoint.rb', line 15 def create(opts={}, subid=nil) e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint data = camelize_data(opts) response = @client.post_json_request(e, data) parse_response(response) end |
#delete(id, subid = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/adzerk/api_endpoint.rb', line 41 def delete(id, subid=nil) e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint url = "#{e}/#{id}/delete" @client.get_request(url) end |
#get(id) ⇒ Object
22 23 24 25 |
# File 'lib/adzerk/api_endpoint.rb', line 22 def get(id) response = @client.get_request("#{endpoint}/#{id}") parse_response(response) end |
#list(subid = nil, page: 1, pageSize: 500) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/adzerk/api_endpoint.rb', line 27 def list(subid=nil, page: 1, pageSize: 500) e = (subid && subendpoint) ? "#{subendpoint}/#{subid}/#{endpoint}" : endpoint e = "#{e}?page=#{page}&pageSize=#{pageSize}" response = @client.get_request(e) parse_response(response) end |
#update(opts = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/adzerk/api_endpoint.rb', line 34 def update(opts={}) id = opts[:id].to_s data = camelize_data(opts) response = @client.put_json_request("#{endpoint}/#{id}", data) parse_response(response) end |