Class: Adzerk::ApiEndpoint
- Inherits:
-
Object
- Object
- Adzerk::ApiEndpoint
show all
- Includes:
- Util
- Defined in:
- lib/adzerk/api_endpoint.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
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
|
# File 'lib/adzerk/api_endpoint.rb', line 8
def initialize(args= {})
@client = args[:client]
@endpoint = args[:endpoint]
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6
7
8
|
# File 'lib/adzerk/api_endpoint.rb', line 6
def client
@client
end
|
#endpoint ⇒ Object
Returns the value of attribute endpoint.
6
7
8
|
# File 'lib/adzerk/api_endpoint.rb', line 6
def endpoint
@endpoint
end
|
Instance Method Details
#create(opts = {}) ⇒ Object
13
14
15
16
17
|
# File 'lib/adzerk/api_endpoint.rb', line 13
def create(opts={})
data = { endpoint => camelize_data(opts).to_json }
response = @client.post_request(endpoint, data)
parse_response(response)
end
|
#delete(id) ⇒ Object
36
37
38
39
|
# File 'lib/adzerk/api_endpoint.rb', line 36
def delete(id)
url = "#{endpoint}/#{id}/delete"
@client.get_request(url)
end
|
#get(id) ⇒ Object
19
20
21
22
|
# File 'lib/adzerk/api_endpoint.rb', line 19
def get(id)
response = @client.get_request("#{endpoint}/#{id}")
parse_response(response)
end
|
#list ⇒ Object
24
25
26
27
|
# File 'lib/adzerk/api_endpoint.rb', line 24
def list
response = @client.get_request(endpoint)
parse_response(response)
end
|
#update(opts = {}) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/adzerk/api_endpoint.rb', line 29
def update(opts={})
id = opts[:id].to_s
data = { endpoint => camelize_data(opts).to_json }
response = @client.put_request("#{endpoint}/#{id}", data)
parse_response(response)
end
|