forked from checkout/checkout-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkout_previous_sdk_builder.go
53 lines (41 loc) · 1.37 KB
/
checkout_previous_sdk_builder.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
package abc
import (
"net/http"
"github.com/PaddleHQ/checkout-sdk-go/configuration"
)
type CheckoutPreviousSdkBuilder struct {
configuration.StaticKeysBuilder
}
func (b *CheckoutPreviousSdkBuilder) WithEnvironment(environment configuration.Environment) *CheckoutPreviousSdkBuilder {
b.Environment = environment
return b
}
func (b *CheckoutPreviousSdkBuilder) WithHttpClient(client *http.Client) *CheckoutPreviousSdkBuilder {
b.HttpClient = client
return b
}
func (b *CheckoutPreviousSdkBuilder) WithLogger(logger configuration.StdLogger) *CheckoutPreviousSdkBuilder {
b.Logger = logger
return b
}
func (b *CheckoutPreviousSdkBuilder) WithPublicKey(publicKey string) *CheckoutPreviousSdkBuilder {
b.PublicKey = publicKey
return b
}
func (b *CheckoutPreviousSdkBuilder) WithSecretKey(secretKey string) *CheckoutPreviousSdkBuilder {
b.SecretKey = secretKey
return b
}
func (b *CheckoutPreviousSdkBuilder) Build() (*Api, error) {
err := b.ValidateSecretKey(configuration.PreviousSecretKeyPattern)
if err != nil {
return nil, err
}
err = b.ValidatePublicKey(configuration.PreviousPublicKeyPattern)
if err != nil {
return nil, err
}
sdkCredentials := configuration.NewPreviousKeysSdkCredentials(b.SecretKey, b.PublicKey)
newConfiguration := configuration.NewConfiguration(sdkCredentials, b.Environment, b.HttpClient, b.Logger)
return CheckoutApi(newConfiguration), nil
}