Class: GdsApi::Base
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/gds_api/base.rb
Direct Known Subclasses
AssetManager, BusinessSupportApi, ContentApi, FactCave, GovUkDelivery, Imminence, LicenceApplication, Mapit, NeedApi, Needotron, Organisations, Panopticon, Publisher, Router, Rummager, Support, Worldwide
Defined Under Namespace
Classes: InvalidAPIURL
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(endpoint_url, options = {}) ⇒ Base
Returns a new instance of Base.
39
40
41
42
43
44
45
|
# File 'lib/gds_api/base.rb', line 39
def initialize(endpoint_url, options={})
options[:endpoint_url] = endpoint_url
raise InvalidAPIURL unless endpoint_url =~ URI::regexp
default_options = GdsApi::Base.default_options || {}
@options = default_options.merge(options)
self.endpoint = options[:endpoint_url]
end
|
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
32
33
34
|
# File 'lib/gds_api/base.rb', line 32
def default_options
@default_options
end
|
.logger ⇒ Object
35
36
37
|
# File 'lib/gds_api/base.rb', line 35
def self.logger
@logger ||= NullLogger.instance
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
28
29
30
|
# File 'lib/gds_api/base.rb', line 28
def options
@options
end
|
Instance Method Details
#adapter_name ⇒ Object
47
48
49
|
# File 'lib/gds_api/base.rb', line 47
def adapter_name
self.class.to_s.split("::").last.downcase
end
|
#client ⇒ Object
13
14
15
|
# File 'lib/gds_api/base.rb', line 13
def client
@client ||= create_client
end
|
#create_client ⇒ Object
17
18
19
|
# File 'lib/gds_api/base.rb', line 17
def create_client
GdsApi::JsonClient.new(options)
end
|
#get_list!(url) ⇒ Object
55
56
57
58
59
|
# File 'lib/gds_api/base.rb', line 55
def get_list!(url)
get_json!(url) do |r|
GdsApi::ListResponse.new(r, self)
end
end
|
#url_for_slug(slug, options = {}) ⇒ Object
51
52
53
|
# File 'lib/gds_api/base.rb', line 51
def url_for_slug(slug, options={})
base = "#{base_url}/#{slug}.json#{query_string(options)}"
end
|