class Tenios::API::Client
Constants
- URL
Public Class Methods
new(access_key:, url: URL)
click to toggle source
# File lib/tenios/api/client.rb, line 12 def initialize(access_key:, url: URL) @access_key = access_key @http_client = build_http_client(url) end
Private Class Methods
endpoint(name, klass)
click to toggle source
# File lib/tenios/api/client.rb, line 20 def endpoint(name, klass) API.autoload klass, "tenios/api/#{name}" class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{name} @#{name} ||= #{klass}.new(self) end RUBY end
Public Instance Methods
post(path, **payload)
click to toggle source
@api private
# File lib/tenios/api/client.rb, line 37 def post(path, **payload) @http_client.post(path, payload.merge(access_key: @access_key)).body end
Private Instance Methods
build_http_client(url)
click to toggle source
# File lib/tenios/api/client.rb, line 43 def build_http_client(url) Faraday.new(url: url) { |c| c.request :json c.response :json c.response :raise_error c.use :gzip c.adapter Faraday.default_adapter } end