Class: CloudPDF::Doc::Annotations::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/CloudPDF/doc/annotations/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



10
11
12
# File 'lib/CloudPDF/doc/annotations/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ CloudPDF::Types::DocAnnotationsCreate200Response

Doc JWTs may instead carry collab scopes (annotations:create:self, …) that refine per-annotation authorship rules; the API token is exempt from both.

Examples:

client.doc.annotations.create(
  doc_id: "docId",
  layer_name: "layerName",
  pon: 1,
  request: {
    key: "value"
  }
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :doc_id (String)
  • :layer_name (String)
  • :pon (Integer)
  • :document_password (String, nil)

Returns:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/CloudPDF/doc/annotations/client.rb', line 133

def create(request_options: {}, **params)
  params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[doc_id layer_name pon]
  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)}/annotations/pages/#{URI.encode_uri_component(params[:pon].to_s)}/items",
    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::DocAnnotationsCreate200Response.load(response.body)
  else
    error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ CloudPDF::Types::DocAnnotationsDelete200Response

Examples:

client.doc.annotations.delete(
  doc_id: "docId",
  layer_name: "layerName",
  pon: 1,
  annot_key: "annotKey"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :doc_id (String)
  • :layer_name (String)
  • :pon (Integer)
  • :annot_key (String)
  • :document_password (String, nil)

Returns:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/CloudPDF/doc/annotations/client.rb', line 185

def delete(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: "DELETE",
    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[:pon].to_s)}/items/#{URI.encode_uri_component(params[:annot_key].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)
    CloudPDF::Types::DocAnnotationsDelete200Response.load(response.body)
  else
    error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list(request_options: {}, **params) ⇒ CloudPDF::Types::DocAnnotationsList200Response

Examples:

client.doc.annotations.list(
  doc_id: "docId",
  layer_name: "layerName",
  pon: 1
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :doc_id (String)
  • :layer_name (String)
  • :pon (Integer)
  • :document_password (String, nil)

Returns:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/CloudPDF/doc/annotations/client.rb', line 81

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)}/annotations/pages/#{URI.encode_uri_component(params[:pon].to_s)}/items",
    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)
    CloudPDF::Types::DocAnnotationsList200Response.load(response.body)
  else
    error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_all(request_options: {}, **params) ⇒ CloudPDF::Types::DocAnnotationsListAll200Response

Returns one entry per page plus the audit-log cursor for reconciling subsequent document events. Page order is unspecified; join by pageState.pageObjectNumber when display order matters.

Examples:

client.doc.annotations.list_all(
  doc_id: "docId",
  layer_name: "layerName"
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :doc_id (String)
  • :layer_name (String)
  • :document_password (String, nil)

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/CloudPDF/doc/annotations/client.rb', line 35

def list_all(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/items",
    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)
    CloudPDF::Types::DocAnnotationsListAll200Response.load(response.body)
  else
    error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ CloudPDF::Types::DocAnnotationsUpdate200Response

Examples:

client.doc.annotations.update(
  doc_id: "docId",
  layer_name: "layerName",
  pon: 1,
  annot_key: "annotKey",
  request: {
    key: "value"
  }
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :doc_id (String)
  • :layer_name (String)
  • :pon (Integer)
  • :annot_key (String)
  • :document_password (String, nil)

Returns:



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/CloudPDF/doc/annotations/client.rb', line 236

def update(request_options: {}, **params)
  params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
  path_param_names = %i[doc_id layer_name pon annot_key]
  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: "PATCH",
    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[:pon].to_s)}/items/#{URI.encode_uri_component(params[:annot_key].to_s)}",
    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::DocAnnotationsUpdate200Response.load(response.body)
  else
    error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end