Skip to content
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

v2.0.0 beta 1 minor fixes #167

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/main/kotlin/com/nylas/NylasClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,21 @@ class NylasClient(

private fun addQueryParams(url: HttpUrl.Builder, params: Map<String, Any>): HttpUrl.Builder {
for ((key, value) in params) {
url.addQueryParameter(key, value.toString())
when (value) {
is List<*> -> {
for (item in value) {
url.addQueryParameter(key, item.toString())
}
}
is Map<*, *> -> {
for ((k, v) in value) {
url.addQueryParameter(key, "$k:$v")
}
}
else -> {
url.addQueryParameter(key, value.toString())
}
}
}
return url
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/IQueryParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface IQueryParams {
* Convert the query parameters to a json-formatted map.
* @return Map of query parameters
*/
fun convertToMap(): Map<String, String> {
fun convertToMap(): Map<String, Any> {
val json = JsonHelper.moshi()
.adapter(this.javaClass)
.toJson(this)
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/com/nylas/resources/Calendars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.squareup.moshi.Types
class Calendars(client: NylasClient) : Resource<Calendar>(client, Calendar::class.java) {
/**
* Return all Calendars
* @param identifier The identifier of the grant to act upon
* @param identifier Grant ID or email account to query.
* @param queryParams The query parameters to include in the request
* @return The list of Calendars
*/
Expand All @@ -30,9 +30,9 @@ class Calendars(client: NylasClient) : Resource<Calendar>(client, Calendar::clas

/**
* Return a Calendar
* @param identifier The identifier of the grant to act upon
* @param identifier Grant ID or email account to query.
* @param calendarId The id of the Calendar to retrieve. Use "primary" to refer to the primary calendar associated with grant.
* @return The Calendar
* @return The calendar
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun find(identifier: String, calendarId: String): Response<Calendar> {
Expand All @@ -42,9 +42,9 @@ class Calendars(client: NylasClient) : Resource<Calendar>(client, Calendar::clas

/**
* Create a Calendar
* @param identifier The identifier of the grant to act upon
* @param requestBody The values to create the Calendar with
* @return The created Calendar
* @param identifier Grant ID or email account in which to create the object.
* @param requestBody The values to create the calendar with
* @return The created calendar
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun create(identifier: String, requestBody: CreateCalendarRequest): Response<Calendar> {
Expand All @@ -56,10 +56,10 @@ class Calendars(client: NylasClient) : Resource<Calendar>(client, Calendar::clas

/**
* Update a Calendar
* @param identifier The identifier of the grant to act upon
* @param calendarId The id of the Calendar to update. Use "primary" to refer to the primary calendar associated with grant.
* @param requestBody The values to update the Calendar with
* @return The updated Calendar
* @param identifier Grant ID or email account in which to update an object.
* @param calendarId The id of the calendar to update. Use "primary" to refer to the primary calendar associated with grant.
* @param requestBody The values to update the calendar with
* @return The updated calendar
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun update(identifier: String, calendarId: String, requestBody: UpdateCalendarRequest): Response<Calendar> {
Expand All @@ -71,7 +71,7 @@ class Calendars(client: NylasClient) : Resource<Calendar>(client, Calendar::clas

/**
* Delete a Calendar
* @param identifier The identifier of the grant to act upon
* @param identifier Grant ID or email account from which to delete an object.
* @param calendarId The id of the Calendar to delete. Use "primary" to refer to the primary calendar associated with grant.
* @return The deletion response
*/
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/com/nylas/resources/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import com.nylas.util.JsonHelper
class Events(client: NylasClient) : Resource<Event>(client, Event::class.java) {
/**
* Return all Events
* @param identifier The identifier of the grant to act upon
* @param identifier Grant ID or email account to query
* @param queryParams The query parameters to include in the request
* @return The list of Events
* @return The list of events
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun list(identifier: String, queryParams: ListEventQueryParams): ListResponse<Event> {
Expand All @@ -26,10 +26,10 @@ class Events(client: NylasClient) : Resource<Event>(client, Event::class.java) {

/**
* Return an Event
* @param identifier The identifier of the grant to act upon
* @param eventId The id of the Event to retrieve.
* @param identifier Grant ID or email account to query
* @param eventId The id of the event to retrieve.
* @param queryParams The query parameters to include in the request
* @return The Event
* @return The event
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun find(identifier: String, eventId: String, queryParams: FindEventQueryParams): Response<Event> {
Expand All @@ -39,10 +39,10 @@ class Events(client: NylasClient) : Resource<Event>(client, Event::class.java) {

/**
* Create an Event
* @param identifier The identifier of the grant to act upon
* @param requestBody The values to create the Event with
* @param identifier Grant ID or email account in which to create the object
* @param requestBody The values to create the event with
* @param queryParams The query parameters to include in the request
* @return The created Event
* @return The created event
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun create(identifier: String, requestBody: CreateEventRequest, queryParams: CreateEventQueryParams): Response<Event> {
Expand All @@ -55,10 +55,10 @@ class Events(client: NylasClient) : Resource<Event>(client, Event::class.java) {
/**
* Update an Event
* @param identifier The identifier of the grant to act upon
* @param eventId The id of the Event to update.
* @param eventId The id of the event to update.
* @param requestBody The values to update the Event with
* @param queryParams The query parameters to include in the request
* @return The updated Event
* @return The updated event
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun update(identifier: String, eventId: String, requestBody: UpdateEventRequest, queryParams: UpdateEventQueryParams): Response<Event> {
Expand All @@ -71,7 +71,7 @@ class Events(client: NylasClient) : Resource<Event>(client, Event::class.java) {
/**
* Delete an Event
* @param identifier The identifier of the grant to act upon
* @param eventId The id of the Event to delete.
* @param eventId The id of the event to delete.
* @param queryParams The query parameters to include in the request
* @return The deletion response
*/
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/nylas/resources/RedirectUris.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RedirectUris(client: NylasClient) : Resource<RedirectUri>(client, Redirect
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun find(redirectUriId: String): Response<RedirectUri> {
val path = String.format("v3/grants/redirect-uris/%s", redirectUriId)
val path = String.format("v3/applications/redirect-uris/%s", redirectUriId)
return findResource(path)
}

Expand All @@ -56,7 +56,7 @@ class RedirectUris(client: NylasClient) : Resource<RedirectUri>(client, Redirect
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun update(redirectUriId: String, requestBody: UpdateRedirectUriRequest): Response<RedirectUri> {
val path = String.format("v3/grants/redirect-uris/%s", redirectUriId)
val path = String.format("v3/applications/redirect-uris/%s", redirectUriId)
val serializedRequestBody = JsonHelper.moshi()
.adapter(UpdateRedirectUriRequest::class.java)
.toJson(requestBody)
Expand All @@ -71,7 +71,7 @@ class RedirectUris(client: NylasClient) : Resource<RedirectUri>(client, Redirect
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun destroy(redirectUriId: String): DeleteResponse {
val path = String.format("v3/grants/redirect-uris/%s", redirectUriId)
val path = String.format("v3/applications/redirect-uris/%s", redirectUriId)
return destroyResource(path)
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/nylas/util/JsonHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class JsonHelper {
* @suppress Not for public use.
*/
@JvmStatic
val jsonMapAdapter = moshi.adapter<Map<String, String>>(
mapTypeOf(String::class.java, String::class.java),
val jsonMapAdapter = moshi.adapter<Map<String, Any>>(
mapTypeOf(String::class.java, Any::class.java),
).indent(" ")

/**
Expand Down