Class: Api::Client
- Inherits:
-
Object
- Object
- Api::Client
- Includes:
- Authentication, Configurable, Connection
- Defined in:
- lib/api/client.rb
Overview
Client for an API
Constant Summary collapse
- CONVENIENCE_HEADERS =
Header keys that can be passed in options hash to Api::Connection#get
Set.new([:accept, :content_type])
Instance Attribute Summary
Attributes included from Configurable
#access_token, #access_token_prefix, #api_endpoint, #api_version, #auto_paginate, #basic_login, #basic_password, #connection_options, #per_page, #sawyer_options, #user_agent
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Text representation of the client, masking tokens and passwords.
Methods included from Connection
#agent, #delete, #get, #head, #last_response, #paginate, #patch, #post, #put, #root
Methods included from Configurable
#configure, keys, #reset!, #same_options?
Methods included from Authentication
#basic_authenticated?, #token_authenticated?
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/api/client.rb', line 17 def initialize( = {}) reset!() end |
Instance Method Details
#inspect ⇒ String
Text representation of the client, masking tokens and passwords
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/api/client.rb', line 24 def inspect inspected = super # mask password inspected = inspected.gsub! @basic_password, "*******" if @basic_password # Only show last 4 of token, secret if @access_token inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}" end inspected end |