-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
83 lines (70 loc) 路 1.49 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"context"
"fmt"
"github.com/cirocosta/pizza-controller/pkg/dominos"
)
func run() error {
ctx := context.Background()
client, err := dominos.NewClient(dominos.CanadaURL, true)
if err != nil {
return fmt.Errorf("new client: %w", err)
}
var (
addr = dominos.Address{
StreetNumber: "90",
StreetName: "Queens Wharf Rd",
City: "Toronto",
State: "ON",
Zip: "M5V0J4",
}
// pi = dominos.PersonalInformation{
// FirstName: "",
// LastName: "",
// Email: "",
// Phone: "",
// }
// cc = dominos.CreditCard{
// Type: dominos.CreditCardTypeVisa,
// Number: "",
// Expiration: "",
// SecurityCode: "",
// PostalCode: "",
// }
products = []dominos.Product{
{
ID: "10SCREEN",
},
}
service = dominos.ServiceCarryout
)
stores, err := client.StoresNearby(ctx, addr, service)
if err != nil {
return fmt.Errorf("stores nearby: %w", err)
}
storeID := stores[0].ID
items, err := client.StoreMenu(ctx, storeID)
if err != nil {
return fmt.Errorf("store '%s' menu: %w", storeID, err)
}
for _, item := range items {
fmt.Println(item.ID, "\t", item.Name)
}
order := dominos.Order{
StoreID: storeID,
Address: addr,
Products: products,
Service: service,
}
price, err := client.PriceOrder(ctx, order)
if err != nil {
return fmt.Errorf("submit order: %w", err)
}
fmt.Println(price)
return nil
}
func main() {
if err := run(); err != nil {
panic(err)
}
}