示例#1
0
func (c Client) List(params *stripe.BitcoinReceiverListParams) *Iter {
	type receiverList struct {
		stripe.ListMeta
		Values []*stripe.BitcoinReceiver `json:"data"`
	}

	var body *url.Values
	var lp *stripe.ListParams

	if params != nil {
		body = &url.Values{}

		body.Add("filled", strconv.FormatBool(!params.NotFilled))
		body.Add("active", strconv.FormatBool(!params.NotActive))
		body.Add("uncaptured_funds", strconv.FormatBool(params.Uncaptured))

		params.AppendTo(body)
		lp = &params.ListParams
	}

	return &Iter{stripe.GetIter(lp, body, func(b url.Values) ([]interface{}, stripe.ListMeta, error) {
		list := &receiverList{}
		err := c.B.Call("GET", "/bitcoin/receivers", c.Key, &b, nil, list)

		ret := make([]interface{}, len(list.Values))
		for i, v := range list.Values {
			ret[i] = v
		}

		return ret, list.ListMeta, err
	})}
}
示例#2
0
func (c Client) List(params *stripe.BitcoinReceiverListParams) *Iter {
	var body *stripe.RequestValues
	var lp *stripe.ListParams
	var p *stripe.Params

	if params != nil {
		body = &stripe.RequestValues{}

		body.Add("filled", strconv.FormatBool(!params.NotFilled))
		body.Add("active", strconv.FormatBool(!params.NotActive))
		body.Add("uncaptured_funds", strconv.FormatBool(params.Uncaptured))

		params.AppendTo(body)
		lp = &params.ListParams
		p = params.ToParams()
	}

	return &Iter{stripe.GetIter(lp, body, func(b *stripe.RequestValues) ([]interface{}, stripe.ListMeta, error) {
		list := &stripe.BitcoinReceiverList{}
		err := c.B.Call("GET", "/bitcoin/receivers", c.Key, b, p, list)

		ret := make([]interface{}, len(list.Values))
		for i, v := range list.Values {
			ret[i] = v
		}

		return ret, list.ListMeta, err
	})}
}