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": "0606e988ebff3773183ef02e0a820c36b3a25f8d",
"originGitCommit": "622018abaf6e4578d1f4d8377982c48b92c9ced3",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0.alpha.19",
"requestedVersion": "3.0.0.alpha.20",
"ciProvider": "github"
}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ client.doc.changes(

## Environments

This SDK allows you to configure different custom URLs for API requests. You can specify your own custom URL.
This SDK allows you to configure different environments or custom URLs for API requests. You can either use the predefined environments or specify your own custom URL.
### Environments
```ruby
require "cloudpdf"

CloudPDF = CloudPDF::Client.new(
base_url: CloudPDF::Environment::SAAS
)
```

### Custom URL
```ruby
Expand Down
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.19",
"sdkVersion": "3.0.0.alpha.19",
"canonicalVersion": "3.0.0-next.20",
"sdkVersion": "3.0.0.alpha.20",
"source": {
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "e88e02ed71f422ad08b2393abeda474e8dcf6707b6e753af74ba2f40da8e7d6b",
"gitCommit": "0606e988ebff3773183ef02e0a820c36b3a25f8d",
"openapiSha256": "47d739acb956ce8ba0c3990117e505be2e9406038d9e0cd1729608921a40b2d9",
"gitCommit": "622018abaf6e4578d1f4d8377982c48b92c9ced3",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
2 changes: 1 addition & 1 deletion lib/CloudPDF/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Client
# @return [void]
def initialize(token:, base_url: nil, max_retries: 2)
@raw_client = CloudPDF::Internal::Http::RawClient.new(
base_url: base_url,
base_url: base_url || CloudPDF::Environment::SAAS,
headers: {
"X-Fern-Language" => "Ruby",
Authorization: "Bearer #{token}"
Expand Down
5 changes: 5 additions & 0 deletions lib/CloudPDF/doc/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ def attachments
@attachments ||= CloudPDF::Doc::Attachments::Client.new(client: @client)
end

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

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

module CloudPDF
module Doc
module Fonts
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.fonts.list(
# doc_id: "docId",
# layer_name: "layerName"
# )
#
# @return [CloudPDF::Types::FontList]
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)}/fonts",
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::DocFontsList200Response.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::DocFontsResolveRequest]
# @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.fonts.resolve(
# doc_id: "docId",
# layer_name: "layerName",
# runs: [{
# text: "text"
# }]
# )
#
# @return [CloudPDF::Types::FontResolution]
def resolve(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)}/fonts/resolve",
headers: headers,
body: CloudPDF::Types::FontResolveRequest.new(body_params).to_h,
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::DocFontsResolve200Response.load(response.body))
else
error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
raise error_class.new(response.body, code: code)
end
end

# @return [CloudPDF::Programs::Client]
def programs
@programs ||= CloudPDF::Doc::Fonts::Programs::Client.new(client: @client)
end
end
end
end
end
111 changes: 111 additions & 0 deletions lib/CloudPDF/doc/fonts/programs/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# frozen_string_literal: true

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

# A document token needs any one of the listed capabilities: one that may write text in the document. A file
# the list says can't be downloaded (`canDownload: false`) is not found.
#
# @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] :display_hash
# @option params [String, nil] :document_password
#
# @example
# client.doc.fonts.programs.download(
# doc_id: "docId",
# layer_name: "layerName",
# display_hash: "displayHash"
# )
#
# @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)}/font-program-files/#{URI.encode_uri_component(params[:display_hash].to_s)}",
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 [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] :display_hash
# @option params [String, nil] :document_password
#
# @example
# client.doc.fonts.programs.get(
# doc_id: "docId",
# layer_name: "layerName",
# display_hash: "displayHash"
# )
#
# @return [CloudPDF::Types::FontProgramInfo]
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)}/font-programs/#{URI.encode_uri_component(params[:display_hash].to_s)}",
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::DocFontsProgramsGet200Response.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
end
21 changes: 21 additions & 0 deletions lib/CloudPDF/doc/fonts/programs/types/download_programs_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Fonts
module Programs
module Types
class DownloadProgramsRequest < 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 :display_hash, -> { String }, optional: false, nullable: false, api_name: "displayHash"

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
end
end
end
end
21 changes: 21 additions & 0 deletions lib/CloudPDF/doc/fonts/programs/types/get_programs_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module CloudPDF
module Doc
module Fonts
module Programs
module Types
class GetProgramsRequest < 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 :display_hash, -> { String }, optional: false, nullable: false, api_name: "displayHash"

field :document_password, -> { String }, optional: true, nullable: false, api_name: "X-Document-Password"
end
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/CloudPDF/doc/fonts/types/list_fonts_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 Fonts
module Types
class ListFontsRequest < 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
19 changes: 19 additions & 0 deletions lib/CloudPDF/doc/fonts/types/resolve_fonts_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 Fonts
module Types
class ResolveFontsRequest < 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, -> { CloudPDF::Types::FontResolveRequest }, optional: false, nullable: false
end
end
end
end
end
Loading
Loading