Class: Ralph::CLI::Commands::Base

Inherits:
Hanami::CLI::Command
  • Object
show all
Defined in:
lib/ralph/cli/commands/base.rb

Direct Known Subclasses

Delete, Get, Post, Token

Instance Method Summary collapse

Instance Method Details

#gen_clientObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ralph/cli/commands/base.rb', line 6

def gen_client
  api_url = ENV['RALPH_URL']
  token   = ENV['RALPH_TOKEN']

  Faraday.new(api_url) do |conn|
    conn.request  :json
    conn.response :json, content_type: /\bjson$/
    conn.adapter  Faraday.default_adapter

    if token
      conn.authorization :Token, token
    end
  end
end