// Populate loads this resource from `row` func (this *Base) Populate(ctx context.Context, row history.Effect) { this.ID = row.ID() this.PT = row.PagingToken() this.Account = row.Account this.populateType(row) lb := hal.LinkBuilder{httpx.BaseURL(ctx)} this.Links.Operation = lb.Linkf("/operations/%d", row.HistoryOperationID) this.Links.Succeeds = lb.Linkf("/effects?order=desc&cursor=%s", this.PT) this.Links.Precedes = lb.Linkf("/effects?order=asc&cursor=%s", this.PT) }
// Populate fills out the details func (res *Trade) Populate(ctx context.Context, row history.Effect) (err error) { if row.Type != history.EffectTrade { err = errors.New("invalid effect; not a trade") return } row.UnmarshalDetails(res) res.ID = row.PagingToken() res.PT = row.PagingToken() res.Buyer = row.Account lb := hal.LinkBuilder{httpx.BaseURL(ctx)} res.Links.Self = lb.Link("/accounts", res.Seller) res.Links.Seller = lb.Link("/accounts", res.Seller) res.Links.Buyer = lb.Link("/accounts", res.Buyer) return }