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

Fixes for contacts api support #185

Merged
merged 7 commits into from
Jan 3, 2024
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
8 changes: 8 additions & 0 deletions src/main/kotlin/com/nylas/NylasClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ class NylasClient(
return Webhooks(this)
}

/**
* Access the Contacts API
* @return The Contacts API
*/
fun contacts(): Contacts {
return Contacts(this)
}

/**
* Get a URL builder instance for the Nylas API.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/Contact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ data class Contact(
val groups: List<ContactGroupId>? = null,
) {
fun getObject() = obj
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/ContactEmail.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ data class ContactEmail(
fun type(type: ContactType) = apply { this.type = type }
fun build() = ContactEmail(email, type)
}
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/ContactGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ data class ContactGroup(
private val obj: String = "contact_group",
) {
fun getObject() = obj
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/ContactGroupId.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package com.nylas.models
*/
data class ContactGroupId(
val id: String,
)
)
5 changes: 4 additions & 1 deletion src/main/kotlin/com/nylas/models/ContactType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ enum class ContactType {

@Json(name = "other")
OTHER,
}

@Json(name = "mobile")
MOBILE,
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/nylas/models/FindContactQueryParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import com.squareup.moshi.Json
data class FindContactQueryParams(
@Json(name = "profile_picture")
val profilePicture: Boolean? = null,
): IQueryParams
) : IQueryParams
6 changes: 4 additions & 2 deletions src/main/kotlin/com/nylas/models/GroupType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import com.squareup.moshi.Json
enum class GroupType {
@Json(name = "user")
USER,

@Json(name = "system")
SYSTEM,

@Json(name = "other")
OTHER
}
OTHER,
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/nylas/models/ListContactsQueryParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data class ListContactsQueryParams(
*/
@Json(name = "recurse")
val recurse: Boolean? = null,
): IQueryParams {
) : IQueryParams {
class Builder {
private var limit: Int? = null
private var pageToken: String? = null
Expand Down Expand Up @@ -120,4 +120,4 @@ data class ListContactsQueryParams(
recurse = recurse,
)
}
}
}
6 changes: 4 additions & 2 deletions src/main/kotlin/com/nylas/models/SourceType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import com.squareup.moshi.Json
enum class SourceType {
@Json(name = "address_book")
ADDRESS_BOOK,

@Json(name = "inbox")
INBOX,

@Json(name = "domain")
DOMAIN
}
DOMAIN,
}
14 changes: 14 additions & 0 deletions src/main/kotlin/com/nylas/resources/Contacts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ class Contacts(client: NylasClient) : Resource<Contact>(client, Contact::class.j
return findResource(path)
}

/**
* Create a Contact
* @param identifier Grant ID or email account in which to create the object
* @param requestBody The values to create the event with
* @return The created contact
*/
@Throws(NylasApiError::class, NylasSdkTimeoutError::class)
fun create(identifier: String, requestBody: CreateContactRequest): Response<Contact> {
val path = String.format("v3/grants/%s/contacts", identifier)
val adapter = JsonHelper.moshi().adapter(CreateContactRequest::class.java)
val serializedRequestBody = adapter.toJson(requestBody)
return createResource(path, serializedRequestBody)
}

/**
* Update a Contact
* @param identifier The identifier of the grant to act upon
Expand Down