-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptional_payloads.go
More file actions
26 lines (24 loc) · 916 Bytes
/
optional_payloads.go
File metadata and controls
26 lines (24 loc) · 916 Bytes
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
package paystack
// OptionalPayload is a type for storing optional parameters used by some APIClient methods that needs
// to accept optional parameter.
type OptionalPayload = func(map[string]any) map[string]any
// WithOptionalPayload lets you add optional parameters when calling some client methods and you need to add
// optional parameters to your payload.
//
// Example
//
// import (
// p "github.com/gray-adeyi/paystack"
// "context"
// )
//
// client := p.NewAPIClient(p.WithSecretKey("<your-paystack-secret-key>"))
// resp, err := client.DedicatedVirtualAccounts.Create(context.TODO(),"481193", p.WithOptionalPayload("preferred_bank","wema-bank"))
//
// WithOptionalPayload is used to pass the `preferred_bank` optional parameter in the client method call
func WithOptionalPayload(key string, value any) OptionalPayload {
return func(m map[string]any) map[string]any {
m[key] = value
return m
}
}