// Cards get the user card's balances
979925
func (client *Client) Cards() (cards []Card, err error) {
	req, err := http.NewRequest(
		"GET",
		client.BaseURL+"/user/card/preference/list",
		nil,
	)
	if err != nil {
		return cards, err
	}
	resp, err := client.Do(req)
	if err != nil {
		return cards, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != 200 {
		// this should never happen
		return cards, ErrDumbass
	}
	var preferences preferencesJSON
	err = json.NewDecoder(resp.Body).Decode(&preferences)
	return preferences.List, err
}
670681
func Get(id string, params *stripe.CardParams) (*stripe.Card, error) {
	return getC().Get(id, params)
}
197931
func (a *Action) DidUnarchiveCard() bool {
	return (a.Type == "updateCard") && a.Data != nil && a.Data.Old != nil && a.Data.Old.Closed
}
597551
func (c *UsersController) List(ctx *app.ListUsersContext) error {
	var users []accountrepo.User
	var identities []accountrepo.Identity
	err := transaction.Transactional(c.app, func(tr transaction.TransactionalResources) error {
		var err error
		users, identities, err = filterUsers(tr, ctx)
		return err
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return ctx.ConditionalEntities(users, c.config.GetCacheControlUsers, func() error {
		appUsers := make([]*app.UserData, len(users))
		for i := range users {
			appUser := ConvertToAppUser(ctx.RequestData, &users[i], &identities[i], false)
			appUsers[i] = appUser.Data
		}
		return ctx.OK(&app.UserArray{Data: appUsers})
	})
}
417994
func (api *API) WalletBalances() (wallet WalletBalances, err error) {
	request := struct {
		URL   string `json:"request"`
		Nonce string `json:"nonce"`
	}{
		"/v1/balances",
		strconv.FormatInt(time.Now().UnixNano(), 10),
	}

	body, err := api.post(request.URL, request)
	if err != nil {
		return
	}

	tmpBalances := []WalletBalance{}
	err = json.Unmarshal(body, &tmpBalances)
	if err != nil { // Failed to unmarshal expected message
		// Attempt to unmarshal the error message
		errorMessage := ErrorMessage{}
		err = json.Unmarshal(body, &errorMessage)
		if err != nil { // Not expected message and not expected error, bailing...
			return
		}

		return nil, errors.New("API: " + errorMessage.Message)
	}

	wallet = make(WalletBalances)
	for _, w := range tmpBalances {
		wallet[WalletKey{w.Type, w.Currency}] = w
	}

	return
}
977172
func (ctrl Controller) CompleteCreditCard(w http.ResponseWriter, req *http.Request) {
	req.ParseForm()

	order := getCurrentOrder(w, req)

	expMonth, _ := strconv.Atoi(req.Form.Get("exp_month"))
	expYear, _ := strconv.Atoi(req.Form.Get("exp_year"))

	creditCard := gomerchant.CreditCard{
		Name:     req.Form.Get("name"),
		Number:   req.Form.Get("creditcard"),
		CVC:      req.Form.Get("cvv"),
		ExpYear:  uint(expYear),
		ExpMonth: uint(expMonth),
	}

	if creditCard.ValidNumber() {
		// TODO integrate with https://github.com/qor/gomerchant to handle those information
		tx := utils.GetDB(req)
		err := orders.OrderState.Trigger("checkout", order, tx, "")

		if err == nil {
			tx.Save(order)
			http.Redirect(w, req, "/cart/success", http.StatusFound)
			return
		}
	}

	utils.AddFlashMessage(w, req, "Invalid Credit Card", "error")
	http.Redirect(w, req, "/cart", http.StatusFound)
}
814443
func (p Payment) CreditCardNumber(v reflect.Value) (interface{}, error) {
	return p.ccnumber(), nil
}
197011
func (c *Client) GetCard(cardID string, args Arguments) (card *Card, err error) {
	path := fmt.Sprintf("cards/%s", cardID)
	err = c.Get(path, args, &card)
	if card != nil {
		card.client = c
	}
	return card, err
}
1041265
func (b *Board) GetLists(args Arguments) (lists []*List, err error) {
	path := fmt.Sprintf("boards/%s/lists", b.ID)
	err = b.client.Get(path, args, &lists)
	for i := range lists {
		lists[i].client = b.client
		for j := range lists[i].Cards {
			lists[i].Cards[j].client = b.client
		}
	}
	return
}
71468
func (api *API) GetBalances(addresses Hashes, threshold uint64, tips ...Hash) (*Balances, error) {
    if err := Validate(ValidateAddresses(false, addresses...)); err != nil {
		return nil, err
	}

	if threshold > 100 {
		return nil, ErrInvalidThreshold
	}

	cleanedAddrs, err := checksum.RemoveChecksums(addresses)
	if err != nil {
		return nil, err
	}

	cmd := &GetBalancesCommand{
		Addresses: cleanedAddrs,
		Threshold: threshold,
		Command:   Command{GetBalancesCmd},
		Tips:      tips,
	}
	rsp := &GetBalancesResponse{}
	if err := api.provider.Send(cmd, rsp); err != nil {
		return nil, err
	}
	balances := &Balances{
		Balances:  make([]uint64, len(rsp.Balances)),
		Milestone: rsp.Milestone, MilestoneIndex: rsp.MilestoneIndex,
	}
	for i, s := range rsp.Balances {
		num, err := strconv.ParseUint(s, 10, 64)
		if err != nil {
			return nil, err
		}
		balances.Balances[i] = num
	}
	return balances, err
}
1042970
func (db *DB) ZCard(key []byte) (int64, error) {
	if err := checkKeySize(key); err != nil {
		return 0, err
	}

	sk := db.zEncodeSizeKey(key)
	return Int64(db.bucket.Get(sk))
}
743487
func (self *Contact) Balance() (*BalanceInformation, error) {
	var res map[string]interface{}
	params := []interface{}{self.Key}
	if err := self.Call("contact.balance", params, &res); err != nil {
		return nil, err
	}
	return toBalanceInformation(res), nil
}
706359
func (s *Statement) SetResponseCard(v string) *Statement {
	s.ResponseCard = &v
	return s
}
1088268
func (hub *Hub) Wallets() []accounts.Wallet {
	// Make sure the list of wallets is up to date
	hub.refreshWallets()

	hub.stateLock.RLock()
	defer hub.stateLock.RUnlock()

	cpy := make([]accounts.Wallet, 0, len(hub.wallets))
	for _, wallet := range hub.wallets {
		cpy = append(cpy, wallet)
	}
	sort.Sort(accounts.WalletsByURL(cpy))
	return cpy
}
33461
func GetBalanceTransaction(id string, params *stripe.BalanceTransactionParams) (*stripe.BalanceTransaction, error) {
	return getC().GetBalanceTransaction(id, params)
}
501128
func (sd *StandardDeck) NextCard() (*card.Card, error) {
	var ans *card.Card

	if sd.idx < sd.Size() { // ensure we're not at the end of the cards array
		ans = sd.cards[sd.idx]
		sd.idx += 1 // go to the next card
		return ans, nil
	}

	// otherwise
	return &card.Card{}, deck.EmptyDeck{}
}
641395
func (w *walletAPIHandler) balances(ctx context.Context, c Call, wr io.Writer) error {
	accounts, err := w.cli.WalletGetAccountsCLILocal(ctx)
	if err != nil {
		return w.encodeErr(c, err, wr)
	}
	return w.encodeResult(c, accounts, wr)
}