Module: Ledger::Sdk

Extended by:
Configuration
Defined in:
lib/ledger/sdk.rb,
lib/ledger/sdk/client.rb,
lib/ledger/sdk/version.rb,
lib/ledger/sdk/models/fee.rb,
lib/ledger/sdk/models/base.rb,
lib/ledger/sdk/configuration.rb,
lib/ledger/sdk/models/account.rb,
lib/ledger/sdk/models/balance.rb,
lib/ledger/sdk/models/fee_kind.rb,
lib/ledger/sdk/models/movement.rb,
lib/ledger/sdk/models/position.rb,
lib/ledger/sdk/models/container.rb,
lib/ledger/sdk/models/inventory.rb,
lib/ledger/sdk/models/fee_exclusion.rb

Overview

Main module of the Ledger SDK.

Provides factory methods to access API resources (containers and their nested accounts, positions, inventories, balances, fees and fee exclusions, plus the fee-kind registry) and configuration management via Configuration.

The SDK is mostly read-only: resources are browsed with list and data, chaining associations from container down to inventory. The write surface is narrow and explicit: a container's characteristics (+Container::Instance#update+) and its fees/fee-exclusions (+create+/+update+/+destroy+ via Container::Instance#fees and #fee_exclusions) can be managed; everything else, including the fee-kind registry, stays read-only.

Examples:

Access resources

Ledger::Sdk.Container.list              # list all containers
Ledger::Sdk.Container(42).data          # get a specific container
Ledger::Sdk.Container(42).accounts.list # list accounts for a container

Chain associations down to inventories

Ledger::Sdk.Container(42).accounts(7).positions(3).inventories.list

Manage a container's fees

fee = Ledger::Sdk.Container(42).fees.create(kind: 'financial_management', rate: 0.01)
fee.update(rate: 0.02)
fee.destroy

Defined Under Namespace

Modules: Configuration, Models Classes: Client

Constant Summary collapse

VERSION =
'0.6.0'

Class Method Summary collapse

Methods included from Configuration

config, configure

Class Method Details

.Container(id = nil) ⇒ Models::Container, Models::Container::Instance

Returns a container collection or a specific container instance.

Parameters:

  • id (String, Integer, nil) (defaults to: nil)

    the container ID, or nil for the collection

Returns:

.FeeKind(id = nil) ⇒ Models::FeeKind, Models::FeeKind::Instance

Returns a fee-kind collection or a specific fee-kind instance.

Fee kinds have no show endpoint: an instance built with an id only exposes data if it was pre-loaded via Ledger::Sdk::Models::Base#list.

Parameters:

  • id (String, Integer, nil) (defaults to: nil)

    the fee-kind ID, or nil for the collection

Returns:

.Movement(id = nil) ⇒ Models::Movement, Models::Movement::Instance

Returns a movement collection or a specific movement instance.

Parameters:

  • id (String, Integer, nil) (defaults to: nil)

    the movement ID, or nil for the collection

Returns:

.Position(id = nil) ⇒ Models::Position, Models::Position::Instance

Returns a root-level position collection or a specific position instance.

Positions have no show endpoint: an instance built with an id only exposes data if it was pre-loaded via Ledger::Sdk::Models::Base#list. The root collection requires a filters[code] security-code filter — without it the Ledger API returns an empty array. A bare root instance (built via this factory) has no container/account context, so calling .inventories on it raises NotImplementedError: nested usage (account- or container-scoped positions, and their inventories) still goes through Ledger::Sdk::Models::Container::Instance#positions and Ledger::Sdk::Models::Account::Instance#positions.

Parameters:

  • id (String, Integer, nil) (defaults to: nil)

    the position ID, or nil for the collection

Returns: