Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Java with Kotlin + Add Auth, Calendar & Event support #154

Merged
merged 44 commits into from Jul 6, 2023

Conversation

mrashed-dev
Copy link
Collaborator

@mrashed-dev mrashed-dev commented Jun 15, 2023

Description

This PR shifts the Java SDK into a Kotlin SDK. This is done to enable friendlier support for Kotlin-powered applications while still keeping the SDK feeling native to Java, as we're designing this SDK with Java interoperability in mind. This PR also brings support for:

  • Nylas API v3
  • Auth methods
  • Calendars API CRUD
  • Events API CRUD
  • Application CRUD

License

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.

@mrashed-dev mrashed-dev changed the title Replace Java with Kotlin + Add Calendar & Event support Replace Java with Kotlin + Add Auth, Calendar & Event support Jun 21, 2023
- easier to setup
- directly uses ktlint so it's akin to running it locally
- doesn't deprecate java 8
Comment on lines +8 to +19
class AddVersionHeadersInterceptor : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
val requestBuilder = chain.request().newBuilder()
.header("User-Agent", USER_AGENT)
return chain.proceed(requestBuilder.build())
}

companion object {
private val USER_AGENT = "Nylas Java SDK " + (BuildInfo.VERSION ?: "unknown")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment on lines 236 to 247
companion object {
const val DEFAULT_BASE_URL = "https://api-staging.us.nylas.com/"
const val EU_BASE_URL = "https://ireland.api.nylas.com/"
private fun defaultHttpClient(): OkHttpClient.Builder {
return OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.protocols(listOf(Protocol.HTTP_1_1))
// .addNetworkInterceptor(HttpLoggingInterceptor())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrashed-dev do we access this like static properties?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronDDM thanks for calling this out. This is not intended to be used by the end user, here we're stashing default values. I have updated the Regions enum to contain the different API urls and that's what the user can use to set a different URL:

NylasClient nylas = new NylasClient.Builder("API_KEY")
  .baseUrl(Region.EU.getNylasApiUrl())
  .build();

@mrashed-dev mrashed-dev merged commit 031ca69 into sdk-v2-staging Jul 6, 2023
@mrashed-dev mrashed-dev deleted the kotlin-v3 branch July 6, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants