Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package smobilpay |
||
2 | |||
3 | import ( |
||
4 | "time" |
||
5 | ) |
||
6 | |||
7 | // RequestOption is options for constructing an API request |
||
8 | type RequestOption interface { |
||
9 | apply(config *requestConfig) |
||
10 | } |
||
11 | |||
12 | type requestOptionFunc func(config *requestConfig) |
||
13 | |||
14 | func (fn requestOptionFunc) apply(config *requestConfig) { |
||
15 | fn(config) |
||
16 | } |
||
17 | |||
18 | // WithRequestTimestamp sets the timestamp in the s3pAuth_timestamp header |
||
19 | func WithRequestTimestamp(timestamp time.Time) RequestOption { |
||
20 | return requestOptionFunc(func(config *requestConfig) { |
||
21 | config.timestamp = timestamp |
||
22 | }) |
||
23 | } |
||
24 | |||
25 | // WithRequestNonce sets the nonce in the s3pAuth_nonce header |
||
26 | func WithRequestNonce(nonce string) RequestOption { |
||
27 | return requestOptionFunc(func(config *requestConfig) { |
||
28 | config.nonce = nonce |
||
29 | }) |
||
31 |