-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create client-user profile (#41)
- Loading branch information
Showing
35 changed files
with
1,812 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package enums | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"strconv" | ||
) | ||
|
||
// ClientType defines various client types | ||
type ClientType string | ||
|
||
const ( | ||
// ClientTypePmtct represents a Prevention of mother-to-child transmission client type | ||
ClientTypePmtct ClientType = "PMTCT" | ||
|
||
// ClientTypeOvc represents an Orphan and Vulnerable Children client type | ||
ClientTypeOvc ClientType = "OVC" | ||
) | ||
|
||
// AllClientType represents a slice of all possible `ClientType` values | ||
var AllClientType = []ClientType{ | ||
ClientTypePmtct, | ||
ClientTypeOvc, | ||
} | ||
|
||
// IsValid returns true if a client type is valid | ||
func (e ClientType) IsValid() bool { | ||
switch e { | ||
case ClientTypePmtct, ClientTypeOvc: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// String ... | ||
func (e ClientType) String() string { | ||
return string(e) | ||
} | ||
|
||
// UnmarshalGQL converts the supplied value to a metric type. | ||
func (e *ClientType) UnmarshalGQL(v interface{}) error { | ||
str, ok := v.(string) | ||
if !ok { | ||
return fmt.Errorf("enums must be strings") | ||
} | ||
|
||
*e = ClientType(str) | ||
if !e.IsValid() { | ||
return fmt.Errorf("%s is not a valid ClientType", str) | ||
} | ||
return nil | ||
} | ||
|
||
// MarshalGQL writes the metric type to the supplied writer | ||
func (e ClientType) MarshalGQL(w io.Writer) { | ||
fmt.Fprint(w, strconv.Quote(e.String())) | ||
} |
2 changes: 1 addition & 1 deletion
2
pkg/onboarding/domain/enum.go → pkg/onboarding/application/enums/metrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package domain | ||
package enums | ||
|
||
import ( | ||
"fmt" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.