request_option.go   A
last analyzed

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 14
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A smobilpay.requestOptionFunc.apply 0 2 1
A smobilpay.WithRequestTimestamp 0 3 2
A smobilpay.WithRequestNonce 0 3 2
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
	})
30
}
31