Class: Whitehouse::Client
- Inherits:
-
Object
- Object
- Whitehouse::Client
- Includes:
- Authentication, Catalog, Order, Webhook, Configurable
- Defined in:
- lib/whitehouse/client.rb,
lib/whitehouse/client/order.rb,
lib/whitehouse/client/catalog.rb,
lib/whitehouse/client/webhook.rb
Overview
Client for the WHCC API
Defined Under Namespace
Modules: Catalog, Order, Webhook
Constant Summary
Constants included from Order
Instance Attribute Summary
Attributes included from Configurable
#access_token, #api_endpoint, #connection_options, #consumer_key, #consumer_secret, #default_media_type, #user_agent
Instance Method Summary collapse
- #connection ⇒ Object
- #get(*args) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Text representation of the client, masking tokens.
- #post(*args) ⇒ Object
-
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options.
Methods included from Webhook
#create_webhook, #verify_webhook
Methods included from Order
Methods included from Catalog
Methods included from Configurable
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 |
# File 'lib/whitehouse/client.rb', line 23 def initialize( = {}) Whitehouse::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Whitehouse.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#connection ⇒ Object
29 30 31 |
# File 'lib/whitehouse/client.rb', line 29 def connection @connection || init_connection(:oauth2) end |
#get(*args) ⇒ Object
58 59 60 |
# File 'lib/whitehouse/client.rb', line 58 def get(*args) request :get, *args end |
#inspect ⇒ String
Text representation of the client, masking tokens
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/whitehouse/client.rb', line 44 def inspect inspected = super # Only show last 4 of token, secret if @access_token inspected = inspected.gsub! @access_token, "#{'*'*8}#{@access_token[8..-1]}" end if @consumer_secret inspected = inspected.gsub! @consumer_secret, "#{'*'*8}#{@consumer_secret[8..-1]}" end inspected end |
#post(*args) ⇒ Object
62 63 64 |
# File 'lib/whitehouse/client.rb', line 62 def post(*args) request :post, *args end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
37 38 39 |
# File 'lib/whitehouse/client.rb', line 37 def (opts) opts.hash == .hash end |