Skip to content

Instantly share code, notes, and snippets.

@devotdev
Last active May 15, 2026 13:06
Show Gist options
  • Select an option

  • Save devotdev/6ab134045ce3211827242d015972685e to your computer and use it in GitHub Desktop.

Select an option

Save devotdev/6ab134045ce3211827242d015972685e to your computer and use it in GitHub Desktop.
app/services/partner_api/client.rb
require 'net/http/persistent'
module PartnerApi
class Client
def initialize(base_url:)
@base_url = base_url
@http = Net::HTTP::Persistent.new(name: 'partner_api')
@http.open_timeout = ENV.fetch('PARTNER_API_OPEN_TIMEOUT', 5).to_i
@http.read_timeout = ENV.fetch('PARTNER_API_REQUEST_TIMEOUT', 15).to_i
end
def get(path, headers: {})
uri = URI.join(@base_url, path)
request = Net::HTTP::Get.new(uri)
headers.each { |k, v| request[k] = v }
@http.request(uri, request)
end
def shutdown
@http.shutdown
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment