forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
40 lines (31 loc) · 967 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Package loginlink provides the /login_links APIs
package loginlink
import (
"errors"
"fmt"
stripe "github.com/stripe/stripe-go"
)
// Client is used to invoke /login_links APIs.
type Client struct {
B stripe.Backend
Key string
}
// New POSTs to create a login_link for an account
// For more details see https://stripe.com/docs/api#create_login_link.
func New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
return getC().New(params)
}
func (c Client) New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
body := &stripe.RequestValues{}
loginLink := &stripe.LoginLink{}
var err error
if len(params.Account) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/login_links", params.Account), c.Key, body, nil, loginLink)
} else {
err = errors.New("Invalid login link params: Account must be set")
}
return loginLink, err
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}