lib/wolf_core/infrastructure/http_data_source.rb



module WolfCore
  module HttpDataSource
    module_function

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

    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
  end
end