Documentation ¶
Index ¶
- func GenerateID() string
- func GetAttachmentIDFromVars(vars map[string]string) string
- func GetPractitionerIDFromVars(vars map[string]string) string
- func GetTransactionIDFromVars(vars map[string]string) string
- func IsDateBeforeDate(beforeDate string, afterDate string) (bool, error)
- func IsDateBetweenIncorporationAndNow(dateToTest string, incorporationDate string) (bool, error)
- func IsDateInFuture(dateToTest string) (bool, error)
- func ResponseTypeToStatus(responseType string) (int, error)
- func Validate(data interface{}) string
- func ValidateDate(dateToTest string) (time.Time, error)
- func ValidateTransaction(helperService HelperService, req *http.Request, res http.ResponseWriter, ...) (string, bool)
- func WriteJSONWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, status int)
- type HelperService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateID ¶
func GenerateID() string
GenerateID generates an ID in the format of [A-Z]{2}[0-9]{8}
func GetAttachmentIDFromVars ¶
GetAttachmentIDFromVars returns the attachment id from the supplied request vars
func GetPractitionerIDFromVars ¶
GetPractitionerIDFromVars returns the practitioner id from the supplied request vars.
func GetTransactionIDFromVars ¶
GetTransactionIDFromVars returns the transaction id from the supplied request vars.
func IsDateBeforeDate ¶
IsDateBeforeDate check if before date is earlier than after date
func IsDateBetweenIncorporationAndNow ¶
IsDateBetweenIncorporationAndNow is a helper function to check if the date supplied is in the future or before the incorporation date
func IsDateInFuture ¶
IsDateInFuture check if the date supplied is after today
func ResponseTypeToStatus ¶
ResponseTypeToStatus converts a response type to an http status
func Validate ¶
func Validate(data interface{}) string
Validate takes in any request object and checks whether it has met the validation criteria according to the annotations on that object. If the object is invalid, the method returns a human-readable string which can then be added to the message response for the API user
func ValidateDate ¶
ValidateDate check date is in a valid date format
func ValidateTransaction ¶
func WriteJSONWithStatus ¶
func WriteJSONWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, status int)
WriteJSONWithStatus writes the interface as a json string with the supplied status.
Types ¶
type HelperService ¶
type HelperService interface { HandleTransactionIdExistsValidation(w http.ResponseWriter, req *http.Request, transactionID string) (bool, string) HandleTransactionNotClosedValidation(w http.ResponseWriter, req *http.Request, transactionID string, isTransactionClosed bool, httpStatus int, err error) bool HandleBodyDecodedValidation(w http.ResponseWriter, req *http.Request, transactionID string, err error) bool HandleMandatoryFieldValidation(w http.ResponseWriter, req *http.Request, err string) bool HandleAttachmentValidation(w http.ResponseWriter, req *http.Request, transactionID string, attachment models.AttachmentResourceDao, err error) bool HandleAttachmentTypeValidation(w http.ResponseWriter, req *http.Request, responseMessage string, err error) int HandleEtagGenerationValidation(err error) bool HandleCreateResourceValidation(w http.ResponseWriter, req *http.Request, statusCode int, err error) bool // GenerateEtag generates a random etag which is generated on every write action GenerateEtag() (string, error) }
HelperService interface declares
func NewHelperService ¶
func NewHelperService() HelperService
NewHelperService will create a new instance of the HelperService interface.