Module: WolfCore::HttpDataSource

Defined in:
lib/wolf_core/infrastructure/http_data_source.rb

Class Method Summary collapse

Class Method Details

.http_get(url:, headers: {}, query: nil) ⇒ Object



5
6
7
# File 'lib/wolf_core/infrastructure/http_data_source.rb', line 5

def http_get(url:, headers: {}, query: nil)
  HTTParty.get(url, headers: headers, query: query)
end

.http_post(url:, headers: {}, query: nil, body: nil) ⇒ Object



9
10
11
12
13
# File 'lib/wolf_core/infrastructure/http_data_source.rb', line 9

def http_post(url:, headers: {}, query: nil, body: nil)
  headers['Content-Type'] ||= 'application/json'
  body = body&.to_json if headers['Content-Type'] == 'application/json'
  HTTParty.post(url, headers: headers, query: query, body: body)
end

.http_put(url:, headers: {}, query: nil, body: nil) ⇒ Object



15
16
17
18
19
# File 'lib/wolf_core/infrastructure/http_data_source.rb', line 15

def http_put(url:, headers: {}, query: nil, body: nil)
  headers['Content-Type'] ||= 'application/json'
  body = body&.to_json if headers['Content-Type'] == 'application/json'
  HTTParty.put(url, headers: headers, query: query, body: body)
end