Class: GdsApi::Base
- Inherits:
-
Object
- Object
- GdsApi::Base
- Extended by:
- Forwardable
- Defined in:
- lib/gds_api/base.rb
Direct Known Subclasses
AssetManager, BusinessSupportApi, ContentApi, ContentStore, EmailAlertApi, ExternalLinkTracker, GovUkDelivery, Imminence, LicenceApplication, Mapit, Maslow, NeedApi, Needotron, Organisations, Panopticon, PerformancePlatform::DataIn, Publisher, PublishingApi, PublishingApiV2, Router, Rummager, Support, SupportApi, WhitehallAdminApi, Worldwide
Defined Under Namespace
Classes: InvalidAPIURL
Class Attribute Summary collapse
-
.default_options ⇒ Object
Returns the value of attribute default_options.
- .logger ⇒ Object
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #client ⇒ Object
- #create_client ⇒ Object
- #get_list!(url) ⇒ Object
-
#initialize(endpoint_url, options = {}) ⇒ Base
constructor
A new instance of Base.
- #url_for_slug(slug, options = {}) ⇒ Object
Constructor Details
#initialize(endpoint_url, options = {}) ⇒ Base
Returns a new instance of Base.
41 42 43 44 45 46 47 48 |
# File 'lib/gds_api/base.rb', line 41 def initialize(endpoint_url, ={}) [:endpoint_url] = endpoint_url raise InvalidAPIURL unless endpoint_url =~ URI::regexp = { logger: self.class.logger } = .merge(GdsApi::Base. || {}) @options = .merge() self.endpoint = [:endpoint_url] end |
Class Attribute Details
.default_options ⇒ Object
Returns the value of attribute default_options.
34 35 36 |
# File 'lib/gds_api/base.rb', line 34 def @default_options end |
.logger ⇒ Object
37 38 39 |
# File 'lib/gds_api/base.rb', line 37 def self.logger @logger ||= NullLogger.instance end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
30 31 32 |
# File 'lib/gds_api/base.rb', line 30 def @options end |
Instance Method Details
#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() end |
#get_list!(url) ⇒ Object
54 55 56 57 58 |
# File 'lib/gds_api/base.rb', line 54 def get_list!(url) get_json!(url) do |r| GdsApi::ListResponse.new(r, self) end end |
#url_for_slug(slug, options = {}) ⇒ Object
50 51 52 |
# File 'lib/gds_api/base.rb', line 50 def url_for_slug(slug, ={}) "#{base_url}/#{slug}.json#{query_string()}" end |