Last active
May 15, 2026 13:06
-
-
Save devotdev/6ab134045ce3211827242d015972685e to your computer and use it in GitHub Desktop.
app/services/partner_api/client.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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