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": "20cebe429411ef5019c9e31fc7841d72b7fb98a8",
"originGitCommit": "e5cd0731cb3a1f2ed5821f8d60191bd58934c3dd",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0.alpha.8",
"requestedVersion": "3.0.0.alpha.9",
"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.8",
"sdkVersion": "3.0.0.alpha.8",
"canonicalVersion": "3.0.0-next.9",
"sdkVersion": "3.0.0.alpha.9",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "e997d51317662fe0666e6582916ded9b17a8bcd225c178548e1ff226e4d01c6d",
"gitCommit": "20cebe429411ef5019c9e31fc7841d72b7fb98a8",
"openapiSha256": "4ee27900dbb0b13408ce00a0e80d606444ab81e9d5a76186fa984c8c8dfe09fe",
"gitCommit": "e5cd0731cb3a1f2ed5821f8d60191bd58934c3dd",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
157 changes: 157 additions & 0 deletions lib/CloudPDF/doc/pages/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,60 @@ def delete(request_options: {}, **params)
end
end

# A read, not a mutation: the source document is untouched and no event is published. Body is
# `{"pageObjectNumbers": number[]}`; the response body is the new PDF.
#
# @param request_options [Hash]
# @param params [CloudPDF::Types::DocPagesExtractRequest]
# @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.pages.extract(
# doc_id: "docId",
# layer_name: "layerName",
# request: {
# string: {
# key: "value"
# }
# }
# )
#
# @return [untyped]
def extract(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
path_param_names = %i[doc_id layer_name]
body_params = params.except(*path_param_names)

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: "POST",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/pages/extract",
headers: headers,
body: body_params,
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::DocPagesFlattenRequest]
# @option request_options [String] :base_url
Expand Down Expand Up @@ -113,6 +167,109 @@ def flatten(request_options: {}, **params)
end
end

# Multipart mutation envelope: a `body` field holding `{"destIndex"?: number}` (omitted → append) plus a
# `resource:source` file part carrying the standalone PDF whose pages are copied in. The inserted copies get
# fresh page object numbers, returned in insertion order.
#
# @param request_options [Hash]
# @param params [void]
# @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.pages.insert(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::DocPagesInsert200Response]
def insert(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
body = Internal::Multipart::FormData.new

body.add_part(params[:file].to_form_data_part(name: "file")) if params[:file]

request = CloudPDF::Internal::Multipart::Request.new(
base_url: request_options[:base_url],
method: "POST",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/pages/insert",
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)
CloudPDF::Types::DocPagesInsert200Response.load(response.body)
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end

# Body is `{"size": {"width", "height"}, "count"?, "destIndex"?}` — size in PDF points, count in [1, 100],
# destIndex omitted → append.
#
# @param request_options [Hash]
# @param params [CloudPDF::Types::DocPagesInsertBlankRequest]
# @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.pages.insert_blank(
# doc_id: "docId",
# layer_name: "layerName",
# request: {
# key: "value"
# }
# )
#
# @return [CloudPDF::Types::DocPagesInsertBlank200Response]
def insert_blank(request_options: {}, **params)
params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
path_param_names = %i[doc_id layer_name]
body_params = params.except(*path_param_names)

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: "POST",
path: "v1/docs/#{URI.encode_uri_component(params[:doc_id].to_s)}/layers/#{URI.encode_uri_component(params[:layer_name].to_s)}/pages/insert-blank",
headers: headers,
body: body_params,
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)
CloudPDF::Types::DocPagesInsertBlank200Response.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::Types::DocPagesMoveRequest]
# @option request_options [String] :base_url
Expand Down
19 changes: 19 additions & 0 deletions lib/CloudPDF/doc/pages/types/extract_pages_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Pages
module Types
class ExtractPagesRequest < 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 :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/CloudPDF/doc/pages/types/insert_blank_pages_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Pages
module Types
class InsertBlankPagesRequest < 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 :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/CloudPDF/doc/pages/types/insert_pages_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Pages
module Types
class InsertPagesRequest < 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
end
end
end
15 changes: 15 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract400response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocPagesExtract400Response < Internal::Types::Model
field :name, -> { CloudPDF::Types::DocPagesExtract400ResponseName }, optional: false, nullable: false

field :code, -> { CloudPDF::Types::DocPagesExtract400ResponseCode }, optional: false, nullable: false

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

field :details, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
end
end
end
29 changes: 29 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract400response_code.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocPagesExtract400ResponseCode
extend CloudPDF::Internal::Types::Enum

UNKNOWN = "Unknown"
INVALID_ARG = "InvalidArg"
DOC_NOT_OPEN = "DocNotOpen"
DOC_OPEN_FAILED = "DocOpenFailed"
DOC_PASSWORD_REQUIRED = "DocPasswordRequired"
DOC_PASSWORD_INCORRECT = "DocPasswordIncorrect"
SHARE_PASSWORD_REQUIRED = "SharePasswordRequired"
ABORTED = "Aborted"
NETWORK = "Network"
UNAUTHENTICATED = "Unauthenticated"
FORBIDDEN = "Forbidden"
NOT_FOUND = "NotFound"
WIRE_FORMAT = "WireFormat"
RUNTIME_UNAVAILABLE = "RuntimeUnavailable"
INVALID_REFERENCE = "InvalidReference"
WEAK_ANNOTATION_SESSION_CONFLICT = "WeakAnnotationSessionConflict"
LAYER_VERSION_CONFLICT = "LayerVersionConflict"
NOT_IMPLEMENTED = "NotImplemented"
MALFORMED_PDF = "MalformedPdf"
end
end
end
11 changes: 11 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract400response_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocPagesExtract400ResponseName
extend CloudPDF::Internal::Types::Enum

ENGINE_ERROR = "EngineError"
end
end
end
15 changes: 15 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract404response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module CloudPDF
module Types
class DocPagesExtract404Response < Internal::Types::Model
field :name, -> { CloudPDF::Types::DocPagesExtract404ResponseName }, optional: false, nullable: false

field :code, -> { CloudPDF::Types::DocPagesExtract404ResponseCode }, optional: false, nullable: false

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

field :details, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
end
end
end
29 changes: 29 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract404response_code.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocPagesExtract404ResponseCode
extend CloudPDF::Internal::Types::Enum

UNKNOWN = "Unknown"
INVALID_ARG = "InvalidArg"
DOC_NOT_OPEN = "DocNotOpen"
DOC_OPEN_FAILED = "DocOpenFailed"
DOC_PASSWORD_REQUIRED = "DocPasswordRequired"
DOC_PASSWORD_INCORRECT = "DocPasswordIncorrect"
SHARE_PASSWORD_REQUIRED = "SharePasswordRequired"
ABORTED = "Aborted"
NETWORK = "Network"
UNAUTHENTICATED = "Unauthenticated"
FORBIDDEN = "Forbidden"
NOT_FOUND = "NotFound"
WIRE_FORMAT = "WireFormat"
RUNTIME_UNAVAILABLE = "RuntimeUnavailable"
INVALID_REFERENCE = "InvalidReference"
WEAK_ANNOTATION_SESSION_CONFLICT = "WeakAnnotationSessionConflict"
LAYER_VERSION_CONFLICT = "LayerVersionConflict"
NOT_IMPLEMENTED = "NotImplemented"
MALFORMED_PDF = "MalformedPdf"
end
end
end
11 changes: 11 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract404response_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocPagesExtract404ResponseName
extend CloudPDF::Internal::Types::Enum

ENGINE_ERROR = "EngineError"
end
end
end
23 changes: 23 additions & 0 deletions lib/CloudPDF/types/doc_pages_extract_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module CloudPDF
module Types
module DocPagesExtractRequest
# DocPagesExtractRequest is an alias for Hash

# @option str [String]
#
# @return [untyped]
def self.load(str)
::JSON.parse(str)
end

# @option value [untyped]
#
# @return [String]
def self.dump(value)
::JSON.generate(value)
end
end
end
end
Loading
Loading