class JeffreyBotterhillClient::Client

Constants

BASE_ENDPOINT
LATEST_API_VERSION

Public Class Methods

new(api_key:, endpoint: BASE_ENDPOINT, version: LATEST_API_VERSION) click to toggle source
# File lib/jeffrey_botterhill_client/client.rb, line 9
def initialize(api_key:, endpoint: BASE_ENDPOINT, version: LATEST_API_VERSION)
  @endpoint = endpoint
  @api_key = api_key
  @version = version
end

Public Instance Methods

record_phrase(message:, source:, metadata: {}) click to toggle source
# File lib/jeffrey_botterhill_client/client.rb, line 15
def record_phrase(message:, source:, metadata: {})
  api_connection.post '/blurbs' do |req|
    req.body = { blurb: {
      message: message,
      source: source,
      metadata: metadata
    } }
  end
end

Private Instance Methods

api_connection() click to toggle source
# File lib/jeffrey_botterhill_client/client.rb, line 26
def api_connection
  @api_connection ||= Faraday.new(:url => @endpoint) do |faraday|
    faraday.request :json
    faraday.request  :authorization, 'JeffreyBotterhill', @api_key
    faraday.response :json, :content_type => /\bjson$/
    faraday.adapter  Faraday.default_adapter
  end
end