Class: Headquarters::API

Inherits:
Object
  • Object
show all
Defined in:
lib/headquarters/api.rb,
lib/headquarters/api/factory.rb,
lib/headquarters/api/endpoints.rb,
lib/headquarters/api/oauth_authenticator.rb

Direct Known Subclasses

Client, Client::Email, Client::Github, Client::Members

Defined Under Namespace

Modules: Endpoints, Factory Classes: OAuthAuthenticator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ API

Returns a new instance of API.



7
8
9
# File 'lib/headquarters/api.rb', line 7

def initialize(**options)
  @authenticator = options[:authenticator] || OAuthAuthenticator.new(options)
end

Instance Attribute Details

#authenticatorObject (readonly)

Returns the value of attribute authenticator.



17
18
19
# File 'lib/headquarters/api.rb', line 17

def authenticator
  @authenticator
end

Instance Method Details

#get(endpoint, **params) ⇒ Object



19
20
21
# File 'lib/headquarters/api.rb', line 19

def get(endpoint, **params)
  perform_request(:get, endpoint, params)
end

#headersObject



11
12
13
14
15
# File 'lib/headquarters/api.rb', line 11

def headers
  authenticator.headers.merge(
    'Accept' => 'v2'
  )
end

#post(endpoint, **params) ⇒ Object



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

def post(endpoint, **params)
  perform_request(:post, endpoint, params)
end