Class: GatherContent::Api::Base
- Inherits:
-
Object
- Object
- GatherContent::Api::Base
show all
- Defined in:
- lib/gather_content/api/base.rb
Direct Known Subclasses
Account, Accounts, File, Files, Item, Items, Me, Project, Projects, Status, Statuses, Template, Templates
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
5
6
7
|
# File 'lib/gather_content/api/base.rb', line 5
def initialize
raise RuntimeError, "Cannot initialize this interface!"
end
|
Instance Method Details
#fetch ⇒ Object
32
33
34
|
# File 'lib/gather_content/api/base.rb', line 32
def fetch
@data ||= parse(get.body)
end
|
#get(path_override = nil) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/gather_content/api/base.rb', line 9
def get(path_override = nil)
connection.get do |request|
request.url(path_override || path)
request.params = params unless params.nil?
request.['Accept'] = "application/vnd.gathercontent.v0.5+json"
end
end
|
#post(data = {}, path_override = nil) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/gather_content/api/base.rb', line 17
def post(data = {}, path_override = nil)
connection.post do |request|
request.url(path_override || path)
request.body = data
request.['Accept'] = "application/vnd.gathercontent.v0.5+json"
yield request if block_given?
end
end
|
#post_json(data = {}, path_override = nil) ⇒ Object
26
27
28
29
30
|
# File 'lib/gather_content/api/base.rb', line 26
def post_json(data = {}, path_override = nil)
post(data.to_json, path_override) do |request|
request.['Content-type'] = "application/json"
end
end
|
#reset ⇒ Object
36
37
38
|
# File 'lib/gather_content/api/base.rb', line 36
def reset
@data = nil
end
|