Passed
Push — main ( cad01e...53329a )
by Acho
02:26
created

afrikpay.AirtimeMode.String   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 afrikpay
2
3
import "net/http"
4
5
// AirtimeTransferParams parameters for airtime transfer request
6
type AirtimeTransferParams struct {
7
	Operator          string
8
	PhoneNumber       string
9
	PurchaseReference string
10
	Amount            string
11
	Mode              AirtimeMode
12
}
13
14
// AirtimeMode is used to determine the payment mode
15
type AirtimeMode string
16
17
const (
18
	// AirtimeModeCash payment from agent partner account
19
	AirtimeModeCash = AirtimeMode("cash")
20
	// AirtimeModeMoney send payment request
21
	AirtimeModeMoney = AirtimeMode("money")
22
	// AirtimeModeAccount make payment operation from afrikpay client
23
	AirtimeModeAccount = AirtimeMode("account")
24
)
25
26
// String converts the AirtimeMode to a string
27
func (mode AirtimeMode) String() string {
28
	return string(mode)
29
}
30
31
// AirtimeResponse is returned from airtime api requests
32
type AirtimeResponse struct {
33
	Code    int                 `json:"code"`
34
	Message string              `json:"message"`
35
	Result  *AirtimeTransaction `json:"result,omitempty"`
36
}
37
38
// AirtimeTransaction is the details for an aitime transaction
39
type AirtimeTransaction struct {
40
	OperatorID       string      `json:"operatorid"`
41
	TransactionID    string      `json:"txnid"`
42
	Status           string      `json:"status"`
43
	Date             string      `json:"date"`
44
	Ticket           interface{} `json:"ticket,omitempty"`
45
	ReferenceID      string      `json:"referenceid"`
46
	ProcessingNumber string      `json:"processingnumber"`
47
}
48
49
// IsSuccessfull determines if the transaction was successful
50
func (response AirtimeResponse) IsSuccessfull() bool {
51
	return response.Code == http.StatusOK
52
}
53