Passed
Push — main ( 53329a...1d4b72 )
by Acho
02:01
created

afrikpay.BillResponse.IsSuccessful   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
dl 0
loc 2
rs 10
c 0
b 0
f 0
nop 0
1
package afrikpay
2
3
import "net/http"
4
5
// Biller is the type of bill we want to pay
6
type Biller string
7
8
const (
9
	// BillerEneoPostpay is used for postpaid bills of ENEO
10
	BillerEneoPostpay = Biller("eneopostpay")
11
	// BillerEneoPrepay is used for postpaid bills of ENEO
12
	BillerEneoPrepay = Biller("eneoprepay")
13
	// BillerCamwater is used for postpaid bills of Cameroon Water Utilities Corporation
14
	BillerCamwater = Biller("camwater")
15
	// BillerCanal is used for postpaid bills of canal+ subscriptions
16
	BillerCanal = Biller("canal")
17
18
	// BillerUDS is used for postpaid bills of UDS
19
	BillerUDS = Biller("uds")
20
)
21
22
// string converts the Biller to a string
23
func (biller Biller) string() string {
24
	return string(biller)
25
}
26
27
// BillSMS determines if we want to receive a notification via SMS
28
type BillSMS string
29
30
const (
31
	// BillSMSEnabled means you will receive a notification via SMS
32
	BillSMSEnabled = BillSMS("yes")
33
	// BillSMSDisabled means you will not receive a notification via SMS
34
	BillSMSDisabled = BillSMS("no")
35
)
36
37
// string converts the BillSMS to a string
38
func (sms *BillSMS) string() string {
39
	if sms == nil {
40
		return string(BillSMSDisabled)
41
	}
42
	return string(*sms)
43
}
44
45
// Pointer converts BillSMS to *BillSMS
46
func (sms BillSMS) Pointer() *BillSMS {
47
	return &sms
48
}
49
50
// BillPayParams parameters for bill payment request
51
type BillPayParams struct {
52
	Biller           Biller
53
	BillID           string
54
	Mode             Mode
55
	Amount           *string
56
	Provider         *string
57
	Account          *string
58
	Mobile           *string
59
	Code             *string
60
	SMS              *BillSMS
61
	ProcessingNumber *string
62
}
63
64
// BillResponse is returned from bill api requests
65
type BillResponse struct {
66
	Code    int              `json:"code"`
67
	Message string           `json:"message"`
68
	Result  *BillTransaction `json:"result,omitempty"`
69
}
70
71
// BillTransaction is the details for a bill payment transaction
72
type BillTransaction struct {
73
	OperatorID       string      `json:"operatorid"`
74
	TransactionID    string      `json:"txnid"`
75
	Status           string      `json:"status"`
76
	Date             string      `json:"date"`
77
	ReferenceID      interface{} `json:"referenceid"`
78
	ProcessingNumber string      `json:"processingnumber"`
79
}
80
81
// IsSuccessful determines if the transaction was successful
82
func (response BillResponse) IsSuccessful() bool {
83
	return response.Code == http.StatusOK
84
}
85