Module: PublishingPlatformApi

Defined in:
lib/publishing_platform_api.rb,
lib/publishing_platform_api/railtie.rb,
lib/publishing_platform_api/version.rb,
lib/publishing_platform_api/response.rb,
lib/publishing_platform_api/exceptions.rb,
lib/publishing_platform_api/json_client.rb,
lib/publishing_platform_api/list_response.rb,
lib/publishing_platform_api/test_helpers/router.rb,
lib/publishing_platform_api/test_helpers/content_store.rb,
lib/publishing_platform_api/publishing_platform_headers.rb,
lib/publishing_platform_api/test_helpers/content_item_helpers.rb,
lib/publishing_platform_api/publishing_api/special_route_publisher.rb,
lib/publishing_platform_api/middleware/publishing_platform_header_sniffer.rb

Defined Under Namespace

Modules: ExceptionHandling, TestHelpers Classes: Base, BaseError, ContentStore, EndpointNotFound, HTTPBadGateway, HTTPBadRequest, HTTPClientError, HTTPConflict, HTTPErrorResponse, HTTPForbidden, HTTPGatewayTimeout, HTTPGone, HTTPIntermittentClientError, HTTPIntermittentServerError, HTTPInternalServerError, HTTPNotFound, HTTPPayloadTooLarge, HTTPServerError, HTTPTooManyRequests, HTTPUnauthorized, HTTPUnavailable, HTTPUnprocessableEntity, InvalidUrl, JsonClient, ListResponse, Organisations, PublishingApi, PublishingPlatformHeaderSniffer, PublishingPlatformHeaders, Railtie, Response, Router, SocketErrorException, TimedOutException

Constant Summary collapse

VERSION =
"0.8.3"

Class Method Summary collapse

Class Method Details

.content_store(options = {}) ⇒ PublishingPlatformApi::ContentStore

Creates a PublishingPlatformApi::ContentStore adapter

This will set a bearer token if a CONTENT_STORE_BEARER_TOKEN environment variable is set



17
18
19
20
21
22
# File 'lib/publishing_platform_api.rb', line 17

def self.content_store(options = {})
  PublishingPlatformApi::ContentStore.new(
    PublishingPlatformLocation.find("content-store"),
    { bearer_token: ENV["CONTENT_STORE_BEARER_TOKEN"] }.merge(options),
  )
end

.organisations(options = {}) ⇒ PublishingPlatformApi::Organisations

Creates a PublishingPlatformApi::Organisations adapter for accessing APIs through the origin, where the requests will be handled by Collections frontend.



29
30
31
32
33
34
# File 'lib/publishing_platform_api.rb', line 29

def self.organisations(options = {})
  PublishingPlatformApi::Organisations.new(
    PublishingPlatformLocation.new.website_root,
    options,
  )
end

.publishing_api(options = {}) ⇒ PublishingPlatformApi::PublishingApi

Creates a PublishingPlatformApi::PublishingApi adapter

This will set a bearer token if a PUBLISHING_API_BEARER_TOKEN environment variable is set



42
43
44
45
46
47
# File 'lib/publishing_platform_api.rb', line 42

def self.publishing_api(options = {})
  PublishingPlatformApi::PublishingApi.new(
    PublishingPlatformLocation.find("publishing-api"),
    { bearer_token: ENV["PUBLISHING_API_BEARER_TOKEN"] }.merge(options),
  )
end

.router(options = {}) ⇒ PublishingPlatformApi::Router

Creates a PublishingPlatformApi::Router adapter for communicating with Router API

This will set a bearer token if a ROUTER_API_BEARER_TOKEN environment variable is set



55
56
57
58
59
60
# File 'lib/publishing_platform_api.rb', line 55

def self.router(options = {})
  PublishingPlatformApi::Router.new(
    PublishingPlatformLocation.find("router-api"),
    { bearer_token: ENV["ROUTER_API_BEARER_TOKEN"] }.merge(options),
  )
end