This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
forked from chweez/africastalking-go
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathutils.go
91 lines (73 loc) · 2.4 KB
/
utils.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
79
80
81
82
83
84
85
86
87
88
89
90
91
package util
import "fmt"
// Constants for responses
const (
PendingConfirmation = "PendingConfirmation"
PendingValidation = "PendingValidation"
InvalidRequest = "InvalidRequest"
NotSupported = "NotSupported"
SUCCESS = "Success"
FAILED = "Failed"
QUEUED = "Queued"
SENT = "Sent"
)
// GetAPIHost returns either sandbox or prod
func GetAPIHost(env string) string {
return getHost(env, "api")
}
// GetSmsURL is the sms endpoint
func GetSmsURL(env string) string {
return GetAPIHost(env) + "/version1/messaging"
}
// GetPaymentHost returns the payments domain
func GetPaymentHost(env string) string {
return getHost(env, "payments")
}
// GetVoiceHost returns the voice host domain
func GetVoiceHost(env string) string {
return getHost(env, "voice")
}
// GetVoiceURL returns the voice endpoint
func GetVoiceURL(env string) string {
return GetVoiceHost(env)
}
// GetSubURL returns the Subscription endpoint
func GetSubURL(env string) string {
return GetAPIHost(env) + "/version1/subscription"
}
// GetCreateSubURL returns the Subscription create endpoint
func GetCreateSubURL(env string) string {
return GetAPIHost(env) + "/version1/subscription/create"
}
// GetUserDataURL returns the user data endpoint
func GetUserDataURL(env string) string {
return GetAPIHost(env) + "/version1/user"
}
// GetAirtimeURL returns the airtime endpoint
func GetAirtimeURL(env string) string {
return GetAPIHost(env) + "/version1/airtime"
}
// GetMobilePaymentCheckoutURL returns the mobile payments checkout endpoint
func GetMobilePaymentCheckoutURL(env string) string {
return GetPaymentHost(env) + "/mobile/checkout/request"
}
// GetMobilePaymentB2BURL returns the Mobile Payments B2B endpoint
func GetMobilePaymentB2BURL(env string) string {
return GetPaymentHost(env) + "/mobile/b2b/request"
}
// GetMobilePaymentB2CURL returns the Mobile Payment B2C endpoint
func GetMobilePaymentB2CURL(env string) string {
return GetPaymentHost(env) + "/mobile/b2c/request"
}
func GetCreateCheckoutTokenURL(env string) string {
return GetAPIHost(env) + "/checkout/token/create"
}
func GetGenerateAuthTokenURL(env string) string {
return GetAPIHost(env) + "/auth-token/generate"
}
func getHost(env, service string) string {
if env != "sandbox" {
return fmt.Sprintf("https://%s.africastalking.com", service)
}
return fmt.Sprintf("https://%s.sandbox.africastalking.com", service)
}