-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPA-77_get-events-by-policy #8
base: develop
Are you sure you want to change the base?
Changes from all commits
819c9f9
83c265e
590e2ca
9fa17eb
4a6315c
26a9abb
8844180
9074eeb
cd3b02d
81e2f6c
95fa820
7e8f93d
7d7ae58
1bee040
2844972
b957c92
5cc0e26
563f3da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,20 @@ class EventApiClient(engine: HttpClientEngine) : IEventApiClient { | |
|
||
private val apiHttpClient = ApiHttpClient(engine) | ||
private val httpClient = apiHttpClient.httpClient | ||
|
||
override suspend fun getEventsByPolicy(userId: String, policyId: String): Result<List<EventDTO>> { | ||
return try { | ||
val response = httpClient.get("${apiHttpClient.url}/events/${userId}?policy=${policyId}") | ||
|
||
if (response.status == HttpStatusCode.OK) { | ||
Result.success(response.body()) | ||
} else { | ||
Result.failure(Exception(response.status.description)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Há algum tipo de documentação ou swagger que diga o tipo de excepções que podem ocorrer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Não, é por isso que decidimos criar uma exception com a mensagem que vem da API |
||
} | ||
} catch (e: Exception) { | ||
Result.failure(e) | ||
} | ||
} | ||
|
||
override suspend fun getAllEventsForUser(userId: String): Result<List<EventDTO>> { | ||
return try { | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline? :)