├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── pull-reqeust.yml │ └── sdk-reference.yaml ├── .gitignore ├── .vscode └── settings.json ├── CHANGELOG.md ├── Contributing.md ├── LICENSE ├── README.md ├── UPGRADE.md ├── build.gradle.kts ├── examples ├── .env.example ├── .gitignore ├── Makefile ├── README.md ├── build.gradle.kts └── src │ └── main │ ├── java │ └── com │ │ └── nylas │ │ └── examples │ │ ├── EventsExample.java │ │ ├── MessagesExample.java │ │ └── NotetakerExample.java │ └── kotlin │ └── com │ └── nylas │ └── examples │ ├── KotlinMessagesExample.kt │ └── KotlinNotetakerExample.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pull_request_template.md ├── settings.gradle.kts └── src ├── main ├── kotlin │ └── com │ │ └── nylas │ │ ├── BuildInfo.kt │ │ ├── NylasClient.kt │ │ ├── interceptors │ │ ├── AddVersionHeadersInterceptor.kt │ │ ├── ContentHeadersInterceptor.kt │ │ └── HttpLoggingInterceptor.kt │ │ ├── models │ │ ├── AbstractNylasApiError.kt │ │ ├── AbstractNylasSdkError.kt │ │ ├── AccessType.kt │ │ ├── ApplicationDetails.kt │ │ ├── Attachment.kt │ │ ├── AuthProvider.kt │ │ ├── AvailabilityMethod.kt │ │ ├── AvailabilityParticipant.kt │ │ ├── AvailabilityRules.kt │ │ ├── BookingGuest.kt │ │ ├── BookingOrganizer.kt │ │ ├── BookingReminder.kt │ │ ├── BookingStatus.kt │ │ ├── BookingType.kt │ │ ├── Calendar.kt │ │ ├── CalendarNotetaker.kt │ │ ├── CleanMessagesRequest.kt │ │ ├── CleanMessagesResponse.kt │ │ ├── CodeExchangeRequest.kt │ │ ├── CodeExchangeResponse.kt │ │ ├── ComposeMessageRequest.kt │ │ ├── ComposeMessageResponse.kt │ │ ├── Conferencing.kt │ │ ├── ConferencingProvider.kt │ │ ├── ConfigurationAvailability.kt │ │ ├── ConfigurationAvailabilityParticipant.kt │ │ ├── ConfigurationBookingParticipant.kt │ │ ├── ConfigurationEventBooking.kt │ │ ├── ConfigurationParticipant.kt │ │ ├── ConfigurationSchedulerSettings.kt │ │ ├── ConfirmBookingQueryParams.kt │ │ ├── ConfirmBookingRequest.kt │ │ ├── ConfirmBookingStatus.kt │ │ ├── Connector.kt │ │ ├── Contact.kt │ │ ├── ContactEmail.kt │ │ ├── ContactGroup.kt │ │ ├── ContactGroupId.kt │ │ ├── CreateAttachmentRequest.kt │ │ ├── CreateBookingGuest.kt │ │ ├── CreateBookingOrganizer.kt │ │ ├── CreateBookingQueryParams.kt │ │ ├── CreateBookingReminder.kt │ │ ├── CreateBookingRequest.kt │ │ ├── CreateCalendarRequest.kt │ │ ├── CreateConfigurationRequest.kt │ │ ├── CreateConnectorRequest.kt │ │ ├── CreateContactRequest.kt │ │ ├── CreateCredentialRequest.kt │ │ ├── CreateDraftRequest.kt │ │ ├── CreateEventQueryParams.kt │ │ ├── CreateEventRequest.kt │ │ ├── CreateFolderRequest.kt │ │ ├── CreateGrantRequest.kt │ │ ├── CreateNotetakerRequest.kt │ │ ├── CreateRedirectUriRequest.kt │ │ ├── CreateSessionRequest.kt │ │ ├── CreateWebhookRequest.kt │ │ ├── Credential.kt │ │ ├── CredentialData.kt │ │ ├── CredentialType.kt │ │ ├── CustomHeader.kt │ │ ├── DeleteResponse.kt │ │ ├── DestroyBookingQueryParams.kt │ │ ├── DestroyBookingRequest.kt │ │ ├── DestroyEventQueryParams.kt │ │ ├── Draft.kt │ │ ├── EmailLanguage.kt │ │ ├── EmailName.kt │ │ ├── Environment.kt │ │ ├── Event.kt │ │ ├── EventNotetaker.kt │ │ ├── EventQueryOrderBy.kt │ │ ├── EventStatus.kt │ │ ├── EventType.kt │ │ ├── EventVisibility.kt │ │ ├── FindAttachmentQueryParams.kt │ │ ├── FindBookingQueryParams.kt │ │ ├── FindContactQueryParams.kt │ │ ├── FindEventQueryParams.kt │ │ ├── FindMessageQueryParams.kt │ │ ├── Folder.kt │ │ ├── FreeBusyTimeSlot.kt │ │ ├── FreeBusyType.kt │ │ ├── GetAvailabilityRequest.kt │ │ ├── GetAvailabilityResponse.kt │ │ ├── GetFreeBusyRequest.kt │ │ ├── GetFreeBusyResponse.kt │ │ ├── GoogleConnectorSettings.kt │ │ ├── GoogleCreateConnectorSettings.kt │ │ ├── Grant.kt │ │ ├── GrantStatus.kt │ │ ├── GroupType.kt │ │ ├── IMessage.kt │ │ ├── IMessageAttachmentRequest.kt │ │ ├── IQueryParams.kt │ │ ├── InstantMessagingAddress.kt │ │ ├── ListCalendersQueryParams.kt │ │ ├── ListConfigurationsQueryParams.kt │ │ ├── ListConnectorsQueryParams.kt │ │ ├── ListContactGroupsQueryParams.kt │ │ ├── ListContactsQueryParams.kt │ │ ├── ListCredentialsQueryParams.kt │ │ ├── ListDraftsQueryParams.kt │ │ ├── ListEventQueryParams.kt │ │ ├── ListFoldersQueryParams.kt │ │ ├── ListGrantsQueryParams.kt │ │ ├── ListImportEventQueryParams.kt │ │ ├── ListMessagesQueryParams.kt │ │ ├── ListNotetakersQueryParams.kt │ │ ├── ListResponse.kt │ │ ├── ListThreadsQueryParams.kt │ │ ├── MeetingBuffer.kt │ │ ├── Message.kt │ │ ├── MessageFields.kt │ │ ├── MessageHeaders.kt │ │ ├── MicrosoftConnectorSettings.kt │ │ ├── MicrosoftCreateConnectorSettings.kt │ │ ├── Notetaker.kt │ │ ├── NylasApiError.kt │ │ ├── NylasApiErrorResponse.kt │ │ ├── NylasOAuthError.kt │ │ ├── NylasSdkRemoteClosedError.kt │ │ ├── NylasSdkTimeoutError.kt │ │ ├── OpenHours.kt │ │ ├── OrderBy.kt │ │ ├── PKCEAuthURL.kt │ │ ├── Participant.kt │ │ ├── ParticipantStatus.kt │ │ ├── PhoneNumber.kt │ │ ├── PhysicalAddress.kt │ │ ├── Platform.kt │ │ ├── Prompt.kt │ │ ├── ProviderDetectParams.kt │ │ ├── ProviderDetectResponse.kt │ │ ├── RedirectUri.kt │ │ ├── RedirectUriSettings.kt │ │ ├── Region.kt │ │ ├── ReminderMethod.kt │ │ ├── ReminderOverride.kt │ │ ├── Reminders.kt │ │ ├── RequestOverrides.kt │ │ ├── RescheduleBookingQueryParams.kt │ │ ├── RescheduleBookingRequest.kt │ │ ├── Response.kt │ │ ├── RsvpStatus.kt │ │ ├── ScheduledMessage.kt │ │ ├── ScheduledMessageStatus.kt │ │ ├── ScheduledMessagesList.kt │ │ ├── Scheduler.kt │ │ ├── SendMessageRequest.kt │ │ ├── SendRsvpQueryParams.kt │ │ ├── SendRsvpRequest.kt │ │ ├── SortBy.kt │ │ ├── SourceType.kt │ │ ├── StopScheduledMessageResponse.kt │ │ ├── Thread.kt │ │ ├── TimeSlot.kt │ │ ├── TokenExchangeRequest.kt │ │ ├── TokenInfoRequest.kt │ │ ├── TokenInfoResponse.kt │ │ ├── TokenParams.kt │ │ ├── TrackingOptions.kt │ │ ├── UpdateCalendarRequest.kt │ │ ├── UpdateConfigurationRequest.kt │ │ ├── UpdateConnectorRequest.kt │ │ ├── UpdateContactRequest.kt │ │ ├── UpdateCredentialRequest.kt │ │ ├── UpdateDraftRequest.kt │ │ ├── UpdateEventQueryParams.kt │ │ ├── UpdateEventRequest.kt │ │ ├── UpdateFolderRequest.kt │ │ ├── UpdateGrantRequest.kt │ │ ├── UpdateMessageRequest.kt │ │ ├── UpdateNotetakerRequest.kt │ │ ├── UpdateRedirectUriRequest.kt │ │ ├── UpdateThreadRequest.kt │ │ ├── UpdateWebhookRequest.kt │ │ ├── UrlForAuthenticationConfig.kt │ │ ├── WebPage.kt │ │ ├── Webhook.kt │ │ ├── WebhookDeleteResponse.kt │ │ ├── WebhookIpAddressesResponse.kt │ │ ├── WebhookStatus.kt │ │ ├── WebhookTriggers.kt │ │ ├── WebhookWithSecret.kt │ │ ├── When.kt │ │ └── WhenType.kt │ │ ├── resources │ │ ├── Applications.kt │ │ ├── Attachments.kt │ │ ├── Auth.kt │ │ ├── Bookings.kt │ │ ├── Calendars.kt │ │ ├── Configurations.kt │ │ ├── Connectors.kt │ │ ├── Contacts.kt │ │ ├── Credentials.kt │ │ ├── Drafts.kt │ │ ├── Events.kt │ │ ├── Folders.kt │ │ ├── Grants.kt │ │ ├── Messages.kt │ │ ├── Notetakers.kt │ │ ├── RedirectUris.kt │ │ ├── Resource.kt │ │ ├── Scheduler.kt │ │ ├── Sessions.kt │ │ ├── SmartCompose.kt │ │ ├── Threads.kt │ │ └── Webhooks.kt │ │ └── util │ │ ├── ConferencingAdapter.kt │ │ ├── CreateAttachmentRequestAdapter.kt │ │ ├── CreateConferencingAdapter.kt │ │ ├── CreateWhenAdapter.kt │ │ ├── CredentialDataAdapter.kt │ │ ├── FileUtils.kt │ │ ├── IMessageAdapter.kt │ │ ├── JsonHelper.kt │ │ ├── UpdateConferencingAdapter.kt │ │ ├── UpdateConnectorAdapter.kt │ │ ├── UpdateWhenAdapter.kt │ │ └── WebhookRequestValidator.kt └── resources │ └── build.properties └── test └── kotlin └── com └── nylas ├── NylasClientTest.kt ├── models ├── CalendarNotetakerTest.kt ├── EventNotetakerTest.kt ├── FindMessageQueryParamsTests.kt ├── ListThreadsQueryParamsTest.kt └── MessageFieldsTests.kt ├── resources ├── ApplicationsTests.kt ├── AttachmentsTests.kt ├── AuthTests.kt ├── BookingsTest.kt ├── CalendarsTest.kt ├── ConfigurationsTest.kt ├── ConnectorsTests.kt ├── ContactsTests.kt ├── CredentialsTests.kt ├── DraftsTests.kt ├── EventsTests.kt ├── FoldersTests.kt ├── GrantsTests.kt ├── MessagesTests.kt ├── NotetakersTests.kt ├── RedirectUriTests.kt ├── SessionsTest.kt ├── SmartComposeTests.kt ├── ThreadsTests.kt └── WebhooksTests.kt └── util └── WebhookRequestValidatorTest.kt /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{kt,kts}] 4 | ktlint_code_style = intellij_idea 5 | indent_size = 2 6 | indent_style = space 7 | ktlint_standard_no-wildcard-imports = disabled 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug or issue to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Some steps involved to reproduce the bug and any code samples you can share. 15 | ``` 16 | // Helps us with reproducing the error :) 17 | ``` 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **SDK Version:** 23 | Providing the SDK version can help with the reproduction of the issue and to know if a change could have broken something. 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/pull-reqeust.yml: -------------------------------------------------------------------------------- 1 | name: Pull Request 2 | on: 3 | # Trigger the workflow on push or pull request, 4 | # but only for the main branch 5 | push: 6 | branches: 7 | - main 8 | pull_request: 9 | branches: 10 | - main 11 | 12 | jobs: 13 | checks: 14 | runs-on: ubuntu-latest 15 | name: Lint, Build, Test, and Upload Coverage 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Setup Java 8 19 | uses: actions/setup-java@v3 20 | with: 21 | java-version: '8' 22 | distribution: 'corretto' 23 | 24 | - name: Grant execute permission for gradlew 25 | run: chmod +x gradlew 26 | 27 | - name: Lint project 28 | run: ./gradlew lintKotlin 29 | 30 | - name: Build project 31 | run: ./gradlew clean build 32 | 33 | - name: Run tests 34 | run: ./gradlew test 35 | 36 | - name: Upload coverage to Codecov 37 | uses: codecov/codecov-action@v4 38 | env: 39 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 40 | -------------------------------------------------------------------------------- /.github/workflows/sdk-reference.yaml: -------------------------------------------------------------------------------- 1 | name: sdk-reference 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | docs: 11 | runs-on: ubuntu-latest 12 | environment: 13 | name: sdk-reference 14 | url: ${{ steps.deploy.outputs.url }} 15 | steps: 16 | - uses: actions/checkout@v3 17 | - name: Setup Java 8 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: "8" 21 | distribution: "corretto" 22 | cache: gradle 23 | - uses: burrunan/gradle-cache-action@v1 24 | name: Build SDK refernece 25 | with: 26 | arguments: dokkaHtml 27 | gradle-version: wrapper 28 | properties: | 29 | kotlin.js.compiler=ir 30 | kotlin.parallel.tasks.in.project=true 31 | - name: Set env BRANCH 32 | run: echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV 33 | - name: Set env CLOUDFLARE_BRANCH 34 | run: | 35 | if [[ $BRANCH == 'main' && $GITHUB_EVENT_NAME == 'push' ]]; then 36 | echo "CLOUDFLARE_BRANCH=main" >> "$GITHUB_ENV" 37 | else 38 | echo "CLOUDFLARE_BRANCH=$BRANCH" >> "$GITHUB_ENV" 39 | fi 40 | - name: Publish to Cloudflare Pages 41 | uses: cloudflare/pages-action@v1 42 | id: deploy 43 | with: 44 | apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} 45 | accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} 46 | projectName: nylas-java-sdk-reference 47 | directory: build/dokka/html 48 | wranglerVersion: "3" 49 | branch: ${{ env.CLOUDFLARE_BRANCH }} 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | 7 | # Ignore eclipse files 8 | .classpath 9 | .project 10 | .settings 11 | bin 12 | out 13 | 14 | # Ignore Intellij files 15 | .idea 16 | .DS_Store 17 | src/main/kotlin/com/nylas/Main.kt 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contribute to Nylas 2 | 👍🎉 First off, thanks for taking the time to contribute! 🎉👍 3 | 4 | The following is a set of guidelines for contributing to the Nylas Java SDK; these are guidelines, not rules, so please use your best judgement and feel free to propose changes to this document via pull request. 5 | 6 | # How to Ask a Question 7 | 8 | If you have a question about how to use the Java SDK, please [create an issue](https://github.com/nylas/nylas-java/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to support@nylas.com to get help. 9 | 10 | # How To Contribute 11 | ## Report a Bug or Request a Feature 12 | 13 | If you encounter any bugs while using this software, or want to request a new feature or enhancement, please [create an issue](https://github.com/nylas/nylas-java/issues) to report it, and make sure you add a label to indicate what type of issue it is. 14 | 15 | ## Contribute Code 16 | 17 | Pull requests are welcome for bug fixes. If you want to implement something new, [please request a feature](https://github.com/nylas/nylas-java/issues) first so we can discuss it. 18 | 19 | ## Creating a Pull Request 20 | 21 | Please follow [best practices](https://github.com/trein/dev-best-practices/wiki/Git-Commit-Best-Practices) for creating git commits. When your code is ready to be submitted, you can [submit a pull request](https://help.github.com/articles/creating-a-pull-request/) to begin the code review process. 22 | 23 | All PRs from contributors that aren't employed by Nylas must contain the following text in the PR description: "I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner." 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Nylas, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/.env.example: -------------------------------------------------------------------------------- 1 | # Nylas API Key - Required 2 | # Get it from your Nylas Dashboard: https://dashboard.nylas.com/ 3 | NYLAS_API_KEY=your_api_key_here 4 | 5 | # Meeting Link - Required for Notetaker examples 6 | # This should be a link to a Zoom, Google Meet, or Microsoft Teams meeting 7 | MEETING_LINK=your_meeting_link_here 8 | 9 | # Nylas API URI - Optional (defaults to https://api.us.nylas.com) 10 | # Only change this if instructed by Nylas support 11 | NYLAS_API_URI=https://api.us.nylas.com 12 | 13 | # Grant ID - Required for message and event examples 14 | # You can get this from your Nylas Dashboard after connecting an account 15 | NYLAS_GRANT_ID=your_grant_id_here -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class files 2 | *.class 3 | 4 | # Build output 5 | /build/ 6 | 7 | # Gradle files 8 | .gradle/ 9 | 10 | # IntelliJ IDEA files 11 | .idea/ 12 | *.iml 13 | *.iws 14 | *.ipr 15 | out/ 16 | 17 | # Eclipse files 18 | .classpath 19 | .project 20 | .settings/ 21 | bin/ 22 | 23 | # VS Code files 24 | .vscode/ 25 | 26 | # Environment variables 27 | .env 28 | 29 | # Mac files 30 | .DS_Store 31 | 32 | # Logs 33 | *.log -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: help list java kotlin 2 | 3 | # Default target 4 | help: 5 | @echo "Nylas Java/Kotlin SDK Examples" 6 | @echo "" 7 | @echo "Available targets:" 8 | @echo " help - Show this help message" 9 | @echo " list - List available examples" 10 | @echo " java-notetaker - Run the Java Notetaker example" 11 | @echo " java-events - Run the Java Events example" 12 | @echo " kotlin-notetaker - Run the Kotlin Notetaker example" 13 | 14 | # List available examples 15 | list: 16 | @cd .. && ./gradlew :examples:listExamples 17 | 18 | # Run the Java example 19 | java-notetaker: 20 | @cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.NotetakerExample 21 | 22 | java-events: 23 | @cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.EventsExample 24 | 25 | # Run the Kotlin example 26 | kotlin-notetaker: 27 | @cd .. && ./gradlew :examples:run -PmainClass=com.nylas.examples.KotlinNotetakerExampleKt -------------------------------------------------------------------------------- /examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | id("java") 5 | id("application") 6 | id("org.jetbrains.kotlin.jvm") version "1.8.21" 7 | } 8 | 9 | group = "com.nylas.examples" 10 | version = "1.0-SNAPSHOT" 11 | 12 | repositories { 13 | mavenCentral() 14 | mavenLocal() // For local Nylas SDK development 15 | } 16 | 17 | dependencies { 18 | // Add the Nylas SDK dependency 19 | implementation(project(":")) // References the main Nylas SDK project 20 | 21 | // Core dependencies 22 | implementation("org.json:json:20230227") 23 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 24 | 25 | // Test dependencies 26 | testImplementation(platform("org.junit:junit-bom:5.9.1")) 27 | testImplementation("org.junit.jupiter:junit-jupiter") 28 | } 29 | 30 | java { 31 | sourceCompatibility = JavaVersion.VERSION_1_8 32 | targetCompatibility = JavaVersion.VERSION_1_8 33 | } 34 | 35 | tasks.withType { 36 | kotlinOptions { 37 | jvmTarget = "1.8" 38 | } 39 | } 40 | 41 | application { 42 | // The mainClass will be overridden by the -PmainClass command-line parameter 43 | mainClass.set(findProperty("mainClass") as String? ?: "com.nylas.examples.NotetakerExample") 44 | } 45 | 46 | tasks.test { 47 | useJUnitPlatform() 48 | } 49 | 50 | // Task to list available examples 51 | tasks.register("listExamples") { 52 | doLast { 53 | println("Available examples:") 54 | println("- Java-Notetaker: com.nylas.examples.NotetakerExample") 55 | println("- Java-Events: com.nylas.examples.EventsExample") 56 | println("- Java-Messages: com.nylas.examples.MessagesExample") 57 | println("- Kotlin-Notetaker: com.nylas.examples.KotlinNotetakerExampleKt") 58 | println("- Kotlin-Messages: com.nylas.examples.KotlinMessagesExampleKt") 59 | println("\nRun an example with: ./gradlew :examples:run -PmainClass=") 60 | } 61 | } 62 | 63 | // Configure source sets for Java and Kotlin 64 | sourceSets { 65 | main { 66 | java { 67 | srcDir("src/main/java") 68 | } 69 | kotlin { 70 | srcDir("src/main/kotlin") 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=com.nylas.sdk 2 | version=2.9.0 3 | 4 | # Override and set these in ~/.gradle/gradle.properties 5 | ossrhUser= 6 | ossrhPassword= 7 | signing.keyId= 8 | signing.password= 9 | signing.secretKeyRingFile=~/.gnupg/secring.gpg 10 | 11 | # 2020-04-27 - workaround for https://issues.sonatype.org/browse/NEXUS-21802 12 | # PLEASE CHECK once in awhile to see if this issue is resolved 13 | # and this flag can be removed to improve the security of release checksums 14 | systemProp.org.gradle.internal.publish.checksums.insecure=true 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nylas/nylas-java/8e0b0ab41dd0c48ec9228aea300c273e93efe986/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner. -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/5.4/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = "nylas" 11 | 12 | // Include the examples subproject 13 | include("examples") 14 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/BuildInfo.kt: -------------------------------------------------------------------------------- 1 | package com.nylas 2 | 3 | import org.slf4j.LoggerFactory 4 | import java.io.FileInputStream 5 | import java.util.* 6 | 7 | /** 8 | * @suppress Not for public use. 9 | */ 10 | object BuildInfo { 11 | private val log = LoggerFactory.getLogger(BuildInfo::class.java) 12 | var VERSION: String? = null 13 | 14 | init { 15 | try { 16 | // First, look for build.properties file left by gradle 17 | BuildInfo::class.java.getResourceAsStream("/build.properties").use { `in` -> 18 | if (`in` != null) { 19 | val props = Properties() 20 | props.load(`in`) 21 | VERSION = props.getProperty("nylas.build.version") 22 | } 23 | } 24 | 25 | // Otherwise, look directly for gradle.properties file (e.g. in an IDE) 26 | if (VERSION == null || VERSION!!.isEmpty()) { 27 | FileInputStream("gradle.properties").use { `in` -> 28 | val props = Properties() 29 | props.load(`in`) 30 | VERSION = props.getProperty("version") 31 | } 32 | } 33 | } catch (t: Throwable) { 34 | log.error("Failed to load build info", t) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/interceptors/AddVersionHeadersInterceptor.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.interceptors 2 | 3 | import com.nylas.BuildInfo 4 | import okhttp3.Interceptor 5 | import okhttp3.Response 6 | import java.io.IOException 7 | 8 | /** 9 | * @suppress Not for public use. 10 | */ 11 | class AddVersionHeadersInterceptor : Interceptor { 12 | @Throws(IOException::class) 13 | override fun intercept(chain: Interceptor.Chain): Response { 14 | val requestBuilder = chain.request().newBuilder() 15 | .header("User-Agent", USER_AGENT) 16 | return chain.proceed(requestBuilder.build()) 17 | } 18 | 19 | companion object { 20 | private val USER_AGENT = "Nylas Java SDK " + (BuildInfo.VERSION ?: "unknown") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/interceptors/ContentHeadersInterceptor.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.interceptors 2 | 3 | import com.nylas.NylasClient 4 | import okhttp3.Interceptor 5 | import okhttp3.Response 6 | import java.io.IOException 7 | 8 | /** 9 | * @suppress Not for public use. 10 | */ 11 | class ContentHeadersInterceptor : Interceptor { 12 | @Throws(IOException::class) 13 | override fun intercept(chain: Interceptor.Chain): Response { 14 | val request = chain.request() 15 | val path = request.url().encodedPath() 16 | val contentHeader = request.header(NylasClient.HttpHeaders.CONTENT_TYPE.headerName) 17 | if (contentHeader == null && !isDownloadablePath(path)) { 18 | val enhancedRequest = request.newBuilder() 19 | if (request.body() != null && request.body()!!.contentType() != null) { 20 | enhancedRequest.header( 21 | NylasClient.HttpHeaders.CONTENT_TYPE.headerName, 22 | request.body()!!.contentType()!!.toString(), 23 | ) 24 | } else if (request.body() != null) { 25 | enhancedRequest.header( 26 | NylasClient.HttpHeaders.CONTENT_TYPE.headerName, 27 | NylasClient.MediaType.APPLICATION_JSON.mediaType, 28 | ) 29 | } 30 | 31 | enhancedRequest.header(NylasClient.HttpHeaders.ACCEPT.headerName, NylasClient.MediaType.APPLICATION_JSON.mediaType) 32 | return chain.proceed(enhancedRequest.build()) 33 | } 34 | return chain.proceed(request) 35 | } 36 | 37 | private fun isDownloadablePath(path: String): Boolean { 38 | return path == "%2Fcontacts%2Fpicture" || path == "%2Ffiles%2Fdownload" || path == "%2Fdelta%2Fstreaming" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AbstractNylasApiError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Base class for all Nylas API errors. 5 | * @param message The error message. 6 | * @param statusCode The HTTP status code of the error response. 7 | * @param requestId The unique identifier of the request. 8 | * @param headers The HTTP headers of the error response. 9 | */ 10 | sealed class AbstractNylasApiError( 11 | override val message: String, 12 | open var statusCode: Int? = null, 13 | open var requestId: String? = null, 14 | open var headers: Map>? = null, 15 | ) : Exception(message) 16 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AbstractNylasSdkError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Base class for all Nylas SDK errors. 5 | * @param message The error message. 6 | */ 7 | sealed class AbstractNylasSdkError( 8 | override val message: String, 9 | ) : Exception(message) 10 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AccessType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for the access type of the authentication URL. 7 | */ 8 | enum class AccessType { 9 | @Json(name = "offline") 10 | OFFLINE, 11 | 12 | @Json(name = "online") 13 | ONLINE, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Attachment.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas attachment object 7 | */ 8 | data class Attachment( 9 | /** 10 | * Globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String? = null, 14 | /** 15 | * Nylas grant ID that is now successfully created. 16 | */ 17 | @Json(name = "grant_id") 18 | val grantId: String? = null, 19 | /** 20 | * The size of the attachment in bytes. 21 | */ 22 | @Json(name = "size") 23 | val size: Int? = null, 24 | /** 25 | * The filename of the attachment. 26 | */ 27 | @Json(name = "filename") 28 | val filename: String? = null, 29 | /** 30 | * The content type of the attachment. 31 | */ 32 | @Json(name = "content_type") 33 | val contentType: String? = null, 34 | /** 35 | * If it's an inline attachment. 36 | */ 37 | @Json(name = "is_inline") 38 | val isInline: Boolean? = null, 39 | /** 40 | * The content ID of the attachment. 41 | */ 42 | @Json(name = "content_id") 43 | val contentId: String? = null, 44 | /** 45 | * The content disposition if the attachment is located inline. 46 | */ 47 | @Json(name = "content_disposition") 48 | val contentDisposition: String? = null, 49 | ) 50 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AuthProvider.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum class for the different authentication providers. 7 | */ 8 | enum class AuthProvider(val value: String) { 9 | @Json(name = "google") 10 | GOOGLE("google"), 11 | 12 | @Json(name = "microsoft") 13 | MICROSOFT("microsoft"), 14 | 15 | @Json(name = "imap") 16 | IMAP("imap"), 17 | 18 | @Json(name = "virtual-calendar") 19 | VIRTUAL_CALENDAR("virtual-calendar"), 20 | 21 | @Json(name = "icloud") 22 | ICLOUD("icloud"), 23 | 24 | @Json(name = "ews") 25 | EWS("ews"), 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AvailabilityMethod.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the method used to determine availability for a meeting. 7 | */ 8 | enum class AvailabilityMethod { 9 | @Json(name = "max-fairness") 10 | MAX_FAIRNESS, 11 | 12 | @Json(name = "max-availability") 13 | MAX_AVAILABILITY, 14 | 15 | @Json(name = "collective") 16 | COLLECTIVE, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/AvailabilityParticipant.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of participant details to check availability for. 7 | */ 8 | data class AvailabilityParticipant( 9 | /** 10 | * The email address of the participant. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * An optional list of the calendar IDs associated with each participant's email address. 16 | * If not provided, Nylas uses the primary calendar ID. 17 | */ 18 | @Json(name = "calendar_ids") 19 | val calendarIds: List? = null, 20 | /** 21 | * Open hours for this participant. The endpoint searches for free time slots during these open hours. 22 | */ 23 | @Json(name = "open_hours") 24 | val openHours: List? = null, 25 | ) { 26 | /** 27 | * A builder for creating an [AvailabilityParticipant]. 28 | * @param email The email address of the participant. 29 | */ 30 | data class Builder( 31 | private val email: String, 32 | ) { 33 | private var calendarIds: List? = null 34 | private var openHours: List? = null 35 | 36 | /** 37 | * Set the calendar IDs associated with each participant's email address. 38 | * @param calendarIds The calendar IDs associated with each participant's email address. 39 | * @return The builder. 40 | */ 41 | fun calendarIds(calendarIds: List) = apply { this.calendarIds = calendarIds } 42 | 43 | /** 44 | * Set the open hours for this participant. 45 | * @param openHours Open hours for this participant. 46 | * @return The builder. 47 | */ 48 | fun openHours(openHours: List) = apply { this.openHours = openHours } 49 | 50 | /** 51 | * Build the [AvailabilityParticipant]. 52 | * @return The [AvailabilityParticipant]. 53 | */ 54 | fun build() = AvailabilityParticipant( 55 | email, 56 | calendarIds, 57 | openHours, 58 | ) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/BookingGuest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a booking guest. 7 | */ 8 | data class BookingGuest( 9 | /** 10 | * The email address of the guest. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * The name of the guest. 16 | */ 17 | @Json(name = "name") 18 | val name: String? = null, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/BookingOrganizer.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a booking organizer. 7 | */ 8 | data class BookingOrganizer( 9 | /** 10 | * The email address of the participant designated as the organizer of the event. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * The name of the participant designated as the organizer of the event. 16 | */ 17 | @Json(name = "name") 18 | val name: String? = null, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/BookingReminder.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a booking reminder. 7 | */ 8 | data class BookingReminder( 9 | /** 10 | * The reminder type. 11 | */ 12 | @Json(name = "type") 13 | val type: String, 14 | /** 15 | * The number of minutes before the event to send the reminder. 16 | */ 17 | @Json(name = "minutes_before_event") 18 | val minutesBeforeEvent: Int, 19 | /** 20 | * The recipient of the reminder. 21 | */ 22 | @Json(name = "recipient") 23 | val recipient: String? = null, 24 | /** 25 | * The subject of the email reminder. 26 | */ 27 | @Json(name = "email_subject") 28 | val emailSubject: String? = null, 29 | ) 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/BookingStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for booking statuses. 7 | */ 8 | enum class BookingStatus { 9 | @Json(name = "pending") 10 | PENDING, 11 | 12 | @Json(name = "booked") 13 | BOOKED, 14 | 15 | @Json(name = "cancelled") 16 | CANCELLED, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/BookingType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for booking types. 7 | */ 8 | enum class BookingType { 9 | @Json(name = "booking") 10 | BOOKING, 11 | 12 | @Json(name = "organizer-confirmation") 13 | ORGANIZER_CONFIRMATION, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Calendar.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas calendar object 7 | */ 8 | data class Calendar( 9 | /** 10 | * Globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String = "", 14 | /** 15 | * Grant ID of the Nylas account. 16 | */ 17 | @Json(name = "grant_id") 18 | val grantId: String = "", 19 | /** 20 | * Name of the Calendar. 21 | */ 22 | @Json(name = "name") 23 | val name: String = "", 24 | /** 25 | * The type of object. 26 | */ 27 | @Json(name = "object") 28 | private val obj: String = "calendar", 29 | /** 30 | * IANA time zone database formatted string (e.g. America/New_York). 31 | * @see List of tz database time zones 32 | */ 33 | @Json(name = "timezone") 34 | val timezone: String = "", 35 | /** 36 | * If the event participants are able to edit the event. 37 | */ 38 | @Json(name = "read_only") 39 | val readOnly: Boolean = false, 40 | /** 41 | * If the calendar is owned by the user account. 42 | */ 43 | @Json(name = "is_owned_by_user") 44 | val isOwnedByUser: Boolean = false, 45 | /** 46 | * If the calendar is the primary calendar. 47 | */ 48 | @Json(name = "is_primary") 49 | val isPrimary: Boolean = false, 50 | /** 51 | * Description of the calendar. 52 | */ 53 | @Json(name = "description") 54 | val description: String? = null, 55 | /** 56 | * Geographic location of the calendar as free-form text. 57 | */ 58 | @Json(name = "location") 59 | val location: String? = null, 60 | /** 61 | * The background color of the calendar in the hexadecimal format (e.g. #0099EE). 62 | * Empty indicates default color. 63 | */ 64 | @Json(name = "hex_color") 65 | val hexColor: String? = null, 66 | /** 67 | * The background color of the calendar in the hexadecimal format (e.g. #0099EE). 68 | * Empty indicates default color. (Google only) 69 | */ 70 | @Json(name = "hex_foreground_color") 71 | val hexForegroundColor: String? = null, 72 | /** 73 | * A list of key-value pairs storing additional data. 74 | */ 75 | @Json(name = "metadata") 76 | val metadata: Map? = null, 77 | /** 78 | * Notetaker meeting bot settings for this calendar. 79 | */ 80 | @Json(name = "notetaker") 81 | val notetaker: CalendarNotetaker? = null, 82 | ) { 83 | /** 84 | * Get the type of object. 85 | * @return The type of object. 86 | */ 87 | fun getObject(): String = obj 88 | } 89 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CalendarNotetaker.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of Notetaker meeting bot settings for a calendar. 7 | */ 8 | data class CalendarNotetaker( 9 | /** 10 | * The display name for the Notetaker bot. 11 | */ 12 | @Json(name = "name") 13 | val name: String? = "Nylas Notetaker", 14 | 15 | /** 16 | * Notetaker Meeting Settings 17 | */ 18 | @Json(name = "meeting_settings") 19 | val meetingSettings: MeetingSettings? = null, 20 | 21 | /** 22 | * Rules for when the Notetaker should join a meeting. 23 | */ 24 | @Json(name = "rules") 25 | val rules: Rules? = null, 26 | ) { 27 | /** 28 | * Data class for Notetaker Meeting Settings 29 | */ 30 | data class MeetingSettings( 31 | /** 32 | * When true, Notetaker records the meeting's video. 33 | */ 34 | @Json(name = "video_recording") 35 | val videoRecording: Boolean? = true, 36 | 37 | /** 38 | * When true, Notetaker records the meeting's audio. 39 | */ 40 | @Json(name = "audio_recording") 41 | val audioRecording: Boolean? = true, 42 | 43 | /** 44 | * When true, Notetaker transcribes the meeting's audio. 45 | */ 46 | @Json(name = "transcription") 47 | val transcription: Boolean? = true, 48 | ) 49 | 50 | /** 51 | * Data class for Notetaker event selection rules 52 | */ 53 | data class Rules( 54 | /** 55 | * Types of events to include for notetaking. 56 | */ 57 | @Json(name = "event_selection") 58 | val eventSelection: List? = null, 59 | 60 | /** 61 | * Filters to apply based on the number of participants. 62 | */ 63 | @Json(name = "participant_filter") 64 | val participantFilter: ParticipantFilter? = null, 65 | ) 66 | 67 | /** 68 | * Event selection types for Notetaker. 69 | */ 70 | enum class EventSelectionType { 71 | @Json(name = "internal") 72 | INTERNAL, 73 | 74 | @Json(name = "external") 75 | EXTERNAL, 76 | 77 | @Json(name = "own_events") 78 | OWN_EVENTS, 79 | 80 | @Json(name = "participant_only") 81 | PARTICIPANT_ONLY, 82 | 83 | @Json(name = "all") 84 | ALL, 85 | } 86 | 87 | /** 88 | * Participant filters for Notetaker. 89 | */ 90 | data class ParticipantFilter( 91 | /** 92 | * Only have meeting bot join meetings with greater than or equal to this number of participants. 93 | */ 94 | @Json(name = "participants_gte") 95 | val participantsGte: Int? = null, 96 | 97 | /** 98 | * Only have meeting bot join meetings with less than or equal to this number of participants. 99 | */ 100 | @Json(name = "participants_lte") 101 | val participantsLte: Int? = null, 102 | ) 103 | } 104 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CodeExchangeRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas code exchange request 7 | */ 8 | data class CodeExchangeRequest( 9 | /** 10 | * Should match the same redirect URI that was used for getting the code during the initial authorization request. 11 | */ 12 | @Json(name = "redirect_uri") 13 | val redirectUri: String, 14 | /** 15 | * OAuth 2.0 code fetched from the previous step. 16 | */ 17 | @Json(name = "code") 18 | val code: String, 19 | /** 20 | * Client ID of the application. 21 | */ 22 | @Json(name = "client_id") 23 | var clientId: String, 24 | /** 25 | * Client secret of the application. 26 | * If not provided, the API Key will be used instead. 27 | */ 28 | @Json(name = "client_secret") 29 | var clientSecret: String? = null, 30 | /** 31 | * The original plain text code verifier (code_challenge) used in the initial authorization request (PKCE). 32 | */ 33 | @Json(name = "code_verifier") 34 | val codeVerifier: String? = null, 35 | ) { 36 | /** 37 | * The grant type for the request. For code exchange, it should always be 'authorization_code'. 38 | */ 39 | @Json(name = "grant_type") 40 | private var grantType: String = "authorization_code" 41 | 42 | /** 43 | * A builder for creating a [CodeExchangeRequest]. 44 | * 45 | * @param redirectUri Should match the same redirect URI that was used for getting the code during the initial authorization request. 46 | * @param code OAuth 2.0 code fetched from the previous step. 47 | * @param clientId Client ID of the application. 48 | */ 49 | data class Builder( 50 | private val redirectUri: String, 51 | private val code: String, 52 | private val clientId: String, 53 | ) { 54 | private var clientSecret: String? = null 55 | private var codeVerifier: String? = null 56 | 57 | /** 58 | * Set the client secret. 59 | * If not provided, the API Key will be used instead. 60 | * @param clientSecret The client secret. 61 | * @return The builder. 62 | */ 63 | fun clientSecret(clientSecret: String) = apply { this.clientSecret = clientSecret } 64 | 65 | /** 66 | * Set the code verifier. 67 | * Should be the original plain text code verifier (code_challenge) used in the initial authorization request (PKCE). 68 | * @param codeVerifier The code verifier. 69 | * @return The builder. 70 | */ 71 | fun codeVerifier(codeVerifier: String) = apply { this.codeVerifier = codeVerifier } 72 | 73 | /** 74 | * Build the [CodeExchangeRequest]. 75 | * @return The [CodeExchangeRequest]. 76 | */ 77 | fun build() = CodeExchangeRequest(redirectUri, code, clientId, clientSecret, codeVerifier) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CodeExchangeResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas code exchange response 7 | */ 8 | data class CodeExchangeResponse( 9 | /** 10 | * Supports exchanging the code for tokens, or refreshing an access token using [Auth.refreshAccessToken][com.nylas.resources.Auth.refreshAccessToken]. 11 | */ 12 | @Json(name = "access_token") 13 | val accessToken: String, 14 | /** 15 | * Nylas grant ID that is now successfully created. 16 | */ 17 | @Json(name = "grant_id") 18 | val grantId: String, 19 | /** 20 | * The remaining lifetime of the access token in seconds. 21 | */ 22 | @Json(name = "expires_in") 23 | val expiresIn: Int, 24 | /** 25 | * List of scopes associated with this token. 26 | */ 27 | @Json(name = "scope") 28 | val scope: String? = null, 29 | /** 30 | * Email address of the grant that is created. 31 | */ 32 | @Json(name = "email") 33 | val email: String? = null, 34 | /** 35 | * The provider that the code was exchanged with. 36 | */ 37 | @Json(name = "provider") 38 | val provider: AuthProvider? = null, 39 | /** 40 | * Only returned if the code was requested using [AccessType.OFFLINE][com.nylas.models.AccessType.OFFLINE]. 41 | */ 42 | @Json(name = "refresh_token") 43 | val refreshToken: String? = null, 44 | /** 45 | * A JWT that contains identity information about the user that is digitally signed by Nylas. 46 | */ 47 | @Json(name = "id_token") 48 | val idToken: String? = null, 49 | /** 50 | * Currently always Bearer. 51 | */ 52 | @Json(name = "token_type") 53 | val tokenType: String? = "Bearer", 54 | ) 55 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ComposeMessageRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to compose a message. 7 | */ 8 | data class ComposeMessageRequest( 9 | /** 10 | * The prompt that smart compose will use to generate a message suggestion. 11 | */ 12 | @Json(name = "prompt") 13 | val prompt: String, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ComposeMessageResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a response to a message composition request. 7 | */ 8 | data class ComposeMessageResponse( 9 | /** 10 | * The message suggestion generated by smart compose. 11 | */ 12 | @Json(name = "suggestion") 13 | val suggestion: String, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Conferencing.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.* 4 | 5 | /** 6 | * This sealed class represents the different types of conferencing configurations. 7 | */ 8 | sealed class Conferencing { 9 | /** 10 | * Class representation of a conferencing autocreate object 11 | */ 12 | data class Autocreate( 13 | /** 14 | * The conferencing provider 15 | */ 16 | @Json(name = "provider") 17 | val provider: ConferencingProvider? = null, 18 | /** 19 | * Empty dict to indicate an intention to autocreate a video link. 20 | * Additional provider settings may be included in autocreate.settings, but Nylas does not validate these. 21 | */ 22 | @Json(name = "autocreate") 23 | val autocreate: Map = emptyMap(), 24 | ) : Conferencing() 25 | 26 | /** 27 | * Class representation of a conferencing details object 28 | */ 29 | data class Details( 30 | /** 31 | * The conferencing provider 32 | */ 33 | @Json(name = "provider") 34 | val provider: ConferencingProvider? = null, 35 | /** 36 | * The conferencing details 37 | */ 38 | @Json(name = "details") 39 | val details: Config, 40 | ) : Conferencing() { 41 | /** 42 | * Class representation of the configuration for a conferencing object 43 | */ 44 | data class Config( 45 | /** 46 | * The conferencing meeting code. Used for Zoom. 47 | */ 48 | @Json(name = "meeting_code") 49 | val meetingCode: String? = null, 50 | /** 51 | * The conferencing meeting password. Used for Zoom. 52 | */ 53 | @Json(name = "password") 54 | val password: String? = null, 55 | /** 56 | * The conferencing meeting url. 57 | */ 58 | @Json(name = "url") 59 | val url: String? = null, 60 | /** 61 | * The conferencing meeting pin. Used for Google Meet. 62 | */ 63 | @Json(name = "pin") 64 | val pin: String? = null, 65 | /** 66 | * The conferencing meeting phone numbers. Used for Google Meet. 67 | */ 68 | @Json(name = "phone") 69 | val phone: List? = null, 70 | ) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConferencingProvider.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for the different conferencing providers. 7 | */ 8 | enum class ConferencingProvider { 9 | @Json(name = "Zoom Meeting") 10 | ZOOM_MEETING, 11 | 12 | @Json(name = "Google Meet") 13 | GOOGLE_MEET, 14 | 15 | @Json(name = "Microsoft Teams") 16 | MICROSOFT_TEAMS, 17 | 18 | @Json(name = "WebEx") 19 | WEBEX, 20 | 21 | @Json(name = "GoToMeeting") 22 | GOTOMEETING, 23 | 24 | @Json(name = "skypeForConsumer") 25 | SKYPE_FOR_CONSUMER, 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfigurationAvailability.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of availability settings. 7 | */ 8 | data class ConfigurationAvailability( 9 | /** 10 | * The total number of minutes the event should last. 11 | */ 12 | @Json(name = "duration_minutes") 13 | val durationMinutes: Int? = null, 14 | /** 15 | * The interval between meetings in minutes. 16 | */ 17 | @Json(name = "interval_minutes") 18 | val intervalMinutes: Int? = null, 19 | /** 20 | * Nylas rounds each time slot to the nearest multiple of this number of minutes. 21 | */ 22 | @Json(name = "round_to") 23 | val roundTo: Int? = null, 24 | /** 25 | * Availability rules for scheduling configuration. 26 | */ 27 | @Json(name = "availability_rules") 28 | val availabilityRules: AvailabilityRules? = null, 29 | ) { 30 | class Builder { 31 | private var durationMinutes: Int? = null 32 | private var intervalMinutes: Int? = null 33 | private var roundTo: Int? = null 34 | private var availabilityRules: AvailabilityRules? = null 35 | 36 | /** 37 | * Set the duration of the event in minutes. 38 | * @param durationMinutes The duration of the event in minutes. 39 | * @return The builder. 40 | */ 41 | fun durationMinutes(durationMinutes: Int?) = apply { this.durationMinutes = durationMinutes } 42 | 43 | /** 44 | * Set the interval between meetings in minutes. 45 | * @param intervalMinutes The interval between meetings in minutes. 46 | * @return The builder. 47 | */ 48 | fun intervalMinutes(intervalMinutes: Int?) = apply { this.intervalMinutes = intervalMinutes } 49 | 50 | /** 51 | * Set Nylas rounds each time slot to the nearest multiple of this number of minutes. 52 | * @param roundTo Nylas rounds each time slot to the nearest multiple of this number of minutes. 53 | * @return The builder. 54 | */ 55 | fun roundTo(roundTo: Int?) = apply { this.roundTo = roundTo } 56 | 57 | /** 58 | * Set availability rules for scheduling configuration. 59 | * @param availabilityRules Availability rules for scheduling configuration. 60 | * @return The builder. 61 | */ 62 | fun availabilityRules(availabilityRules: AvailabilityRules?) = apply { this.availabilityRules = availabilityRules } 63 | 64 | /** 65 | * Build the [ConfigurationAvailability]. 66 | * @return The [ConfigurationAvailability]. 67 | */ 68 | fun build() = ConfigurationAvailability( 69 | durationMinutes, 70 | intervalMinutes, 71 | roundTo, 72 | availabilityRules, 73 | ) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfigurationAvailabilityParticipant.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a participant in a booking. 7 | */ 8 | 9 | data class ConfigurationAvailabilityParticipant( 10 | /** 11 | * @param calendarIds The calendar IDs that the event is created in. 12 | */ 13 | @Json(name = "calendar_ids") 14 | val calendarIds: List? = emptyList(), 15 | /** 16 | * Open hours for this participant. The endpoint searches for free time slots during these open hours. 17 | */ 18 | @Json(name = "open_hours") 19 | val openHours: List? = null, 20 | ) { 21 | /** 22 | * Builder for [ConfigurationAvailabilityParticipant]. 23 | */ 24 | class Builder { 25 | private var calendarIds: List? = null 26 | private var openHours: List? = null 27 | 28 | /** 29 | * Set the calendar IDs for this participant. 30 | * @param calendarIds Calendar IDs for this participant. 31 | * @return The builder. 32 | */ 33 | fun calendarIds(calendarIds: List) = apply { this.calendarIds = calendarIds } 34 | 35 | /** 36 | * Set the open hours for this participant. 37 | * @param openHours Open hours for this participant. 38 | * @return The builder. 39 | */ 40 | fun openHours(openHours: List) = apply { this.openHours = openHours } 41 | 42 | /** 43 | * Set the open hours for this participant. 44 | * @param openHours Open hours for this participant. 45 | * @return The builder. 46 | */ 47 | fun build() = ConfigurationAvailabilityParticipant( 48 | calendarIds, 49 | openHours, 50 | ) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfigurationBookingParticipant.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a participant in a booking. 7 | */ 8 | data class ConfigurationBookingParticipant( 9 | /** 10 | * The calendar ID that the event is created in. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String? = null, 14 | ) { 15 | /** 16 | * Builder for [ConfigurationBookingParticipant]. 17 | */ 18 | class Builder { 19 | private var calendarId: String? = null 20 | 21 | /** 22 | * Set the calendar ID for this participant. 23 | * @param calendarId The calendar ID for this participant. 24 | * @return The builder. 25 | */ 26 | fun calendarId(calendarId: String?) = apply { this.calendarId = calendarId } 27 | 28 | /** 29 | * Builds a [ConfigurationBookingParticipant] instance. 30 | * @return The [ConfigurationBookingParticipant] instance. 31 | */ 32 | fun build() = ConfigurationBookingParticipant(calendarId) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfirmBookingQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for confirming a booking. 7 | */ 8 | data class ConfirmBookingQueryParams( 9 | /** 10 | * The ID of the Configuration object whose settings are used for calculating availability. 11 | */ 12 | @Json(name = "configuration_id") 13 | val configurationId: String? = null, 14 | /** 15 | * The slug of the Configuration object whose settings are used for calculating availability. 16 | */ 17 | @Json(name = "slug") 18 | val slug: String? = null, 19 | /** 20 | * The client ID that was used to create the Configuration object. 21 | */ 22 | @Json(name = "client_id") 23 | val clientId: String? = null, 24 | ) : IQueryParams { 25 | /** 26 | * Builder for [ConfirmBookingQueryParams]. 27 | */ 28 | class Builder { 29 | private var configurationId: String? = null 30 | private var slug: String? = null 31 | private var clientId: String? = null 32 | 33 | /** 34 | * Set the configuration ID of the booking. 35 | * @param configurationId The configuration ID of the booking. 36 | * @return The builder. 37 | */ 38 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 39 | 40 | /** 41 | * Set the slug of the booking. 42 | * @param slug The slug of the booking. 43 | * @return The builder. 44 | */ 45 | fun slug(slug: String) = apply { this.slug = slug } 46 | 47 | /** 48 | * Set the client ID of the booking. 49 | * @param clientId The client ID of the booking. 50 | * @return The builder. 51 | */ 52 | fun clientId(clientId: String) = apply { this.clientId = clientId } 53 | 54 | /** 55 | * Builds a [ConfirmBookingQueryParams] instance. 56 | * @return The [ConfirmBookingQueryParams] instance. 57 | */ 58 | fun build() = ConfirmBookingQueryParams(configurationId, slug, clientId) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfirmBookingRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the request body for confirming a booking. 7 | */ 8 | data class ConfirmBookingRequest( 9 | @Json(name = "status") 10 | val status: ConfirmBookingStatus? = null, 11 | /** 12 | * The salt extracted from the booking reference embedded in the organizer confirmation link. 13 | */ 14 | @Json(name = "salt") 15 | val salt: String? = null, 16 | /** 17 | * The reason the booking is being cancelled. 18 | */ 19 | @Json(name = "cancellation_reason") 20 | val cancellationReason: String? = null, 21 | ) { 22 | /** 23 | * Builder for [ConfirmBookingRequest]. 24 | */ 25 | class Builder { 26 | private var status: ConfirmBookingStatus? = null 27 | private var salt: String? = null 28 | private var cancellationReason: String? = null 29 | 30 | /** 31 | * Set the status of the booking. 32 | * @param status The status of the booking. 33 | * @return The builder. 34 | */ 35 | fun status(status: ConfirmBookingStatus) = apply { this.status = status } 36 | 37 | /** 38 | * Set the salt of the booking. 39 | * @param salt The salt of the booking. 40 | * @return The builder. 41 | */ 42 | fun salt(salt: String) = apply { this.salt = salt } 43 | 44 | /** 45 | * Set the cancellation reason of the booking. 46 | * @param cancellationReason The cancellation reason of the booking. 47 | * @return The builder. 48 | */ 49 | fun cancellationReason(cancellationReason: String) = apply { this.cancellationReason = cancellationReason } 50 | 51 | /** 52 | * Builds a [ConfirmBookingRequest] instance. 53 | * @return The [ConfirmBookingRequest] instance. 54 | */ 55 | fun build() = ConfirmBookingRequest(status, salt, cancellationReason) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ConfirmBookingStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for confirm booking statuses. 7 | */ 8 | enum class ConfirmBookingStatus { 9 | @Json(name = "confirmed") 10 | CONFIRMED, 11 | 12 | @Json(name = "cancelled") 13 | CANCELLED, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Connector.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory 5 | 6 | /** 7 | * Class representation of the Nylas connector response. 8 | */ 9 | sealed class Connector( 10 | /** 11 | * The provider type 12 | */ 13 | @Json(name = "provider") 14 | val provider: AuthProvider, 15 | ) { 16 | /** 17 | * Class representing a Google connector creation request. 18 | */ 19 | data class Google( 20 | /** 21 | * The Google OAuth provider credentials and settings 22 | */ 23 | @Json(name = "settings") 24 | val settings: GoogleConnectorSettings, 25 | /** 26 | * The Google OAuth scopes 27 | */ 28 | @Json(name = "scope") 29 | val scope: List? = null, 30 | ) : Connector(AuthProvider.GOOGLE) 31 | 32 | /** 33 | * Class representing a Microsoft connector creation request. 34 | */ 35 | data class Microsoft( 36 | /** 37 | * The Microsoft OAuth provider credentials and settings 38 | */ 39 | @Json(name = "settings") 40 | val settings: MicrosoftConnectorSettings, 41 | /** 42 | * The Microsoft OAuth scopes 43 | */ 44 | @Json(name = "scope") 45 | val scope: List? = null, 46 | ) : Connector(AuthProvider.MICROSOFT) 47 | 48 | /** 49 | * Class representing an IMAP connector creation request. 50 | */ 51 | class Imap : Connector(AuthProvider.IMAP) 52 | 53 | /** 54 | * Class representing a virtual calendar connector creation request. 55 | */ 56 | class VirtualCalendar : Connector(AuthProvider.VIRTUAL_CALENDAR) 57 | 58 | companion object { 59 | @JvmStatic 60 | val CONNECTOR_JSON_ADAPTER_FACTORY: PolymorphicJsonAdapterFactory = 61 | PolymorphicJsonAdapterFactory.of(Connector::class.java, "provider") 62 | .withSubtype(Google::class.java, AuthProvider.GOOGLE.value) 63 | .withSubtype(Microsoft::class.java, AuthProvider.MICROSOFT.value) 64 | .withSubtype(Imap::class.java, AuthProvider.IMAP.value) 65 | .withSubtype(VirtualCalendar::class.java, AuthProvider.VIRTUAL_CALENDAR.value) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Contact.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas contact object 7 | */ 8 | data class Contact( 9 | @Json(name = "id") 10 | val id: String = "", 11 | @Json(name = "grant_id") 12 | val grantId: String = "", 13 | @Json(name = "object") 14 | private val obj: String = "contact", 15 | @Json(name = "birthday") 16 | val birthday: String? = null, 17 | @Json(name = "company_name") 18 | val companyName: String? = null, 19 | @Json(name = "display_name") 20 | val displayName: String = "", 21 | @Json(name = "emails") 22 | val emails: List? = null, 23 | @Json(name = "im_addresses") 24 | val imAddresses: List? = null, 25 | @Json(name = "given_name") 26 | val givenName: String? = null, 27 | @Json(name = "job_title") 28 | val jobTitle: String? = null, 29 | @Json(name = "manager_name") 30 | val managerName: String? = null, 31 | @Json(name = "middle_name") 32 | val middleName: String? = null, 33 | @Json(name = "nickname") 34 | val nickname: String? = null, 35 | @Json(name = "notes") 36 | val notes: String? = null, 37 | @Json(name = "office_location") 38 | val officeLocation: String? = null, 39 | @Json(name = "picture_url") 40 | val pictureUrl: String? = null, 41 | @Json(name = "picture") 42 | val picture: String? = null, 43 | @Json(name = "suffix") 44 | val suffix: String? = null, 45 | @Json(name = "surname") 46 | val surname: String? = null, 47 | @Json(name = "source") 48 | val source: SourceType? = null, 49 | @Json(name = "phone_numbers") 50 | val phoneNumbers: List? = null, 51 | @Json(name = "physical_addresses") 52 | val physicalAddresses: List? = null, 53 | @Json(name = "web_pages") 54 | val webPages: List? = null, 55 | @Json(name = "groups") 56 | val groups: List? = null, 57 | ) { 58 | fun getObject() = obj 59 | } 60 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ContactEmail.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Interface for email addresses in a contact. 7 | */ 8 | data class ContactEmail( 9 | @Json(name = "email") 10 | val email: String? = null, 11 | @Json(name = "type") 12 | val type: String? = null, 13 | ) { 14 | class Builder { 15 | private var email: String? = null 16 | private var type: String? = null 17 | 18 | fun email(email: String) = apply { this.email = email } 19 | 20 | fun type(type: String) = apply { this.type = type } 21 | 22 | fun build() = ContactEmail(email, type) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ContactGroup.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a contact group. 7 | */ 8 | data class ContactGroup( 9 | @Json(name = "id") 10 | val id: String, 11 | @Json(name = "grant_id") 12 | val grantId: String? = null, 13 | @Json(name = "group_type") 14 | val groupType: GroupType? = null, 15 | @Json(name = "name") 16 | val name: String? = null, 17 | @Json(name = "path") 18 | val path: String? = null, 19 | @Json(name = "object") 20 | private val obj: String = "contact_group", 21 | ) { 22 | fun getObject() = obj 23 | } 24 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ContactGroupId.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing an object that points to a contact group ID. 7 | */ 8 | data class ContactGroupId( 9 | /** 10 | * The ID of the contact group. 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateBookingGuest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a request to create a booking guest. 7 | */ 8 | data class CreateBookingGuest( 9 | /** 10 | * The email address of the guest. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * The name of the guest. 16 | */ 17 | @Json(name = "name") 18 | val name: String? = null, 19 | ) { 20 | /** 21 | * Builder for [CreateBookingGuest]. 22 | */ 23 | data class Builder( 24 | private val email: String, 25 | ) { 26 | private var name: String? = null 27 | 28 | /** 29 | * Set the name of the guest. 30 | * @param name The name of the guest. 31 | * @return The builder. 32 | */ 33 | fun name(name: String) = apply { this.name = name } 34 | 35 | /** 36 | * Builds a [CreateBookingGuest] instance. 37 | * @return The [CreateBookingGuest] instance. 38 | */ 39 | fun build() = CreateBookingGuest(email, name) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateBookingOrganizer.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to create a booking organizer. 7 | */ 8 | data class CreateBookingOrganizer( 9 | /** 10 | * The email address of the participant designated as the organizer of the event. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * The name of the participant designated as the organizer of the event. 16 | */ 17 | @Json(name = "name") 18 | val name: String? = null, 19 | ) { 20 | /** 21 | * Builder for [CreateBookingOrganizer]. 22 | */ 23 | data class Builder( 24 | private val email: String, 25 | ) { 26 | private var name: String? = null 27 | 28 | /** 29 | * Set the name of the participant designated as the organizer of the event. 30 | * @param name The name of the participant designated as the organizer of the event. 31 | * @return The builder. 32 | */ 33 | fun name(name: String) = apply { this.name = name } 34 | 35 | /** 36 | * Builds a [CreateBookingOrganizer] instance. 37 | * @return The [CreateBookingOrganizer] instance. 38 | */ 39 | fun build() = CreateBookingOrganizer(email, name) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateBookingQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for creating a booking. 7 | */ 8 | data class CreateBookingQueryParams( 9 | /** 10 | * The ID of the Configuration object whose settings are used for calculating availability. 11 | */ 12 | @Json(name = "configuration_id") 13 | val configurationId: String? = null, 14 | /** 15 | * The slug of the Configuration object whose settings are used for calculating availability. 16 | */ 17 | @Json(name = "slug") 18 | val slug: String? = null, 19 | /** 20 | * The client ID that was used to create the Configuration object. 21 | */ 22 | @Json(name = "client_id") 23 | val clientId: String? = null, 24 | ) : IQueryParams { 25 | /** 26 | * Builder for [CreateBookingQueryParams]. 27 | */ 28 | class Builder { 29 | private var configurationId: String? = null 30 | private var slug: String? = null 31 | private var clientId: String? = null 32 | 33 | /** 34 | * Sets the ID of the Configuration object whose settings are used for calculating availability. 35 | * @param configurationId The ID of the Configuration object whose settings are used for calculating availability. 36 | * @return The builder. 37 | */ 38 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 39 | 40 | /** 41 | * Sets the slug of the Configuration object whose settings are used for calculating availability. 42 | * @param slug The slug of the Configuration object whose settings are used for calculating availability. 43 | * @return The builder. 44 | */ 45 | fun slug(slug: String) = apply { this.slug = slug } 46 | 47 | /** 48 | * Sets the client ID that was used to create the Configuration object. 49 | * @param clientId The client ID that was used to create the Configuration object. 50 | * @return The builder. 51 | */ 52 | fun clientId(clientId: String) = apply { this.clientId = clientId } 53 | 54 | /** 55 | * Builds a [CreateBookingQueryParams] instance. 56 | * @return The [CreateBookingQueryParams] instance. 57 | */ 58 | fun build() = CreateBookingQueryParams(configurationId, slug, clientId) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateBookingReminder.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a request to create a booking reminder. 7 | */ 8 | data class CreateBookingReminder( 9 | /** 10 | * The reminder type. 11 | */ 12 | @Json(name = "type") 13 | val type: String, 14 | /** 15 | * The number of minutes before the event to send the reminder. 16 | */ 17 | @Json(name = "minutes_before_event") 18 | val minutesBeforeEvent: Int, 19 | /** 20 | * The recipient of the reminder. 21 | */ 22 | @Json(name = "recipient") 23 | val recipient: String? = null, 24 | /** 25 | * The subject of the email reminder. 26 | */ 27 | @Json(name = "email_subject") 28 | val emailSubject: String? = null, 29 | ) { 30 | /** 31 | * Builder for [CreateBookingReminder]. 32 | */ 33 | data class Builder( 34 | private val type: String, 35 | private val minutesBeforeEvent: Int, 36 | ) { 37 | private var recipient: String? = null 38 | private var emailSubject: String? = null 39 | 40 | /** 41 | * Set the recipient of the reminder. 42 | * @param recipient The recipient of the reminder. 43 | * @return The builder. 44 | */ 45 | fun recipient(recipient: String) = apply { this.recipient = recipient } 46 | 47 | /** 48 | * Set the subject of the email reminder. 49 | * @param emailSubject The subject of the email reminder. 50 | * @return The builder. 51 | */ 52 | fun emailSubject(emailSubject: String) = apply { this.emailSubject = emailSubject } 53 | 54 | /** 55 | * Builds a [CreateBookingReminder] instance. 56 | * @return The [CreateBookingReminder] instance. 57 | */ 58 | fun build() = CreateBookingReminder(type, minutesBeforeEvent, recipient, emailSubject) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateEventQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for creating an event. 7 | */ 8 | data class CreateEventQueryParams( 9 | /** 10 | * The ID of the calendar to create the event in. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String, 14 | /** 15 | * Email notifications containing the calendar event is sent to all event participants. 16 | */ 17 | @Json(name = "notify_participants") 18 | val notifyParticipants: Boolean? = null, 19 | ) : IQueryParams { 20 | /** 21 | * Builder for [CreateEventQueryParams]. 22 | * @property calendarId The ID of the calendar to create the event in. 23 | */ 24 | data class Builder( 25 | private val calendarId: String, 26 | ) { 27 | private var notifyParticipants: Boolean? = null 28 | 29 | /** 30 | * Sets whether notifications containing the calendar event is sent to all event participants. 31 | * @param notifyParticipants Email notifications containing the calendar event is sent to all event participants. 32 | * @return The builder. 33 | */ 34 | fun notifyParticipants(notifyParticipants: Boolean?) = apply { this.notifyParticipants = notifyParticipants } 35 | 36 | /** 37 | * Builds a [CreateEventQueryParams] instance. 38 | * @return The [CreateEventQueryParams] instance. 39 | */ 40 | fun build() = CreateEventQueryParams( 41 | calendarId, 42 | notifyParticipants, 43 | ) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateFolderRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the Nylas folder creation request. 7 | */ 8 | data class CreateFolderRequest( 9 | /** 10 | * The name of the folder. 11 | */ 12 | @Json(name = "name") 13 | val name: String, 14 | /** 15 | * The parent ID of the folder. (Microsoft only) 16 | */ 17 | @Json(name = "parent_id") 18 | val parentId: String? = null, 19 | /** 20 | * The background color of the folder. (Google only) 21 | */ 22 | @Json(name = "background_color") 23 | val backgroundColor: String? = null, 24 | /** 25 | * The text color of the folder. (Google only) 26 | */ 27 | @Json(name = "text_color") 28 | val textColor: String? = null, 29 | ) { 30 | /** 31 | * Builder for [CreateFolderRequest]. 32 | * @param name The name of the folder. 33 | */ 34 | data class Builder( 35 | private val name: String, 36 | ) { 37 | private var parentId: String? = null 38 | private var backgroundColor: String? = null 39 | private var textColor: String? = null 40 | 41 | /** 42 | * Set the parent ID of the folder. (Microsoft only) 43 | * @param parentId The parent ID of the folder. 44 | * @return The builder. 45 | */ 46 | fun parentId(parentId: String) = apply { this.parentId = parentId } 47 | 48 | /** 49 | * Set the background color of the folder. (Google only) 50 | * 51 | * The background color of the folder in the hexadecimal format `#0099EE`. 52 | * See Google Defined Values for more information. 53 | * 54 | * @param backgroundColor The background color of the folder. 55 | * @return The builder. 56 | */ 57 | fun backgroundColor(backgroundColor: String) = apply { this.backgroundColor = backgroundColor } 58 | 59 | /** 60 | * Set the text color of the folder. (Google only) 61 | * 62 | * The text color of the folder in the hexadecimal format `#0099EE`. 63 | * See Google Defined Values for more information. 64 | * 65 | * @param textColor The text color of the folder. 66 | * @return The builder. 67 | */ 68 | fun textColor(textColor: String) = apply { this.textColor = textColor } 69 | 70 | /** 71 | * Build the [CreateFolderRequest]. 72 | * @return The [CreateFolderRequest]. 73 | */ 74 | fun build() = CreateFolderRequest( 75 | name = name, 76 | parentId = parentId, 77 | backgroundColor = backgroundColor, 78 | textColor = textColor, 79 | ) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateGrantRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to create a grant. 7 | */ 8 | data class CreateGrantRequest( 9 | /** 10 | * OAuth provider 11 | */ 12 | @Json(name = "provider") 13 | val provider: AuthProvider, 14 | /** 15 | * Settings required by provider. 16 | */ 17 | @Json(name = "settings") 18 | val settings: Map, 19 | /** 20 | * Optional state value to return to developer's website after authentication flow is completed. 21 | */ 22 | @Json(name = "state") 23 | val state: String? = null, 24 | /** 25 | * Optional list of scopes to request. If not specified it will use the integration default scopes. 26 | */ 27 | @Json(name = "scope") 28 | val scope: List? = null, 29 | ) { 30 | /** 31 | * Builder for [CreateGrantRequest]. 32 | * @property provider OAuth provider 33 | * @property settings Settings required by provider. 34 | */ 35 | data class Builder( 36 | private val provider: AuthProvider, 37 | private val settings: Map, 38 | ) { 39 | private var state: String? = null 40 | private var scopes: List? = null 41 | 42 | /** 43 | * Set the state value to return to developer's website after authentication flow is completed. 44 | * @param state State value 45 | * @return This builder 46 | */ 47 | fun state(state: String) = apply { this.state = state } 48 | 49 | /** 50 | * Set the list of scopes to request. If not specified it will use the integration default scopes. 51 | * @param scopes List of scopes 52 | * @return This builder 53 | */ 54 | fun scopes(scopes: List) = apply { this.scopes = scopes } 55 | 56 | /** 57 | * Build the [CreateGrantRequest]. 58 | * @return The built [CreateGrantRequest] 59 | */ 60 | fun build() = CreateGrantRequest(provider, settings, state, scopes) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateRedirectUriRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to create a redirect uri. 7 | */ 8 | data class CreateRedirectUriRequest( 9 | /** 10 | * Redirect URL. 11 | */ 12 | @Json(name = "url") 13 | val url: String, 14 | /** 15 | * Platform identifier. 16 | */ 17 | @Json(name = "platform") 18 | val platform: Platform, 19 | /** 20 | * Optional settings for the redirect uri. 21 | */ 22 | @Json(name = "settings") 23 | val settings: RedirectUriSettings? = null, 24 | ) { 25 | /** 26 | * Builder for [CreateRedirectUriRequest]. 27 | * @property url Redirect URL. 28 | * @property platform Platform identifier. 29 | */ 30 | data class Builder( 31 | private val url: String, 32 | private val platform: Platform, 33 | ) { 34 | private var settings: RedirectUriSettings? = null 35 | 36 | /** 37 | * Set the settings for the redirect uri. 38 | * @param settings Settings for the redirect uri 39 | * @return This builder 40 | */ 41 | fun settings(settings: RedirectUriSettings) = apply { this.settings = settings } 42 | 43 | /** 44 | * Build the [CreateRedirectUriRequest]. 45 | * @return The built [CreateRedirectUriRequest] 46 | */ 47 | fun build() = CreateRedirectUriRequest(url, platform, settings) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateSessionRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a request to create a session. 7 | */ 8 | data class CreateSessionRequest( 9 | /** 10 | * The identifier of the Configuration to act upon. If you're using slug, configuration_id is not required. 11 | */ 12 | @Json(name = "configuration_id") 13 | val configurationId: String? = null, 14 | /** 15 | * The time to live for the session. 16 | */ 17 | @Json(name = "time_to_live") 18 | val timeToLive: Int? = null, 19 | 20 | /** 21 | * The slug of the Scheduler Configuration object for the session. You can use slug instead of configuration_id 22 | */ 23 | @Json(name = "slug") 24 | val slug: String? = null, 25 | ) { 26 | /** 27 | * A builder for creating a [CreateSessionRequest]. 28 | * @param configurationId The identifier of the Configuration to act upon. 29 | * @param timeToLive The time to live for the session. 30 | * @param slug The slug of the Scheduler Configuration object for the session. 31 | */ 32 | class Builder { 33 | private var configurationId: String? = null 34 | private var timeToLive: Int? = null 35 | private var slug: String? = null 36 | 37 | /** 38 | * Set the configuration ID. 39 | * @param configurationId The identifier of the Configuration to act upon. 40 | * @return The builder. 41 | */ 42 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 43 | 44 | /** 45 | * Set the time to live for the session. 46 | * @param timeToLive The time to live for the session. 47 | * @return The builder. 48 | */ 49 | fun timeToLive(timeToLive: Int) = apply { this.timeToLive = timeToLive } 50 | 51 | /** 52 | * Set the slug of the Scheduler Configuration object for the session. 53 | * @param slug The slug of the Scheduler Configuration object for the session. 54 | * @return The builder. 55 | */ 56 | fun slug(slug: String) = apply { this.slug = slug } 57 | 58 | /** 59 | * Build the [CreateSessionRequest]. 60 | * @return The [CreateSessionRequest]. 61 | */ 62 | fun build() = CreateSessionRequest(configurationId, timeToLive, slug) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CreateWebhookRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas create webhook request. 7 | */ 8 | data class CreateWebhookRequest( 9 | /** 10 | * Select the event that triggers the webhook. 11 | */ 12 | @Json(name = "trigger_types") 13 | val triggerTypes: List, 14 | /** 15 | * The url to send webhooks to. 16 | */ 17 | @Json(name = "webhook_url") 18 | val webhookUrl: String, 19 | /** 20 | * A human-readable description of the webhook destination. 21 | */ 22 | @Json(name = "description") 23 | val description: String? = null, 24 | /** 25 | * The email addresses that Nylas notifies when a webhook is down for a while. 26 | */ 27 | @Json(name = "notification_email_addresses") 28 | val notificationEmailAddresses: List? = null, 29 | ) { 30 | /** 31 | * A builder for creating a [CreateWebhookRequest]. 32 | * @param triggerTypes Select the event that triggers the webhook. 33 | * @param webhookUrl The url to send webhooks to. 34 | */ 35 | data class Builder( 36 | private val triggerTypes: List, 37 | private val webhookUrl: String, 38 | ) { 39 | private var description: String? = null 40 | private var notificationEmailAddresses: List? = null 41 | 42 | /** 43 | * Set a human-readable description of the webhook destination. 44 | * @param description A human-readable description of the webhook destination. 45 | * @return The builder. 46 | */ 47 | fun description(description: String?) = apply { this.description = description } 48 | 49 | /** 50 | * Set the email addresses that Nylas notifies when a webhook is down for a while. 51 | * @param notificationEmailAddresses The email addresses that Nylas notifies when a webhook is down for a while. 52 | * @return The builder. 53 | */ 54 | fun notificationEmailAddresses(notificationEmailAddresses: List?) = apply { 55 | this.notificationEmailAddresses = notificationEmailAddresses 56 | } 57 | 58 | /** 59 | * Build the [CreateWebhookRequest]. 60 | * @return The created [CreateWebhookRequest]. 61 | */ 62 | fun build() = CreateWebhookRequest(triggerTypes, webhookUrl, description, notificationEmailAddresses) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Credential.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class Credential( 6 | /** 7 | * Globally unique object identifier 8 | */ 9 | @Json(name = "id") 10 | val id: String, 11 | /** 12 | * Name of the credential 13 | */ 14 | @Json(name = "name") 15 | val name: String, 16 | /** 17 | * The type of credential 18 | */ 19 | @Json(name = "credential_type") 20 | val credentialType: CredentialType? = null, 21 | /** 22 | * Hashed value of the credential that you created 23 | */ 24 | @Json(name = "hashed_data") 25 | val hashedData: String? = null, 26 | /** 27 | * Timestamp of when the credential was created 28 | */ 29 | @Json(name = "created_at") 30 | val createdAt: Long? = null, 31 | /** 32 | * Timestamp of when the credential was updated 33 | */ 34 | @Json(name = "updated_at") 35 | val updatedAt: Long? = null, 36 | ) 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CredentialData.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Sealed class representing the data needed to create a credential 7 | */ 8 | sealed class CredentialData( 9 | open val extraProperties: Map? = emptyMap(), 10 | ) { 11 | /** 12 | * Class representing additional data needed to create a credential for Microsoft Admin Consent 13 | */ 14 | data class MicrosoftAdminConsent( 15 | @Json(name = "client_id") 16 | val clientId: String, 17 | @Json(name = "client_secret") 18 | val clientSecret: String, 19 | override val extraProperties: Map? = emptyMap(), 20 | ) : CredentialData(extraProperties) 21 | 22 | /** 23 | * Class representing additional data needed to create a credential for Google Service Account 24 | */ 25 | data class GoogleServiceAccount( 26 | @Json(name = "private_key_id") 27 | val privateKeyId: String, 28 | @Json(name = "private_key") 29 | val privateKey: String, 30 | @Json(name = "client_email") 31 | val clientEmail: String, 32 | override val extraProperties: Map? = emptyMap(), 33 | ) : CredentialData(extraProperties) 34 | 35 | /** 36 | * Class representing additional data needed to create a credential for a Connector Override 37 | */ 38 | data class ConnectorOverride( 39 | override val extraProperties: Map, 40 | ) : CredentialData(extraProperties) 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CredentialType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class CredentialType(val value: String) { 6 | @Json(name = "adminconsent") 7 | ADMINCONSENT("adminconsent"), 8 | 9 | @Json(name = "serviceaccount") 10 | SERVICEACCOUNT("serviceaccount"), 11 | 12 | @Json(name = "connector") 13 | CONNECTOR("connector"), 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/CustomHeader.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Custom headers to be used when drafting or sending an email. 7 | */ 8 | data class CustomHeader( 9 | /** 10 | * The name of the custom header. 11 | */ 12 | @Json(name = "name") 13 | val name: String, 14 | /** 15 | * The value of the custom header. 16 | */ 17 | @Json(name = "value") 18 | val value: String, 19 | ) { 20 | /** 21 | * Builder for [CustomHeader]. 22 | * @property name The name of the custom header. 23 | * @property value The value of the custom header. 24 | */ 25 | data class Builder( 26 | private val name: String, 27 | private val value: String, 28 | ) { 29 | /** 30 | * Build the [CustomHeader] object. 31 | */ 32 | fun build(): CustomHeader { 33 | return CustomHeader(name, value) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/DeleteResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a response to a delete request. 7 | */ 8 | data class DeleteResponse( 9 | /** 10 | * ID of the request. 11 | */ 12 | @Json(name = "request_id") 13 | val requestId: String = "", 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/DestroyBookingQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for destroying a booking. 7 | */ 8 | data class DestroyBookingQueryParams( 9 | /** 10 | * The ID of the Configuration object whose settings are used for calculating availability. 11 | */ 12 | @Json(name = "configuration_id") 13 | val configurationId: String? = null, 14 | /** 15 | * The slug of the Configuration object whose settings are used for calculating availability. 16 | */ 17 | @Json(name = "slug") 18 | val slug: String? = null, 19 | /** 20 | * The client ID that was used to create the Configuration object. 21 | */ 22 | @Json(name = "client_id") 23 | val clientId: String? = null, 24 | ) : IQueryParams { 25 | /** 26 | * Builder for [DestroyBookingQueryParams]. 27 | */ 28 | class Builder { 29 | private var configurationId: String? = null 30 | private var slug: String? = null 31 | private var clientId: String? = null 32 | 33 | /** 34 | * Sets the ID of the Configuration object whose settings are used for calculating availability. 35 | * @param configurationId The ID of the Configuration object whose settings are used for calculating availability. 36 | * @return The builder. 37 | */ 38 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 39 | 40 | /** 41 | * Sets the slug of the Configuration object whose settings are used for calculating availability. 42 | * @param slug The slug of the Configuration object whose settings are used for calculating availability. 43 | * @return The builder. 44 | */ 45 | fun slug(slug: String) = apply { this.slug = slug } 46 | 47 | /** 48 | * Sets the client ID that was used to create the Configuration object. 49 | * @param clientId The client ID that was used to create the Configuration object. 50 | * @return The builder. 51 | */ 52 | fun clientId(clientId: String) = apply { this.clientId = clientId } 53 | 54 | /** 55 | * Builds a [DestroyBookingQueryParams] instance. 56 | * @return The [DestroyBookingQueryParams] instance. 57 | */ 58 | fun build() = DestroyBookingQueryParams(configurationId, slug, clientId) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/DestroyBookingRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a request to destroy a booking. 7 | */ 8 | data class DestroyBookingRequest( 9 | /** 10 | * The reason for the cancellation of the booking. 11 | */ 12 | @Json(name = "cancellation_reason") 13 | val cancellationReason: String, 14 | ) { 15 | /** 16 | * Builder for [DestroyBookingRequest]. 17 | */ 18 | data class Builder( 19 | private val cancellationReason: String, 20 | ) { 21 | /** 22 | * Builds a [DestroyBookingRequest] instance. 23 | * @return The [DestroyBookingRequest] instance. 24 | */ 25 | fun build() = DestroyBookingRequest(cancellationReason) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/DestroyEventQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a query to delete an event. 7 | */ 8 | data class DestroyEventQueryParams( 9 | /** 10 | * Specify calendar ID of the event. "primary" is a supported value indicating the user's primary calendar. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String, 14 | /** 15 | * Defaults to true, email notifications containing the calendar event is sent to all event participants. 16 | * Microsoft accounts do not support notify_participants = False. 17 | */ 18 | @Json(name = "notify_participants") 19 | val notifyParticipants: Boolean? = null, 20 | ) : IQueryParams { 21 | /** 22 | * Builder for [DestroyEventQueryParams]. 23 | * @property calendarId Specify calendar ID of the event. "primary" is a supported value indicating the user's primary calendar. 24 | */ 25 | data class Builder( 26 | private val calendarId: String, 27 | ) { 28 | private var notifyParticipants: Boolean? = null 29 | 30 | /** 31 | * Set whether to send email notifications containing the calendar event to all event participants. 32 | * Microsoft accounts do not support notify_participants = False. 33 | * @param notifyParticipants Whether to send email notifications containing the calendar event to all event participants 34 | * @return This builder 35 | */ 36 | fun notifyParticipants(notifyParticipants: Boolean?) = apply { this.notifyParticipants = notifyParticipants } 37 | 38 | /** 39 | * Build the [DestroyEventQueryParams]. 40 | * @return The built [DestroyEventQueryParams] 41 | */ 42 | fun build() = DestroyEventQueryParams( 43 | calendarId, 44 | notifyParticipants, 45 | ) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EmailLanguage.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for email language options. 7 | */ 8 | enum class EmailLanguage { 9 | @Json(name = "en") 10 | EN, 11 | 12 | @Json(name = "es") 13 | ES, 14 | 15 | @Json(name = "fr") 16 | FR, 17 | 18 | @Json(name = "de") 19 | DE, 20 | 21 | @Json(name = "nl") 22 | NL, 23 | 24 | @Json(name = "sv") 25 | SV, 26 | 27 | @Json(name = "ja") 28 | JA, 29 | 30 | @Json(name = "zh") 31 | ZH, 32 | } 33 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EmailName.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing an email address and optional name. 7 | */ 8 | data class EmailName( 9 | /** 10 | * Email address. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * Full name. 16 | */ 17 | @Json(name = "name") 18 | val name: String? = null, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Environment.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the different Nylas environments. 7 | */ 8 | enum class Environment { 9 | @Json(name = "production") 10 | PRODUCTION, 11 | 12 | @Json(name = "staging") 13 | STAGING, 14 | 15 | @Json(name = "sandbox") 16 | SANDBOX, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EventNotetaker.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of Notetaker meeting bot settings for an event. 7 | * This is used for responses and contains the id field. 8 | */ 9 | data class EventNotetaker( 10 | /** 11 | * The Notetaker ID. 12 | */ 13 | @Json(name = "id") 14 | val id: String? = null, 15 | 16 | /** 17 | * The display name for the Notetaker bot. 18 | */ 19 | @Json(name = "name") 20 | val name: String? = "Nylas Notetaker", 21 | 22 | /** 23 | * Notetaker Meeting Settings 24 | */ 25 | @Json(name = "meeting_settings") 26 | val meetingSettings: MeetingSettings? = null, 27 | ) { 28 | /** 29 | * Data class for Notetaker Meeting Settings 30 | */ 31 | data class MeetingSettings( 32 | /** 33 | * When true, Notetaker records the meeting's video. 34 | */ 35 | @Json(name = "video_recording") 36 | val videoRecording: Boolean? = true, 37 | 38 | /** 39 | * When true, Notetaker records the meeting's audio. 40 | */ 41 | @Json(name = "audio_recording") 42 | val audioRecording: Boolean? = true, 43 | 44 | /** 45 | * When true, Notetaker transcribes the meeting's audio. 46 | */ 47 | @Json(name = "transcription") 48 | val transcription: Boolean? = true, 49 | ) 50 | } 51 | 52 | /** 53 | * Class representation of Notetaker meeting bot settings for an event creation request. 54 | * This version omits the id field as it should not be part of the request. 55 | */ 56 | data class EventNotetakerRequest( 57 | /** 58 | * The display name for the Notetaker bot. 59 | */ 60 | @Json(name = "name") 61 | val name: String? = "Nylas Notetaker", 62 | 63 | /** 64 | * Notetaker Meeting Settings 65 | */ 66 | @Json(name = "meeting_settings") 67 | val meetingSettings: MeetingSettings? = null, 68 | ) { 69 | /** 70 | * Data class for Notetaker Meeting Settings 71 | */ 72 | data class MeetingSettings( 73 | /** 74 | * When true, Notetaker records the meeting's video. 75 | */ 76 | @Json(name = "video_recording") 77 | val videoRecording: Boolean? = true, 78 | 79 | /** 80 | * When true, Notetaker records the meeting's audio. 81 | */ 82 | @Json(name = "audio_recording") 83 | val audioRecording: Boolean? = true, 84 | 85 | /** 86 | * When true, Notetaker transcribes the meeting's audio. 87 | */ 88 | @Json(name = "transcription") 89 | val transcription: Boolean? = true, 90 | ) 91 | } 92 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EventQueryOrderBy.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class EventQueryOrderBy { 6 | @Json(name = "start") 7 | START, 8 | } 9 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EventStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the status of an event. 7 | */ 8 | enum class EventStatus { 9 | @Json(name = "confirmed") 10 | CONFIRMED, 11 | 12 | @Json(name = "tentative") 13 | TENTATIVE, 14 | 15 | @Json(name = "cancelled") 16 | CANCELLED, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EventType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the different Google Event types. 7 | */ 8 | enum class EventType { 9 | @Json(name = "default") 10 | DEFAULT, 11 | 12 | @Json(name = "outOfOffice") 13 | OUT_OF_OFFICE, 14 | 15 | @Json(name = "focusTime") 16 | FOCUS_TIME, 17 | 18 | @Json(name = "workingLocation") 19 | WORKING_LOCATION, 20 | } 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/EventVisibility.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representation of visibility of the event, if the event is private or public. 7 | */ 8 | enum class EventVisibility { 9 | @Json(name = "default") 10 | DEFAULT, 11 | 12 | @Json(name = "public") 13 | PUBLIC, 14 | 15 | @Json(name = "private") 16 | PRIVATE, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FindAttachmentQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for finding an attachment. 7 | */ 8 | data class FindAttachmentQueryParams( 9 | /** 10 | * Message ID to find the attachment in. 11 | */ 12 | @Json(name = "message_id") 13 | val messageId: String, 14 | ) : IQueryParams { 15 | /** 16 | * Builder for [FindAttachmentQueryParams]. 17 | * @property messageId Message ID to find the attachment in. 18 | */ 19 | data class Builder( 20 | private val messageId: String, 21 | ) { 22 | /** 23 | * Builds a new [FindAttachmentQueryParams] instance. 24 | * @return [FindAttachmentQueryParams] 25 | */ 26 | fun build() = FindAttachmentQueryParams( 27 | messageId, 28 | ) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FindBookingQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for finding a booking. 7 | */ 8 | data class FindBookingQueryParams( 9 | /** 10 | * The ID of the Configuration object whose settings are used for calculating availability. 11 | * If you're using session authentication (requires_session_auth is set to true), configuration_id is not required 12 | */ 13 | @Json(name = "configuration_id") 14 | val configurationId: String? = null, 15 | /** 16 | * The slug of the Configuration object whose settings are used for calculating availability. 17 | * If you're using session authentication (requires_session_auth is set to true), or using configuration_id, slug is not required 18 | */ 19 | @Json(name = "slug") 20 | val slug: String? = null, 21 | /** 22 | * The client ID that was used to create the Configuration object. 23 | * client_id is required only if using slug. 24 | */ 25 | @Json(name = "client_id") 26 | val clientId: String? = null, 27 | ) : IQueryParams { 28 | /** 29 | * Builder for [FindBookingQueryParams]. 30 | */ 31 | class Builder { 32 | private var configurationId: String? = null 33 | private var slug: String? = null 34 | private var clientId: String? = null 35 | 36 | /** 37 | * Sets the ID of the Configuration object whose settings are used for calculating availability. 38 | * @param configurationId The ID of the Configuration object whose settings are used for calculating availability. 39 | * @return The builder. 40 | */ 41 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 42 | 43 | /** 44 | * Sets the slug of the Configuration object whose settings are used for calculating availability. 45 | * @param slug The slug of the Configuration object whose settings are used for calculating availability. 46 | * @return The builder. 47 | */ 48 | fun slug(slug: String) = apply { this.slug = slug } 49 | 50 | /** 51 | * Sets the client ID that was used to create the Configuration object. 52 | * @param clientId The client ID that was used to create the Configuration object. 53 | * @return The builder. 54 | */ 55 | fun clientId(clientId: String) = apply { this.clientId = clientId } 56 | 57 | /** 58 | * Builds a [FindBookingQueryParams] instance. 59 | * @return The [FindBookingQueryParams] instance. 60 | */ 61 | fun build() = FindBookingQueryParams(configurationId, slug, clientId) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FindContactQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class FindContactQueryParams( 6 | @Json(name = "profile_picture") 7 | val profilePicture: Boolean? = null, 8 | ) : IQueryParams 9 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FindEventQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for finding an event. 7 | */ 8 | data class FindEventQueryParams( 9 | /** 10 | * Calendar ID to find the event in. "primary" is a supported value indicating the user's primary calendar. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String, 14 | ) : IQueryParams { 15 | /** 16 | * Builder for [FindEventQueryParams]. 17 | * @property calendarId Calendar ID to find the event in. "primary" is a supported value indicating the user's primary calendar. 18 | */ 19 | data class Builder( 20 | private val calendarId: String, 21 | ) { 22 | /** 23 | * Builds a new [FindEventQueryParams] instance. 24 | * @return [FindEventQueryParams] 25 | */ 26 | fun build() = FindEventQueryParams( 27 | calendarId, 28 | ) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FindMessageQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the query parameters for finding a message. 7 | */ 8 | data class FindMessageQueryParams( 9 | /** 10 | * Allows you to specify to the message with headers included. 11 | */ 12 | @Json(name = "fields") 13 | val fields: MessageFields? = null, 14 | ) : IQueryParams { 15 | /** 16 | * Builder for [FindMessageQueryParams]. 17 | */ 18 | class Builder { 19 | private var fields: MessageFields? = null 20 | 21 | /** 22 | * Set the fields to include in the response. 23 | * @param fields The fields to include in the response. 24 | * @return The builder. 25 | */ 26 | fun fields(fields: MessageFields?) = apply { this.fields = fields } 27 | 28 | /** 29 | * Builds the [FindMessageQueryParams] object. 30 | * @return The [FindMessageQueryParams] object. 31 | */ 32 | fun build() = FindMessageQueryParams( 33 | fields = fields, 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Folder.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the Nylas folder response. 7 | */ 8 | data class Folder( 9 | /** 10 | * A globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | /** 15 | * A Grant ID of the Nylas account. 16 | */ 17 | @Json(name = "grant_id") 18 | val grantId: String, 19 | /** 20 | * Folder name 21 | */ 22 | @Json(name = "name") 23 | val name: String? = null, 24 | /** 25 | * The type of object. 26 | */ 27 | @Json(name = "object") 28 | val obj: String = "folder", 29 | /** 30 | * ID of the parent folder. (Microsoft only) 31 | */ 32 | @Json(name = "parent_id") 33 | val parentId: String? = null, 34 | /** 35 | * Folder background color. (Google only) 36 | */ 37 | @Json(name = "background_color") 38 | val backgroundColor: String? = null, 39 | /** 40 | * Folder text color. (Google only) 41 | */ 42 | @Json(name = "text_color") 43 | val textColor: String? = null, 44 | /** 45 | * Indicates if the folder is user created or system created. (Google Only) 46 | */ 47 | @Json(name = "system_folder") 48 | val systemFolder: Boolean? = null, 49 | /** 50 | * The number of immediate child folders in the current folder. (Microsoft only) 51 | */ 52 | @Json(name = "child_count") 53 | val childCount: Int? = null, 54 | /** 55 | * The number of unread items inside of a folder. 56 | */ 57 | @Json(name = "unread_count") 58 | val unreadCount: Int? = null, 59 | /** 60 | * The number of items inside of a folder. 61 | */ 62 | @Json(name = "total_count") 63 | val totalCount: Int? = null, 64 | /** 65 | * Common attribute descriptors shared by system folders across providers. 66 | * For example, Sent email folders have the `["\\Sent"]` attribute. 67 | * For IMAP grants, IMAP providers provide the attributes. 68 | * For Google and Microsoft Graph, Nylas matches system folders to a set of common attributes. 69 | */ 70 | @Json(name = "attributes") 71 | val attributes: List? = null, 72 | ) { 73 | /** 74 | * Get the type of object. 75 | * @return The type of object. 76 | */ 77 | fun getObject() = obj 78 | } 79 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FreeBusyTimeSlot.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas free-busy time slot object. 7 | */ 8 | data class FreeBusyTimeSlot( 9 | /** 10 | * Unix timestamp for the start of the slot. 11 | */ 12 | @Json(name = "start_time") 13 | val startTime: Int, 14 | /** 15 | * Unix timestamp for the end of the slot. 16 | */ 17 | @Json(name = "end_time") 18 | val endTime: Int, 19 | /** 20 | * The status of the time slot. 21 | */ 22 | @Json(name = "status") 23 | val status: String, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/FreeBusyType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the type of free/busy information returned for a calendar. 7 | */ 8 | enum class FreeBusyType(val value: String) { 9 | @Json(name = "free_busy") 10 | FREE_BUSY("free_busy"), 11 | 12 | @Json(name = "error") 13 | ERROR("error"), 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GetAvailabilityResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas get availability response 7 | */ 8 | data class GetAvailabilityResponse( 9 | /** 10 | * This property is only populated for round-robin events. 11 | * It will contain the order in which the accounts would be next in line to attend the proposed meeting. 12 | */ 13 | @Json(name = "order") 14 | val order: List? = null, 15 | /** 16 | * The available time slots where a new meeting can be created for the requested preferences. 17 | */ 18 | @Json(name = "time_slots") 19 | val timeSlots: List? = null, 20 | ) 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GetFreeBusyRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas get free-busy request 7 | */ 8 | data class GetFreeBusyRequest( 9 | /** 10 | * Unix timestamp representing the start of the time block for assessing the account's free/busy schedule. 11 | */ 12 | @Json(name = "start_time") 13 | val startTime: Int, 14 | /** 15 | * Unix timestamp representing the end of the time block for assessing the account's free/busy schedule. 16 | */ 17 | @Json(name = "end_time") 18 | val endTime: Int, 19 | /** 20 | * A list of email addresses to check the free/busy schedules for. 21 | */ 22 | @Json(name = "emails") 23 | val emails: List, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GetFreeBusyResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.nylas.util.JsonHelper 4 | import com.squareup.moshi.Json 5 | import com.squareup.moshi.JsonAdapter 6 | import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory 7 | 8 | /** 9 | * Class representation of a Nylas get free busy response. 10 | * It can be either a [FreeBusy] or a [FreeBusyError]. 11 | */ 12 | sealed class GetFreeBusyResponse { 13 | /** 14 | * The type of the response. 15 | */ 16 | @Json(name = "object") 17 | protected open val obj: FreeBusyType? = null 18 | 19 | /** 20 | * The participant's email address. 21 | */ 22 | @Json(name = "email") 23 | abstract val email: String 24 | 25 | /** 26 | * This class represents a successful free-busy response. 27 | */ 28 | data class FreeBusy( 29 | /** 30 | * A list of busy time slots. 31 | */ 32 | @Json(name = "time_slots") 33 | val timeSlots: List, 34 | @Json(name = "object") 35 | override val obj: FreeBusyType = FreeBusyType.FREE_BUSY, 36 | @Json(name = "email") 37 | override val email: String, 38 | ) : GetFreeBusyResponse() 39 | 40 | /** 41 | * This class represents a failed free-busy response. 42 | */ 43 | data class FreeBusyError( 44 | /** 45 | * Description of the error fetching data for this participant. 46 | */ 47 | @Json(name = "error") 48 | val error: String, 49 | @Json(name = "object") 50 | override val obj: FreeBusyType = FreeBusyType.ERROR, 51 | @Json(name = "email") 52 | override val email: String, 53 | ) : GetFreeBusyResponse() 54 | 55 | /** 56 | * Returns the type of object. 57 | * @return The type of object. 58 | */ 59 | fun getObject() = obj 60 | 61 | companion object { 62 | /** 63 | * A JsonAdapter factory for the [GetFreeBusyResponse] sealed class (used for deserialization). 64 | * @suppress Not for public use. 65 | */ 66 | @JvmStatic 67 | val FREE_BUSY_JSON_FACTORY: JsonAdapter.Factory = PolymorphicJsonAdapterFactory.of(GetFreeBusyResponse::class.java, "object") 68 | .withSubtype(FreeBusy::class.java, FreeBusyType.FREE_BUSY.value) 69 | .withSubtype(FreeBusyError::class.java, FreeBusyType.ERROR.value) 70 | 71 | /** 72 | * A JsonAdapter for the [GetFreeBusyResponse] sealed class (used for serialization). 73 | * @suppress Not for public use. 74 | */ 75 | @JvmStatic 76 | val GET_FREE_BUSY_RESPONSE_ADAPTER = JsonHelper.listTypeOf(GetFreeBusyResponse::class.java) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GoogleConnectorSettings.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing Google connector setting. 7 | */ 8 | data class GoogleConnectorSettings( 9 | /** 10 | * The Google Pub/Sub topic name 11 | */ 12 | @Json(name = "topic_name") 13 | val topicName: String? = null, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GoogleCreateConnectorSettings.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Google connector creation request. 7 | */ 8 | data class GoogleCreateConnectorSettings( 9 | /** 10 | * The Google Client ID 11 | */ 12 | @Json(name = "client_id") 13 | val clientId: String, 14 | /** 15 | * The Google Client Secret 16 | */ 17 | @Json(name = "client_secret") 18 | val clientSecret: String, 19 | /** 20 | * The Google Pub/Sub topic name 21 | */ 22 | @Json(name = "topic_name") 23 | val topicName: String? = null, 24 | ) { 25 | /** 26 | * Builder for [GoogleCreateConnectorSettings]. 27 | * @property clientId The Google Client ID 28 | * @property clientSecret The Google Client Secret 29 | */ 30 | data class Builder( 31 | private val clientId: String, 32 | private var clientSecret: String, 33 | ) { 34 | private var topicName: String? = null 35 | 36 | /** 37 | * Set the Google Pub/Sub topic name 38 | * @param topicName The Google Pub/Sub topic name 39 | * @return The builder 40 | */ 41 | fun topicName(topicName: String) = apply { this.topicName = topicName } 42 | 43 | /** 44 | * Build the [GoogleCreateConnectorSettings] object 45 | * @return The [GoogleCreateConnectorSettings] object 46 | */ 47 | fun build() = GoogleCreateConnectorSettings( 48 | clientId = clientId, 49 | clientSecret = clientSecret, 50 | topicName = topicName, 51 | ) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Grant.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Nylas Grant object. 7 | */ 8 | data class Grant( 9 | /** 10 | * Globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | /** 15 | * OAuth provider that the user authenticated with. 16 | */ 17 | @Json(name = "provider") 18 | val provider: AuthProvider, 19 | /** 20 | * Scopes specified for the grant. 21 | */ 22 | @Json(name = "scope") 23 | val scope: List? = null, 24 | /** 25 | * Unix timestamp when the grant was created. 26 | */ 27 | @Json(name = "created_at") 28 | val createdAt: Long, 29 | /** 30 | * Status of the grant, if it is still valid or if the user needs to re-authenticate. 31 | */ 32 | @Json(name = "grant_status") 33 | val grantStatus: GrantStatus? = null, 34 | /** 35 | * Email address associated with the grant. 36 | */ 37 | @Json(name = "email") 38 | val email: String? = null, 39 | /** 40 | * End user's client user agent. 41 | */ 42 | @Json(name = "user_agent") 43 | val userAgent: String? = null, 44 | /** 45 | * End user's client IP address. 46 | */ 47 | @Json(name = "ip") 48 | val ip: String? = null, 49 | /** 50 | * Initial state that was sent as part of the OAuth request. 51 | */ 52 | @Json(name = "state") 53 | val state: String? = null, 54 | /** 55 | * Unix timestamp when the grant was updated. 56 | */ 57 | @Json(name = "updated_at") 58 | val updatedAt: Long? = null, 59 | /** 60 | * Provider's ID for the user this grant is associated with. 61 | */ 62 | @Json(name = "provider_user_id") 63 | val providerUserId: String? = null, 64 | 65 | /** 66 | * Settings required by the provider that were sent as part of the OAuth request. 67 | */ 68 | @Json(name = "settings") 69 | val settings: Map? = null, 70 | ) 71 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GrantStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class GrantStatus { 6 | @Json(name = "valid") 7 | VALID, 8 | 9 | @Json(name = "invalid") 10 | INVALID, 11 | } 12 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/GroupType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class GroupType { 6 | @Json(name = "user") 7 | USER, 8 | 9 | @Json(name = "system") 10 | SYSTEM, 11 | 12 | @Json(name = "other") 13 | OTHER, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/IMessage.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | interface IMessage 4 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/IMessageAttachmentRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Represents a message-related request that uses an attachment 5 | */ 6 | interface IMessageAttachmentRequest { 7 | /** 8 | * An array of files to attach to the message. 9 | */ 10 | val attachments: List? 11 | } 12 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/IQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.nylas.util.JsonHelper 4 | 5 | /** 6 | * Interface for query parameters. 7 | */ 8 | interface IQueryParams { 9 | /** 10 | * Convert the query parameters to a json-formatted map. 11 | * @return Map of query parameters 12 | */ 13 | fun convertToMap(): Map { 14 | val json = JsonHelper.moshi() 15 | .adapter(this.javaClass) 16 | .toJson(this) 17 | 18 | if (json.isEmpty()) { 19 | return emptyMap() 20 | } 21 | 22 | return JsonHelper.jsonMapAdapter.fromJson(json)!! 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/InstantMessagingAddress.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation for an IM address in a contact. 7 | */ 8 | data class InstantMessagingAddress( 9 | @Json(name = "im_address") 10 | val imAddress: String? = null, 11 | @Json(name = "type") 12 | val type: String? = null, 13 | ) { 14 | class Builder { 15 | private var imAddress: String? = null 16 | private var type: String? = null 17 | 18 | fun imAddress(imAddress: String) = apply { this.imAddress = imAddress } 19 | 20 | fun type(type: String) = apply { this.type = type } 21 | 22 | fun build() = InstantMessagingAddress(imAddress, type) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListCalendersQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for listing calendars. 7 | */ 8 | data class ListCalendersQueryParams( 9 | /** 10 | * The maximum number of objects to return. 11 | * This field defaults to 50. The maximum allowed value is 200. 12 | */ 13 | @Json(name = "limit") 14 | val limit: Int? = null, 15 | /** 16 | * An identifier that specifies which page of data to return. 17 | * This value should be taken from the [ListResponse.nextCursor] response field. 18 | */ 19 | @Json(name = "page_token") 20 | val pageToken: String? = null, 21 | /** 22 | * Pass in your metadata key and value pair to search for metadata. 23 | */ 24 | @Json(name = "metadata_pair") 25 | val metadataPair: Map? = null, 26 | ) : IQueryParams { 27 | /** 28 | * Builder for [ListCalendersQueryParams]. 29 | */ 30 | class Builder { 31 | private var limit: Int? = null 32 | private var pageToken: String? = null 33 | private var metadataPair: Map? = null 34 | 35 | /** 36 | * Sets the maximum number of objects to return. 37 | * This field defaults to 50. The maximum allowed value is 200. 38 | * @param limit The maximum number of objects to return. 39 | * @return The builder. 40 | */ 41 | fun limit(limit: Int?) = apply { this.limit = limit } 42 | 43 | /** 44 | * Sets the identifier that specifies which page of data to return. 45 | * This value should be taken from the next_cursor response field. 46 | * @param pageToken The identifier that specifies which page of data to return. 47 | * @return The builder. 48 | */ 49 | fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } 50 | 51 | /** 52 | * Sets the metadata key and value pair to search for metadata. 53 | * @param metadataPair The metadata key and value pair to search for metadata. 54 | * @return The builder. 55 | */ 56 | fun metadataPair(metadataPair: Map?) = apply { this.metadataPair = metadataPair } 57 | 58 | /** 59 | * Builds a [ListCalendersQueryParams] instance. 60 | * @return The [ListCalendersQueryParams] instance. 61 | */ 62 | fun build() = ListCalendersQueryParams( 63 | limit, 64 | pageToken, 65 | metadataPair, 66 | ) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListConfigurationsQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class ListConfigurationsQueryParams( 6 | /** 7 | * The maximum number of objects to return. 8 | * Defaults to 50. The maximum allowed value is 200. 9 | */ 10 | @Json(name = "limit") 11 | val limit: Int? = null, 12 | /** 13 | * An identifier that specifies which page of data to return. 14 | * This value should be taken from the [ListResponse.nextCursor] response field. 15 | */ 16 | @Json(name = "page_token") 17 | val pageToken: String? = null, 18 | ) : IQueryParams 19 | 20 | /** 21 | * Builder for [ListConfigurationsQueryParams]. 22 | */ 23 | class Builder { 24 | private var limit: Int? = null 25 | private var pageToken: String? = null 26 | 27 | /** 28 | * Sets the maximum number of objects to return. 29 | * This field defaults to 50. The maximum allowed value is 200. 30 | * @param limit The maximum number of objects to return. 31 | * @return The builder. 32 | */ 33 | 34 | fun limit(limit: Int?) = apply { this.limit = limit } 35 | 36 | /** 37 | * Sets the identifier that specifies which page of data to return. 38 | * This value should be taken from the next_cursor response field. 39 | * @param pageToken The identifier that specifies which page of data to return. 40 | * @return The builder. 41 | */ 42 | 43 | fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } 44 | 45 | /** 46 | * Builds a [ListConfigurationsQueryParams] instance. 47 | * @return The [ListConfigurationsQueryParams] instance. 48 | */ 49 | fun build() = ListConfigurationsQueryParams(limit, pageToken) 50 | } 51 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListConnectorsQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class ListConnectorsQueryParams( 6 | /** 7 | * The maximum number of objects to return. 8 | * This field defaults to 50. The maximum allowed value is 200. 9 | */ 10 | @Json(name = "limit") 11 | val limit: Int? = null, 12 | /** 13 | * An identifier that specifies which page of data to return. 14 | * This value should be taken from the [ListResponse.nextCursor] response field. 15 | */ 16 | @Json(name = "page_token") 17 | val pageToken: String? = null, 18 | ) : IQueryParams { 19 | /** 20 | * Builder for [ListConnectorsQueryParams]. 21 | */ 22 | class Builder { 23 | private var limit: Int? = null 24 | private var pageToken: String? = null 25 | 26 | /** 27 | * Set the maximum number of objects to return. 28 | * This field defaults to 50. The maximum allowed value is 200. 29 | * @param limit The maximum number of objects to return. 30 | * @return The builder. 31 | */ 32 | fun limit(limit: Int?) = apply { this.limit = limit } 33 | 34 | /** 35 | * Set the identifier that specifies which page of data to return. 36 | * This value should be taken from the [ListResponse.nextCursor] response field. 37 | * @param pageToken The identifier that specifies which page of data to return. 38 | * @return The builder. 39 | */ 40 | fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } 41 | 42 | /** 43 | * Build the [ListConnectorsQueryParams] object. 44 | * @return The [ListConnectorsQueryParams] object. 45 | */ 46 | fun build() = ListConnectorsQueryParams(limit, pageToken) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListContactGroupsQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class ListContactGroupsQueryParams( 6 | /** 7 | * The maximum number of objects to return. 8 | * This field defaults to 50. The maximum allowed value is 200. 9 | */ 10 | @Json(name = "limit") 11 | val limit: Int? = null, 12 | /** 13 | * An identifier that specifies which page of data to return. 14 | * This value should be taken from the [ListResponse.nextCursor] response field. 15 | */ 16 | @Json(name = "page_token") 17 | val pageToken: String? = null, 18 | ) : IQueryParams { 19 | /** 20 | * Builder for [ListContactGroupsQueryParams]. 21 | */ 22 | class Builder { 23 | private var limit: Int? = null 24 | private var pageToken: String? = null 25 | 26 | /** 27 | * Set the maximum number of objects to return. 28 | * This field defaults to 50. The maximum allowed value is 200. 29 | * @param limit The maximum number of objects to return. 30 | * @return The builder. 31 | */ 32 | fun limit(limit: Int?) = apply { this.limit = limit } 33 | 34 | /** 35 | * Set the identifier that specifies which page of data to return. 36 | * This value should be taken from the [ListResponse.nextCursor] response field. 37 | * @param pageToken The identifier that specifies which page of data to return. 38 | * @return The builder. 39 | */ 40 | fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } 41 | 42 | /** 43 | * Build the [ListContactGroupsQueryParams] object. 44 | * @return The [ListContactGroupsQueryParams] object. 45 | */ 46 | fun build() = ListContactGroupsQueryParams(limit, pageToken) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListCredentialsQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for listing credentials. 7 | */ 8 | data class ListCredentialsQueryParams( 9 | /** 10 | * Limit the number of results 11 | */ 12 | @Json(name = "limit") 13 | val limit: Int? = null, 14 | /** 15 | * Offset the results by this number 16 | */ 17 | @Json(name = "offset") 18 | val offset: Int? = null, 19 | /** 20 | * Sort the results by field name 21 | */ 22 | @Json(name = "sort_by") 23 | val sortBy: SortBy? = null, 24 | /** 25 | * Order the results by ascending or descending 26 | */ 27 | @Json(name = "order_by") 28 | val orderBy: OrderBy? = null, 29 | ) : IQueryParams { 30 | /** 31 | * Builder for [ListCredentialsQueryParams]. 32 | */ 33 | class Builder { 34 | private var limit: Int? = null 35 | private var offset: Int? = null 36 | private var sortBy: SortBy? = null 37 | private var orderBy: OrderBy? = null 38 | 39 | /** 40 | * Sets the maximum number of objects to return. 41 | * This field defaults to 10. The maximum allowed value is 200. 42 | * @param limit The maximum number of objects to return. 43 | * @return The builder. 44 | */ 45 | fun limit(limit: Int?) = apply { this.limit = limit } 46 | 47 | /** 48 | * Sets the offset grant results by this number. 49 | * @param offset The offset grant results by this number. 50 | * @return The builder. 51 | */ 52 | fun offset(offset: Int?) = apply { this.offset = offset } 53 | 54 | /** 55 | * Sets the sort entries by field name. 56 | * @param sortBy The sort entries by field name. 57 | * @return The builder. 58 | */ 59 | fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } 60 | 61 | /** 62 | * Sets the specify ascending or descending order. 63 | * @param orderBy The specify ascending or descending order. 64 | * @return The builder. 65 | */ 66 | fun orderBy(orderBy: OrderBy?) = apply { this.orderBy = orderBy } 67 | 68 | /** 69 | * Builds a [ListCredentialsQueryParams] instance. 70 | * @return The [ListCredentialsQueryParams] instance. 71 | */ 72 | fun build() = ListCredentialsQueryParams(limit, offset, sortBy, orderBy) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ListResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas response object that contains a list of objects. 7 | */ 8 | data class ListResponse( 9 | /** 10 | * The list of requested data objects. 11 | */ 12 | @Json(name = "data") 13 | val data: List = emptyList(), 14 | /** 15 | * The request ID. 16 | */ 17 | @Json(name = "request_id") 18 | val requestId: String = "", 19 | /** 20 | * The cursor to use to get the next page of data. 21 | */ 22 | @Json(name = "next_cursor") 23 | val nextCursor: String? = null, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/MeetingBuffer.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the meeting buffer object within an availability request. 7 | */ 8 | data class MeetingBuffer( 9 | /** 10 | * The amount of buffer time in increments of 5 minutes to add before existing meetings. 11 | * Defaults to 0. 12 | */ 13 | @Json(name = "before") 14 | val before: Int? = null, 15 | /** 16 | * The amount of buffer time in increments of 5 minutes to add after existing meetings. 17 | * Defaults to 0. 18 | */ 19 | @Json(name = "after") 20 | val after: Int? = null, 21 | ) { 22 | /** 23 | * A builder for creating a [MeetingBuffer]. 24 | */ 25 | data class Builder( 26 | private var before: Int? = null, 27 | private var after: Int? = null, 28 | ) { 29 | /** 30 | * Set the amount of buffer time in increments of 5 minutes to add before existing meetings. 31 | * Defaults to 0. 32 | * @param before The amount of buffer time in increments of 5 minutes to add before existing meetings. 33 | * @return The builder. 34 | */ 35 | fun before(before: Int) = apply { this.before = before } 36 | 37 | /** 38 | * Set the amount of buffer time in increments of 5 minutes to add after existing meetings. 39 | * Defaults to 0. 40 | * @param after The amount of buffer time in increments of 5 minutes to add after existing meetings. 41 | * @return The builder. 42 | */ 43 | fun after(after: Int) = apply { this.after = after } 44 | 45 | /** 46 | * Build the [MeetingBuffer] object. 47 | * @return The meeting buffer object. 48 | */ 49 | fun build() = MeetingBuffer(before, after) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/MessageFields.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class MessageFields { 6 | @Json(name = "standard") 7 | STANDARD, 8 | 9 | @Json(name = "include_headers") 10 | INCLUDE_HEADERS, 11 | 12 | @Json(name = "include_tracking_options") 13 | INCLUDE_TRACKING_OPTIONS, 14 | 15 | @Json(name = "raw_mime") 16 | RAW_MIME, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/MessageHeaders.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a message header. 7 | */ 8 | data class MessageHeaders( 9 | /** 10 | * The header name. 11 | */ 12 | @Json(name = "name") 13 | val name: String, 14 | /** 15 | * The header value. 16 | */ 17 | @Json(name = "value") 18 | val value: String, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/MicrosoftConnectorSettings.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing Microsoft credentials and settings. 7 | */ 8 | data class MicrosoftConnectorSettings( 9 | /** 10 | * The Microsoft tenant ID 11 | */ 12 | @Json(name = "tenant") 13 | val tenant: String? = null, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/MicrosoftCreateConnectorSettings.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Microsoft connector creation request. 7 | */ 8 | data class MicrosoftCreateConnectorSettings( 9 | /** 10 | * The Microsoft Client ID 11 | */ 12 | @Json(name = "client_id") 13 | val clientId: String, 14 | /** 15 | * The Microsoft Client Secret 16 | */ 17 | @Json(name = "client_secret") 18 | val clientSecret: String, 19 | /** 20 | * The Microsoft tenant ID 21 | */ 22 | @Json(name = "tenant") 23 | val tenant: String? = null, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/NylasApiError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a general Nylas API error. 7 | */ 8 | data class NylasApiError( 9 | /** 10 | * Error type. 11 | */ 12 | @Json(name = "type") 13 | val type: String, 14 | /** 15 | * Error message. 16 | */ 17 | @Json(name = "message") 18 | override val message: String, 19 | /** 20 | * Provider Error. 21 | */ 22 | @Json(name = "provider_error") 23 | val providerError: Map? = null, 24 | /** 25 | * The HTTP status code of the error response 26 | */ 27 | override var statusCode: Int? = null, 28 | /** 29 | * The HTTP status code of the error response. 30 | */ 31 | override var requestId: String? = null, 32 | /** 33 | * The HTTP headers of the error response 34 | */ 35 | override var headers: Map>? = null, 36 | ) : AbstractNylasApiError(message, statusCode, requestId, headers) 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/NylasApiErrorResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing an error response from the Nylas API. 7 | */ 8 | data class NylasApiErrorResponse( 9 | /** 10 | * The error. 11 | */ 12 | @Json(name = "error") 13 | val error: NylasApiError, 14 | /** 15 | * The request ID. 16 | */ 17 | @Json(name = "request_id") 18 | val requestId: String, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/NylasOAuthError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing an OAuth error returned by the Nylas API. 7 | */ 8 | data class NylasOAuthError( 9 | /** 10 | * Error type. 11 | */ 12 | @Json(name = "error") 13 | val error: String, 14 | /** 15 | * Human readable error description. 16 | */ 17 | @Json(name = "error_description") 18 | val errorDescription: String, 19 | /** 20 | * URL to the related documentation and troubleshooting regarding this error. 21 | */ 22 | @Json(name = "error_uri") 23 | val errorUri: String, 24 | /** 25 | * Error code used for referencing the docs, logs, and data stream. 26 | */ 27 | @Json(name = "error_code") 28 | var errorCode: String, 29 | /** 30 | * The HTTP status code of the error response. 31 | */ 32 | @Json(name = "request_id") 33 | override var requestId: String? = null, 34 | /** 35 | * The HTTP status code of the error response. 36 | */ 37 | override var statusCode: Int? = null, 38 | /** 39 | * The HTTP headers of the error response 40 | */ 41 | override var headers: Map>? = null, 42 | ) : AbstractNylasApiError(error, statusCode, requestId, headers) 43 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/NylasSdkRemoteClosedError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Error thrown when the Nylas API closes the connection before the Nylas SDK receives a response. 5 | * @param url The URL that timed out. 6 | * @param originalErrorMessage The error message from the library that closed the connection. 7 | */ 8 | class NylasSdkRemoteClosedError( 9 | url: String, 10 | originalErrorMessage: String, 11 | ) : AbstractNylasSdkError("Nylas API closed the connection before the Nylas SDK received a response.") 12 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/NylasSdkTimeoutError.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Error thrown when the Nylas SDK times out before receiving a response from the server. 5 | * @param url The URL that timed out. 6 | * @param timeout The timeout value set in the Nylas SDK, in seconds. 7 | */ 8 | class NylasSdkTimeoutError( 9 | url: String, 10 | timeout: Int, 11 | ) : AbstractNylasSdkError("Nylas SDK timed out before receiving a response from the server.") 12 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/OrderBy.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for the order options 7 | */ 8 | enum class OrderBy { 9 | @Json(name = "desc") 10 | DESCENDING, 11 | 12 | @Json(name = "asc") 13 | ASCENDING, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/PKCEAuthURL.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the object containing the OAuth 2.0 URL as well as the hashed secret. 7 | */ 8 | data class PKCEAuthURL( 9 | /** 10 | * The URL for hosted authentication 11 | */ 12 | @Json(name = "url") 13 | val url: String, 14 | /** 15 | * Server-side challenge used in the OAuth 2.0 flow 16 | */ 17 | @Json(name = "secret") 18 | val secret: String, 19 | /** 20 | * SHA-256 hash of the secret 21 | */ 22 | @Json(name = "secret_hash") 23 | val secretHash: String, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Participant.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing an Event participant. 7 | */ 8 | data class Participant( 9 | /** 10 | * Participant's email address. 11 | */ 12 | @Json(name = "email") 13 | val email: String = "", 14 | /** 15 | * Participant's status. 16 | */ 17 | @Json(name = "status") 18 | val status: ParticipantStatus = ParticipantStatus.NOREPLY, 19 | /** 20 | * Participant's name. 21 | */ 22 | @Json(name = "name") 23 | val name: String? = null, 24 | /** 25 | * Participant's phone number. 26 | */ 27 | @Json(name = "phone_number") 28 | val phoneNumber: String? = null, 29 | /** 30 | * Comment by the participant. 31 | */ 32 | @Json(name = "comment") 33 | val comment: String? = null, 34 | ) 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ParticipantStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the status of an Event participant. 7 | */ 8 | enum class ParticipantStatus { 9 | @Json(name = "noreply") 10 | NOREPLY, 11 | 12 | @Json(name = "yes") 13 | YES, 14 | 15 | @Json(name = "no") 16 | NO, 17 | 18 | @Json(name = "maybe") 19 | MAYBE, 20 | } 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/PhoneNumber.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation for phone numbers in a contact. 7 | */ 8 | data class PhoneNumber( 9 | @Json(name = "number") 10 | val number: String? = null, 11 | @Json(name = "type") 12 | val type: String? = null, 13 | ) { 14 | class Builder { 15 | private var number: String? = null 16 | private var type: String? = null 17 | 18 | fun number(number: String) = apply { this.number = number } 19 | 20 | fun type(type: String) = apply { this.type = type } 21 | 22 | fun build() = PhoneNumber(number, type) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/PhysicalAddress.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation for a physical address in a contact. 7 | */ 8 | data class PhysicalAddress( 9 | @Json(name = "format") 10 | val format: String? = null, 11 | @Json(name = "street_address") 12 | val streetAddress: String? = null, 13 | @Json(name = "city") 14 | val city: String? = null, 15 | @Json(name = "postal_code") 16 | val postalCode: String? = null, 17 | @Json(name = "state") 18 | val state: String? = null, 19 | @Json(name = "country") 20 | val country: String? = null, 21 | @Json(name = "type") 22 | val type: String? = null, 23 | ) { 24 | class Builder { 25 | private var format: String? = null 26 | private var streetAddress: String? = null 27 | private var city: String? = null 28 | private var postalCode: String? = null 29 | private var state: String? = null 30 | private var country: String? = null 31 | private var type: String? = null 32 | 33 | fun format(format: String) = apply { this.format = format } 34 | 35 | fun streetAddress(streetAddress: String) = apply { this.streetAddress = streetAddress } 36 | 37 | fun city(city: String) = apply { this.city = city } 38 | 39 | fun postalCode(postalCode: String) = apply { this.postalCode = postalCode } 40 | 41 | fun state(state: String) = apply { this.state = state } 42 | 43 | fun country(country: String) = apply { this.country = country } 44 | 45 | fun type(type: String) = apply { this.type = type } 46 | 47 | fun build() = 48 | PhysicalAddress( 49 | format = format, 50 | streetAddress = streetAddress, 51 | city = city, 52 | postalCode = postalCode, 53 | state = state, 54 | country = country, 55 | type = type, 56 | ) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Platform.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the different platforms supported by the redirect URI endpoints. 7 | */ 8 | enum class Platform { 9 | @Json(name = "web") 10 | WEB, 11 | 12 | @Json(name = "desktop") 13 | DESKTOP, 14 | 15 | @Json(name = "mobile") 16 | JS, 17 | 18 | @Json(name = "ios") 19 | IOS, 20 | 21 | @Json(name = "android") 22 | ANDROID, 23 | } 24 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Prompt.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class Prompt { 6 | @Json(name = "select_provider") 7 | SELECT_PROVIDER, 8 | 9 | @Json(name = "detect") 10 | DETECT, 11 | 12 | @Json(name = "select_provider,detect") 13 | SELECT_PROVIDER_DETECT, 14 | 15 | @Json(name = "detect,select_provider") 16 | DETECT_SELECT_PROVIDER, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ProviderDetectParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the object used to set parameters for detecting a provider. 7 | */ 8 | data class ProviderDetectParams( 9 | /** 10 | * Email address to detect the provider for. 11 | */ 12 | @Json(name = "email") 13 | val email: String, 14 | /** 15 | * Search by all providers regardless of created integrations. If unset, defaults to false. 16 | */ 17 | @Json(name = "all_provider_types") 18 | val allProviderTypes: Boolean? = null, 19 | ) : IQueryParams { 20 | /** 21 | * Builder for [ProviderDetectParams]. 22 | * @property email Email address to detect the provider for. 23 | */ 24 | data class Builder( 25 | private val email: String, 26 | ) { 27 | private var allProviderTypes: Boolean? = null 28 | 29 | /** 30 | * Search by all providers regardless of created integrations 31 | * If unset, defaults to false 32 | * @param allProviderTypes Search by all providers regardless of created integrations 33 | * @return The builder 34 | */ 35 | fun allProviderTypes(allProviderTypes: Boolean?) = apply { this.allProviderTypes = allProviderTypes } 36 | 37 | /** 38 | * Build the [ProviderDetectParams] object 39 | * @return The [ProviderDetectParams] object 40 | */ 41 | fun build() = ProviderDetectParams( 42 | email, 43 | allProviderTypes, 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ProviderDetectResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the Nylas provider detect response. 7 | */ 8 | data class ProviderDetectResponse( 9 | /** 10 | * Email provided for autodetection 11 | */ 12 | @Json(name = "email_address") 13 | val emailAddress: String, 14 | /** 15 | * Whether the provider was detected 16 | */ 17 | @Json(name = "detected") 18 | val detected: Boolean, 19 | /** 20 | * Detected provider 21 | */ 22 | @Json(name = "provider") 23 | val provider: String? = null, 24 | /** 25 | * Provider type (if IMAP provider detected displays the IMAP provider) 26 | */ 27 | @Json(name = "type") 28 | val type: String? = null, 29 | ) 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RedirectUri.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Redirect URI object 7 | */ 8 | data class RedirectUri( 9 | /** 10 | * Globally unique object identifier 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | /** 15 | * Redirect URL 16 | */ 17 | @Json(name = "url") 18 | val url: String, 19 | /** 20 | * Platform identifier 21 | */ 22 | @Json(name = "platform") 23 | val platform: Platform, 24 | /** 25 | * Configuration settings 26 | */ 27 | @Json(name = "settings") 28 | val settings: RedirectUriSettings? = null, 29 | ) 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RedirectUriSettings.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Configuration settings for a Redirect URI object 7 | */ 8 | data class RedirectUriSettings( 9 | /** 10 | * Related to JS platform 11 | */ 12 | @Json(name = "origin") 13 | val origin: String? = null, 14 | /** 15 | * Related to iOS platform 16 | */ 17 | @Json(name = "bundle_id") 18 | val bundleId: String? = null, 19 | /** 20 | * Related to iOS platform 21 | */ 22 | @Json(name = "app_store_id") 23 | val appStoreId: String? = null, 24 | /** 25 | * Related to iOS platform 26 | */ 27 | @Json(name = "team_id") 28 | val teamId: String? = null, 29 | /** 30 | * Related to Android platform 31 | */ 32 | @Json(name = "package_name") 33 | val packageName: String? = null, 34 | /** 35 | * Related to Android platform 36 | */ 37 | @Json(name = "sha1_certificate_fingerprint") 38 | val sha1CertificateFingerprint: String? = null, 39 | ) 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Region.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the available Nylas API regions. 7 | * @param nylasApiUrl The base URL for the region's API 8 | */ 9 | enum class Region(val nylasApiUrl: String) { 10 | @Json(name = "us") 11 | US("https://api.us.nylas.com"), 12 | 13 | @Json(name = "eu") 14 | EU("https://api.eu.nylas.com"), 15 | } 16 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ReminderMethod.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the different types of reminders. 7 | */ 8 | enum class ReminderMethod { 9 | @Json(name = "email") 10 | EMAIL, 11 | 12 | @Json(name = "sound") 13 | SOUND, 14 | 15 | @Json(name = "popup") 16 | POPUP, 17 | 18 | @Json(name = "display") 19 | DISPLAY, 20 | } 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ReminderOverride.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the reminder details for an event. 7 | */ 8 | data class ReminderOverride( 9 | /** 10 | * The number of minutes before the event start time when a user wants a reminder for this event. 11 | * Reminder minutes are in the following format: "[20]". 12 | */ 13 | @Json(name = "reminder_minutes") 14 | val reminderMinutes: Int? = null, 15 | /** 16 | * Method to remind the user about the event. (Google only). 17 | */ 18 | @Json(name = "reminder_method") 19 | val reminderMethod: ReminderMethod? = null, 20 | ) 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Reminders.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the reminders field of an event. 7 | */ 8 | data class Reminders( 9 | /** 10 | * Whether to use the default reminders for the calendar. 11 | * When true, uses the default reminder settings for the calendar 12 | */ 13 | @Json(name = "use_default") 14 | val useDefault: Boolean, 15 | /** 16 | * list of reminders for the event if useDefault is set to false. 17 | */ 18 | @Json(name = "overrides") 19 | val overrides: List? = null, 20 | ) 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RequestOverrides.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | /** 4 | * Overrides to use for an outgoing request to the Nylas API. 5 | */ 6 | data class RequestOverrides( 7 | /** 8 | * The API key to use for the request. 9 | */ 10 | val apiKey: String? = null, 11 | /** 12 | * The API URI to use for the request. 13 | */ 14 | val apiUri: String? = null, 15 | /** 16 | * The timeout to use for the request. 17 | */ 18 | val timeout: Long? = null, 19 | /** 20 | * Additional headers to include in the request. 21 | */ 22 | val headers: Map? = emptyMap(), 23 | ) { 24 | /** 25 | * Builder for [RequestOverrides]. 26 | */ 27 | class Builder { 28 | private var apiKey: String? = null 29 | private var apiUri: String? = null 30 | private var timeout: Long? = null 31 | private var headers: Map? = null 32 | 33 | /** 34 | * Set the API key to use for the request. 35 | */ 36 | fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } 37 | 38 | /** 39 | * Set the API URI to use for the request. 40 | */ 41 | fun apiUri(apiUri: String) = apply { this.apiUri = apiUri } 42 | 43 | /** 44 | * Set the timeout to use for the request. 45 | */ 46 | fun timeout(timeout: Long) = apply { this.timeout = timeout } 47 | 48 | /** 49 | * Add additional headers to include in the request. 50 | */ 51 | fun headers(headers: Map) = apply { this.headers = headers } 52 | 53 | /** 54 | * Build the [RequestOverrides]. 55 | */ 56 | fun build() = RequestOverrides(apiKey, apiUri, timeout, headers) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RescheduleBookingQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for rescheduling a booking. 7 | */ 8 | data class RescheduleBookingQueryParams( 9 | /** 10 | * The ID of the Configuration object whose settings are used for calculating availability. 11 | */ 12 | @Json(name = "configuration_id") 13 | val configurationId: String, 14 | /** 15 | * The slug of the Configuration object whose settings are used for calculating availability. 16 | */ 17 | @Json(name = "slug") 18 | val slug: String, 19 | /** 20 | * The client ID that was used to create the Configuration object. 21 | */ 22 | @Json(name = "client_id") 23 | val clientId: String, 24 | ) : IQueryParams { 25 | /** 26 | * Builder for [RescheduleBookingQueryParams]. 27 | */ 28 | class Builder { 29 | private var configurationId: String? = null 30 | private var slug: String? = null 31 | private var clientId: String? = null 32 | 33 | /** 34 | * Sets the ID of the Configuration object whose settings are used for calculating availability. 35 | * @param configurationId The ID of the Configuration object whose settings are used for calculating availability. 36 | * @return The builder. 37 | */ 38 | fun configurationId(configurationId: String) = apply { this.configurationId = configurationId } 39 | 40 | /** 41 | * Sets the slug of the Configuration object whose settings are used for calculating availability. 42 | * @param slug The slug of the Configuration object whose settings are used for calculating availability. 43 | * @return The builder. 44 | */ 45 | fun slug(slug: String) = apply { this.slug = slug } 46 | 47 | /** 48 | * Sets the client ID that was used to create the Configuration object. 49 | * @param clientId The client ID that was used to create the Configuration object. 50 | * @return The builder. 51 | */ 52 | fun clientId(clientId: String) = apply { this.clientId = clientId } 53 | } 54 | fun build() = RescheduleBookingQueryParams(configurationId, slug, clientId) 55 | } 56 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RescheduleBookingRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class RescheduleBookingRequest( 6 | /** 7 | * The event's start time, in Unix epoch format. 8 | */ 9 | @Json(name = "start_time") 10 | val startTime: Int? = null, 11 | /** 12 | * The event's end time, in Unix epoch format. 13 | */ 14 | @Json(name = "end_time") 15 | val endTime: Int? = null, 16 | ) { 17 | /** 18 | * Builder for [RescheduleBookingRequest]. 19 | */ 20 | class Builder { 21 | private var startTime: Int? = null 22 | private var endTime: Int? = null 23 | 24 | /** 25 | * Set the start time of the booking. 26 | * @param startTime The start time of the booking. 27 | * @return The builder. 28 | */ 29 | fun startTime(startTime: Int) = apply { this.startTime = startTime } 30 | 31 | /** 32 | * Set the end time of the booking. 33 | * @param endTime The end time of the booking. 34 | * @return The builder. 35 | */ 36 | fun endTime(endTime: Int) = apply { this.endTime = endTime } 37 | 38 | /** 39 | * Builds a [RescheduleBookingRequest] instance. 40 | * @return The [RescheduleBookingRequest] instance. 41 | */ 42 | fun build() = RescheduleBookingRequest(startTime, endTime) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Response.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas response object 7 | */ 8 | data class Response( 9 | /** 10 | * The requested data object 11 | */ 12 | @Json(name = "data") 13 | val data: T, 14 | /** 15 | * The request ID 16 | */ 17 | @Json(name = "request_id") 18 | val requestId: String = "", 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/RsvpStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the allowed RSVP status values. 7 | */ 8 | enum class RsvpStatus { 9 | @Json(name = "yes") 10 | YES, 11 | 12 | @Json(name = "no") 13 | NO, 14 | 15 | @Json(name = "maybe") 16 | MAYBE, 17 | } 18 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ScheduledMessage.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing information about a scheduled message. 7 | */ 8 | data class ScheduledMessage( 9 | /** 10 | * The unique identifier for the scheduled message. 11 | */ 12 | @Json(name = "schedule_id") 13 | val scheduleId: String, 14 | /** 15 | * The status of the scheduled message. 16 | */ 17 | @Json(name = "status") 18 | val status: ScheduledMessageStatus, 19 | /** 20 | * The time the message was sent or failed to send, in epoch time. 21 | */ 22 | @Json(name = "close_time") 23 | val closeTime: Int? = null, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ScheduledMessageStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a scheduled message status. 7 | */ 8 | data class ScheduledMessageStatus( 9 | /** 10 | * The status code the describes the state of the scheduled message 11 | */ 12 | @Json(name = "code") 13 | val code: String, 14 | /** 15 | * A description of the status of the scheduled message 16 | */ 17 | @Json(name = "description") 18 | val description: String, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/ScheduledMessagesList.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a list of scheduled messages. 7 | */ 8 | data class ScheduledMessagesList( 9 | /** 10 | * The list of scheduled messages. 11 | */ 12 | @Json(name = "schedules") 13 | val schedules: List, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/SendRsvpQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for sending RSVP. 7 | */ 8 | data class SendRsvpQueryParams( 9 | /** 10 | * The ID of the calendar to create the event in. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String, 14 | ) : IQueryParams { 15 | 16 | /** 17 | * Builder for [SendRsvpQueryParams]. 18 | * @param calendarId The ID of the calendar to create the event in. 19 | */ 20 | data class Builder(private val calendarId: String) { 21 | 22 | /** 23 | * Builds a [SendRsvpQueryParams] instance. 24 | * @return The [SendRsvpQueryParams] instance. 25 | */ 26 | fun build() = SendRsvpQueryParams(calendarId) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/SendRsvpRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas send-rsvp request 7 | */ 8 | data class SendRsvpRequest( 9 | /** 10 | * RSVP status. must be yes, no, or maybe 11 | */ 12 | @Json(name = "status") 13 | val status: RsvpStatus, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/SortBy.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum for the sort options 7 | */ 8 | enum class SortBy { 9 | @Json(name = "created_at") 10 | CREATED_AT, 11 | 12 | @Json(name = "updated_at") 13 | UPDATED_AT, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/SourceType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | enum class SourceType { 6 | @Json(name = "address_book") 7 | ADDRESS_BOOK, 8 | 9 | @Json(name = "inbox") 10 | INBOX, 11 | 12 | @Json(name = "domain") 13 | DOMAIN, 14 | } 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/StopScheduledMessageResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a response after stopping a scheduled message. 7 | */ 8 | data class StopScheduledMessageResponse( 9 | /** 10 | * A message describing the result of the request. 11 | */ 12 | @Json(name = "message") 13 | val message: String, 14 | ) 15 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Thread.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class Thread( 6 | /** 7 | * The unique identifier for the thread. 8 | */ 9 | @Json(name = "id") 10 | val id: String, 11 | /** 12 | * Grant ID of the Nylas account. 13 | */ 14 | @Json(name = "grant_id") 15 | val grantId: String, 16 | /** 17 | * The type of object. 18 | */ 19 | @Json(name = "object") 20 | val obj: String = "thread", 21 | /** 22 | * The latest message or draft in the thread. 23 | */ 24 | @Json(name = "latest_draft_or_message") 25 | val latestDraftOrMessage: IMessage? = null, 26 | /** 27 | * Whether or not a message in a thread has attachments. 28 | */ 29 | @Json(name = "has_attachments") 30 | val hasAttachments: Boolean? = null, 31 | /** 32 | * Whether or not a message in a thread has drafts. 33 | */ 34 | @Json(name = "has_drafts") 35 | val hasDrafts: Boolean? = null, 36 | /** 37 | * A boolean indicating whether the thread is starred or not. 38 | */ 39 | @Json(name = "starred") 40 | val starred: Boolean? = null, 41 | /** 42 | * A boolean indicating if all messages within the thread are read or not. 43 | */ 44 | @Json(name = "unread") 45 | val unread: Boolean? = null, 46 | /** 47 | * Unix timestamp of the earliest or first message in the thread. 48 | */ 49 | @Json(name = "earliest_message_date") 50 | val earliestMessageDate: Long? = null, 51 | /** 52 | * Unix timestamp of the most recent message received in the thread. 53 | */ 54 | @Json(name = "latest_message_received_date") 55 | val latestMessageReceivedDate: Long? = null, 56 | /** 57 | * Unix timestamp of the most recent message sent in the thread. 58 | */ 59 | @Json(name = "latest_message_sent_date") 60 | val latestMessageSentDate: Long? = null, 61 | /** 62 | * An array of participants in the thread. 63 | */ 64 | @Json(name = "participants") 65 | val participants: List? = null, 66 | /** 67 | * An array of message IDs in the thread. 68 | */ 69 | @Json(name = "message_ids") 70 | val messageIds: List? = null, 71 | /** 72 | * An array of draft IDs in the thread. 73 | */ 74 | @Json(name = "draft_ids") 75 | val draftIds: List? = null, 76 | /** 77 | * An array of folder IDs the thread appears in. 78 | */ 79 | @Json(name = "folders") 80 | val folders: List? = null, 81 | /** 82 | * A short snippet of the last received message/draft body. 83 | * This is the first 100 characters of the message body, with any HTML tags removed. 84 | */ 85 | @Json(name = "snippet") 86 | val snippet: String? = null, 87 | /** 88 | * The subject line of the thread. 89 | */ 90 | @Json(name = "subject") 91 | val subject: String? = null, 92 | ) { 93 | /** 94 | * Get the type of object. 95 | * @return The type of object. 96 | */ 97 | fun getObject() = obj 98 | } 99 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TimeSlot.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas availability time slot 7 | */ 8 | data class TimeSlot( 9 | /** 10 | * The emails of the participants who are available for the time slot. 11 | */ 12 | @Json(name = "emails") 13 | val emails: List, 14 | /** 15 | * Unix timestamp for the start of the slot. 16 | */ 17 | @Json(name = "start_time") 18 | val startTime: Int, 19 | /** 20 | * Unix timestamp for the end of the slot. 21 | */ 22 | @Json(name = "end_time") 23 | val endTime: Int, 24 | ) 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TokenExchangeRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas token exchange request 7 | */ 8 | data class TokenExchangeRequest( 9 | /** 10 | * Should match the same redirect URI that was used for getting the code during the initial authorization request. 11 | */ 12 | @Json(name = "redirect_uri") 13 | val redirectUri: String, 14 | /** 15 | * Token to refresh/request your short-lived access token 16 | */ 17 | @Json(name = "refresh_token") 18 | val refreshToken: String, 19 | /** 20 | * Client ID of the application. 21 | */ 22 | @Json(name = "client_id") 23 | var clientId: String, 24 | /** 25 | * Client secret of the application. 26 | * If not provided, the API Key will be used instead. 27 | */ 28 | @Json(name = "client_secret") 29 | var clientSecret: String? = null, 30 | ) { 31 | /** 32 | * The grant type for the request. For refreshing tokens, it should always be 'refresh_token'. 33 | */ 34 | @Json(name = "grant_type") 35 | private var grantType: String = "refresh_token" 36 | 37 | /** 38 | * A builder for creating a [TokenExchangeRequest]. 39 | * 40 | * @param redirectUri Should match the same redirect URI that was used for getting the code during the initial authorization request. 41 | * @param refreshToken Token to refresh/request your short-lived access token 42 | * @param clientId Client ID of the application. 43 | */ 44 | data class Builder( 45 | private val redirectUri: String, 46 | private val refreshToken: String, 47 | private val clientId: String, 48 | ) { 49 | private var clientSecret: String? = null 50 | 51 | /** 52 | * Set the client secret. 53 | * If not provided, the API Key will be used instead. 54 | * @param clientSecret The client secret. 55 | * @return The builder. 56 | */ 57 | fun clientSecret(clientSecret: String) = apply { this.clientSecret = clientSecret } 58 | 59 | /** 60 | * Build the [TokenExchangeRequest]. 61 | * 62 | * @return The [TokenExchangeRequest]. 63 | */ 64 | fun build() = TokenExchangeRequest( 65 | redirectUri = redirectUri, 66 | refreshToken = refreshToken, 67 | clientId = clientId, 68 | clientSecret = clientSecret, 69 | ) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TokenInfoRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * A request to query the information of a token. 7 | * @suppress Used internally by the SDK 8 | */ 9 | data class TokenInfoRequest( 10 | /** 11 | * The ID token to query. 12 | */ 13 | @Json(name = "id_token") 14 | val idToken: String? = null, 15 | /** 16 | * The access token to query. 17 | */ 18 | @Json(name = "access_token") 19 | val accessToken: String? = null, 20 | ) : IQueryParams 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TokenInfoResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class TokenInfoResponse( 6 | /** 7 | * The issuer of the token. 8 | */ 9 | @Json(name = "iss") 10 | val iss: String, 11 | /** 12 | * The token's audience. 13 | */ 14 | @Json(name = "aud") 15 | val aud: String, 16 | /** 17 | * The time that the token was issued. 18 | */ 19 | @Json(name = "iat") 20 | val iat: Int, 21 | /** 22 | * The time that the token expires. 23 | */ 24 | @Json(name = "exp") 25 | val exp: Int, 26 | /** 27 | * The token's subject. 28 | */ 29 | @Json(name = "sub") 30 | val sub: String? = null, 31 | /** 32 | * The email address of the Grant belonging to the user's token. 33 | */ 34 | @Json(name = "email") 35 | val email: String? = null, 36 | ) 37 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TokenParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | data class TokenParams( 6 | /** 7 | * Token to be revoked. 8 | */ 9 | @Json(name = "token") 10 | val token: String, 11 | ) : IQueryParams { 12 | /** 13 | * Builder for [TokenParams]. 14 | * @property token Token to be revoked. 15 | */ 16 | data class Builder( 17 | private val token: String, 18 | ) { 19 | 20 | /** 21 | * Build the [TokenParams] object 22 | * @return The [TokenParams] object 23 | */ 24 | fun build() = TokenParams( 25 | token, 26 | ) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/TrackingOptions.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the different tracking options for when a message is sent. 7 | */ 8 | data class TrackingOptions( 9 | /** 10 | * The label to apply to tracked messages. 11 | */ 12 | @Json(name = "label") 13 | val label: String? = null, 14 | /** 15 | * Whether to track links. 16 | */ 17 | @Json(name = "links") 18 | val links: Boolean? = null, 19 | /** 20 | * Whether to track opens. 21 | */ 22 | @Json(name = "opens") 23 | val opens: Boolean? = null, 24 | /** 25 | * Whether to track thread replies. 26 | */ 27 | @Json(name = "thread_replies") 28 | val threadReplies: Boolean? = null, 29 | ) 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateCredentialRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to update a credential 7 | */ 8 | data class UpdateCredentialRequest( 9 | /** 10 | * Unique name of this credential 11 | */ 12 | @Json(name = "name") 13 | val name: String? = null, 14 | /** 15 | * Data that specifies some special data required for this credential 16 | */ 17 | @Json(name = "credential_data") 18 | val credentialData: CredentialData? = null, 19 | ) { 20 | /** 21 | * Builder for [UpdateCredentialRequest] 22 | */ 23 | class Builder { 24 | private var name: String? = null 25 | private var credentialData: CredentialData? = null 26 | 27 | /** 28 | * Update the unique name of this credential. 29 | * @param name The unique name of this credential. 30 | * @return The builder. 31 | */ 32 | fun name(name: String) = apply { this.name = name } 33 | 34 | /** 35 | * Update data that specifies some special data required for this credential. 36 | * @param credentialData The data that specifies some special data required for this credential. 37 | * @return The builder. 38 | */ 39 | fun credentialData(credentialData: CredentialData) = apply { this.credentialData = credentialData } 40 | 41 | /** 42 | * Build the UpdateCredentialRequest object. 43 | */ 44 | fun build() = UpdateCredentialRequest(name, credentialData) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateEventQueryParams.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the query parameters for updating events. 7 | */ 8 | data class UpdateEventQueryParams( 9 | /** 10 | * The ID of the calendar containing the event. 11 | */ 12 | @Json(name = "calendar_id") 13 | val calendarId: String, 14 | /** 15 | * Whether to send email notifications containing the calendar event to all event participants. 16 | * Microsoft accounts do not support notify_participants = False. 17 | */ 18 | @Json(name = "notify_participants") 19 | val notifyParticipants: Boolean? = null, 20 | ) : IQueryParams { 21 | 22 | /** 23 | * Builder for [UpdateEventQueryParams]. 24 | * @param calendarId The ID of the calendar containing the event. 25 | */ 26 | data class Builder( 27 | private val calendarId: String, 28 | ) { 29 | private var notifyParticipants: Boolean? = null 30 | 31 | /** 32 | * Sets whether to send email notifications containing the calendar event to all event participants. 33 | * Microsoft accounts do not support notify_participants = False. 34 | * @param notifyParticipants Whether to send email notifications containing the calendar event to all event participants. 35 | * @return The builder. 36 | */ 37 | fun notifyParticipants(notifyParticipants: Boolean?) = apply { this.notifyParticipants = notifyParticipants } 38 | 39 | /** 40 | * Builds a [UpdateEventQueryParams] instance. 41 | * @return The [UpdateEventQueryParams] instance. 42 | */ 43 | fun build() = UpdateEventQueryParams( 44 | calendarId, 45 | notifyParticipants, 46 | ) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateFolderRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of the Nylas folder update request. 7 | */ 8 | data class UpdateFolderRequest( 9 | /** 10 | * The name of the folder. 11 | */ 12 | @Json(name = "name") 13 | val name: String? = null, 14 | /** 15 | * The parent ID of the folder. (Microsoft only) 16 | */ 17 | @Json(name = "parent_id") 18 | val parentId: String? = null, 19 | /** 20 | * The background color of the folder. (Google only) 21 | */ 22 | @Json(name = "background_color") 23 | val backgroundColor: String? = null, 24 | /** 25 | * The text color of the folder. (Google only) 26 | */ 27 | @Json(name = "text_color") 28 | val textColor: String? = null, 29 | ) { 30 | /** 31 | * Builder for [UpdateFolderRequest]. 32 | */ 33 | class Builder { 34 | private var name: String? = null 35 | private var parentId: String? = null 36 | private var backgroundColor: String? = null 37 | private var textColor: String? = null 38 | 39 | /** 40 | * Set the name of the folder. 41 | * @param name The name of the folder. 42 | * @return The builder. 43 | */ 44 | fun name(name: String) = apply { this.name = name } 45 | 46 | /** 47 | * Set the parent ID of the folder. (Microsoft only) 48 | * @param parentId The parent ID of the folder. 49 | * @return The builder. 50 | */ 51 | fun parentId(parentId: String) = apply { this.parentId = parentId } 52 | 53 | /** 54 | * Set the background color of the folder. (Google only) 55 | * 56 | * The background color of the folder in the hexadecimal format `#0099EE`. 57 | * See Google Defined Values for more information. 58 | * 59 | * @param backgroundColor The background color of the folder. 60 | * @return The builder. 61 | */ 62 | fun backgroundColor(backgroundColor: String) = apply { this.backgroundColor = backgroundColor } 63 | 64 | /** 65 | * Set the text color of the folder. (Google only) 66 | * 67 | * The text color of the folder in the hexadecimal format `#0099EE`. 68 | * See Google Defined Values for more information. 69 | * 70 | * @param textColor The text color of the folder. 71 | * @return The builder. 72 | */ 73 | fun textColor(textColor: String) = apply { this.textColor = textColor } 74 | 75 | /** 76 | * Build the [UpdateFolderRequest]. 77 | * @return The [UpdateFolderRequest]. 78 | */ 79 | fun build() = UpdateFolderRequest( 80 | name = name, 81 | parentId = parentId, 82 | backgroundColor = backgroundColor, 83 | textColor = textColor, 84 | ) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateGrantRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas update grant request 7 | */ 8 | data class UpdateGrantRequest( 9 | /** 10 | * Settings required by provider. 11 | */ 12 | @Json(name = "settings") 13 | val settings: Map? = null, 14 | /** 15 | * List of integration scopes for the grant. 16 | */ 17 | @Json(name = "scope") 18 | val scope: List? = null, 19 | ) { 20 | /** 21 | * Builder for [UpdateGrantRequest]. 22 | */ 23 | class Builder { 24 | private var settings: Map? = null 25 | private var scope: List? = null 26 | 27 | /** 28 | * Update the settings required by provider. 29 | * @param settings Settings required by provider. 30 | * @return This builder 31 | */ 32 | fun settings(settings: Map) = apply { this.settings = settings } 33 | 34 | /** 35 | * Update the list of integration scopes for the grant. 36 | * @param scopes List of scopes 37 | * @return This builder 38 | */ 39 | fun scopes(scopes: List) = apply { this.scope = scopes } 40 | 41 | /** 42 | * Build the [UpdateGrantRequest]. 43 | * @return The built [UpdateGrantRequest] 44 | */ 45 | fun build() = UpdateGrantRequest(settings, scope) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateMessageRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to update a message. 7 | */ 8 | data class UpdateMessageRequest( 9 | /** 10 | * Sets the message as starred or unstarred. 11 | */ 12 | @Json(name = "starred") 13 | val starred: Boolean? = null, 14 | /** 15 | * Sets the message as read or unread. 16 | */ 17 | @Json(name = "unread") 18 | val unread: Boolean? = null, 19 | /** 20 | * The IDs of the folders the message should appear in. 21 | */ 22 | @Json(name = "folders") 23 | val folders: List? = null, 24 | /** 25 | * A list of key-value pairs storing additional data. 26 | */ 27 | @Json(name = "metadata") 28 | val metadata: Map? = null, 29 | ) { 30 | /** 31 | * Builder for [UpdateMessageRequest]. 32 | */ 33 | class Builder { 34 | private var starred: Boolean? = null 35 | private var unread: Boolean? = null 36 | private var folders: List? = null 37 | private var metadata: Map? = null 38 | 39 | /** 40 | * Set if the message is starred. 41 | * @param starred If the message is starred. 42 | * @return The builder. 43 | */ 44 | fun starred(starred: Boolean) = apply { this.starred = starred } 45 | 46 | /** 47 | * Set if the message is unread. 48 | * @param unread If the message is unread. 49 | * @return The builder. 50 | */ 51 | fun unread(unread: Boolean) = apply { this.unread = unread } 52 | 53 | /** 54 | * Set the folders the message should appear in. 55 | * @param folders The folders the message should appear in. 56 | * @return The builder. 57 | */ 58 | fun folders(folders: List) = apply { this.folders = folders } 59 | 60 | /** 61 | * Set the metadata. 62 | * @param metadata The metadata. 63 | * @return The builder. 64 | */ 65 | fun metadata(metadata: Map) = apply { this.metadata = metadata } 66 | 67 | /** 68 | * Build the [UpdateMessageRequest]. 69 | * @return The [UpdateMessageRequest]. 70 | */ 71 | fun build() = UpdateMessageRequest( 72 | starred = starred, 73 | unread = unread, 74 | folders = folders, 75 | metadata = metadata, 76 | ) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateRedirectUriRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas update redirect uri request 7 | */ 8 | data class UpdateRedirectUriRequest( 9 | /** 10 | * Redirect URL. 11 | */ 12 | @Json(name = "url") 13 | val url: String? = null, 14 | /** 15 | * Platform identifier. 16 | */ 17 | @Json(name = "platform") 18 | val platform: Platform? = null, 19 | /** 20 | * Settings for the redirect uri. 21 | */ 22 | @Json(name = "settings") 23 | val settings: RedirectUriSettings? = null, 24 | ) { 25 | class Builder { 26 | private var url: String? = null 27 | private var platform: Platform? = null 28 | private var settings: RedirectUriSettings? = null 29 | 30 | /** 31 | * Update the redirect URL. 32 | * @param url Redirect URL. 33 | * @return This builder 34 | */ 35 | fun url(url: String) = apply { this.url = url } 36 | 37 | /** 38 | * Update the platform identifier. 39 | * @param platform Platform identifier. 40 | * @return This builder 41 | */ 42 | fun platform(platform: Platform) = apply { this.platform = platform } 43 | 44 | /** 45 | * Update the settings for the redirect uri. 46 | * @param settings Settings for the redirect uri 47 | * @return This builder 48 | */ 49 | fun settings(settings: RedirectUriSettings) = apply { this.settings = settings } 50 | 51 | /** 52 | * Build the [UpdateRedirectUriRequest]. 53 | * @return The built [UpdateRedirectUriRequest] 54 | */ 55 | fun build() = UpdateRedirectUriRequest(url, platform, settings) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateThreadRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a request to update a thread. 7 | */ 8 | data class UpdateThreadRequest( 9 | /** 10 | * Sets all messages in the thread as starred or unstarred. 11 | */ 12 | @Json(name = "starred") 13 | val starred: Boolean? = null, 14 | /** 15 | * Sets all messages in the thread as read or unread. 16 | */ 17 | @Json(name = "unread") 18 | val unread: Boolean? = null, 19 | /** 20 | * The IDs of the folders to apply, overwriting all previous folders for all messages in the thread. 21 | */ 22 | @Json(name = "folders") 23 | val folders: List? = null, 24 | ) { 25 | /** 26 | * Builder for [UpdateThreadRequest]. 27 | */ 28 | class Builder { 29 | private var starred: Boolean? = null 30 | private var unread: Boolean? = null 31 | private var folders: List? = null 32 | private var metadata: Map? = null 33 | 34 | /** 35 | * Sets if all messages in the thread as starred or unstarred. 36 | * @param starred If the thread is starred. 37 | * @return The builder. 38 | */ 39 | fun starred(starred: Boolean) = apply { this.starred = starred } 40 | 41 | /** 42 | * Sets if all messages in the thread as read or unread. 43 | * @param unread If the thread is unread. 44 | * @return The builder. 45 | */ 46 | fun unread(unread: Boolean) = apply { this.unread = unread } 47 | 48 | /** 49 | * The IDs of the folders to apply, overwriting all previous folders for all messages in the thread. 50 | * @param folders The folders the thread should appear in. 51 | * @return The builder. 52 | */ 53 | fun folders(folders: List) = apply { this.folders = folders } 54 | 55 | /** 56 | * Build the [UpdateThreadRequest]. 57 | * @return The [UpdateThreadRequest]. 58 | */ 59 | fun build() = UpdateThreadRequest( 60 | starred = starred, 61 | unread = unread, 62 | folders = folders, 63 | ) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/UpdateWebhookRequest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation of a Nylas update webhook request. 7 | */ 8 | data class UpdateWebhookRequest( 9 | /** 10 | * Select the event that triggers the webhook. 11 | */ 12 | @Json(name = "trigger_types") 13 | val triggerTypes: List? = null, 14 | /** 15 | * The url to send webhooks to. 16 | */ 17 | @Json(name = "webhook_url") 18 | val webhookUrl: String? = null, 19 | /** 20 | * A human-readable description of the webhook destination. 21 | */ 22 | @Json(name = "description") 23 | val description: String? = null, 24 | /** 25 | * The email addresses that Nylas notifies when a webhook is down for a while. 26 | */ 27 | @Json(name = "notification_email_addresses") 28 | val notificationEmailAddresses: List? = null, 29 | ) { 30 | /** 31 | * A builder for creating a [UpdateWebhookRequest]. 32 | */ 33 | class Builder { 34 | private var triggerTypes: List? = null 35 | private var webhookUrl: String? = null 36 | private var description: String? = null 37 | private var notificationEmailAddresses: List? = null 38 | 39 | /** 40 | * Set the event that triggers the webhook. 41 | * @param triggerTypes Select the event that triggers the webhook. 42 | * @return The builder. 43 | */ 44 | fun triggerTypes(triggerTypes: List?) = apply { this.triggerTypes = triggerTypes } 45 | 46 | /** 47 | * Set the url to send webhooks to. 48 | * @param webhookUrl The url to send webhooks to. 49 | * @return The builder. 50 | */ 51 | fun webhookUrl(webhookUrl: String?) = apply { this.webhookUrl = webhookUrl } 52 | 53 | /** 54 | * Set a human-readable description of the webhook destination. 55 | * @param description A human-readable description of the webhook destination. 56 | * @return The builder. 57 | */ 58 | fun description(description: String?) = apply { this.description = description } 59 | 60 | /** 61 | * Set the email addresses that Nylas notifies when a webhook is down for a while. 62 | * @param notificationEmailAddresses The email addresses that Nylas notifies when a webhook is down for a while. 63 | * @return The builder. 64 | */ 65 | fun notificationEmailAddresses(notificationEmailAddresses: List?) = apply { 66 | this.notificationEmailAddresses = notificationEmailAddresses 67 | } 68 | 69 | /** 70 | * Build the [UpdateWebhookRequest]. 71 | * @return The created [UpdateWebhookRequest]. 72 | */ 73 | fun build() = UpdateWebhookRequest(triggerTypes, webhookUrl, description, notificationEmailAddresses) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebPage.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representation for web pages in a contact. 7 | */ 8 | data class WebPage( 9 | @Json(name = "url") 10 | val url: String? = null, 11 | @Json(name = "type") 12 | val type: String? = null, 13 | ) { 14 | class Builder { 15 | private var url: String? = null 16 | private var type: String? = null 17 | 18 | fun url(url: String) = apply { this.url = url } 19 | 20 | fun type(type: String) = apply { this.type = type } 21 | 22 | fun build() = WebPage(url, type) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/Webhook.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Nylas webhook. 7 | */ 8 | data class Webhook( 9 | /** 10 | * Globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | /** 15 | * The url to send webhooks to. 16 | */ 17 | @Json(name = "webhook_url") 18 | val webhookUrl: String, 19 | /** 20 | * Select the event that triggers the webhook. 21 | */ 22 | @Json(name = "trigger_types") 23 | val triggerTypes: List, 24 | /** 25 | * The status of the new destination. 26 | */ 27 | @Json(name = "status") 28 | val status: WebhookStatus, 29 | /** 30 | * The time the status field was last updated, represented as a Unix timestamp in seconds. 31 | */ 32 | @Json(name = "status_updated_at") 33 | val statusUpdatedAt: Long, 34 | /** 35 | * The time the status field was created, represented as a Unix timestamp in seconds 36 | */ 37 | @Json(name = "created_at") 38 | val createdAt: Long, 39 | /** 40 | * The time the status field was last updated, represented as a Unix timestamp in seconds. 41 | */ 42 | @Json(name = "updated_at") 43 | val updatedAt: Long, 44 | /** 45 | * A human-readable description of the webhook destination. 46 | */ 47 | @Json(name = "description") 48 | val description: String? = null, 49 | /** 50 | * The email addresses that Nylas notifies when a webhook is down for a while. 51 | */ 52 | @Json(name = "notification_email_addresses") 53 | val notificationEmailAddresses: List? = null, 54 | ) 55 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebhookDeleteResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Nylas webhook delete response. 7 | */ 8 | data class WebhookDeleteResponse( 9 | /** 10 | * ID of the request. 11 | */ 12 | @Json(name = "request_id") 13 | val requestId: String, 14 | /** 15 | * Object containing the webhook deletion status. 16 | */ 17 | @Json(name = "data") 18 | val data: DataWebhookDeleteData? = null, 19 | ) { 20 | /** 21 | * Class representing the object enclosing the webhook deletion status. 22 | */ 23 | data class DataWebhookDeleteData( 24 | /** 25 | * The status of the webhook deletion. 26 | */ 27 | @Json(name = "status") 28 | val status: String, 29 | ) 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebhookIpAddressesResponse.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing the response for getting a list of webhook ip addresses. 7 | */ 8 | data class WebhookIpAddressesResponse( 9 | /** 10 | * The IP addresses that Nylas send you webhook from. 11 | */ 12 | @Json(name = "ip_addresses") 13 | val ipAddress: List, 14 | /** 15 | * UNIX timestamp when Nylas updated the list of IP addresses. 16 | */ 17 | @Json(name = "updated_at") 18 | val updatedAt: Long, 19 | ) 20 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebhookStatus.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the possible webhook statuses. 7 | */ 8 | enum class WebhookStatus { 9 | @Json(name = "active") 10 | ACTIVE, 11 | 12 | @Json(name = "failing") 13 | FAILING, 14 | 15 | @Json(name = "failed") 16 | FAILED, 17 | 18 | @Json(name = "paused") 19 | PAUSE, 20 | } 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebhookTriggers.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representing the available webhook triggers. 7 | */ 8 | enum class WebhookTriggers { 9 | @Json(name = "calendar.created") 10 | CALENDAR_CREATED, 11 | 12 | @Json(name = "calendar.updated") 13 | CALENDAR_UPDATED, 14 | 15 | @Json(name = "calendar.deleted") 16 | CALENDAR_DELETED, 17 | 18 | @Json(name = "event.created") 19 | EVENT_CREATED, 20 | 21 | @Json(name = "event.updated") 22 | EVENT_UPDATED, 23 | 24 | @Json(name = "event.deleted") 25 | EVENT_DELETED, 26 | 27 | @Json(name = "grant.created") 28 | GRANT_CREATED, 29 | 30 | @Json(name = "grant.updated") 31 | GRANT_UPDATED, 32 | 33 | @Json(name = "grant.deleted") 34 | GRANT_DELETED, 35 | 36 | @Json(name = "grant.expired") 37 | GRANT_EXPIRED, 38 | 39 | @Json(name = "message.created") 40 | MESSAGE_CREATED, 41 | 42 | @Json(name = "message.updated") 43 | MESSAGE_UPDATED, 44 | 45 | @Json(name = "message.send_success") 46 | MESSAGE_SEND_SUCCESS, 47 | 48 | @Json(name = "message.send_failed") 49 | MESSAGE_SEND_FAILED, 50 | 51 | @Json(name = "message.bounce_detected") 52 | MESSAGE_BOUNCE_DETECTED, 53 | 54 | @Json(name = "message.opened") 55 | MESSAGE_OPENED, 56 | 57 | @Json(name = "message.link_clicked") 58 | MESSAGE_LINK_CLICKED, 59 | 60 | @Json(name = "thread.replied") 61 | THREAD_REPLIED, 62 | } 63 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WebhookWithSecret.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Class representing a Nylas webhook with secret. 7 | */ 8 | data class WebhookWithSecret( 9 | /** 10 | * Globally unique object identifier. 11 | */ 12 | @Json(name = "id") 13 | val id: String, 14 | /** 15 | * The url to send webhooks to. 16 | */ 17 | @Json(name = "webhook_url") 18 | val webhookUrl: String, 19 | /** 20 | * A secret value used to encode the X-Nylas-Signature header on webhook requests. 21 | */ 22 | @Json(name = "webhook_secret") 23 | val webhookSecret: String, 24 | /** 25 | * Select the event that triggers the webhook. 26 | */ 27 | @Json(name = "trigger_types") 28 | val triggerTypes: List, 29 | /** 30 | * The status of the new destination. 31 | */ 32 | @Json(name = "status") 33 | val status: WebhookStatus, 34 | /** 35 | * The time the status field was last updated, represented as a Unix timestamp in seconds. 36 | */ 37 | @Json(name = "status_updated_at") 38 | val statusUpdatedAt: Long, 39 | /** 40 | * The time the status field was created, represented as a Unix timestamp in seconds 41 | */ 42 | @Json(name = "created_at") 43 | val createdAt: Long, 44 | /** 45 | * The time the status field was last updated, represented as a Unix timestamp in seconds. 46 | */ 47 | @Json(name = "updated_at") 48 | val updatedAt: Long, 49 | /** 50 | * A human-readable description of the webhook destination. 51 | */ 52 | @Json(name = "description") 53 | val description: String? = null, 54 | /** 55 | * The email addresses that Nylas notifies when a webhook is down for a while. 56 | */ 57 | @Json(name = "notification_email_addresses") 58 | val notificationEmailAddresses: List? = null, 59 | ) 60 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/models/WhenType.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.squareup.moshi.Json 4 | 5 | /** 6 | * Enum representation of the different types of event time configurations. 7 | */ 8 | enum class WhenType(val value: String) { 9 | @Json(name = "date") 10 | DATE("date"), 11 | 12 | @Json(name = "datespan") 13 | DATESPAN("datespan"), 14 | 15 | @Json(name = "time") 16 | TIME("time"), 17 | 18 | @Json(name = "timespan") 19 | TIMESPAN("timespan"), 20 | } 21 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/Applications.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | import com.nylas.models.* 5 | import com.squareup.moshi.Types 6 | 7 | /** 8 | * Nylas Applications API 9 | * 10 | * This endpoint allows for getting application details as well as redirect URI operations. 11 | */ 12 | class Applications(private val client: NylasClient) { 13 | /** 14 | * Access the collection of redirect URI related API endpoints. 15 | * @return The collection of redirect URI related API endpoints. 16 | */ 17 | fun redirectUris(): RedirectUris { 18 | return RedirectUris(client) 19 | } 20 | 21 | /** 22 | * Get application details 23 | * @param overrides Optional request overrides to apply 24 | * @return The application details 25 | */ 26 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 27 | @JvmOverloads 28 | fun getDetails(overrides: RequestOverrides? = null): Response { 29 | val path = "v3/applications" 30 | val responseType = Types.newParameterizedType(Response::class.java, ApplicationDetails::class.java) 31 | return client.executeGet(path, responseType, overrides = overrides) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/Grants.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | import com.nylas.models.* 5 | import com.nylas.util.JsonHelper 6 | 7 | /** 8 | * Nylas Grants API 9 | * 10 | * The Nylas Grants API allows for the management of grants. 11 | * 12 | * @param client The configured Nylas API client 13 | */ 14 | class Grants(client: NylasClient) : Resource(client, Grant::class.java) { 15 | /** 16 | * Return all Grants 17 | * @param queryParams The query parameters to include in the request 18 | * @param overrides Optional request overrides to apply 19 | * @return The list of Grants 20 | */ 21 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 22 | @JvmOverloads 23 | fun list(queryParams: ListGrantsQueryParams? = null, overrides: RequestOverrides? = null): ListResponse { 24 | val path = "v3/grants" 25 | return listResource(path, queryParams, overrides) 26 | } 27 | 28 | /** 29 | * Return a Grant 30 | * @param grantId The id of the Grant to retrieve. 31 | * @param overrides Optional request overrides to apply 32 | * @return The Grant 33 | */ 34 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 35 | @JvmOverloads 36 | fun find(grantId: String, overrides: RequestOverrides? = null): Response { 37 | val path = String.format("v3/grants/%s", grantId) 38 | return findResource(path, overrides = overrides) 39 | } 40 | 41 | /** 42 | * Update a Grant 43 | * @param grantId The id of the Grant to update. 44 | * @param requestBody The values to update the Grant with 45 | * @param overrides Optional request overrides to apply 46 | * @return The updated Grant 47 | */ 48 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 49 | @JvmOverloads 50 | fun update(grantId: String, requestBody: UpdateGrantRequest, overrides: RequestOverrides? = null): Response { 51 | val path = String.format("v3/grants/%s", grantId) 52 | val serializedRequestBody = JsonHelper.moshi() 53 | .adapter(UpdateGrantRequest::class.java) 54 | .toJson(requestBody) 55 | 56 | return patchResource(path, serializedRequestBody, overrides = overrides) 57 | } 58 | 59 | /** 60 | * Delete a Grant 61 | * @param grantId The id of the Grant to delete. 62 | * @param overrides Optional request overrides to apply 63 | * @return The deletion response 64 | */ 65 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 66 | @JvmOverloads 67 | fun destroy(grantId: String, overrides: RequestOverrides? = null): DeleteResponse { 68 | val path = String.format("v3/grants/%s", grantId) 69 | return destroyResource(path, overrides = overrides) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/Resource.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | import com.nylas.models.* 5 | import com.squareup.moshi.Types 6 | import java.lang.reflect.Type 7 | 8 | /** 9 | * Base class for Nylas API resources 10 | * 11 | * @suppress No public constructor or functions 12 | */ 13 | abstract class Resource protected constructor( 14 | protected val client: NylasClient, 15 | modelClass: Class, 16 | ) { 17 | private val responseType: Type = Types.newParameterizedType(Response::class.java, modelClass) 18 | private val listResponseType: Type = Types.newParameterizedType(ListResponse::class.java, modelClass) 19 | 20 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 21 | protected fun listResource(path: String, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): ListResponse { 22 | return client.executeGet(path, listResponseType, queryParams, overrides) 23 | } 24 | 25 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 26 | protected fun findResource(path: String, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): Response { 27 | return client.executeGet(path, responseType, queryParams, overrides) 28 | } 29 | 30 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 31 | protected fun createResource(path: String, requestBody: String?, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): Response { 32 | return client.executePost(path, responseType, requestBody, queryParams, overrides) 33 | } 34 | 35 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 36 | protected fun updateResource(path: String, requestBody: String?, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): Response { 37 | return client.executePut(path, responseType, requestBody, queryParams, overrides) 38 | } 39 | 40 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 41 | protected fun patchResource(path: String, requestBody: String?, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): Response { 42 | return client.executePatch(path, responseType, requestBody, queryParams, overrides) 43 | } 44 | 45 | @Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class) 46 | protected fun destroyResource(path: String, queryParams: IQueryParams? = null, overrides: RequestOverrides? = null): DeleteResponse { 47 | return client.executeDelete(path, DeleteResponse::class.java, queryParams, overrides) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/Scheduler.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | 5 | /** 6 | * Nylas Scheduler API 7 | * 8 | * The Nylas Scheduler API allows you to manage scheduling configurations, bookings, and sessions. 9 | * 10 | * @param client The configured Nylas API client 11 | */ 12 | class Scheduler(private val client: NylasClient) { 13 | 14 | /** 15 | * Access the Configurations API. 16 | * 17 | * @return The Configurations API. 18 | */ 19 | fun configurations(): Configurations = Configurations(client) 20 | 21 | /** 22 | * Access the Sessions API. 23 | * 24 | * @return The Sessions API. 25 | */ 26 | fun sessions(): Sessions = Sessions(client) 27 | 28 | /** 29 | * Access the Bookings API. 30 | * 31 | * @return The Bookings API. 32 | */ 33 | fun bookings(): Bookings = Bookings(client) 34 | } 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/Sessions.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | import com.nylas.models.* 5 | import com.nylas.util.JsonHelper 6 | /** 7 | * Nylas Sessions API 8 | * 9 | * The Nylas Sessions API allows you to create and delete sessions on user Schedulerconfigurations. 10 | * 11 | * @param client The configured Nylas API client 12 | */ 13 | class Sessions(client: NylasClient) : Resource(client, Session::class.java) { 14 | /** 15 | * Create a Session 16 | * @param requestBody The values to create the session with 17 | * @param overrides Optional request overrides to apply 18 | * @return The created session 19 | */ 20 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 21 | @JvmOverloads 22 | fun create(requestBody: CreateSessionRequest, overrides: RequestOverrides? = null): Response { 23 | val path = "v3/scheduling/sessions" 24 | val adapter = JsonHelper.moshi().adapter(CreateSessionRequest::class.java) 25 | val serializedRequestBody = adapter.toJson(requestBody) 26 | return createResource(path, serializedRequestBody, overrides = overrides) 27 | } 28 | 29 | /** 30 | * Delete a Session 31 | * @param sessionId The ID of the session to delete 32 | * @param overrides Optional request overrides to apply 33 | * @return The deleted response 34 | */ 35 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 36 | @JvmOverloads 37 | fun destroy(sessionId: String, overrides: RequestOverrides? = null): DeleteResponse { 38 | val path = String.format("v3/scheduling/sessions/%s", sessionId) 39 | return destroyResource(path, overrides = overrides) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/resources/SmartCompose.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.resources 2 | 3 | import com.nylas.NylasClient 4 | import com.nylas.models.* 5 | import com.nylas.util.JsonHelper 6 | import com.squareup.moshi.Types 7 | import kotlin.jvm.Throws 8 | 9 | /** 10 | * A collection of Smart Compose related API endpoints. 11 | * 12 | * These endpoints allow for the generation of message suggestions. 13 | * 14 | * @param client The configured Nylas API client 15 | */ 16 | class SmartCompose(private val client: NylasClient) { 17 | /** 18 | * Compose a message 19 | * @param identifier The identifier of the grant to act upon 20 | * @param requestBody The prompt that smart compose will use to generate a message suggestion 21 | * @param overrides Optional request overrides to apply 22 | * @return The generated message 23 | */ 24 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 25 | @JvmOverloads 26 | fun composeMessage(identifier: String, requestBody: ComposeMessageRequest, overrides: RequestOverrides? = null): Response { 27 | val path = "v3/grants/$identifier/messages/smart-compose" 28 | 29 | val serializedRequestBody = JsonHelper.moshi() 30 | .adapter(ComposeMessageRequest::class.java) 31 | .toJson(requestBody) 32 | val responseType = Types.newParameterizedType(Response::class.java, ComposeMessageResponse::class.java) 33 | 34 | return client.executePost(path, responseType, serializedRequestBody, overrides = overrides) 35 | } 36 | 37 | /** 38 | * Compose a message reply 39 | * @param identifier The identifier of the grant to act upon 40 | * @param messageId The id of the message to reply to 41 | * @param requestBody The prompt that smart compose will use to generate a reply suggestion 42 | * @param overrides Optional request overrides to apply 43 | * @return The generated message reply 44 | */ 45 | @Throws(NylasApiError::class, NylasSdkTimeoutError::class) 46 | @JvmOverloads 47 | fun composeMessageReply(identifier: String, messageId: String, requestBody: ComposeMessageRequest, overrides: RequestOverrides? = null): Response { 48 | val path = "v3/grants/$identifier/messages/$messageId/smart-compose" 49 | 50 | val serializedRequestBody = JsonHelper.moshi() 51 | .adapter(ComposeMessageRequest::class.java) 52 | .toJson(requestBody) 53 | val responseType = Types.newParameterizedType(Response::class.java, ComposeMessageResponse::class.java) 54 | 55 | return client.executePost(path, responseType, serializedRequestBody, overrides = overrides) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/ConferencingAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.Conferencing 4 | import com.squareup.moshi.* 5 | import java.io.IOException 6 | 7 | /** 8 | * This class is used to serialize and deserialize the Conferencing object. 9 | * @suppress Not for public use. 10 | */ 11 | class ConferencingAdapter { 12 | @FromJson 13 | @Throws(IOException::class) 14 | fun fromJson( 15 | reader: JsonReader, 16 | delegateAutocreate: JsonAdapter, 17 | delegateDetails: JsonAdapter, 18 | ): Conferencing? { 19 | val json = JsonHelper.jsonToMap(reader) 20 | 21 | return if (json.containsKey("details")) { 22 | delegateDetails.fromJsonValue(json) 23 | } else { 24 | delegateAutocreate.fromJsonValue(json) 25 | } 26 | } 27 | 28 | @ToJson 29 | fun toJson( 30 | writer: JsonWriter, 31 | value: Conferencing?, 32 | delegateAutocreate: JsonAdapter, 33 | delegateDetails: JsonAdapter, 34 | ) { 35 | when (value) { 36 | is Conferencing.Autocreate -> delegateAutocreate.toJson(writer, value) 37 | is Conferencing.Details -> delegateDetails.toJson(writer, value) 38 | else -> writer.nullValue() 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/CreateAttachmentRequestAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.CreateAttachmentRequest 4 | import com.squareup.moshi.FromJson 5 | import com.squareup.moshi.JsonWriter 6 | import com.squareup.moshi.ToJson 7 | 8 | /** 9 | * This class is used to serialize and deserialize the CreateAttachmentRequest class. 10 | * @suppress Not for public use. 11 | */ 12 | class CreateAttachmentRequestAdapter { 13 | @ToJson 14 | @Throws(UnsupportedOperationException::class) 15 | fun toJson(writer: JsonWriter, value: CreateAttachmentRequest?) { 16 | writer.beginObject() 17 | writer.name("filename").value(value?.filename) 18 | writer.name("content_type").value(value?.contentType) 19 | writer.name("size").value(value?.size) 20 | value?.isInline?.let { writer.name("is_inline").value(it) } 21 | value?.contentId?.let { writer.name("content_id").value(it) } 22 | value?.contentDisposition?.let { writer.name("content_disposition").value(it) } 23 | 24 | // Encode the file stream to base64 25 | value?.content?.let { 26 | val base64Content = it.use { stream -> 27 | FileUtils.encodeStreamToBase64(stream) 28 | } 29 | writer.name("content").value(base64Content) 30 | } 31 | 32 | writer.endObject() 33 | } 34 | 35 | @FromJson 36 | @Throws(UnsupportedOperationException::class) 37 | fun fromJson(reader: com.squareup.moshi.JsonReader): CreateAttachmentRequest? { 38 | throw UnsupportedOperationException("Deserialization not supported") 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/CreateConferencingAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.CreateEventRequest 4 | import com.squareup.moshi.* 5 | 6 | /** 7 | * This class is used to serialize and deserialize the CreateEventRequest.Conferencing object. 8 | * @suppress Not for public use. 9 | */ 10 | class CreateConferencingAdapter { 11 | @FromJson 12 | @Throws(UnsupportedOperationException::class) 13 | fun fromJson(reader: JsonReader): CreateEventRequest.Conferencing? { 14 | throw UnsupportedOperationException("CreateConferencingAdapter is only used for serialization") 15 | } 16 | 17 | @ToJson 18 | fun toJson( 19 | writer: JsonWriter, 20 | value: CreateEventRequest.Conferencing?, 21 | delegateAutocreate: JsonAdapter, 22 | delegateDetails: JsonAdapter, 23 | ) { 24 | when (value) { 25 | is CreateEventRequest.Conferencing.Autocreate -> delegateAutocreate.toJson(writer, value) 26 | is CreateEventRequest.Conferencing.Details -> delegateDetails.toJson(writer, value) 27 | else -> writer.nullValue() 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/CreateWhenAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.CreateEventRequest 4 | import com.squareup.moshi.* 5 | 6 | /** 7 | * This class is used to serialize and deserialize the CreateEventRequest.When object. 8 | * @suppress Not for public use. 9 | */ 10 | class CreateWhenAdapter { 11 | @FromJson 12 | @Throws(UnsupportedOperationException::class) 13 | fun fromJson(reader: JsonReader): CreateEventRequest.When? { 14 | throw UnsupportedOperationException("CreateWhenAdapter is only used for serialization") 15 | } 16 | 17 | @ToJson 18 | fun toJson( 19 | writer: JsonWriter, 20 | value: CreateEventRequest.When?, 21 | delegateTime: JsonAdapter, 22 | delegateTimespan: JsonAdapter, 23 | delegateDate: JsonAdapter, 24 | delegateDatespan: JsonAdapter, 25 | ) { 26 | when (value) { 27 | is CreateEventRequest.When.Time -> delegateTime.toJson(writer, value) 28 | is CreateEventRequest.When.Timespan -> delegateTimespan.toJson(writer, value) 29 | is CreateEventRequest.When.Date -> delegateDate.toJson(writer, value) 30 | is CreateEventRequest.When.Datespan -> delegateDatespan.toJson(writer, value) 31 | else -> writer.nullValue() 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/IMessageAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.Draft 4 | import com.nylas.models.IMessage 5 | import com.nylas.models.Message 6 | import com.squareup.moshi.* 7 | 8 | /** 9 | * This class is used to serialize and deserialize the IMessage interface. 10 | * @suppress Not for public use. 11 | */ 12 | class IMessageAdapter { 13 | @FromJson 14 | fun fromJson( 15 | reader: JsonReader, 16 | messageAdapter: JsonAdapter, 17 | draftAdapter: JsonAdapter, 18 | ): IMessage? { 19 | val map = reader.readJsonValue() as? Map<*, *> ?: return null 20 | return when { 21 | map.containsKey("object") && map["object"]?.equals("drafts") == true -> draftAdapter.fromJsonValue(map) 22 | else -> messageAdapter.fromJsonValue(map) 23 | } 24 | } 25 | 26 | @ToJson 27 | fun toJson( 28 | writer: JsonWriter, 29 | value: IMessage?, 30 | messageAdapter: JsonAdapter, 31 | draftAdapter: JsonAdapter, 32 | ) { 33 | when (value) { 34 | is Message -> messageAdapter.toJson(writer, value) 35 | is Draft -> draftAdapter.toJson(writer, value) 36 | else -> writer.nullValue() 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/UpdateConferencingAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.UpdateEventRequest 4 | import com.squareup.moshi.* 5 | 6 | /** 7 | * This class is used to serialize and deserialize the UpdateEventRequest.Conferencing object. 8 | * @suppress Not for public use. 9 | */ 10 | class UpdateConferencingAdapter { 11 | @FromJson 12 | @Throws(UnsupportedOperationException::class) 13 | fun fromJson(reader: JsonReader): UpdateEventRequest.Conferencing? { 14 | throw UnsupportedOperationException("UpdateConferencingAdapter is only used for serialization") 15 | } 16 | 17 | @ToJson 18 | fun toJson( 19 | writer: JsonWriter, 20 | value: UpdateEventRequest.Conferencing?, 21 | delegateAutocreate: JsonAdapter, 22 | delegateDetails: JsonAdapter, 23 | ) { 24 | when (value) { 25 | is UpdateEventRequest.Conferencing.Autocreate -> delegateAutocreate.toJson(writer, value) 26 | is UpdateEventRequest.Conferencing.Details -> delegateDetails.toJson(writer, value) 27 | else -> writer.nullValue() 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/UpdateConnectorAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.* 4 | import com.squareup.moshi.* 5 | 6 | /** 7 | * This class is used to serialize and deserialize the UpdateConnectorRequest object. 8 | * @suppress Not for public use. 9 | */ 10 | class UpdateConnectorAdapter { 11 | @FromJson 12 | @Throws(UnsupportedOperationException::class) 13 | fun fromJson(reader: JsonReader): UpdateConnectorRequest? { 14 | throw UnsupportedOperationException("UpdateConnectorRequest is only used for serialization") 15 | } 16 | 17 | @ToJson 18 | fun toJson( 19 | writer: JsonWriter, 20 | value: UpdateConnectorRequest?, 21 | delegateGoogle: JsonAdapter, 22 | delegateMicrosoft: JsonAdapter, 23 | ) { 24 | when (value) { 25 | is UpdateConnectorRequest.Google -> delegateGoogle.toJson(writer, value) 26 | is UpdateConnectorRequest.Microsoft -> delegateMicrosoft.toJson(writer, value) 27 | else -> writer.nullValue() 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/UpdateWhenAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import com.nylas.models.UpdateEventRequest 4 | import com.squareup.moshi.* 5 | 6 | /** 7 | * This class is used to serialize and deserialize the UpdateEventRequest.When object. 8 | * @suppress Not for public use. 9 | */ 10 | class UpdateWhenAdapter { 11 | @FromJson 12 | @Throws(UnsupportedOperationException::class) 13 | fun fromJson(reader: JsonReader): UpdateEventRequest.When? { 14 | throw UnsupportedOperationException("UpdateWhenAdapter is only used for serialization") 15 | } 16 | 17 | @ToJson 18 | fun toJson( 19 | writer: JsonWriter, 20 | value: UpdateEventRequest.When?, 21 | delegateTime: JsonAdapter, 22 | delegateTimespan: JsonAdapter, 23 | delegateDate: JsonAdapter, 24 | delegateDatespan: JsonAdapter, 25 | ) { 26 | when (value) { 27 | is UpdateEventRequest.When.Time -> delegateTime.toJson(writer, value) 28 | is UpdateEventRequest.When.Timespan -> delegateTimespan.toJson(writer, value) 29 | is UpdateEventRequest.When.Date -> delegateDate.toJson(writer, value) 30 | is UpdateEventRequest.When.Datespan -> delegateDatespan.toJson(writer, value) 31 | else -> writer.nullValue() 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/kotlin/com/nylas/util/WebhookRequestValidator.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import java.nio.charset.StandardCharsets 4 | import java.security.GeneralSecurityException 5 | import javax.crypto.Mac 6 | import javax.crypto.spec.SecretKeySpec 7 | 8 | /** 9 | * Utility class to validate the signature of a webhook request. 10 | */ 11 | object WebhookRequestValidator { 12 | 13 | /** 14 | * Validates the signature of a webhook request 15 | * 16 | * @param payload the raw payload of the request 17 | * @param webhookSecret your webhook secret key 18 | * @param expectedSignature the expected signature of the request. (Header "X-Nylas-Signature") 19 | * @return true if the request is valid 20 | */ 21 | @JvmStatic 22 | fun isRequestValid(payload: String, webhookSecret: String, expectedSignature: String): Boolean { 23 | return try { 24 | val expectedBytes = hexStringToByteArray(expectedSignature) 25 | val mac = Mac.getInstance("HmacSHA256") 26 | val secretKeySpec = SecretKeySpec(webhookSecret.toByteArray(StandardCharsets.UTF_8), "HmacSHA256") 27 | mac.init(secretKeySpec) 28 | val sigBytes = mac.doFinal(payload.toByteArray(StandardCharsets.UTF_8)) 29 | expectedBytes contentEquals sigBytes 30 | } catch (e: GeneralSecurityException) { 31 | throw RuntimeException(e) 32 | } 33 | } 34 | 35 | /** 36 | * Converts a hex string to a byte array 37 | * 38 | * @param s the hex string to convert 39 | * @return the byte array 40 | */ 41 | private fun hexStringToByteArray(s: String): ByteArray { 42 | val len = s.length 43 | val data = ByteArray(len / 2) 44 | for (i in 0 until len step 2) { 45 | data[i / 2] = ((Character.digit(s[i], 16) shl 4) + Character.digit(s[i + 1], 16)).toByte() 46 | } 47 | return data 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/build.properties: -------------------------------------------------------------------------------- 1 | nylas.build.version=${artifact_version} -------------------------------------------------------------------------------- /src/test/kotlin/com/nylas/models/CalendarNotetakerTest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.nylas.util.JsonHelper 4 | import okio.Buffer 5 | import kotlin.test.Test 6 | import kotlin.test.assertEquals 7 | import kotlin.test.assertIs 8 | import kotlin.test.assertNull 9 | 10 | class CalendarNotetakerTest { 11 | @Test 12 | fun `CalendarNotetaker serializes properly`() { 13 | val adapter = JsonHelper.moshi().adapter(CalendarNotetaker::class.java) 14 | val jsonBuffer = Buffer().writeUtf8( 15 | """ 16 | { 17 | "name": "Custom Notetaker", 18 | "meeting_settings": { 19 | "video_recording": true, 20 | "audio_recording": false, 21 | "transcription": true 22 | }, 23 | "rules": { 24 | "event_selection": ["internal", "external"], 25 | "participant_filter": { 26 | "participants_gte": 3, 27 | "participants_lte": 20 28 | } 29 | } 30 | } 31 | """.trimIndent(), 32 | ) 33 | 34 | val notetaker = adapter.fromJson(jsonBuffer)!! 35 | assertIs(notetaker) 36 | assertEquals("Custom Notetaker", notetaker.name) 37 | assertEquals(true, notetaker.meetingSettings?.videoRecording) 38 | assertEquals(false, notetaker.meetingSettings?.audioRecording) 39 | assertEquals(true, notetaker.meetingSettings?.transcription) 40 | assertEquals(2, notetaker.rules?.eventSelection?.size) 41 | assertEquals(CalendarNotetaker.EventSelectionType.INTERNAL, notetaker.rules?.eventSelection?.get(0)) 42 | assertEquals(CalendarNotetaker.EventSelectionType.EXTERNAL, notetaker.rules?.eventSelection?.get(1)) 43 | assertEquals(3, notetaker.rules?.participantFilter?.participantsGte) 44 | assertEquals(20, notetaker.rules?.participantFilter?.participantsLte) 45 | } 46 | 47 | @Test 48 | fun `CalendarNotetaker deserializes with minimal fields`() { 49 | val adapter = JsonHelper.moshi().adapter(CalendarNotetaker::class.java) 50 | val jsonBuffer = Buffer().writeUtf8( 51 | """ 52 | { 53 | "name": "Minimal Notetaker" 54 | } 55 | """.trimIndent(), 56 | ) 57 | 58 | val notetaker = adapter.fromJson(jsonBuffer)!! 59 | assertIs(notetaker) 60 | assertEquals("Minimal Notetaker", notetaker.name) 61 | assertNull(notetaker.meetingSettings) 62 | assertNull(notetaker.rules) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/kotlin/com/nylas/models/FindMessageQueryParamsTests.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import org.junit.jupiter.api.Test 4 | import kotlin.test.assertEquals 5 | 6 | class FindMessageQueryParamsTests { 7 | @Test 8 | fun `FindMessageQueryParams with fields builds correctly`() { 9 | val queryParams = FindMessageQueryParams(fields = MessageFields.INCLUDE_TRACKING_OPTIONS) 10 | 11 | assertEquals(MessageFields.INCLUDE_TRACKING_OPTIONS, queryParams.fields) 12 | } 13 | 14 | @Test 15 | fun `FindMessageQueryParams builder pattern works correctly`() { 16 | val queryParams = FindMessageQueryParams.Builder() 17 | .fields(MessageFields.RAW_MIME) 18 | .build() 19 | 20 | assertEquals(MessageFields.RAW_MIME, queryParams.fields) 21 | } 22 | 23 | @Test 24 | fun `FindMessageQueryParams builder with null fields builds correctly`() { 25 | val queryParams = FindMessageQueryParams.Builder() 26 | .fields(null) 27 | .build() 28 | 29 | assertEquals(null, queryParams.fields) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/kotlin/com/nylas/models/MessageFieldsTests.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.models 2 | 3 | import com.nylas.util.JsonHelper 4 | import org.junit.jupiter.api.Test 5 | import kotlin.test.assertEquals 6 | 7 | class MessageFieldsTests { 8 | @Test 9 | fun `MessageFields enum values serialize correctly`() { 10 | val adapter = JsonHelper.moshi().adapter(MessageFields::class.java) 11 | 12 | assertEquals("\"standard\"", adapter.toJson(MessageFields.STANDARD)) 13 | assertEquals("\"include_headers\"", adapter.toJson(MessageFields.INCLUDE_HEADERS)) 14 | assertEquals("\"include_tracking_options\"", adapter.toJson(MessageFields.INCLUDE_TRACKING_OPTIONS)) 15 | assertEquals("\"raw_mime\"", adapter.toJson(MessageFields.RAW_MIME)) 16 | } 17 | 18 | @Test 19 | fun `MessageFields enum values deserialize correctly`() { 20 | val adapter = JsonHelper.moshi().adapter(MessageFields::class.java) 21 | 22 | assertEquals(MessageFields.STANDARD, adapter.fromJson("\"standard\"")) 23 | assertEquals(MessageFields.INCLUDE_HEADERS, adapter.fromJson("\"include_headers\"")) 24 | assertEquals(MessageFields.INCLUDE_TRACKING_OPTIONS, adapter.fromJson("\"include_tracking_options\"")) 25 | assertEquals(MessageFields.RAW_MIME, adapter.fromJson("\"raw_mime\"")) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/kotlin/com/nylas/util/WebhookRequestValidatorTest.kt: -------------------------------------------------------------------------------- 1 | package com.nylas.util 2 | 3 | import org.junit.jupiter.api.Assertions.assertFalse 4 | import org.junit.jupiter.api.Assertions.assertTrue 5 | import org.junit.jupiter.api.Test 6 | 7 | class WebhookRequestValidatorTest { 8 | 9 | @Test 10 | fun isRequestValid() { 11 | val webhookSecret = "UfZWFrkjsbg5bxLbax-y" 12 | val payload = """{"specversion":"1.0","type":"grant.deleted","source":"/nylas/system","id":"Kkx2QQB7TWjWM3KXRQQn562394","time":1717162394,"webhook_delivery_attempt":1,"data":{"application_id":"a7966b5a-9bc2-44b7-9895-4e2b281ce6be","object":{"code":25013,"grant_id":"4c22c3c5-d163-48b6-ad95-45fedc879683","integration_id":"b7dd6e6e-af6a-463b-92fa-be35c2683f5c","metric":1934,"provider":"google"}}}""" 13 | 14 | // When the signature header value is valid 15 | val validSigHeader = "a4534f7e68dcd54f0621f7539ddd5a0d14a9a46ace9b68a4cfd9c99b4b6b89cc" 16 | // Then isRequestValid() returns true 17 | assertTrue(WebhookRequestValidator.isRequestValid(payload, webhookSecret, validSigHeader)) 18 | 19 | // When the signature header value is invalid 20 | val invalidSigHeader = "a4534f7e68dcd54f0621f7539ddd5a0d14a9a46ace9b68a4cfd9c99b4b6b89ca" 21 | // Then isRequestValid() returns false 22 | assertFalse(WebhookRequestValidator.isRequestValid(payload, webhookSecret, invalidSigHeader)) 23 | } 24 | } 25 | --------------------------------------------------------------------------------