-
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.
Merge branch 'event-all-endpoint' of https://github.com/cs-24-sw-8-04…
…/scheduling into event-all-endpoint
- Loading branch information
Showing
14 changed files
with
321 additions
and
65 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
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
68 changes: 65 additions & 3 deletions
68
frontend/app/src/main/java/dk/scheduling/schedulingfrontend/api/ApiService.kt
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,8 +1,70 @@ | ||
package dk.scheduling.schedulingfrontend.api | ||
import retrofit2.Call | ||
import dk.scheduling.schedulingfrontend.api.protocol.CreateDeviceRequest | ||
import dk.scheduling.schedulingfrontend.api.protocol.CreateTaskRequest | ||
import dk.scheduling.schedulingfrontend.api.protocol.DeleteDeviceRequest | ||
import dk.scheduling.schedulingfrontend.api.protocol.DeleteTaskRequest | ||
import dk.scheduling.schedulingfrontend.api.protocol.Device | ||
import dk.scheduling.schedulingfrontend.api.protocol.RegisterOrLoginRequest | ||
import dk.scheduling.schedulingfrontend.api.protocol.RegisterOrLoginResponse | ||
import dk.scheduling.schedulingfrontend.api.protocol.Task | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.POST | ||
|
||
interface ApiService { | ||
@GET("test") | ||
fun test(): Call<String> | ||
/* | ||
* Accounts | ||
*/ | ||
@POST("accounts/register") | ||
suspend fun registerAccount( | ||
@Body registerOrLoginRequest: RegisterOrLoginRequest, | ||
): Response<RegisterOrLoginResponse> | ||
|
||
@POST("accounts/login") | ||
suspend fun loginToAccount( | ||
@Body registerOrLoginRequest: RegisterOrLoginRequest, | ||
): Response<RegisterOrLoginResponse> | ||
|
||
/* | ||
* Devices | ||
*/ | ||
@GET("devices/all") | ||
suspend fun getDevices( | ||
@Header("X-Auth-Token") authToken: String, | ||
): Response<List<Device>> | ||
|
||
@POST("devices/create") | ||
suspend fun createDevice( | ||
@Header("X-Auth-Token") authToken: String, | ||
@Body createDeviceRequest: CreateDeviceRequest, | ||
): Response<Device> | ||
|
||
@DELETE("devices/delete") | ||
suspend fun deleteDevice( | ||
@Header("X-Auth-Token") authToken: String, | ||
@Body deleteDeviceRequest: DeleteDeviceRequest, | ||
): Response<String> | ||
|
||
/* | ||
* Tasks | ||
*/ | ||
@GET("tasks/all") | ||
suspend fun getTasks( | ||
@Header("X-Auth-Token") authToken: String, | ||
): Response<List<Task>> | ||
|
||
@POST("tasks/create") | ||
suspend fun createTask( | ||
@Header("X-Auth-Token") authToken: String, | ||
@Body createTaskRequest: CreateTaskRequest, | ||
): Response<Task> | ||
|
||
@DELETE("tasks/delete") | ||
suspend fun deleteTask( | ||
@Header("X-Auth-Token") authToken: String, | ||
@Body deleteTaskRequest: DeleteTaskRequest, | ||
): Response<String> | ||
} |
12 changes: 12 additions & 0 deletions
12
frontend/app/src/main/java/dk/scheduling/schedulingfrontend/api/protocol/Accounts.kt
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,12 @@ | ||
package dk.scheduling.schedulingfrontend.api.protocol | ||
|
||
import java.util.UUID | ||
|
||
data class RegisterOrLoginRequest( | ||
val username: String, | ||
val password: String, | ||
) | ||
|
||
data class RegisterOrLoginResponse( | ||
val auth_token: UUID, | ||
) |
15 changes: 15 additions & 0 deletions
15
frontend/app/src/main/java/dk/scheduling/schedulingfrontend/api/protocol/Devices.kt
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,15 @@ | ||
package dk.scheduling.schedulingfrontend.api.protocol | ||
|
||
data class Device( | ||
val id: Long, | ||
val effect: Double, | ||
val account_id: Long, | ||
) | ||
|
||
data class CreateDeviceRequest( | ||
val effect: Double, | ||
) | ||
|
||
data class DeleteDeviceRequest( | ||
val id: Long, | ||
) |
18 changes: 18 additions & 0 deletions
18
frontend/app/src/main/java/dk/scheduling/schedulingfrontend/api/protocol/Tasks.kt
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,18 @@ | ||
package dk.scheduling.schedulingfrontend.api.protocol | ||
|
||
data class Task( | ||
val id: Long, | ||
val timespan: Timespan, | ||
val duration: Long, | ||
val device_id: Long, | ||
) | ||
|
||
data class CreateTaskRequest( | ||
val timespan: Timespan, | ||
val duration: Long, | ||
val device_id: Long, | ||
) | ||
|
||
data class DeleteTaskRequest( | ||
val id: Long, | ||
) |
7 changes: 7 additions & 0 deletions
7
frontend/app/src/main/java/dk/scheduling/schedulingfrontend/api/protocol/Timespan.kt
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,7 @@ | ||
package dk.scheduling.schedulingfrontend.api.protocol | ||
|
||
// TODO: This should not be strings | ||
data class Timespan( | ||
val start: String, | ||
val end: String, | ||
) |
Oops, something went wrong.