Passed
Push — main ( 206f54...06bb6a )
by Acho
02:26
created

stubs.GetPendingTransactionResponse   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package stubs
2
3
// PostTokenResponse is a dummy JSOn response for getting access token
4
func PostTokenResponse() []byte {
5
	return []byte(`
6
	{
7
		"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsInVpZCI6Mn0.eyJpYXQiOjE2MDM4MjQyODMsIm5iZiI6MTYwMzgyNDI4MywiZXhwIjoxNjAzODI3ODgzfQ.ufW8sCrf_W2RFpVvH6zri0l7pJLnkPXCZi1zc10ZvOg",
8
		"expires_in": 3600
9
	}
10
`)
11
}
12
13
// PostCollectResponse is a dummy JSON response for requesting a payment
14
func PostCollectResponse() string {
15
	return `
16
	{
17
		  "reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a",
18
		  "ussd_code": "*126# for MTN or #150*50# for ORANGE",
19
		  "operator": "mtn or orange"
20
	}`
21
}
22
23
// GetPendingTransactionResponse is a dummy JSON response for the Transaction Status
24
func GetPendingTransactionResponse() []byte {
25
	return []byte(`
26
	{
27
		"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a",
28
		"status": "PENDING",
29
		"amount": 1,
30
		"currency": "XAF",
31
		"operator": "MTN",
32
		"code": "CP201027T00005",
33
		"operator_reference": "1880106956"
34
	}`)
35
}
36
37
// GetSuccessfulTransactionResponse is a dummy JSON response for the Transaction Status
38
func GetSuccessfulTransactionResponse() []byte {
39
	return []byte(`
40
	{
41
		"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a",
42
		"status": "SUCCESSFUL",
43
		"amount": 1,
44
		"currency": "XAF",
45
		"operator": "MTN",
46
		"code": "CP201027T00005",
47
		"operator_reference": "1880106956"
48
	}`)
49
}
50
51
// GetPendingAirtimeTransactionResponse is a dummy JSON response for a pending airtime transaction
52
func GetPendingAirtimeTransactionResponse() []byte {
53
	return []byte(`
54
	{
55
		"reference": "971e32ae-bb5a-420a-a38a-c2931536609f",
56
		"external_reference": "5577006791947779410",
57
		"status": "PENDING",
58
		"amount": 100,
59
		"currency": "XAF",
60
		"operator": "ORANGE_CM",
61
		"code": "CP220804U0649K",
62
		"type": "AIRTIME",
63
		"reason": ""
64
	}
65
`)
66
}
67
68
// GetSuccessfullAirtimeTransactionResponse is a dummy JSON response for a successful airtime transaction
69
func GetSuccessfullAirtimeTransactionResponse() []byte {
70
	return []byte(`
71
	{
72
		"reference": "971e32ae-bb5a-420a-a38a-c2931536609f",
73
		"external_reference": "5577006791947779410",
74
		"status": "SUCCESSFUL",
75
		"amount": 100,
76
		"currency": "XAF",
77
		"operator": "ORANGE_CM",
78
		"code": "CP220804U0649K",
79
		"type": "AIRTIME",
80
		"reason": ""
81
	}
82
`)
83
}
84
85
// GetBalanceResponse is a dummy JSON response for the transaction balance
86
func GetBalanceResponse() string {
87
	return `
88
	{
89
		"total_balance": 0,
90
		"mtn_balance": 0,
91
		"orange_balance": 0,
92
		"currency": "XAF"
93
	}
94
`
95
}
96
97
// PostTransferResponse is a dummy JSON response for airtime transfer requests
98
func PostTransferResponse() []byte {
99
	return []byte(`
100
	{
101
		"reference":"26676007-1c31-46d7-9c71-acb031cf0de4",
102
		"status":"PENDING"
103
	}
104
`)
105
}
106
107
// PostWithdrawResponse is a dummy JSON response for withdraw requests
108
func PostWithdrawResponse() []byte {
109
	return []byte(`
110
	{
111
		"reference":"26676007-1c31-46d7-9c71-acb031cf0de4",
112
		"status":"PENDING"
113
	}
114
`)
115
}
116
117
// GetHistoryResponse is a dummy JSON response for the transaction history
118
func GetHistoryResponse() string {
119
	return `
120
	{
121
		"data": [
122
			{
123
				"datetime": "2021-01-29T09:52:34.876707Z",
124
				"code": "CP210129D0001P",
125
				"operator_tx_code": "MP210129.1052.A35072",
126
				"operator": "Orange",
127
				"phone_number": "237696546822",
128
				"description": "Test",
129
				"external_user": "",
130
				"amount": 5,
131
				"charge_amount": 0.05,
132
				"debit": 0,
133
				"credit": 4.95,
134
				"status": "SUCCESSFUL",
135
				"reference_uuid": "25c63c72-8485-4059-85ad-fdb4bfb26c21"
136
			},
137
			{
138
				"datetime": "2021-01-25T12:44:11.808507Z",
139
				"code": "CP210125D0001N",
140
				"operator_tx_code": "2171591856",
141
				"operator": "MTN",
142
				"phone_number": "237679587525",
143
				"description": "Test",
144
				"external_user": "",
145
				"amount": 5,
146
				"charge_amount": 0.05,
147
				"debit": 0,
148
				"credit": 4.95,
149
				"status": "FAILED",
150
				"reference_uuid": "769dc5c3-1a98-4788-bac4-2daaa49a58b6"
151
			}
152
		]
153
	}
154
`
155
}
156