external

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Host                        = "https://www.tinkoff.ru"
	LoginPage                   = Host + "/login/"
	PingEndpoint                = Host + "/api/common/v1/ping"
	SessionEndpoint             = Host + "/api/common/v1/session"
	SignUpEndpoint              = Host + "/api/common/v1/sign_up"
	ConfirmEndpoint             = Host + "/api/common/v1/confirm"
	LevelUpEndpoint             = Host + "/api/common/v1/level_up"
	GroupedRequestsEndpount     = Host + "/api/common/v1/grouped_requests"
	OperationsEndpoint          = Host + "/api/common/v1/operations"
	ShoppingReceiptEndpount     = Host + "/api/common/v1/shopping_receipt"
	TradingOperationsEndpoint   = Host + "/api/trading/user/operations"
	PurchasedSecuritiesEndpoint = Host + "/api/trading/portfolio/purchased_securities"
)
View Source
var MoscowLocation *time.Location

Functions

This section is empty.

Types

type Account

type Account struct {
	ID   string `json:"id" gorm:"primaryKey"`
	Name string `json:"name" gorm:"not null"`
	Type string `json:"accountType" gorm:"not null"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Authorize

func Authorize(ctx context.Context, username, password string, confirm Confirm) (*Client, error)

func NewClient

func NewClient(ctx context.Context, username string) (*Client, error)

func (*Client) Accounts

func (c *Client) Accounts(ctx context.Context) ([]Account, error)

func (*Client) Confirm

func (c *Client) Confirm(ctx context.Context, initialOperationTicket, initialOperation, code string) error

func (*Client) LevelUp

func (c *Client) LevelUp(ctx context.Context) error

func (*Client) Operations

func (c *Client) Operations(ctx context.Context, now time.Time, accountID string, since time.Time) ([]Operation, error)

func (*Client) PurchasedSecurities

func (c *Client) PurchasedSecurities(ctx context.Context, now time.Time) ([]PurchasedSecurity, error)

func (*Client) ShoppingReceipt

func (c *Client) ShoppingReceipt(ctx context.Context, operationID uint64) (*ShoppingReceipt, error)

func (*Client) SignUp

func (c *Client) SignUp(ctx context.Context, password string) (string, error)

func (*Client) TradingOperations

func (c *Client) TradingOperations(ctx context.Context, now time.Time, since time.Time) ([]TradingOperation, error)

func (*Client) Username

func (c *Client) Username() string

type Confirm

type Confirm func(ctx context.Context) (code string, err error)

type Errors

type Errors []error

func (Errors) Add

func (e Errors) Add(err error) Errors

func (Errors) Check

func (e Errors) Check() error

func (Errors) Error

func (e Errors) Error() string

type Operation

type Operation struct {
	ID uint64 `json:"id,string" gorm:"primaryKey;autoIncrement:false"`
	// nolint
	AuthorizationID  null.Int                `json:"authorizationId,string"`
	Time             OperationTime           `json:"operationTime" gorm:"type:timestamptz;not null;index;time"`
	DebitingTime     *OperationTime          `json:"debitingTime" gorm:"type:date"`
	Type             string                  `json:"type" gorm:"not null"`
	Group            string                  `json:"group" gorm:"not null"`
	Status           string                  `json:"status" gorm:"not null"`
	Description      string                  `json:"description" gorm:"not null"`
	Amount           OperationAmount         `json:"amount" gorm:"embedded"`
	AccountAmount    OperationAmount         `json:"accountAmount" gorm:"embedded;embeddedPrefix:account_"`
	Cashback         OperationAmount         `json:"cashbackAmount" gorm:"embedded;embeddedPrefix:cashback_"`
	LoyaltyBonus     []OperationLoyaltyBonus `json:"loyaltyBonus" gorm:"constraint:OnDelete:CASCADE"`
	SpendingCategory struct {
		Name string `json:"name" gorm:"column:category"`
	} `json:"spendingCategory" gorm:"embedded"`

	CardNumber  null.String `json:"cardNumber"`
	MCC         string      `json:"mccString" gorm:"type:char(4);not null"`
	CardPresent bool        `json:"cardPresent" gorm:"not null"`
	//Locations   []OperationLocation `json:"locations" gorm:"constraint:OnDelete:CASCADE;foreignKey:OperationID"`
	Merchant OperationMerchant `json:"merchant" gorm:"embedded;embeddedPrefix:merchant_"`

	AccountID string `json:"account" gorm:"tenant;constraint:OnDelete:CASCADE"`
	Account   Account

	HasShoppingReceipt bool `json:"hasShoppingReceipt" gorm:"-"`

	ShoppingReceipt *ShoppingReceipt `json:"-" gorm:"constraint:OnDelete:CASCADE"`
}

type OperationAmount

type OperationAmount struct {
	Currency struct {
		Name string `json:"name" gorm:"column:currency;type:char(3);not null"`
	} `json:"currency" gorm:"embedded"`
	Value float64 `json:"value" gorm:"column:amount;not null"`
}

type OperationLocation

type OperationLocation struct {
	OperationID uint64  `json:"-" gorm:"primaryKey"`
	Latitude    float64 `json:"latitude" gorm:"primaryKey"`
	Longitude   float64 `json:"longitude" gorm:"primaryKey"`
}

type OperationLoyaltyBonus

type OperationLoyaltyBonus struct {
	OperationID uint64 `json:"-" gorm:"primaryKey"`
	Type        string `json:"loyaltyType" gorm:"primaryKey"`
	Amount      struct {
		ProgramID string  `json:"loyaltyProgramId" gorm:"primaryKey"`
		Value     float64 `json:"value" gorm:"not null"`
	} `json:"amount" gorm:"embedded"`
}

type OperationMerchant

type OperationMerchant struct {
	Name   null.String `json:"name"`
	Region struct {
		Country null.String `json:"country" gorm:"type:char(3)"`
		City    null.String `json:"city"`
		Address null.String `json:"address"`
		ZIP     null.String `json:"zip" gorm:"column:zip"`
	} `json:"region" gorm:"embedded"`
}

type OperationTime

type OperationTime time.Time

func (*OperationTime) UnmarshalJSON

func (t *OperationTime) UnmarshalJSON(data []byte) error

type Operations

type Operations []Operation

func (Operations) Len

func (os Operations) Len() int

func (Operations) Less

func (os Operations) Less(i, j int) bool

func (Operations) Swap

func (os Operations) Swap(i, j int)

type PurchasedSecurity

type PurchasedSecurity struct {
	Ticker       string `json:"ticker" gorm:"primaryKey"`
	SecurityType string `json:"securityType" gorm:"primaryKey"`
	CurrentPrice struct {
		Currency string  `json:"currency" gorm:"type:char(3);not null"`
		Value    float64 `json:"value" gorm:"price;not null"`
	} `json:"currentPrice" gorm:"embedded"`

	Time time.Time `json:"-" gorm:"primaryKey;type:date"`
}

type Response

type Response struct {
	ResultCode      string          `json:"resultCode"`
	Status          string          `json:"status"`
	Payload         json.RawMessage `json:"payload"`
	OperationTicket string          `json:"operationTicket"`
}

func (*Response) DecodeFrom

func (r *Response) DecodeFrom(reader io.Reader) error

func (*Response) Unmarshal

func (r *Response) Unmarshal(ecode string, value interface{}) error

type ResultCodeError

type ResultCodeError string

func (ResultCodeError) Error

func (e ResultCodeError) Error() string

type ShoppingReceipt

type ShoppingReceipt struct {
	OperationID uint64 `json:"-" gorm:"primaryKey"`
	Receipt     struct {
		OperationType      uint8                 `json:"operationType" gorm:"not null"`
		TotalSum           float64               `json:"totalSum" gorm:"not null"`
		Operator           string                `json:"operator" gorm:"not null"`
		User               string                `json:"user" gorm:"not null"`
		RetailPlaceAddress string                `json:"retailPlaceAddress" gorm:"not null"`
		Items              []ShoppingReceiptItem `json:"items"`
	} `json:"receipt" gorm:"embedded"`
}

type ShoppingReceiptItem

type ShoppingReceiptItem struct {
	ShoppingReceiptID uint64  `json:"-" gorm:"primaryKey"`
	Name              string  `json:"name" gorm:"primaryKey"`
	Price             float64 `json:"price" gorm:"primaryKey;not null"`
	Sum               float64 `json:"sum" gorm:"not null"`
	CategoryID        uint    `json:"cat_id" gorm:"not null"`
	Quantity          float64 `json:"quantity" gorm:"not null"`
	GoodID            uint    `json:"good_id" gorm:"not null"`
}

type TradingOperation

type TradingOperation struct {
	Username           string               `json:"-" gorm:"not null;index;tenant"`
	ID                 uint64               `json:"id" gorm:"primaryKey;autoIncrement:false"`
	Time               TradingOperationTime `json:"date" gorm:"type:timestamptz;not null;time"`
	Type               string               `json:"operationType"`
	IsMarginCall       bool                 `json:"isMarginCall"`
	Issuer             null.String          `json:"issuer"`
	InstrumentType     null.String          `json:"instrumentType"`
	Ticker             null.String          `json:"ticker" gorm:"index"`
	Price              null.Float           `json:"price"`
	Payment            float64              `json:"payment" gorm:"not null"`
	Commission         null.Float           `json:"commission"`
	Currency           string               `json:"currency" gorm:"type:char(3);not null"`
	Quantity           null.Int             `json:"quantity"`
	CommissionCurrency null.String          `json:"commissionCurrency"`
	Description        string               `json:"description" gorm:"not null"`
}

type TradingOperationTime

type TradingOperationTime time.Time

func (*TradingOperationTime) UnmarshalJSON

func (t *TradingOperationTime) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL