6 "immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front/db"
9 type MarketConfigQuery struct {
16 func (q MarketConfigQuery) ValidateParams() *Error {
17 if q.In.Market != "poloniex" {
18 return &Error{BadRequest, "invalid market name", fmt.Errorf("'%v' is not a valid market name", q.In.Market)}
24 func (q MarketConfigQuery) Run() (interface{}, *Error) {
25 config, err := db.GetUserMarketConfig(q.In.User.Id, q.In.Market)
27 return nil, NewInternalError(err)
31 configMap := make(map[string]string)
33 configMap["secret"] = ""
35 config, err = db.SetUserMarketConfig(q.In.User.Id, q.In.Market, configMap)
37 return nil, NewInternalError(err)
42 return config.Config, nil
45 type UpdateMarketConfigQuery struct {
54 func (q UpdateMarketConfigQuery) ValidateParams() *Error {
55 if q.In.Market == "" {
56 return &Error{BadRequest, "invalid market name", fmt.Errorf("'%v' is not a valid market name", q.In.Market)}
62 func (q UpdateMarketConfigQuery) Run() (interface{}, *Error) {
63 configMap := make(map[string]string)
65 configMap["key"] = q.In.Key
67 if q.In.Secret != "" {
68 configMap["secret"] = q.In.Secret
71 _, err := db.SetUserMarketConfig(q.In.User.Id, q.In.Market, configMap)
73 return nil, NewInternalError(err)