Class: PoliPage::DocumentDescriptor

Inherits:
Data
  • Object
show all
Defined in:
lib/poli_page/models/document_descriptor.rb

Overview

The stored-document descriptor returned by ‘client.render.document` and the `client.documents.*` methods. Carries every wire field plus an SDK-attached `_client` back-reference used by `#download_pdf`.

The ‘_client` field is hidden from `#to_h` and `#inspect` so it doesn’t leak into logs or marshalled representations (sdk-ruby-plan.md §3.4).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_clientObject (readonly)

Returns the value of attribute _client

Returns:

  • (Object)

    the current value of _client



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def _client
  @_client
end

#api_key_idObject (readonly)

Returns the value of attribute api_key_id

Returns:

  • (Object)

    the current value of api_key_id



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def api_key_id
  @api_key_id
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def created_at
  @created_at
end

#document_idObject (readonly)

Returns the value of attribute document_id

Returns:

  • (Object)

    the current value of document_id



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def document_id
  @document_id
end

#environmentObject (readonly)

Returns the value of attribute environment

Returns:

  • (Object)

    the current value of environment



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def environment
  @environment
end

#expires_atObject (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def expires_at
  @expires_at
end

#formatObject (readonly)

Returns the value of attribute format

Returns:

  • (Object)

    the current value of format



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def format
  @format
end

#localeObject (readonly)

Returns the value of attribute locale

Returns:

  • (Object)

    the current value of locale



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def locale
  @locale
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def 
  @metadata
end

#organization_idObject (readonly)

Returns the value of attribute organization_id

Returns:

  • (Object)

    the current value of organization_id



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def organization_id
  @organization_id
end

#orientationObject (readonly)

Returns the value of attribute orientation

Returns:

  • (Object)

    the current value of orientation



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def orientation
  @orientation
end

#page_countObject (readonly)

Returns the value of attribute page_count

Returns:

  • (Object)

    the current value of page_count



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def page_count
  @page_count
end

#presigned_pdf_urlObject (readonly)

Returns the value of attribute presigned_pdf_url

Returns:

  • (Object)

    the current value of presigned_pdf_url



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def presigned_pdf_url
  @presigned_pdf_url
end

#project_idObject (readonly)

Returns the value of attribute project_id

Returns:

  • (Object)

    the current value of project_id



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def project_id
  @project_id
end

#project_slugObject (readonly)

Returns the value of attribute project_slug

Returns:

  • (Object)

    the current value of project_slug



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def project_slug
  @project_slug
end

#size_bytesObject (readonly)

Returns the value of attribute size_bytes

Returns:

  • (Object)

    the current value of size_bytes



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def size_bytes
  @size_bytes
end

#template_idObject (readonly)

Returns the value of attribute template_id

Returns:

  • (Object)

    the current value of template_id



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def template_id
  @template_id
end

#template_slugObject (readonly)

Returns the value of attribute template_slug

Returns:

  • (Object)

    the current value of template_slug



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def template_slug
  @template_slug
end

#versionObject (readonly)

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



10
11
12
# File 'lib/poli_page/models/document_descriptor.rb', line 10

def version
  @version
end

Instance Method Details

#download_pdfString

Fetch the PDF bytes from ‘presigned_pdf_url`. The URL has a ~15-minute TTL — if it expired, call `client.documents.get(document_id)` to refresh and retry.

Returns:

  • (String)

    raw PDF bytes (binary-encoded)

Raises:



38
39
40
41
42
# File 'lib/poli_page/models/document_descriptor.rb', line 38

def download_pdf
  raise PoliPage::InternalError, "DocumentDescriptor missing client back-reference" if _client.nil?

  _client.fetch_bytes(presigned_pdf_url)
end

#inspectObject



48
49
50
# File 'lib/poli_page/models/document_descriptor.rb', line 48

def inspect
  "#<PoliPage::DocumentDescriptor document_id=#{document_id.inspect} ...>"
end

#to_hObject



44
45
46
# File 'lib/poli_page/models/document_descriptor.rb', line 44

def to_h
  super.except(:_client)
end