Class: Headquarters::API
- Inherits:
-
Object
- Object
- Headquarters::API
- 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
Defined Under Namespace
Modules: Endpoints, Factory Classes: OAuthAuthenticator
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
readonly
Returns the value of attribute authenticator.
Instance Method Summary collapse
- #get(endpoint, **params) ⇒ Object
- #headers ⇒ Object
-
#initialize(**options) ⇒ API
constructor
A new instance of API.
- #post(endpoint, **params) ⇒ Object
Constructor Details
#initialize(**options) ⇒ API
Returns a new instance of API.
7 8 9 |
# File 'lib/headquarters/api.rb', line 7 def initialize(**) @authenticator = [:authenticator] || OAuthAuthenticator.new() end |
Instance Attribute Details
#authenticator ⇒ Object (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 |
#headers ⇒ Object
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 |