-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpay_by_link_test.go
78 lines (63 loc) · 1.89 KB
/
pay_by_link_test.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
package tests
import (
"context"
"github.com/craftgate/craftgate-go-client/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
)
var payByLinkClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")
func Test_CreateProduct(t *testing.T) {
request := adapter.CreateProductRequest{
Name: "A new Product",
Channel: "API",
Price: 10,
Currency: craftgate.Currency_TRY,
EnabledInstallments: []int{1, 2, 3, 6},
}
res, err := payByLinkClient.PayByLink.CreateProduct(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_UpdateProduct(t *testing.T) {
request := adapter.UpdateProductRequest{
Name: "A new Product",
Status: craftgate.Status_ACTIVE,
Channel: "API",
Price: 10,
Currency: craftgate.Currency_TRY,
EnabledInstallments: []int{1, 2, 3, 6, 9},
}
res, err := payByLinkClient.PayByLink.UpdateProduct(context.Background(), 1, request)
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_RetrieveProduct(t *testing.T) {
res, err := payByLinkClient.PayByLink.RetrieveProduct(context.Background(), 1)
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_DeleteProduct(t *testing.T) {
err := payByLinkClient.PayByLink.DeleteProduct(context.Background(), 1)
if err != nil {
t.Errorf("Error %s", err)
}
}
func Test_SearchProducts(t *testing.T) {
request := adapter.SearchProductsRequest{
Page: 0,
Size: 10,
Currency: craftgate.Currency_TRY,
}
res, err := payByLinkClient.PayByLink.SearchProducts(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)
if err != nil {
t.Errorf("Error %s", err)
}
}