publishing_platform_api_adapters 0.6.1 → 0.7.0

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: ba00f3fd59ac75e1c672ed3478d9db8503fbaa56ee682a4358620ff226e3cf6b
4
- data.tar.gz: 190d8d347832fb1cab2df63a2b4dd49198e1c8fb147f4b593696755c31ae8490
3
+ metadata.gz: 546721a4d7c247b0de3d3aed7767d8c355b79628b77248fb3624889f751a3f26
4
+ data.tar.gz: 664183ea7606c204354531ffb4a69b392e6475a01477af2256074c7608aeeeee
5
5
  SHA512:
6
- metadata.gz: a9996d745a94433034e222944d6c30cd76d70a3fff86cbe36ab6ec69ebf945f04defbf18a8d9df9e812006f73c5502dc3c01102ade2eb20bcbff576be5577585
7
- data.tar.gz: 9ea06ebd27980708823a44525c22221fe18e9eaea4eadcf5a23cd43a46b20d6cd2176b87667bbf182e20e024eb133629225506e9729a6de30ac1c520367af032
6
+ metadata.gz: 89072fe076a7b666ca0b661e2f1ae3c51402c163d1c7a6d91fd80fecfa6bcd8e2fa23a3fe02342156af2389f1b3c5475e37333133f0dca6ba6e22c74b1ac74bf
7
+ data.tar.gz: cf14d5aaed20522dea8ebe2d83c1dd87a70fcdb035ea7182181049c9093a8bbbe4bdf7f5dc2a6d18de50322ac9950830deb25806537a2b575cdd271ba22900e4
@@ -0,0 +1,17 @@
1
+ require_relative "base"
2
+
3
+ class PublishingPlatformApi::Organisations < PublishingPlatformApi::Base
4
+ def organisations
5
+ get_list "#{base_url}/organisations"
6
+ end
7
+
8
+ def organisation(organisation_slug)
9
+ get_json "#{base_url}/organisations/#{organisation_slug}"
10
+ end
11
+
12
+ private
13
+
14
+ def base_url
15
+ "#{endpoint}/api"
16
+ end
17
+ end
@@ -0,0 +1,51 @@
1
+ require "publishing_platform_api/publishing_api"
2
+ require "time"
3
+
4
+ module PublishingPlatformApi
5
+ class PublishingApi < PublishingPlatformApi::Base
6
+ class SpecialRoutePublisher
7
+ def initialize(options = {})
8
+ @logger = options[:logger] || PublishingPlatformApi::Base.logger
9
+ @publishing_api = options[:publishing_api] || PublishingPlatformApi::PublishingApi.new(PublishingPlatformLocation.find("publishing-api"))
10
+ end
11
+
12
+ def publish(options)
13
+ logger.info("Publishing #{options.fetch(:type)} route #{options.fetch(:base_path)}, routing to #{options.fetch(:rendering_app)}")
14
+
15
+ update_type = options.fetch(:update_type, "major")
16
+
17
+ put_content_response = publishing_api.put_content(
18
+ options.fetch(:content_id),
19
+ base_path: options.fetch(:base_path),
20
+ document_type: options.fetch(:document_type, "special_route"),
21
+ schema_name: options.fetch(:schema_name, "special_route"),
22
+ title: options.fetch(:title),
23
+ description: options.fetch(:description, ""),
24
+ details: {},
25
+ routes: [
26
+ {
27
+ path: options.fetch(:base_path),
28
+ type: options.fetch(:type),
29
+ },
30
+ ],
31
+ publishing_app: options.fetch(:publishing_app),
32
+ rendering_app: options.fetch(:rendering_app),
33
+ public_updated_at: time.now.iso8601,
34
+ update_type:,
35
+ )
36
+
37
+ publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links]
38
+ publishing_api.publish(options.fetch(:content_id))
39
+ put_content_response
40
+ end
41
+
42
+ private
43
+
44
+ attr_reader :logger, :publishing_api
45
+
46
+ def time
47
+ (Time.respond_to?(:zone) && Time.zone) || Time
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublishingPlatformApi
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -20,6 +20,18 @@ module PublishingPlatformApi
20
20
  )
21
21
  end
22
22
 
23
+ # Creates a PublishingPlatformApi::Organisations adapter for accessing
24
+ # APIs through the origin, where the requests will be handled by
25
+ # Collections frontend.
26
+ #
27
+ # @return [PublishingPlatformApi::Organisations]
28
+ def self.organisations(options = {})
29
+ PublishingPlatformApi::Organisations.new(
30
+ PublishingPlatformLocation.new.website_root,
31
+ options,
32
+ )
33
+ end
34
+
23
35
  # Creates a PublishingPlatformApi::PublishingApi adapter
24
36
  #
25
37
  # This will set a bearer token if a PUBLISHING_API_BEARER_TOKEN environment
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publishing_platform_api_adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Publishing Platform
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-29 00:00:00.000000000 Z
10
+ date: 2025-02-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -95,7 +94,6 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  description: Adapters to work with Publishing Platform APIs
98
- email:
99
97
  executables: []
100
98
  extensions: []
101
99
  extra_rdoc_files: []
@@ -109,18 +107,18 @@ files:
109
107
  - lib/publishing_platform_api/json_client.rb
110
108
  - lib/publishing_platform_api/list_response.rb
111
109
  - lib/publishing_platform_api/middleware/publishing_platform_header_sniffer.rb
110
+ - lib/publishing_platform_api/organisations.rb
112
111
  - lib/publishing_platform_api/publishing_api.rb
112
+ - lib/publishing_platform_api/publishing_api/special_route_publisher.rb
113
113
  - lib/publishing_platform_api/publishing_platform_headers.rb
114
114
  - lib/publishing_platform_api/railtie.rb
115
115
  - lib/publishing_platform_api/response.rb
116
116
  - lib/publishing_platform_api/router.rb
117
117
  - lib/publishing_platform_api/version.rb
118
118
  - lib/publishing_platform_api_adapters.rb
119
- homepage:
120
119
  licenses:
121
120
  - MIT
122
121
  metadata: {}
123
- post_install_message:
124
122
  rdoc_options: []
125
123
  require_paths:
126
124
  - lib
@@ -135,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
133
  - !ruby/object:Gem::Version
136
134
  version: '0'
137
135
  requirements: []
138
- rubygems_version: 3.5.23
139
- signing_key:
136
+ rubygems_version: 3.6.3
140
137
  specification_version: 4
141
138
  summary: Adapters to work with Publishing Platform APIs
142
139
  test_files: []