Skip to content

Commit 1159287

Browse files
committed
Start fleshing out scheme, operations and work orders resources and routers
1 parent ece2e59 commit 1159287

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.ctrlhub.core.governance.schemes.response
2+
3+
class Scheme {
4+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.ctrlhub.core.governance.schemes.workorders.operations
2+
3+
import com.ctrlhub.core.governance.schemes.workorders.operations.response.Operation
4+
import com.ctrlhub.core.router.Router
5+
import io.ktor.client.HttpClient
6+
7+
class OperationsRouter(httpClient: HttpClient) : Router(httpClient) {
8+
suspend fun all(organisationId: String, schemeId: String, workOrderId: String): List<Operation> {
9+
val endpoint = "/v3/orgs/$organisationId/governance/schemes/$schemeId/work-orders/$workOrderId/operations"
10+
11+
return fetchJsonApiResources(endpoint)
12+
}
13+
14+
suspend fun one(organisationId: String, schemeId: String, workOrderId: String, operationId: String): Operation {
15+
val endpoint = "/v3/orgs/$organisationId/governance/schemes/$schemeId/work-orders/$workOrderId/operations/$operationId"
16+
17+
return fetchJsonApiResource(endpoint)
18+
}
19+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.ctrlhub.core.governance.schemes.workorders.operations.response
2+
3+
import com.ctrlhub.core.iam.response.User
4+
import com.fasterxml.jackson.annotation.JsonCreator
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
import com.fasterxml.jackson.annotation.JsonProperty
7+
import com.github.jasminb.jsonapi.annotations.Relationship
8+
import com.github.jasminb.jsonapi.annotations.Type
9+
import java.time.LocalDate
10+
11+
@Type("operations")
12+
@JsonIgnoreProperties(ignoreUnknown = true)
13+
class Operation @JsonCreator constructor(
14+
@JsonProperty("name") var name: String = "",
15+
@JsonProperty("code") var code: String = "",
16+
@JsonProperty("description") var description: String = "",
17+
@JsonProperty("start_date") var startDate: LocalDate? = null,
18+
@JsonProperty("end_date") var endDate: LocalDate? = null,
19+
@JsonProperty("uprns") var uprns: List<String> = emptyList(),
20+
@JsonProperty("usrns") var usrns: List<String> = emptyList(),
21+
@JsonProperty("completed") var completed: Boolean = false,
22+
@JsonProperty("aborted") var aborted: Boolean = false,
23+
@JsonProperty("cancelled") var cancelled: Boolean = false,
24+
25+
@Relationship("assignees")
26+
var assignees: List<User> = emptyList()
27+
) {
28+
constructor(): this(
29+
name = "",
30+
code = "",
31+
description = "",
32+
startDate = null,
33+
endDate = null,
34+
uprns = emptyList(),
35+
usrns = emptyList(),
36+
completed = false,
37+
aborted = false,
38+
cancelled = false
39+
)
40+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.ctrlhub.core.governance.schemes.workorders.response
2+
3+
import com.ctrlhub.core.governance.schemes.workorders.operations.response.Operation
4+
import com.fasterxml.jackson.annotation.JsonCreator
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
6+
import com.fasterxml.jackson.annotation.JsonProperty
7+
import com.github.jasminb.jsonapi.annotations.Relationship
8+
import com.github.jasminb.jsonapi.annotations.Type
9+
import java.time.LocalDate
10+
11+
@Type("work-orders")
12+
@JsonIgnoreProperties(ignoreUnknown = true)
13+
class WorkOrder @JsonCreator constructor(
14+
@JsonProperty("name") var name: String = "",
15+
@JsonProperty("code") var code: String = "",
16+
@JsonProperty("description") var description: String = "",
17+
@JsonProperty("start_date") var startDate: LocalDate? = null,
18+
@JsonProperty("end_date") var endDate: LocalDate? = null,
19+
20+
@Relationship("operations")
21+
var operations: List<Operation> = emptyList()
22+
) {
23+
constructor() : this(
24+
name = "",
25+
code = "",
26+
description = "",
27+
startDate = null,
28+
endDate = null
29+
)
30+
}

0 commit comments

Comments
 (0)