Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"generatorConfig": {
"moduleName": "CloudPDF"
},
"originGitCommit": "07aa3f26c82243b36a5ec94f7072130c7298d977",
"originGitCommit": "3a88df90980e5c0546a5ebbfd1252d8fca77ff9b",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0.alpha.17",
"requestedVersion": "3.0.0.alpha.18",
"ciProvider": "github"
}
8 changes: 4 additions & 4 deletions cloudpdf-generation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"language": "ruby",
"canonicalVersion": "3.0.0-next.17",
"sdkVersion": "3.0.0.alpha.17",
"canonicalVersion": "3.0.0-next.18",
"sdkVersion": "3.0.0.alpha.18",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "8fa53cef2776eb0de9ec50c263aa547b309a04d1a2ecb6ee54b6338d6698dc00",
"gitCommit": "07aa3f26c82243b36a5ec94f7072130c7298d977",
"openapiSha256": "ad2a3baa628061e7b3e8b597cfd15bcda7f103d0f829cb01388a0fed6c4f5873",
"gitCommit": "3a88df90980e5c0546a5ebbfd1252d8fca77ff9b",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
5 changes: 5 additions & 0 deletions lib/CloudPDF/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def documents
@documents ||= CloudPDF::Documents::Client.new(client: @raw_client)
end

# @return [CloudPDF::Folders::Client]
def folders
@folders ||= CloudPDF::Folders::Client.new(client: @raw_client)
end

# @return [CloudPDF::Tokens::Client]
def tokens
@tokens ||= CloudPDF::Tokens::Client.new(client: @raw_client)
Expand Down
9 changes: 5 additions & 4 deletions lib/CloudPDF/doc/signatures/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ def cancel(request_options: {}, **params)
end

# `cms` is the detached CMS over the prepared digest, base64. `expectedVersion` must be what prepare returned.
# Idempotent by signing id: the same CMS again answers `already-completed`. Every layer of the document then
# sits over the new version; refetch the manifest after a completion.
# Idempotent by signing id: the same CMS again answers `already-completed`. The new version is the layer's own:
# only this layer moves to it, and the document and every other layer stay as they were. Refetch the manifest
# after a completion.
#
# @param request_options [Hash]
# @param params [CloudPDF::Doc::Signatures::Types::DocSignaturesCompleteRequest]
Expand Down Expand Up @@ -224,8 +225,8 @@ def analysis(request_options: {}, **params)
# Multipart: a JSON `body` part (field, subFilter, digest, contentsSize, signer, certify, lock), naming the
# appearance PDF it may carry as `resources: { appearance: '<key>' }`, and that PDF as the part
# `resource:<key>`. A certification (`certify.permission`) additionally requires `doc.sign.certify`. The layer
# is read-only until the signing completes, is cancelled, or expires (15 minutes). A layer behind the document
# head cannot sign (StaleBase).
# is read-only until the signing completes, is cancelled, or expires (15 minutes). The signature is made over
# the layer's own base: the upload, or the version its last signature made.
#
# @param request_options [Hash]
# @param params [void]
Expand Down
37 changes: 27 additions & 10 deletions lib/CloudPDF/doc/versions/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def initialize(client:)
@client = client
end

# Every completed signature publishes a new version. Never cached: the list grows.
# Every completed signature makes a new version of its layer; another layer's versions are never listed. Never
# cached: the list grows.
#
# @param request_options [Hash]
# @param params [Hash]
Expand All @@ -21,10 +22,14 @@ def initialize(client:)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String, nil] :document_password
#
# @example
# client.doc.versions.list(doc_id: "docId")
# client.doc.versions.list(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::DocVersionsList200Response]
def list(request_options: {}, **params)
Expand All @@ -35,7 +40,7 @@ def list(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions",
headers: headers,
request_options: request_options
)
Expand All @@ -54,7 +59,7 @@ def list(request_options: {}, **params)
end

# Exactly one of `since.signature` / `since.revision`; `until=<revision>` defaults to the last. The same answer
# for every layer and every caller.
# for every caller.
#
# @param request_options [Hash]
# @param params [Hash]
Expand All @@ -64,6 +69,7 @@ def list(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [Integer, nil] :since_signature
# @option params [Integer, nil] :since_revision
Expand All @@ -75,6 +81,7 @@ def list(request_options: {}, **params)
# @example
# client.doc.versions.analysis(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha"
# )
#
Expand All @@ -94,7 +101,7 @@ def analysis(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/analysis/#{URI.encode_uri_component(params[:sha].to_s)}",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/analysis/#{URI.encode_uri_component(params[:sha].to_s)}",
headers: headers,
query: query_params,
request_options: request_options
Expand All @@ -121,12 +128,14 @@ def analysis(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [String, nil] :document_password
#
# @example
# client.doc.versions.download(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha"
# )
#
Expand All @@ -139,7 +148,7 @@ def download(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/download/#{URI.encode_uri_component(params[:sha].to_s)}",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/download/#{URI.encode_uri_component(params[:sha].to_s)}",
headers: headers,
request_options: request_options
)
Expand All @@ -163,13 +172,15 @@ def download(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [Integer] :index
# @option params [String, nil] :document_password
#
# @example
# client.doc.versions.revision(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha",
# index: 1
# )
Expand All @@ -183,7 +194,7 @@ def revision(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/revisions/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:index].to_s)}",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/revisions/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:index].to_s)}",
headers: headers,
request_options: request_options
)
Expand All @@ -207,12 +218,14 @@ def revision(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [String, nil] :document_password
#
# @example
# client.doc.versions.signatures(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha"
# )
#
Expand All @@ -225,7 +238,7 @@ def signatures(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}",
headers: headers,
request_options: request_options
)
Expand Down Expand Up @@ -253,13 +266,15 @@ def signatures(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [String] :field_key
# @option params [String, nil] :document_password
#
# @example
# client.doc.versions.signature_contents(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha",
# field_key: "fieldKey"
# )
Expand All @@ -273,7 +288,7 @@ def signature_contents(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:field_key].to_s)}/contents",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:field_key].to_s)}/contents",
headers: headers,
request_options: request_options
)
Expand All @@ -299,6 +314,7 @@ def signature_contents(request_options: {}, **params)
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :doc_id
# @option params [String] :layer_name
# @option params [String] :sha
# @option params [String] :field_key
# @option params [CloudPDF::Doc::Versions::Types::SignatureDigestVersionsRequestAlgorithm] :algorithm
Expand All @@ -307,6 +323,7 @@ def signature_contents(request_options: {}, **params)
# @example
# client.doc.versions.signature_digest(
# doc_id: "docId",
# layer_name: "layerName",
# sha: "sha",
# field_key: "fieldKey",
# algorithm: "sha1"
Expand All @@ -321,7 +338,7 @@ def signature_digest(request_options: {}, **params)
request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "GET",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:field_key].to_s)}/digest/#{URI.encode_uri_component(params[:algorithm].to_s)}",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/versions/signatures/#{URI.encode_uri_component(params[:sha].to_s)}/#{URI.encode_uri_component(params[:field_key].to_s)}/digest/#{URI.encode_uri_component(params[:algorithm].to_s)}",
headers: headers,
request_options: request_options
)
Expand Down
2 changes: 2 additions & 0 deletions lib/CloudPDF/doc/versions/types/analysis_versions_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class AnalysisVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :since_signature, -> { Integer }, optional: true, nullable: false, api_name: "since.signature"
Expand Down
2 changes: 2 additions & 0 deletions lib/CloudPDF/doc/versions/types/download_versions_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class DownloadVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
Expand Down
2 changes: 2 additions & 0 deletions lib/CloudPDF/doc/versions/types/list_versions_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class ListVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/CloudPDF/doc/versions/types/revision_versions_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class RevisionVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :index, -> { Integer }, optional: false, nullable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class SignatureContentsVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :field_key, -> { String }, optional: false, nullable: false, api_name: "fieldKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class SignatureDigestVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :field_key, -> { String }, optional: false, nullable: false, api_name: "fieldKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Types
class SignaturesVersionsRequest < Internal::Types::Model
field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"

field :layer_name, -> { String }, optional: false, nullable: false, api_name: "layerName"

field :sha, -> { String }, optional: false, nullable: false

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
Expand Down
55 changes: 55 additions & 0 deletions lib/CloudPDF/documents/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def initialize(client:)
# @option params [Integer, nil] :limit
# @option params [String, nil] :cursor
# @option params [CloudPDF::Documents::Types::ListDocumentsRequestState, nil] :state
# @option params [String, nil] :q
# @option params [String, nil] :folder_id
# @option params [CloudPDF::Documents::Types::ListDocumentsRequestSort, nil] :sort
# @option params [CloudPDF::Documents::Types::ListDocumentsRequestOrder, nil] :order
#
# @example
# client.documents.list(tenant_id: "tenantId")
Expand All @@ -32,6 +36,10 @@ def list(request_options: {}, **params)
query_params["limit"] = params[:limit] if params.key?(:limit)
query_params["cursor"] = params[:cursor] if params.key?(:cursor)
query_params["state"] = params[:state] if params.key?(:state)
query_params["q"] = params[:q] if params.key?(:q)
query_params["folderId"] = params[:folder_id] if params.key?(:folder_id)
query_params["sort"] = params[:sort] if params.key?(:sort)
query_params["order"] = params[:order] if params.key?(:order)

request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
Expand Down Expand Up @@ -130,6 +138,53 @@ def delete(request_options: {}, **params)
raise error_class.new(response.body, code: code)
end

# A document that is being deleted answers 404.
#
# @param request_options [Hash]
# @param params [CloudPDF::Documents::Types::DocumentsUpdateRequest]
# @option request_options [String] :base_url
# @option request_options [Hash{String => Object}] :additional_headers
# @option request_options [Hash{String => Object}] :additional_query_parameters
# @option request_options [Hash{String => Object}] :additional_body_parameters
# @option request_options [Integer] :timeout_in_seconds
# @option params [String] :tenant_id
# @option params [String] :id
#
# @example
# client.documents.update(
# tenant_id: "tenantId",
# id: "id",
# name: "name"
# )
#
# @return [CloudPDF::Types::DocumentsUpdate200Response]
def update(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
request_data = CloudPDF::Documents::Types::DocumentsUpdateRequest.new(params).to_h
non_body_param_names = %w[tenantId id]
body = request_data.except(*non_body_param_names)

request = CloudPDF::Internal::JSON::Request.new(
base_url: request_options[:base_url],
method: "PATCH",
path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/documents/#{URI.encode_uri_component(params[:id].to_s)}",
body: body,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
if code.between?(200, 299)
(response.body.to_s.empty? ? nil : CloudPDF::Types::DocumentsUpdate200Response.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end

# @param request_options [Hash]
# @param params [CloudPDF::Documents::Types::DocumentsCommitRequest]
# @option request_options [String] :base_url
Expand Down
Loading
Loading