Class: Booqable::Client
- Inherits:
-
Object
- Object
- Booqable::Client
- Includes:
- Auth, Configurable, HTTP, Resources
- Defined in:
- lib/booqable/client.rb
Overview
Client for the Booqable API
Provides a Ruby interface to interact with the Booqable rental management API. The client can be configured with various authentication methods including API keys, OAuth, and single-use tokens.
Constant Summary collapse
- SECRETS =
List of configuration keys that contain sensitive information and should be masked in inspect output
%w[ client_secret client_id api_key single_use_token single_use_token_private_key single_use_token_secret refresh_token access_token ]
Constants included from HTTP
Constants included from Resources
Resources::ALL_RESOURCES, Resources::RESOURCES_FILE_PATH
Instance Attribute Summary
Attributes included from Configurable
#api_domain, #api_endpoint, #api_key, #api_version, #auto_paginate, #client_id, #client_secret, #company_id, #connection_options, #debug, #default_media_type, #middleware, #no_retries, #per_page, #proxy, #read_token, #redirect_uri, #single_use_token, #single_use_token_algorithm, #single_use_token_company_id, #single_use_token_expiration_period, #single_use_token_private_key, #single_use_token_secret, #single_use_token_user_id, #ssl_verify_mode, #user_agent, #write_token
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Initialize a new Client.
-
#inspect ⇒ String
String representation of the client with sensitive information masked.
Methods included from HTTP
#agent, #api_endpoint, #default_headers, #delete, #faraday, #faraday_builder, #faraday_options, #get, #head, #last_response, #last_response_body, #logger, #normalized_path, #paginate, #parse_options_with_convenience_headers, #patch, #post, #put, #rate_limit, #request, #response_data_with_correct_encoding, #sawyer_options, #sawyer_serializer, #total_present_in_stats?
Methods included from Auth
#api_key_authenticated?, #authenticate_with_code, #inject_auth_middleware, #oauth_authenticated?, #oauth_client, #single_use_token_authenticated?
Methods included from Configurable
#configure, #debug?, keys, #reset!, #same_options?
Constructor Details
#initialize(options = {}) ⇒ Client
Initialize a new Client
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/booqable/client.rb', line 47 def initialize( = {}) # Use options passed in, but fall back to module defaults # # This may look like a `.keys.each` which should be replaced with `#each_key`, but # this doesn't actually work, since `#keys` is just a method we've defined ourselves. # The class doesn't fulfill the whole `Enumerable` contract. Booqable::Configurable.keys.each do |key| value = [key].nil? ? Booqable.instance_variable_get(:"@#{key}") : [key] instance_variable_set(:"@#{key}", value) end end |
Instance Method Details
#inspect ⇒ String
String representation of the client with sensitive information masked
Overrides the default inspect method to hide sensitive configuration values like API keys, client secrets, and tokens by replacing them with asterisks.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/booqable/client.rb', line 69 def inspect inspected = super secrets = SECRETS.map { |secret| instance_variable_get("@#{secret}") } inspected.gsub!(/"(#{secrets.join("|")})"/) do |match| match.gsub!(/./, "*") end inspected end |