Skip to content

Commit

Permalink
chore: add business hours data models
Browse files Browse the repository at this point in the history
Signed-off-by: Kathurima Kimathi <[email protected]>
  • Loading branch information
KathurimaKimathi committed Oct 12, 2023
1 parent 3a810d8 commit 973f6be
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 40 deletions.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestMakeRequest(t *testing.T) {
ValidTo: "2023-09-01",
},
},
BusinessHours: []any{},
BusinessHours: []BusinessHours{},
},
want: http.StatusOK,
},
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestMakeRequest(t *testing.T) {
ValidTo: "2023-09-01",
},
},
BusinessHours: []any{},
BusinessHours: []BusinessHours{},
},
want: http.StatusOK,
},
Expand Down
60 changes: 46 additions & 14 deletions healthcrm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestHealthCRMLib_CreateFacility(t *testing.T) {
ValidTo: "2023-09-01",
},
},
BusinessHours: []any{},
BusinessHours: []BusinessHours{},
},
},
wantErr: false,
Expand Down Expand Up @@ -111,9 +111,17 @@ func TestHealthCRMLib_CreateFacility(t *testing.T) {
Latitude: 30.4556,
Longitude: 4.54556,
},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []any{},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []BusinessHoursOutput{
{
ID: gofakeit.UUID(),
Day: "MONDAY",
OpeningTime: "08:00:01",
ClosingTime: "18:00:01",
FacilityID: gofakeit.UUID(),
},
},
}
return httpmock.NewJsonResponse(http.StatusCreated, resp)
})
Expand All @@ -132,7 +140,7 @@ func TestHealthCRMLib_CreateFacility(t *testing.T) {
Coordinates: &Coordinates{},
Contacts: []Contacts{},
Identifiers: []Identifiers{},
BusinessHours: []any{},
BusinessHours: []BusinessHours{},
}
return httpmock.NewJsonResponse(http.StatusBadRequest, resp)
})
Expand Down Expand Up @@ -214,9 +222,17 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) {
Latitude: 30.4556,
Longitude: 4.54556,
},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []any{},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []BusinessHoursOutput{
{
ID: gofakeit.UUID(),
Day: "MONDAY",
OpeningTime: "08:00:01",
ClosingTime: "18:00:01",
FacilityID: gofakeit.UUID(),
},
},
}
return httpmock.NewJsonResponse(http.StatusOK, resp)
})
Expand Down Expand Up @@ -311,9 +327,17 @@ func TestHealthCRMLib_GetFacilityByID(t *testing.T) {
Latitude: 30.4556,
Longitude: 4.54556,
},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []any{},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []BusinessHoursOutput{
{
ID: gofakeit.UUID(),
Day: "MONDAY",
OpeningTime: "08:00:01",
ClosingTime: "18:00:01",
FacilityID: gofakeit.UUID(),
},
},
}
return httpmock.NewJsonResponse(http.StatusOK, resp)
})
Expand Down Expand Up @@ -418,9 +442,17 @@ func TestHealthCRMLib_UpdateFacility(t *testing.T) {
Latitude: 30.4556,
Longitude: 4.54556,
},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []any{},
Contacts: []ContactsOutput{},
Identifiers: []IdentifiersOutput{},
BusinessHours: []BusinessHoursOutput{
{
ID: gofakeit.UUID(),
Day: "MONDAY",
OpeningTime: "08:00:01",
ClosingTime: "18:00:01",
FacilityID: gofakeit.UUID(),
},
},
}
return httpmock.NewJsonResponse(http.StatusOK, resp)
})
Expand Down
29 changes: 18 additions & 11 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package healthcrm

// Facility is the hospitals data class
type Facility struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
FacilityType string `json:"facility_type,omitempty"`
County string `json:"county,omitempty"`
Country string `json:"country,omitempty"`
Address string `json:"address,omitempty"`
Coordinates *Coordinates `json:"coordinates,omitempty"`
Contacts []Contacts `json:"contacts,omitempty"`
Identifiers []Identifiers `json:"identifiers,omitempty"`
BusinessHours []any `json:"businesshours,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
FacilityType string `json:"facility_type,omitempty"`
County string `json:"county,omitempty"`
Country string `json:"country,omitempty"`
Address string `json:"address,omitempty"`
Coordinates *Coordinates `json:"coordinates,omitempty"`
Contacts []Contacts `json:"contacts,omitempty"`
Identifiers []Identifiers `json:"identifiers,omitempty"`
BusinessHours []BusinessHours `json:"businesshours,omitempty"`
}

// Coordinates models the geographical's location data class of a facility
Expand All @@ -35,3 +35,10 @@ type Identifiers struct {
ValidFrom string `json:"valid_from,omitempty"`
ValidTo string `json:"valid_to,omitempty"`
}

// BusinessHours models data to store business hours
type BusinessHours struct {
Day string `json:"day"`
OpeningTime string `json:"opening_time"`
ClosingTime string `json:"closing_time"`
}
26 changes: 13 additions & 13 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ type IdentifiersOutput struct {

// FacilityOutput is used to display facility(ies)
type FacilityOutput struct {
ID string `json:"id"`
Created time.Time `json:"created"`
Name string `json:"name"`
Description string `json:"description"`
FacilityType string `json:"facility_type"`
County string `json:"county"`
Country string `json:"country"`
Coordinates CoordinatesOutput `json:"coordinates"`
Status string `json:"status"`
Address string `json:"address"`
Contacts []ContactsOutput `json:"contacts"`
Identifiers []IdentifiersOutput `json:"identifiers"`
BusinessHours []any `json:"businesshours"`
ID string `json:"id"`
Created time.Time `json:"created"`
Name string `json:"name"`
Description string `json:"description"`
FacilityType string `json:"facility_type"`
County string `json:"county"`
Country string `json:"country"`
Coordinates CoordinatesOutput `json:"coordinates"`
Status string `json:"status"`
Address string `json:"address"`
Contacts []ContactsOutput `json:"contacts"`
Identifiers []IdentifiersOutput `json:"identifiers"`
BusinessHours []BusinessHoursOutput `json:"businesshours"`
}

// BusinessHoursOutput models data that show facility's operational hours
Expand Down

0 comments on commit 973f6be

Please sign in to comment.