Class: Ledger::Sdk::Models::Import
- Defined in:
- lib/ledger/sdk/models/import.rb
Overview
Represents the collection of imports from the Ledger API.
Imports are the SDK's only write path into positions and movements: the
Ledger REST routes for both are +index+/+show+ only, so every line that
reaches the ledger goes through POST /imports. The import also creates
the container and the accounts it names, on first sight, by natural key —
there is no separate "create a container" call to make.
Processing is asynchronous: a fresh import comes back pending and the
returned data carries the counts (+total_count+, imported_count,
failure_count), the status and the lines, each with its own error
once processed.
Defined Under Namespace
Classes: Instance
Instance Method Summary collapse
-
#create(filename:, positions: [], movements: [], provider_id: nil) ⇒ Instance
Creates an import from position and/or movement lines.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Ledger::Sdk::Models::Base
Instance Method Details
#create(filename:, positions: [], movements: [], provider_id: nil) ⇒ Instance
Creates an import from position and/or movement lines.
The body is posted FLAT — unlike Fee#create, which wraps its
attributes under a fee key. Ledger's ImportsController reads
params[:filename], params[:positions] and params[:movements] at
the top level: wrapping them would post an import with no lines at all,
answered by a 422 no_lines_provided.
The line shapes are not validated here: Ledger's own JSON schema is the
gate, and a second copy of it in the SDK would drift from it. Sending
two empty lists yields a 422 no_lines_provided.