Class: Guidestar::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Search, Connection, Request
Defined in:
lib/guidestar/client.rb,
lib/guidestar/client/search.rb

Direct Known Subclasses

Chain

Defined Under Namespace

Modules: Search

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Search

#charity_check, #detailed_search, #npo_validation, #search

Methods included from Connection

#connection

Methods included from Request

#get, #get_raw

Constructor Details

#initialize(options = {}) ⇒ Client

Public: Sets up the core Client object that can be reused throughout the request.



22
23
24
25
26
27
28
29
30
31
# File 'lib/guidestar/client.rb', line 22

def initialize(options={})
  @api_url     = options.delete(:endpoint) || Guidestar.default_endpoint
  @proxy       = options.delete(:proxy) || Guidestar.proxy
  @username    = options.delete(:username) || Guidestar.username
  @password    = options.delete(:password) || Guidestar.password
  @ssl_options = options.delete(:ssl_options) || Guidestar.ssl_options
  @options     = { :version => 1.0,
                   :page_size => 25,
                   :page => 1 }.merge options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object

Internal: Allows method chaining of parameters to create template objects.

Returns a Guidestar::Chain object that mimics the Client.



44
45
46
47
48
49
50
51
52
# File 'lib/guidestar/client.rb', line 44

def method_missing(method_name, *args)
  chain = Chain.new({
    :publisher => @publisher,
    :endpoint => @api_url,
    :proxy => @proxy
  }.merge(@options))
  chain.send(method_name.to_sym, *args)
  chain
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



18
19
20
# File 'lib/guidestar/client.rb', line 18

def options
  @options
end

#proxyObject (readonly)

Returns the value of attribute proxy.



16
17
18
# File 'lib/guidestar/client.rb', line 16

def proxy
  @proxy
end

Instance Method Details

#api_urlObject

Internal: Provides the URL for accessing the API

Returns a String to the API root url.



36
37
38
# File 'lib/guidestar/client.rb', line 36

def api_url
  @api_url ||= 'https://gsservices.guidestar.org'
end