Class: Crowi::Client

Inherits:
Object
  • Object
show all
Includes:
ApiMethods
Defined in:
lib/crowi/client.rb

Instance Method Summary collapse

Methods included from ApiMethods

#add_attachment, #add_comment, #attachments, #comments, #create_page, #page, #pages, #update_page

Constructor Details

#initialize(base_url: nil, access_token: nil) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/crowi/client.rb', line 8

def initialize(base_url: nil, access_token: nil)
  @base_url = base_url
  @access_token = access_token
end

Instance Method Details

#delete(path, params = nil, headers = nil) ⇒ Object



29
30
31
# File 'lib/crowi/client.rb', line 29

def delete(path, params = nil, headers = nil)
  send_request(:delete, path, params, headers)
end

#get(path, params = nil, headers = nil) ⇒ Object



13
14
15
# File 'lib/crowi/client.rb', line 13

def get(path, params = nil, headers = nil)
  send_request(:get, path, params, headers)
end

#patch(path, params = nil, headers = nil) ⇒ Object



25
26
27
# File 'lib/crowi/client.rb', line 25

def patch(path, params = nil, headers = nil)
  send_request(:patch, path, params, headers)
end

#post(path, params = nil, headers = nil) ⇒ Object



17
18
19
# File 'lib/crowi/client.rb', line 17

def post(path, params = nil, headers = nil)
  send_request(:post, path, params, headers)
end

#put(path, params = nil, headers = nil) ⇒ Object



21
22
23
# File 'lib/crowi/client.rb', line 21

def put(path, params = nil, headers = nil)
  send_request(:put, path, params, headers)
end

#send_request(method, path, params = {}, headers = nil) ⇒ Object



33
34
35
36
37
# File 'lib/crowi/client.rb', line 33

def send_request(method, path, params = {}, headers = nil)
  # TODO Crowi does not support Authorization: Bearer
  params[:access_token] = @access_token
  Crowi::Response.new(connection.send(method, path, params, headers))
end