Class: Melaya::HttpClient
- Inherits:
-
Object
- Object
- Melaya::HttpClient
- Defined in:
- lib/melaya/http_client.rb
Overview
Internal HTTP client. Injects the API key on every call as both a query-param (?apiKey=) and Authorization: Bearer header.
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://api.melaya.org"
Instance Method Summary collapse
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(api_key:, base_url: DEFAULT_BASE_URL, verify_ssl: true) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(path, body = nil) ⇒ Object
Constructor Details
#initialize(api_key:, base_url: DEFAULT_BASE_URL, verify_ssl: true) ⇒ HttpClient
Returns a new instance of HttpClient.
16 17 18 19 20 |
# File 'lib/melaya/http_client.rb', line 16 def initialize(api_key:, base_url: DEFAULT_BASE_URL, verify_ssl: true) @api_key = api_key @base_uri = URI.parse(base_url.chomp("/")) @verify_ssl = verify_ssl end |
Instance Method Details
#delete(path, params = {}) ⇒ Object
30 31 32 |
# File 'lib/melaya/http_client.rb', line 30 def delete(path, params = {}) request(:delete, path, params: params) end |
#get(path, params = {}) ⇒ Object
22 23 24 |
# File 'lib/melaya/http_client.rb', line 22 def get(path, params = {}) request(:get, path, params: params) end |
#post(path, body = nil) ⇒ Object
26 27 28 |
# File 'lib/melaya/http_client.rb', line 26 def post(path, body = nil) request(:post, path, body: body) end |