Class: PublishingPlatformApi::Base
- Inherits:
-
Object
- Object
- PublishingPlatformApi::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/publishing_platform_api/base.rb
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.
43
44
45
46
47
48
49
50
51
|
# File 'lib/publishing_platform_api/base.rb', line 43
def initialize(endpoint_url, options = {})
options[:endpoint_url] = endpoint_url
raise InvalidAPIURL unless endpoint_url =~ URI::RFC3986_Parser::RFC3986_URI
base_options = { logger: PublishingPlatformApi::Base.logger }
default_options = base_options.merge(PublishingPlatformApi::Base.default_options || {})
@options = default_options.merge(options)
self.endpoint = options[:endpoint_url]
end
|
Class Attribute Details
.default_options ⇒ Object
36
37
38
|
# File 'lib/publishing_platform_api/base.rb', line 36
def default_options
@default_options
end
|
.logger ⇒ Object
39
40
41
|
# File 'lib/publishing_platform_api/base.rb', line 39
def self.logger
@logger ||= NullLogger.instance
end
|
Instance Attribute Details
#options ⇒ Object
32
33
34
|
# File 'lib/publishing_platform_api/base.rb', line 32
def options
@options
end
|
Instance Method Details
#client ⇒ Object
13
14
15
|
# File 'lib/publishing_platform_api/base.rb', line 13
def client
@client ||= create_client
end
|
#url_for_slug(slug, options = {}) ⇒ Object
53
54
55
|
# File 'lib/publishing_platform_api/base.rb', line 53
def url_for_slug(slug, options = {})
"#{base_url}/#{slug}.json#{query_string(options)}"
end
|