Class: DocFox::Document::GetService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/doc_fox/document/get_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, params: {}) ⇒ GetService

Returns a new instance of GetService.



12
13
14
15
# File 'lib/doc_fox/document/get_service.rb', line 12

def initialize(id:, params: {})
  @id     = id
  @params = params
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/doc_fox/document/get_service.rb', line 4

def id
  @id
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/doc_fox/document/get_service.rb', line 4

def params
  @params
end

Instance Method Details

#callObject

Get a document.

https://www.docfoxapp.com/api/v2/documentation#tag/Documents/paths/~1api~1v2~1documents~1%7Bdocument_id%7D/get

Examples

service = DocFox::Document::GetService.call(id: '')

service.success? # => true
service.errors # => #<ActiveModel::Errors []>

service.response # => #<Faraday::Response ...>
service.response.status # => 200
service.response.body # => {}

service.facade # => #<DocFox::Document::Facade ...>
service.facade.id
service.id

service.relationships.dig('evidence_submissions', 'data')
service.relationships.dig('document_tokens', 'links', 'related')

Include related resources.

service = DocFox::Document::GetService.call(id: '', params: { include: 'evidence_submissions' })
service.included

GET /api/v2/documents/:id



45
46
47
# File 'lib/doc_fox/document/get_service.rb', line 45

def call
  connection.get("documents/#{id}", **params)
end