class Luma::Connection
Constants
- DEFAULT_ENDPOINT
Public Class Methods
new(body: nil, headers: {})
click to toggle source
# File lib/luma/connection.rb, line 13 def initialize(body: nil, headers: {}) @body = body @headers = headers end
Public Instance Methods
add_headers_and_body()
click to toggle source
# File lib/luma/connection.rb, line 25 def add_headers_and_body @body = @body.to_json @headers = auth_header.merge(@headers) @headers["Content-Type"] = 'application/json' end
request(endpoint: DEFAULT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post)
click to toggle source
# File lib/luma/connection.rb, line 18 def request(endpoint: DEFAULT_ENDPOINT, body: nil, headers: {}, auth: true, verb: :post) body = body.to_json if body.is_a?(Hash) headers = auth_header.merge(headers) if auth self.class.send("#{verb}", endpoint, body: body, headers: headers) end
Private Instance Methods
auth_header()
click to toggle source
# File lib/luma/connection.rb, line 33 def auth_header @auth ||= Authentication.new return @auth.authenticate.access_header end