Class: WebPurify::Client

Inherits:
Object
  • Object
show all
Includes:
Blacklist, Filters, Whitelist
Defined in:
lib/web_purify/client.rb

Overview

WebPurify::Client

The WebPurify::Client class maintains state of the request parameters like api_key, endpoint, etc., and provides easy methods for accessing WebPurify

Instance Method Summary collapse

Methods included from Whitelist

#add_to_whitelist, #get_whitelist, #remove_from_whitelist

Methods included from Blacklist

#add_to_blacklist, #get_blacklist, #remove_from_blacklist

Methods included from Filters

#check, #check_count, #replace, #return

Constructor Details

#initialize(options) ⇒ Client

Initialize the class

Parameters:

  • options (String, Hash)

    Either an API key string, or a hash of options



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/web_purify/client.rb', line 17

def initialize(options)
  if options.is_a? String
    @api_key    = options
    @endpoint   = :us
    @enterprise = false
  elsif options.is_a? Hash
    @api_key    = options[:api_key]
    @endpoint   = options[:endpoint]   || :us
    @enterprise = options[:enterprise] || false
  end

  @request_base = {
    :host   => WebPurify::Constants.endpoints[@endpoint],
    :path   => WebPurify::Constants.rest_path,
    :scheme => WebPurify::Constants.scheme(@enterprise)
  }

  @query_base = {
    :api_key => @api_key,
    :format  => WebPurify::Constants.format
  }
end