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": "c6f87eecf9636e7ef367946a7fd7f3729401ce90",
"originGitCommit": "7ded7de29f4cc0dc9da18042fca6afd5c9557bfc",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0.alpha.15",
"requestedVersion": "3.0.0.alpha.16",
"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.15",
"sdkVersion": "3.0.0.alpha.15",
"canonicalVersion": "3.0.0-next.16",
"sdkVersion": "3.0.0.alpha.16",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "9d70deca638cc7a80b0e670ec47fc45710d6603eb8f493d5fac95a38d7e5f8b3",
"gitCommit": "c6f87eecf9636e7ef367946a7fd7f3729401ce90",
"openapiSha256": "06543c26918bd79d426bf242c5a3091cdb7d298d3ac3296addabee2be80edb15",
"gitCommit": "7ded7de29f4cc0dc9da18042fca6afd5c9557bfc",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
48 changes: 48 additions & 0 deletions lib/CloudPDF/doc/annotations/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,54 @@ def read_appearance(request_options: {}, **params)
raise error_class.new(response.body, code: code)
end

# A file that decodes past the server's limit is refused (PayloadTooLarge).
#
# @param request_options [Hash]
# @param params [Hash]
# @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] :doc_id
# @option params [String] :layer_name
# @option params [String] :page_key
# @option params [String] :annot_key
# @option params [String, nil] :document_password
#
# @example
# client.doc.annotations.read_file(
# doc_id: "docId",
# layer_name: "layerName",
# page_key: "pageKey",
# annot_key: "annotKey"
# )
#
# @return [untyped]
def read_file(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

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)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/annotations/pages/#{URI.encode_uri_component(params[:page_key].to_s)}/items/#{URI.encode_uri_component(params[:annot_key].to_s)}/resources/file",
headers: headers,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
return if code.between?(200, 299)

error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end

# @param request_options [Hash]
# @param params [CloudPDF::Types::DocAnnotationsExportAppearanceRequest]
# @option request_options [String] :base_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

module CloudPDF
module Doc
module Pages
module Annotations
module Types
class DeletePagesRequest < Internal::Types::Model
class ReadFileAnnotationsRequest < 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"
field :page_key, -> { String }, optional: false, nullable: false, api_name: "pageKey"

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "Idempotency-Key"
field :annot_key, -> { String }, optional: false, nullable: false, api_name: "annotKey"

field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
end
Expand Down
109 changes: 109 additions & 0 deletions lib/CloudPDF/doc/attachments/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Attachments
class Client
# @param client [CloudPDF::Internal::Http::RawClient]
#
# @return [void]
def initialize(client:)
@client = client
end

# A file that decodes past the server's limit is refused (PayloadTooLarge).
#
# @param request_options [Hash]
# @param params [Hash]
# @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] :doc_id
# @option params [String] :layer_name
# @option params [String] :file_key
# @option params [String, nil] :document_password
#
# @example
# client.doc.attachments.download(
# doc_id: "docId",
# layer_name: "layerName",
# file_key: "fileKey"
# )
#
# @return [untyped]
def download(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

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)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/attachment-files/#{URI.encode_uri_component(params[:file_key].to_s)}/data",
headers: headers,
request_options: request_options
)
begin
response = @client.send(request)
rescue Net::HTTPRequestTimeout
raise CloudPDF::Errors::TimeoutError
end
code = response.code.to_i
return if code.between?(200, 299)

error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end

# A file-attachment annotation's file is listed with the annotation; read its bytes with
# `doc.annotations.readFile`.
#
# @param request_options [Hash]
# @param params [Hash]
# @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] :doc_id
# @option params [String] :layer_name
# @option params [String, nil] :document_password
#
# @example
# client.doc.attachments.list(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::AttachmentList]
def list(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

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)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/attachments",
headers: headers,
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::DocAttachmentsList200Response.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

module CloudPDF
module Doc
module Pages
module Attachments
module Types
class InsertPagesRequest < Internal::Types::Model
class DownloadAttachmentsRequest < 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"
field :file_key, -> { String }, optional: false, nullable: false, api_name: "fileKey"

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "Idempotency-Key"
field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

module CloudPDF
module Doc
module Pages
module Attachments
module Types
class RotatePagesRequest < Internal::Types::Model
class ListAttachmentsRequest < 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"

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "Idempotency-Key"

field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
end
end
end
Expand Down
19 changes: 15 additions & 4 deletions lib/CloudPDF/doc/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def head(request_options: {}, **params)
# request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a
# form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked
# against its own capability: annotation ops need `doc.annotate.modify`, form values `doc.forms.fill`, form
# structure `doc.forms.modify`, metadata `doc.metadata.modify`. Bytes (a stamp's drawing, an attached file, a
# signature's artwork) travel as multipart: a JSON `body` part, each op naming its files by role as `resources: {
# <role>: '<key>' }`, and each file as the part `resource:<key>`. At most 64 changes per request and 512 ops per
# change.
# structure `doc.forms.modify`, metadata `doc.metadata.modify`, outline `doc.outline.modify`, pages
# `doc.pages.assemble`, embedded files `doc.attachments.modify`. Bytes (a stamp's drawing, an attached file, a
# signature's artwork, a PDF whose pages come in) travel as multipart: a JSON `body` part, each op naming its
# files by role as `resources: { <role>: '<key>' }`, and each file as the part `resource:<key>`. At most 64
# changes per request and 512 ops per change.
#
# @param request_options [Hash]
# @param params [CloudPDF::Doc::Types::DocChangesRequest]
Expand Down Expand Up @@ -298,6 +299,11 @@ def annotations
@annotations ||= CloudPDF::Doc::Annotations::Client.new(client: @client)
end

# @return [CloudPDF::Attachments::Client]
def attachments
@attachments ||= CloudPDF::Doc::Attachments::Client.new(client: @client)
end

# @return [CloudPDF::Forms::Client]
def forms
@forms ||= CloudPDF::Doc::Forms::Client.new(client: @client)
Expand All @@ -308,6 +314,11 @@ def metadata
@metadata ||= CloudPDF::Doc::Metadata::Client.new(client: @client)
end

# @return [CloudPDF::Outline::Client]
def outline
@outline ||= CloudPDF::Doc::Outline::Client.new(client: @client)
end

# @return [CloudPDF::Pages::Client]
def pages
@pages ||= CloudPDF::Doc::Pages::Client.new(client: @client)
Expand Down
60 changes: 60 additions & 0 deletions lib/CloudPDF/doc/outline/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Outline
class Client
# @param client [CloudPDF::Internal::Http::RawClient]
#
# @return [void]
def initialize(client:)
@client = client
end

# @param request_options [Hash]
# @param params [Hash]
# @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] :doc_id
# @option params [String] :layer_name
# @option params [String, nil] :document_password
#
# @example
# client.doc.outline.get(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::DocumentOutline]
def get(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
headers = {}
headers["X-Document-Password"] = params[:document_password] if params[:document_password]

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)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/outline",
headers: headers,
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::DocOutlineGet200Response.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

module CloudPDF
module Doc
module Pages
module Outline
module Types
class InsertBlankPagesRequest < Internal::Types::Model
class GetOutlineRequest < 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"

field :idempotency_key, -> { String }, optional: true, nullable: false, api_name: "Idempotency-Key"

field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
end
end
end
Expand Down
Loading
Loading