This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
structs.go
75 lines (64 loc) · 2.6 KB
/
structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package efgs
import "time"
type genericVerServerResponse struct {
Error string `json:"error"`
ErrorCode string `json:"errorCode"`
}
type issueCodeRequest struct {
Phone string `json:"phone"`
TestType string `json:"testType"`
}
type issueCodeResponse struct {
genericVerServerResponse
Code string `json:"code"`
}
type verifyRequest struct {
Code string `json:"code"`
}
type verifyResponse struct {
genericVerServerResponse
Token string `json:"token"`
}
type certificateRequest struct {
Token string `json:"token"`
KeyHmac string `json:"ekeyhmac"`
}
type certificateResponse struct {
genericVerServerResponse
Certificate string `json:"certificate"`
}
//DiagnosisKeyWrapper map json response from EFGS to local DiagnosisKey structure
type DiagnosisKeyWrapper struct {
tableName struct{} `pg:"diagnosis_keys,alias:dk"`
ID int32 `pg:",pk" json:"id"`
CreatedAt time.Time `pg:"default:now()" json:"created_at"`
KeyData []byte `json:"keyData,omitempty"`
RollingStartIntervalNumber uint32 `json:"rollingStartIntervalNumber,omitempty"`
RollingPeriod uint32 `json:"rollingPeriod,omitempty"`
TransmissionRiskLevel int32 `json:"transmissionRiskLevel,omitempty"`
VisitedCountries []string `json:"visitedCountries,omitempty"`
Origin string `pg:"default:'CZ'" json:"origin,omitempty"`
ReportType string `json:"reportType,omitempty"`
DaysSinceOnsetOfSymptoms int32 `json:"days_since_onset_of_symptoms,omitempty"`
}
//ToData convert struct from DiagnosisKeyWrapper to DiagnosisKey
func (wrappedKey *DiagnosisKeyWrapper) ToData() *DiagnosisKey {
var mapReportType = map[string]ReportType{
"UNKNOWN": ReportType_UNKNOWN,
"CONFIRMED_TEST": ReportType_CONFIRMED_TEST,
"CONFIRMED_CLINICAL_DIAGNOSIS": ReportType_CONFIRMED_CLINICAL_DIAGNOSIS,
"SELF_REPORT": ReportType_SELF_REPORT,
"RECURSIVE": ReportType_RECURSIVE,
"REVOKED": ReportType_REVOKED,
}
return &DiagnosisKey{
KeyData: wrappedKey.KeyData,
RollingStartIntervalNumber: wrappedKey.RollingStartIntervalNumber,
RollingPeriod: wrappedKey.RollingPeriod,
TransmissionRiskLevel: wrappedKey.TransmissionRiskLevel,
Origin: wrappedKey.Origin,
DaysSinceOnsetOfSymptoms: wrappedKey.DaysSinceOnsetOfSymptoms,
VisitedCountries: wrappedKey.VisitedCountries,
ReportType: mapReportType[wrappedKey.ReportType],
}
}