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
Conversation
Remove classes absolutely not needed at the moment, create packages to organize the SDK and refactor some code
- easier to setup - directly uses ktlint so it's akin to running it locally - doesn't deprecate java 8
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") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
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()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrashed-dev do we access this like static properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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();
square will preappend an empty slash if the passed in path leads with a slash
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:
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.