16 lines
480 B
Gleam
16 lines
480 B
Gleam
import gleam/dynamic/decode.{type Decoder}
|
|
import gleam/json.{type Json}
|
|
import spacetraders_models/trade_symbol.{type TradeSymbol}
|
|
|
|
pub type SurveyDeposit {
|
|
SurveyDeposit(symbol: TradeSymbol)
|
|
}
|
|
|
|
pub fn decoder() -> Decoder(SurveyDeposit) {
|
|
use symbol <- decode.field("symbol", trade_symbol.decoder())
|
|
decode.success(SurveyDeposit(symbol:))
|
|
}
|
|
|
|
pub fn encode(survey_deposit: SurveyDeposit) -> Json {
|
|
json.object([#("symbol", trade_symbol.encode(survey_deposit.symbol))])
|
|
}
|