Class: GdsApi::Base
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Defined in:
- lib/gds_api/base.rb
Direct Known Subclasses
AccountApi, AssetManager, Calendars, ContentStore, EmailAlertApi, LicenceApplication, LinkCheckerApi, LocalLinksManager, LocationsApi, Organisations, PlacesManager, PublishingApi, Search, SearchApiV2, SignonApi, Support, SupportApi, Worldwide
Defined Under Namespace
Classes: InvalidAPIURL, ItemNotFound
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.
49
50
51
52
53
54
55
56
57
|
# File 'lib/gds_api/base.rb', line 49
def initialize(endpoint_url, options = {})
options[:endpoint_url] = endpoint_url
raise InvalidAPIURL unless endpoint_url =~ URI::RFC3986_Parser::RFC3986_URI
base_options = { logger: GdsApi::Base.logger }
default_options = base_options.merge(GdsApi::Base.default_options || {})
@options = default_options.merge(options)
self.endpoint = options[:endpoint_url]
end
|
Class Attribute Details
.default_options ⇒ Object
42
43
44
|
# File 'lib/gds_api/base.rb', line 42
def default_options
@default_options
end
|
.logger ⇒ Object
45
46
47
|
# File 'lib/gds_api/base.rb', line 45
def self.logger
@logger ||= NullLogger.instance
end
|
Instance Attribute Details
#options ⇒ Object
38
39
40
|
# File 'lib/gds_api/base.rb', line 38
def options
@options
end
|
Instance Method Details
#client ⇒ Object
19
20
21
|
# File 'lib/gds_api/base.rb', line 19
def client
@client ||= create_client
end
|
#create_client ⇒ Object
23
24
25
|
# File 'lib/gds_api/base.rb', line 23
def create_client
GdsApi::JsonClient.new(options)
end
|
#get_list(url) ⇒ Object
63
64
65
66
67
|
# File 'lib/gds_api/base.rb', line 63
def get_list(url)
get_json(url) do |r|
GdsApi::ListResponse.new(r, self)
end
end
|
#url_for_slug(slug, options = {}) ⇒ Object
59
60
61
|
# File 'lib/gds_api/base.rb', line 59
def url_for_slug(slug, options = {})
"#{base_url}/#{slug}.json#{query_string(options)}"
end
|