forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
36 lines (29 loc) · 931 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
// Package loginlink provides the /login_links APIs
package loginlink
import (
"errors"
"net/http"
stripe "github.com/stripe/stripe-go"
)
// Client is used to invoke /login_links APIs.
type Client struct {
B stripe.Backend
Key string
}
// New creates a login link for an account.
func New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
return getC().New(params)
}
// New creates a login link for an account.
func (c Client) New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
if params.Account == nil {
return nil, errors.New("Invalid login link params: Account must be set")
}
path := stripe.FormatURLPath("/accounts/%s/login_links", stripe.StringValue(params.Account))
loginLink := &stripe.LoginLink{}
err := c.B.Call(http.MethodPost, path, c.Key, params, loginLink)
return loginLink, err
}
func getC() Client {
return Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
}