-
Notifications
You must be signed in to change notification settings - Fork 58
/
customer.go
44 lines (35 loc) · 1.24 KB
/
customer.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
41
42
43
44
package customer
import (
"context"
"github.com/xendit/xendit-go"
)
// CreateCustomer creates new customer
func CreateCustomer(data *CreateCustomerParams) (*xendit.Customer, *xendit.Error) {
return CreateCustomerWithContext(context.Background(), data)
}
// CreateCustomerWithContext creates new payment
func CreateCustomerWithContext(ctx context.Context, data *CreateCustomerParams) (*xendit.Customer, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.CreateCustomerWithContext(ctx, data)
}
// GetCustomerByReferenceID gets customer by reference ID
func GetCustomerByReferenceID(data *GetCustomerByReferenceIDParams) ([]xendit.Customer, *xendit.Error) {
return GetCustomerByReferenceIDWithContext(context.Background(), data)
}
// GetCustomerByReferenceIDWithContext gets customer by reference ID
func GetCustomerByReferenceIDWithContext(ctx context.Context, data *GetCustomerByReferenceIDParams) ([]xendit.Customer, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetCustomerByReferenceIDWithContext(ctx, data)
}
func getClient() (*Client, *xendit.Error) {
return &Client{
Opt: &xendit.Opt,
APIRequester: xendit.GetAPIRequester(),
}, nil
}