TinkoffInvest.Api (tinkoff_invest v0.2.0) View Source

This module provides two simple requests: GET and POST

payload map converted to query string on request

You will need to define your custom TinkoffInvest.Model to make this work or use existing one.

Examples:

TinkoffInvest.Api.request("/orders", :get, YourCustomModel)
TinkoffInvest.Api.request("/orders", :get, YourCustomModel, %{someQueryParam: true}) # /orders?someParam=true
TinkoffInvest.Api.request("/orders", :post, YourCustomModel, %{someQueryParam: true})
TinkoffInvest.Api.request("/orders", :post, YourCustomModel, %{someQueryParam: true}, %{bodyParam: true})

Please notice that :post request accepts both query and body payloads preferably as maps

Link to this section Summary

Functions

Build body payload and encodes it to JSON.

Builds query payload from map. Account id provided by default in config though can be overridden

Allows you to send request to api if you need custom method that is not currently implemented

Link to this section Types

Specs

method() :: :get | :post

Link to this section Functions

Link to this function

build_body_payload(payload)

View Source

Specs

build_body_payload(map() | nil | String.t()) :: String.t()

Build body payload and encodes it to JSON.

Link to this function

build_payload(path, payload)

View Source

Specs

build_payload(String.t(), map() | nil) :: String.t()

Builds query payload from map. Account id provided by default in config though can be overridden

Examples

# Overwrites default value in config
TinkoffInvest.Api.build_payload("/orders", %{brokerAccountId: "MyCustomId"})
# Adds brokerAccountId field with broker_account_id from config to payload
TinkoffInvest.Api.build_payload("/orders", %{figi: "AAPL"})
Link to this function

request(path, method, module, queryPayload \\ nil, body \\ %{})

View Source

Specs

request(String.t(), method(), module(), map() | nil, map() | nil) ::
  TinkoffInvest.Model.Api.Response.t()

Allows you to send request to api if you need custom method that is not currently implemented