Class: WooCommerce::ApiBase

Inherits:
Object
  • Object
show all
Defined in:
lib/woocommerce_api.rb

Direct Known Subclasses

API

Constant Summary collapse

DEFAULT_ARGS =
{
  wp_api: false, version: "v3", verify_ssl: true,
  signature_method: "HMAC-SHA256", httparty_args: {}
}.freeze
SENSITIVE_ARGS =
[:@consumer_key, :@consumer_secret, :@signature_method].freeze

Instance Method Summary collapse

Constructor Details

#initialize(url, consumer_key, consumer_secret, args = {}) ⇒ ApiBase



19
20
21
22
23
24
25
26
27
28
# File 'lib/woocommerce_api.rb', line 19

def initialize(url, consumer_key, consumer_secret, args = {})
  @url = url
  @consumer_key = consumer_key
  @consumer_secret = consumer_secret

  args = DEFAULT_ARGS.merge(args)
  create_args_variables(args)

  @is_ssl = @url.start_with? "https"
end

Instance Method Details

#inspectObject

Overrides inspect to hide sensitive information

Returns a string representation of the object



33
34
35
36
37
38
39
40
# File 'lib/woocommerce_api.rb', line 33

def inspect
  safe_ivars = instance_variables.each_with_object({}) do |var, hash|
    value = instance_variable_get(var)
    hash[var] = SENSITIVE_ARGS.include?(var) ? "[FILTERED]" : value
  end

  "#<#{self.class}:0x#{object_id.to_s(16)} #{safe_ivars.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')}>"
end