publishing_platform_api_adapters 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5184264eb9e2b1bb5c025980563ad23348940805a21fae7f1f43018f1e1b19
4
- data.tar.gz: b2c57528a81f4e8dc7b5e615ac1c596f6a2035d04f1a47926ac28bd234035e6b
3
+ metadata.gz: dadc8a7f07684d3fad45a0efcfaa222a0763dbebd20fe3e0d5b7fc551196f65d
4
+ data.tar.gz: ecfbc92e940928e42f4d7e09b0a211fb2ebf5edf94dd6c86f5156c533d104a54
5
5
  SHA512:
6
- metadata.gz: f9de58b5a14da0ee00752bf7cb940f97d9ef9bcb1301a12e380bae23ad50e6ccef56e66387cd89e197d047c92de576676623d9a970ed9475638e66c8d6a10252
7
- data.tar.gz: 268df30f6a6806f315d92fe1fc00a8a46c4c52b75b505988756b460b5bf2a00912656113c855ef987cea611f9187e0ca2be7154c44e75ee17db63f6bbc301e63
6
+ metadata.gz: 0ed8d5992d01a25a5313d0e5f7beeb21ff4b46541abca773617adc6398bd33b4847303cc89f086fed0b355b9c896c78f7098e650f77605903b09cbfa78a349f1
7
+ data.tar.gz: 907d770b9ed8568d12e861a04a6b184e20ec5eba029450d27ff40f6349ac0bb249bd465a85056853ae7a23ad44fffec144d31166514a9f26b74a18e79f4eb27a
@@ -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
@@ -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.0"
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.0
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