publishing_platform_api_adapters 0.3.0 → 0.4.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: 3dc1965a7fe4e5b519636780d4a6cbd07b0475259d44b49f89128aa80ec3fd13
4
- data.tar.gz: ef68c7200b15791b97df9da45a7a7264d7b5071d112fda4370308b8ce35285f5
3
+ metadata.gz: 6d5184264eb9e2b1bb5c025980563ad23348940805a21fae7f1f43018f1e1b19
4
+ data.tar.gz: b2c57528a81f4e8dc7b5e615ac1c596f6a2035d04f1a47926ac28bd234035e6b
5
5
  SHA512:
6
- metadata.gz: 5b16bac63f4f8b91c3574789095996c39eeac770fe15e7cddc057466067d94e3bd5c07ee4b7116a63da6322a2ecb00f1149771bd6c62728deda7acbb7054566e
7
- data.tar.gz: 1f381f2e20bc0ca385d9f7fc291d8ed00924a124a35ebe272169149be4a41a95245dd4258cb501bc198637ed0c42caf841fa1535abfb671840a6cecfa50ff512
6
+ metadata.gz: f9de58b5a14da0ee00752bf7cb940f97d9ef9bcb1301a12e380bae23ad50e6ccef56e66387cd89e197d047c92de576676623d9a970ed9475638e66c8d6a10252
7
+ data.tar.gz: 268df30f6a6806f315d92fe1fc00a8a46c4c52b75b505988756b460b5bf2a00912656113c855ef987cea611f9187e0ca2be7154c44e75ee17db63f6bbc301e63
@@ -102,6 +102,61 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
102
102
  post_json(discard_url(content_id), params)
103
103
  end
104
104
 
105
+ # Get the link set for the given content_id.
106
+ #
107
+ # Given a Content ID, it fetchs the existing link set and their version.
108
+ #
109
+ # @param content_id [String]
110
+ #
111
+ # @return [PublishingPlatformApi::Response] A response containing `links` and `version`.
112
+ #
113
+ # @example
114
+ #
115
+ # publishing_api.get_links("a-content-id")
116
+ # # => {
117
+ # "content_id" => "a-content-id",
118
+ # "links" => [
119
+ # "organisation" => "organisation-content-id",
120
+ # "document_collection" => "document-collection-content-id"
121
+ # ],
122
+ # "version" => 17
123
+ # }
124
+ def get_links(content_id)
125
+ get_json(links_url(content_id))
126
+ end
127
+
128
+ # Get expanded links
129
+ #
130
+ # Return the expanded links of the item.
131
+ #
132
+ # @param content_id [UUID]
133
+ # @param with_drafts [Bool] Whether links to draft-only editions are returned, defaulting to `true`.
134
+ # @param generate [Bool] Whether to require publishing-api to generate the expanded links, which may be slow. Defaults to `false`.
135
+ #
136
+ # @example
137
+ #
138
+ # publishing_api.get_expanded_links("8157589b-65e2-4df6-92ba-2c91d80006c0", with_drafts: false).to_h
139
+ #
140
+ # #=> {
141
+ # "generated" => "2017-08-01T10:42:49Z",
142
+ # "expanded_links" => {
143
+ # "organisations" => [
144
+ # {
145
+ # "content_id" => "21aa83a2-a47f-4189-a252-b02f8c322012",
146
+ # ... (and more attributes)
147
+ # }
148
+ # ]
149
+ # }
150
+ # }
151
+ def get_expanded_links(content_id, with_drafts: true, generate: false)
152
+ params = {}
153
+ params[:with_drafts] = "false" unless with_drafts
154
+ params[:generate] = "true" if generate
155
+ query = query_string(params)
156
+ validate_content_id(content_id)
157
+ get_json("#{endpoint}/expanded-links/#{content_id}#{query}")
158
+ end
159
+
105
160
  # Patch the links of a content item
106
161
  #
107
162
  # @param content_id [UUID]
@@ -152,6 +207,15 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
152
207
  get_json("#{endpoint}/content#{query}")
153
208
  end
154
209
 
210
+ # FIXME: Add documentation
211
+ def get_linkables(document_type: nil)
212
+ if document_type.nil?
213
+ raise ArgumentError, "Please provide a `document_type`"
214
+ end
215
+
216
+ get_json("#{endpoint}/linkables?document_type=#{document_type}")
217
+ end
218
+
155
219
  # Reserves a path for a publishing application
156
220
  #
157
221
  # Returns success or failure only.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublishingPlatformApi
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  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.3.0
4
+ version: 0.4.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-18 00:00:00.000000000 Z
11
+ date: 2024-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable