module WolfCore::HttpDataSource

def http_get(url:, headers: {}, query: nil)

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

def http_patch(url:, headers: {}, query: nil, body: nil)

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

def http_post(url:, headers: {}, query: nil, body: nil)

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

def http_put(url:, headers: {}, query: nil, body: nil)

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