Class: DocFox::DocumentToken::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- DocFox::DocumentToken::CreateService
- Defined in:
- lib/doc_fox/document_token/create_service.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#document_id ⇒ Object
readonly
Returns the value of attribute document_id.
Instance Method Summary collapse
-
#call ⇒ Object
Create a document token.
-
#initialize(document_id:, data:) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(document_id:, data:) ⇒ CreateService
Returns a new instance of CreateService.
12 13 14 15 |
# File 'lib/doc_fox/document_token/create_service.rb', line 12 def initialize(document_id:, data:) @document_id = document_id @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/doc_fox/document_token/create_service.rb', line 4 def data @data end |
#document_id ⇒ Object (readonly)
Returns the value of attribute document_id.
4 5 6 |
# File 'lib/doc_fox/document_token/create_service.rb', line 4 def document_id @document_id end |
Instance Method Details
#call ⇒ Object
Create a document token.
Examples
service = DocFox::DocumentToken::CreateService.call(
document_id: '',
data: {
type: 'document_token'
}
)
service.success? # => true
service.errors # => #<ActiveModel::Errors []>
service.response # => #<Faraday::Response ...>
service.response.status # => 201
service.response.body # => {}
service.facade # => #<DocFox::DocumentToken::Facade ...>
service.facade.id
service.id
POST /api/v2/documents/:document_id/document_tokens
42 43 44 |
# File 'lib/doc_fox/document_token/create_service.rb', line 42 def call connection.post("documents/#{document_id}/document_tokens", **params) end |