Passed
Push — main ( a8aa17...206f54 )
by Acho
02:05
created

utilities.go   A

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 22
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A campay.*UtilitiesTransaction.IsSuccessfull 0 2 1
A campay.*UtilitiesTransaction.IsPending 0 2 1
1
package campay
2
3
// AirtimeTransferParams are parameters for transferring airtime
4
type AirtimeTransferParams struct {
5
	Amount            string `json:"amount"`
6
	To                string `json:"to"`
7
	ExternalReference string `json:"external_reference"`
8
}
9
10
// AirtimeTransferResponse is gotten after transferring airtime
11
type AirtimeTransferResponse struct {
12
	Reference string `json:"reference"`
13
	Status    string `json:"status"`
14
}
15
16
// UtilitiesTransaction represent a utility transaction
17
type UtilitiesTransaction struct {
18
	Reference         string      `json:"reference"`
19
	ExternalReference string      `json:"external_reference"`
20
	Status            string      `json:"status"`
21
	Amount            float64     `json:"amount"`
22
	Currency          string      `json:"currency"`
23
	Operator          string      `json:"operator"`
24
	Code              string      `json:"code"`
25
	Type              string      `json:"type"`
26
	Reason            interface{} `json:"reason"`
27
}
28
29
// IsPending checks if a transaction is pending
30
func (transaction *UtilitiesTransaction) IsPending() bool {
31
	return transaction.Status == "PENDING"
32
}
33
34
// IsSuccessfull checks if a transaction is successfull
35
func (transaction *UtilitiesTransaction) IsSuccessfull() bool {
36
	return transaction.Status == "SUCCESSFUL"
37
}
38