-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
56 lines (47 loc) · 1.51 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package square
import (
"fmt"
"github.com/Houndie/square-go/catalog"
"github.com/Houndie/square-go/checkout"
"github.com/Houndie/square-go/inventory"
"github.com/Houndie/square-go/locations"
"github.com/Houndie/square-go/objects"
"github.com/Houndie/square-go/options"
"github.com/Houndie/square-go/orders"
)
type Client struct {
Catalog catalog.Client
Checkout checkout.Client
Inventory inventory.Client
Locations locations.Client
Orders orders.Client
}
func NewClient(apiKey string, environment objects.Environment, options ...options.ClientOption) (*Client, error) {
catalog, err := catalog.NewClient(apiKey, environment, options...)
if err != nil {
return nil, fmt.Errorf("error constructing catalog client: %w", err)
}
checkout, err := checkout.NewClient(apiKey, environment, options...)
if err != nil {
return nil, fmt.Errorf("error constructing catalog client: %w", err)
}
inventory, err := inventory.NewClient(apiKey, environment, options...)
if err != nil {
return nil, fmt.Errorf("error constructing catalog client: %w", err)
}
locations, err := locations.NewClient(apiKey, environment, options...)
if err != nil {
return nil, fmt.Errorf("error constructing catalog client: %w", err)
}
orders, err := orders.NewClient(apiKey, environment, options...)
if err != nil {
return nil, fmt.Errorf("error constructing catalog client: %w", err)
}
return &Client{
Catalog: catalog,
Checkout: checkout,
Inventory: inventory,
Locations: locations,
Orders: orders,
}, nil
}