Add Checkin

This commit is contained in:
aditya.siregar
2024-08-13 23:09:05 +07:00
parent 4c8999a3cf
commit e544ef8f71
18 changed files with 362 additions and 101 deletions
+3
View File
@@ -8,6 +8,7 @@ const (
BadRequest Code = "40000"
InvalidRequest Code = "40001"
Unauthorized Code = "40100"
CheckinInvalid Code = "40002"
Forbidden Code = "40300"
Timeout Code = "50400"
)
@@ -23,6 +24,7 @@ var (
ServerError: "Internal Server Error",
Forbidden: "Forbidden",
InvalidRequest: "Invalid Request",
CheckinInvalid: "Ticket Already Used or Expired",
}
codeHTTPMap = map[Code]int{
@@ -33,6 +35,7 @@ var (
ServerError: http.StatusInternalServerError,
Forbidden: http.StatusForbidden,
InvalidRequest: http.StatusUnprocessableEntity,
CheckinInvalid: http.StatusBadRequest,
}
)
+19 -14
View File
@@ -19,23 +19,25 @@ const (
errUnauthorized ErrType = "Unauthorized"
errInsufficientBalance ErrType = "Insufficient Balance"
errInactivePartner ErrType = "Partner's license is invalid or has expired. Please contact Admin Support."
errTicketAlreadyUsed ErrType = "Ticket Already Used."
)
var (
ErrorBadRequest = NewServiceException(errBadRequest)
ErrorInvalidRequest = NewServiceException(errInvalidRequest)
ErrorUnauthorized = NewServiceException(errUnauthorized)
ErrorOrderNotFound = NewServiceException(errOrderNotFound)
ErrorClientIDNotDefined = NewServiceException(errCheckoutIDNotDefined)
ErrorRequestTimeout = NewServiceException(errRequestTimeOut)
ErrorExternalCall = NewServiceException(errExternalCall)
ErrorFailedExternalCall = NewServiceException(errFailedExternalCall)
ErrorConnectionTimeOut = NewServiceException(errConnectTimeOut)
ErrorInternalServer = NewServiceException(errInternalServer)
ErrorUserIsNotFound = NewServiceException(errUserIsNotFound)
ErrorUserInvalidLogin = NewServiceException(errInvalidLogin)
ErrorInsufficientBalance = NewServiceException(errInsufficientBalance)
ErrorInvalidLicense = NewServiceException(errInactivePartner)
ErrorBadRequest = NewServiceException(errBadRequest)
ErrorInvalidRequest = NewServiceException(errInvalidRequest)
ErrorUnauthorized = NewServiceException(errUnauthorized)
ErrorOrderNotFound = NewServiceException(errOrderNotFound)
ErrorClientIDNotDefined = NewServiceException(errCheckoutIDNotDefined)
ErrorRequestTimeout = NewServiceException(errRequestTimeOut)
ErrorExternalCall = NewServiceException(errExternalCall)
ErrorFailedExternalCall = NewServiceException(errFailedExternalCall)
ErrorConnectionTimeOut = NewServiceException(errConnectTimeOut)
ErrorInternalServer = NewServiceException(errInternalServer)
ErrorUserIsNotFound = NewServiceException(errUserIsNotFound)
ErrorUserInvalidLogin = NewServiceException(errInvalidLogin)
ErrorInsufficientBalance = NewServiceException(errInsufficientBalance)
ErrorInvalidLicense = NewServiceException(errInactivePartner)
ErrorTicketInvalidOrAlreadyUsed = NewServiceException(errTicketAlreadyUsed)
)
type Error interface {
@@ -115,6 +117,9 @@ func (s *ServiceException) MapErrorsToCode() Code {
case errInactivePartner:
return BadRequest
case errTicketAlreadyUsed:
return CheckinInvalid
default:
return BadRequest
}