Module: PublishingPlatformApi

Defined in:
lib/publishing_platform_api.rb,
lib/publishing_platform_api/search.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/search.rb,
lib/publishing_platform_api/test_helpers/asset_manager.rb,
lib/publishing_platform_api/test_helpers/content_store.rb,
lib/publishing_platform_api/test_helpers/organisations.rb,
lib/publishing_platform_api/publishing_platform_headers.rb,
lib/publishing_platform_api/test_helpers/publishing_api.rb,
lib/publishing_platform_api/test_helpers/common_responses.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

Overview

require "plek" require "securerandom"

Defined Under Namespace

Modules: ExceptionHandling, TestHelpers Classes: AssetManager, 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, Search, SignonApi, SocketErrorException, TimedOutException

Constant Summary collapse

VERSION =
"0.15.0"

Class Method Summary collapse

Class Method Details

.asset_manager(options = {}) ⇒ PublishingPlatformApi::AssetManager

Creates a PublishingPlatformApi::AssetManager adapter

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



20
21
22
23
24
25
# File 'lib/publishing_platform_api.rb', line 20

def self.asset_manager(options = {})
  PublishingPlatformApi::AssetManager.new(
    PublishingPlatformLocation.find("asset-manager"),
    { bearer_token: ENV["ASSET_MANAGER_BEARER_TOKEN"] }.merge(options),
  )
end

.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



33
34
35
36
37
38
# File 'lib/publishing_platform_api.rb', line 33

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.



45
46
47
48
49
50
# File 'lib/publishing_platform_api.rb', line 45

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



58
59
60
61
62
63
# File 'lib/publishing_platform_api.rb', line 58

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



71
72
73
74
75
76
# File 'lib/publishing_platform_api.rb', line 71

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

.search(options = {}) ⇒ PublishingPlatformApi::Search

Creates a PublishingPlatformApi::Search adapter to access via a search.* hostname



81
82
83
84
85
86
# File 'lib/publishing_platform_api.rb', line 81

def self.search(options = {})
  PublishingPlatformApi::Search.new(
    PublishingPlatformLocation.find("search-api"),
    options,
  )
end

.signon_api(options = {}) ⇒ PublishingPlatformApi::SignonApi

Creates a PublishingPlatformApi::SignonApi adapter

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



94
95
96
97
98
99
# File 'lib/publishing_platform_api.rb', line 94

def self.signon_api(options = {})
  PublishingPlatformApi::SignonApi.new(
    PublishingPlatformLocation.find("signon"),
    { bearer_token: ENV["SIGNON_API_BEARER_TOKEN"] }.merge(options),
  )
end