Class: Rbdash::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rbdash/request.rb

Instance Method Summary collapse

Constructor Details

#initializeRequest

debug_output $stdout



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rbdash/request.rb', line 10

def initialize
  conf_file = './.rbdash.yml'
  config = YAML.load_file(conf_file)
  self.class.base_uri(config['base_uri'])
  @default_options = {
    verify: false,
    headers: {
      'Authorization' => config['token'],
      'Content-Type' => 'application/json'
    }
  }
end

Instance Method Details

#get(ep, params: {}, options: {}) ⇒ Object



23
24
25
# File 'lib/rbdash/request.rb', line 23

def get(ep, params: {}, options: {})
  self.class.get(ep, @default_options.merge(options.merge(query: params)))
end

#post(ep, body: {}, options: {}) ⇒ Object



27
28
29
# File 'lib/rbdash/request.rb', line 27

def post(ep, body: {}, options: {})
  self.class.post(ep, @default_options.merge(options.merge(body: body.to_json)))
end