Class: Mosaic::Sdk::Models::Clone

Inherits:
Base
  • Object
show all
Includes:
Searchable
Defined in:
lib/mosaic/sdk/models/clone.rb

Overview

Represents the collection of clones (fund share classes) from the Mosaic API.

Clones can be accessed either standalone via /v2/clones or nested under a DNA via /v2/dnas/:dna_id/clones. The context is determined automatically based on the presence of a :dna_id in the extra context.

Examples:

List all clones

clones = Mosaic::Sdk.Clone.list

List clones for a specific DNA

dna = Mosaic::Sdk.Dna(42)
dna.clones.list

Create a clone

clone = Mosaic::Sdk.Clone.create(
  name: 'My Clone', codes: [{ type: 'isin', value: 'FR001' }],
  source: 'manual', dna_id: 42
)

Search for clones by name

clones = Mosaic::Sdk.Clone.list(q: 'My Clone')

Search and filter by code type

clones = Mosaic::Sdk.Clone.list(q: 'My Clone', type: 'isin')

Resolve clones by external code (batch)

Mosaic::Sdk.Clone.list(codes: %w[FR0000000001])

Access a specific clone

clone = Mosaic::Sdk.Clone(7)
clone.data

Defined Under Namespace

Classes: Instance

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Mosaic::Sdk::Models::Base

Instance Method Details

#create(name:, codes:, source:, dna_id: @extra[:dna_id], account_references: [], currency: nil) ⇒ Instance

Creates a new clone.

Parameters:

  • name (String)

    the clone name

  • codes (Array<Hash>)

    list of codes, each with :type and :value (e.g. [{ type: 'isin', value: 'FR0000000001' }])

  • source (String)

    the data source

  • dna_id (Integer) (defaults to: @extra[:dna_id])

    the parent DNA ID (inferred from context when chaining)

  • account_references (Array<String>) (defaults to: [])

    optional list of account references

  • currency (String, nil) (defaults to: nil)

    the clone's denomination (3-letter code, e.g. EUR); sets position_type.currency server-side, used as the base for NAV currency conversion

Returns:

  • (Instance)

    the created clone instance

#list(q: nil, codes: nil, type: nil, view: nil) ⇒ Array<Instance>, Hash{String=>Hash}

Lists clones, optionally filtered by a search query and/or code type; when codes: is given, resolves that batch of external codes via the /search endpoint instead.

Parameters:

  • q (String, nil) (defaults to: nil)

    an optional search string to filter results

  • codes (Array<String>, nil) (defaults to: nil)

    external codes to resolve; when given, POSTs to /search and returns the raw payload keyed by code

  • type (String, nil) (defaults to: nil)

    an optional code type to narrow results (e.g. 'isin')

  • view (String, nil) (defaults to: nil)

    optional payload view (e.g. :full)

Returns:

  • (Array<Instance>)

    clone instances (listing mode)

  • (Hash{String=>Hash})

    raw payload keyed by code (+codes:+ mode)