func (c Client) New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { body := &url.Values{ "customer": {params.Customer}, "amount": {strconv.FormatInt(params.Amount, 10)}, "currency": {string(params.Currency)}, } if len(params.Invoice) > 0 { body.Add("invoice", params.Invoice) } if len(params.Desc) > 0 { body.Add("description", params.Desc) } if len(params.Sub) > 0 { body.Add("subscription", params.Sub) } params.AppendTo(body) invoiceItem := &stripe.InvoiceItem{} err := c.B.Call("POST", "/invoiceitems", c.Key, body, ¶ms.Params, invoiceItem) return invoiceItem, err }
func (c Client) Get(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { var body *url.Values var commonParams *stripe.Params if params != nil { commonParams = ¶ms.Params body = &url.Values{} params.AppendTo(body) } invoiceItem := &stripe.InvoiceItem{} err := c.B.Call("GET", "/invoiceitems/"+id, c.Key, body, commonParams, invoiceItem) return invoiceItem, err }
func (c Client) Update(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) { var body *url.Values var commonParams *stripe.Params if params != nil { commonParams = ¶ms.Params body = &url.Values{} if params.Amount != 0 { body.Add("amount", strconv.FormatInt(params.Amount, 10)) } if len(params.Desc) > 0 { body.Add("description", params.Desc) } params.AppendTo(body) } invoiceItem := &stripe.InvoiceItem{} err := c.B.Call("POST", "/invoiceitems/"+id, c.Key, body, commonParams, invoiceItem) return invoiceItem, err }