Method: CrAPI::Client#initialize
- Defined in:
- lib/crapi/client.rb
#initialize(base_uri, opts = {}) ⇒ Client
Returns a new instance of Client.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/crapi/client.rb', line 57 def initialize(base_uri, opts = {}) @base_uri = case base_uri when URI then base_uri when String then URI(base_uri) else raise CrAPI::ArgumentError, %(Unexpected "base_uri" type: #{base_uri.class}) end @proxy_host = opts[:proxy_host] @proxy_port = opts[:proxy_port] @proxy_username = opts[:proxy_username] @proxy_password = opts[:proxy_password] @http = Net::HTTP.new(@base_uri.host, @base_uri.port, @proxy_host, @proxy_port, @proxy_username, @proxy_password) @http.use_ssl = (@base_uri.scheme == 'https') @http.verify_mode = ::OpenSSL::SSL::VERIFY_NONE if opts[:insecure].present? @default_headers = { 'Content-Type': JSON_CONTENT_TYPE }.with_indifferent_access end |