publishing_platform_api_adapters 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5184264eb9e2b1bb5c025980563ad23348940805a21fae7f1f43018f1e1b19
4
- data.tar.gz: b2c57528a81f4e8dc7b5e615ac1c596f6a2035d04f1a47926ac28bd234035e6b
3
+ metadata.gz: a4cbccea8ae641f826ce2961ac0cc15f43276023f7626fa5ef069bf879989cdf
4
+ data.tar.gz: 18d958e5143484a040340649c1709e59f43bf1fb6d92a6881c00066637affa64
5
5
  SHA512:
6
- metadata.gz: f9de58b5a14da0ee00752bf7cb940f97d9ef9bcb1301a12e380bae23ad50e6ccef56e66387cd89e197d047c92de576676623d9a970ed9475638e66c8d6a10252
7
- data.tar.gz: 268df30f6a6806f315d92fe1fc00a8a46c4c52b75b505988756b460b5bf2a00912656113c855ef987cea611f9187e0ca2be7154c44e75ee17db63f6bbc301e63
6
+ metadata.gz: 6ecc55e99bf9b3940e3a9f58fa0068fcc121511e8e680e1dafeab3516c9cd8f8ac330b54d47c8e1264478cf689379e1a09abe755f2678b74efc4fc4a9eef5f5e
7
+ data.tar.gz: 4533f2ff437bd7cda8d2c6d04b4e15dc0a40581e327ad62ffe2352cd1a14bb239db165ac9b4549fce10a4e5767c4e31202f3afaade3c2de9b48681a4d230f995
@@ -0,0 +1,24 @@
1
+ require "publishing_platform_location"
2
+
3
+ require_relative "base"
4
+ require_relative "exceptions"
5
+
6
+ class PublishingPlatformApi::ContentStore < PublishingPlatformApi::Base
7
+ class ItemNotFound < PublishingPlatformApi::HTTPNotFound
8
+ def self.build_from(http_error)
9
+ new(http_error.code, http_error.message, http_error.error_details)
10
+ end
11
+ end
12
+
13
+ def content_item(base_path)
14
+ get_json(content_item_url(base_path))
15
+ rescue PublishingPlatformApi::HTTPNotFound => e
16
+ raise ItemNotFound.build_from(e)
17
+ end
18
+
19
+ private
20
+
21
+ def content_item_url(base_path)
22
+ "#{endpoint}/content#{base_path}"
23
+ end
24
+ end
@@ -3,27 +3,27 @@ require_relative "middleware/publishing_platform_header_sniffer"
3
3
  module PublishingPlatformApi
4
4
  class Railtie < Rails::Railtie
5
5
  initializer "publishing_platform_api.initialize_publishing_platform_request_id_sniffer" do |app|
6
- Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for PublishingPlatform-Request-Id header"
6
+ Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for Publishing-Platform-Request-Id header"
7
7
  app.middleware.use PublishingPlatformApi::PublishingPlatformHeaderSniffer, "HTTP_PUBLISHING_PLATFORM_REQUEST_ID"
8
8
  end
9
9
 
10
10
  initializer "publishing_platform_api.initialize_publishing_platform_original_url_sniffer" do |app|
11
- Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for PublishingPlatform-Original-Url header"
11
+ Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for Publishing-Platform-Original-Url header"
12
12
  app.middleware.use PublishingPlatformApi::PublishingPlatformHeaderSniffer, "HTTP_PUBLISHING_PLATFORM_ORIGINAL_URL"
13
13
  end
14
14
 
15
15
  initializer "publishing_platform_api.initialize_publishing_platform_authenticated_user_sniffer" do |app|
16
- Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for X-PublishingPlatform-Authenticated-User header"
16
+ Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for X-Publishing-Platform-Authenticated-User header"
17
17
  app.middleware.use PublishingPlatformApi::PublishingPlatformHeaderSniffer, "HTTP_X_PUBLISHING_PLATFORM_AUTHENTICATED_USER"
18
18
  end
19
19
 
20
20
  initializer "publishing_platform_api.initialize_publishing_platform_authenticated_user_organisation_sniffer" do |app|
21
- Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for X-PublishingPlatform-Authenticated-User-Organisation header"
21
+ Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for X-Publishing-Platform-Authenticated-User-Organisation header"
22
22
  app.middleware.use PublishingPlatformApi::PublishingPlatformHeaderSniffer, "HTTP_X_PUBLISHING_PLATFORM_AUTHENTICATED_USER_ORGANISATION"
23
23
  end
24
24
 
25
25
  initializer "publishing_platform_api.initialize_publishing_platform_content_id_sniffer" do |app|
26
- Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for PublishingPlatform-Auth-Bypass-Id header"
26
+ Rails.logger.debug "Using middleware PublishingPlatformApi::PublishingPlatformHeaderSniffer to sniff for Publishing-Platform-Auth-Bypass-Id header"
27
27
  app.middleware.use PublishingPlatformApi::PublishingPlatformHeaderSniffer, "HTTP_PUBLISHING_PLATFORM_AUTH_BYPASS_ID"
28
28
  end
29
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublishingPlatformApi
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
5
5
  end
@@ -2,6 +2,7 @@ require "addressable"
2
2
  require "publishing_platform_location"
3
3
  require "time"
4
4
  require "publishing_platform_api/publishing_api"
5
+ require "publishing_platform_api/content_store"
5
6
 
6
7
  # @api documented
7
8
  module PublishingPlatformApi
@@ -17,4 +18,17 @@ module PublishingPlatformApi
17
18
  { bearer_token: ENV["PUBLISHING_API_BEARER_TOKEN"] }.merge(options),
18
19
  )
19
20
  end
21
+
22
+ # Creates a PublishingPlatformApi::ContentStore adapter
23
+ #
24
+ # This will set a bearer token if a CONTENT_STORE_BEARER_TOKEN environment
25
+ # variable is set
26
+ #
27
+ # @return [PublishingPlatformApi::ContentStore]
28
+ def self.content_store(options = {})
29
+ PublishingPlatformApi::ContentStore.new(
30
+ PublishingPlatformLocation.find("content-store"),
31
+ { bearer_token: ENV["CONTENT_STORE_BEARER_TOKEN"] }.merge(options),
32
+ )
33
+ end
20
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publishing_platform_api_adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Publishing Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-19 00:00:00.000000000 Z
11
+ date: 2024-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -104,6 +104,7 @@ files:
104
104
  - Rakefile
105
105
  - lib/publishing_platform_api.rb
106
106
  - lib/publishing_platform_api/base.rb
107
+ - lib/publishing_platform_api/content_store.rb
107
108
  - lib/publishing_platform_api/exceptions.rb
108
109
  - lib/publishing_platform_api/json_client.rb
109
110
  - lib/publishing_platform_api/list_response.rb