Пример #1
0
func (c Client) Get(id string, params *stripe.FileUploadParams) (*stripe.FileUpload, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params

		body = &url.Values{}
		params.AppendTo(body)
	}

	upload := &stripe.FileUpload{}
	err := c.B.Call("GET", "/files/"+id, c.Key, body, commonParams, upload)

	return upload, err
}
Пример #2
0
func (c Client) New(params *stripe.FileUploadParams) (*stripe.FileUpload, error) {
	if params == nil {
		return nil, fmt.Errorf("params cannot be nil, and params.Purpose and params.File must be set")
	}

	body := &bytes.Buffer{}
	boundary, err := params.AppendDetails(body)
	if err != nil {
		return nil, err
	}

	upload := &stripe.FileUpload{}
	err = c.B.CallMultipart("POST", "/files", c.Key, boundary, body, &params.Params, upload)

	return upload, err
}