Class: Ghub::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ghub/api/client.rb

Overview

A low-level API client.

Instance Method Summary collapse

Constructor Details

#initialize(page: Page) ⇒ Client

Returns a new instance of Client.



12
13
14
15
# File 'lib/ghub/api/client.rb', line 12

def initialize(page: Page, **)
  super(**)
  @page = page
end

Instance Method Details

#delete(path, **parameters) ⇒ Object



35
# File 'lib/ghub/api/client.rb', line 35

def delete(path, **parameters) = call __method__, path, params: parameters

#get(path, **parameters) ⇒ Object



17
18
19
20
21
# File 'lib/ghub/api/client.rb', line 17

def get path, **parameters
  return call __method__, path, params: parameters unless configuration.paginate

  page.of { |index| call __method__, path, params: parameters.merge(page: index) }
end

#patch(path, body = nil, **parameters) ⇒ Object



31
32
33
# File 'lib/ghub/api/client.rb', line 31

def patch path, body = nil, **parameters
  call __method__, path, json: body, params: parameters
end

#post(path, body = nil, **parameters) ⇒ Object



23
24
25
# File 'lib/ghub/api/client.rb', line 23

def post path, body = nil, **parameters
  call __method__, path, json: body, params: parameters
end

#put(path, body = nil, **parameters) ⇒ Object



27
28
29
# File 'lib/ghub/api/client.rb', line 27

def put path, body = nil, **parameters
  call __method__, path, json: body, params: parameters
end