Module: Bl::Requestable

Included in:
Command
Defined in:
lib/bl/requestable.rb

Class Method Summary collapse

Class Method Details

.clientObject



5
6
7
8
9
10
# File 'lib/bl/requestable.rb', line 5

def client
  BacklogKit::Client.new(
    space_id: @config[:space_id],
    api_key: @config[:api_key]
  )
end

.formatterObject



12
13
14
# File 'lib/bl/requestable.rb', line 12

def formatter
  @formatter ||= Formatter.new(format: options[:format])
end

.request(method, url, opts = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bl/requestable.rb', line 16

def request(method, url, opts = nil)
  case method
  when :get
    client.get(url, opts.to_h)
  when :post
    client.post(url, opts.to_h)
  when :patch
    client.patch(url, opts.to_h)
  when :delete
    client.delete(url, opts.to_h)
  else
    raise 'invalid method error'
  end
rescue => e
  puts e.message
end