Skip to content

Commit 28706db

Browse files
feat: make NylasClient and its methods open for mocking
This change makes the NylasClient class and its methods open to enable mocking in tests. - Added open modifier to NylasClient class - Made all resource accessor methods (messages, calendars, etc.) open - Made HTTP execution methods open for comprehensive mocking support Fixes #257 Co-Authored-By: Aaron de Mello <aaron.d@nylas.com>
1 parent 7b99eec commit 28706db

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/main/kotlin/com/nylas/NylasClient.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit
2626
* @param httpClientBuilder The builder to use for creating the http client.
2727
* @param apiUri The URL to use for communicating with the Nylas API.
2828
*/
29-
class NylasClient(
29+
open class NylasClient(
3030
val apiKey: String,
3131
httpClientBuilder: OkHttpClient.Builder = defaultHttpClient(),
3232
apiUri: String = DEFAULT_BASE_URL,
@@ -77,84 +77,84 @@ class NylasClient(
7777
* Access the Applications API
7878
* @return The Applications API
7979
*/
80-
fun applications(): Applications = Applications(this)
80+
open fun applications(): Applications = Applications(this)
8181

8282
/**
8383
* Access the Attachments API
8484
* @return The Attachments API
8585
*/
86-
fun attachments(): Attachments = Attachments(this)
86+
open fun attachments(): Attachments = Attachments(this)
8787

8888
/**
8989
* Access the Auth API
9090
* @return The Auth API
9191
*/
92-
fun auth(): Auth = Auth(this)
92+
open fun auth(): Auth = Auth(this)
9393

9494
/**
9595
* Access the Calendars API
9696
* @return The Calendars API
9797
*/
98-
fun calendars(): Calendars = Calendars(this)
98+
open fun calendars(): Calendars = Calendars(this)
9999

100100
/**
101101
* Access the Connectors API
102102
* @return The Connectors API
103103
*/
104-
fun connectors(): Connectors = Connectors(this)
104+
open fun connectors(): Connectors = Connectors(this)
105105

106106
/**
107107
* Access the Drafts API
108108
* @return The Drafts API
109109
*/
110-
fun drafts(): Drafts = Drafts(this)
110+
open fun drafts(): Drafts = Drafts(this)
111111

112112
/**
113113
* Access the Events API
114114
* @return The Events API
115115
*/
116-
fun events(): Events = Events(this)
116+
open fun events(): Events = Events(this)
117117

118118
/**
119119
* Access the Folders API
120120
* @return The Folders API
121121
*/
122-
fun folders(): Folders = Folders(this)
122+
open fun folders(): Folders = Folders(this)
123123

124124
/**
125125
* Access the Grants API
126126
* @return The Grants API
127127
*/
128-
fun grants(): Grants = Grants(this)
128+
open fun grants(): Grants = Grants(this)
129129

130130
/**
131131
* Access the Messages API
132132
* @return The Messages API
133133
*/
134-
fun messages(): Messages = Messages(this)
134+
open fun messages(): Messages = Messages(this)
135135

136136
/**
137137
* Access the Threads API
138138
* @return The Threads API
139139
*/
140-
fun threads(): Threads = Threads(this)
140+
open fun threads(): Threads = Threads(this)
141141

142142
/**
143143
* Access the Webhooks API
144144
* @return The Webhooks API
145145
*/
146-
fun webhooks(): Webhooks = Webhooks(this)
146+
open fun webhooks(): Webhooks = Webhooks(this)
147147

148148
/**
149149
* Access the Contacts API
150150
* @return The Contacts API
151151
*/
152-
fun contacts(): Contacts = Contacts(this)
152+
open fun contacts(): Contacts = Contacts(this)
153153

154154
/**
155155
* Get a URL builder instance for the Nylas API.
156156
*/
157-
fun newUrlBuilder(): HttpUrl.Builder = apiUri.newBuilder()
157+
open fun newUrlBuilder(): HttpUrl.Builder = apiUri.newBuilder()
158158

159159
/**
160160
* Execute a GET request to the Nylas API.
@@ -165,7 +165,7 @@ class NylasClient(
165165
* @suppress Not for public use.
166166
*/
167167
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
168-
fun <T> executeGet(
168+
open fun <T> executeGet(
169169
path: String,
170170
resultType: Type,
171171
queryParams: IQueryParams? = null,
@@ -185,7 +185,7 @@ class NylasClient(
185185
* @suppress Not for public use.
186186
*/
187187
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
188-
fun <T> executePut(
188+
open fun <T> executePut(
189189
path: String,
190190
resultType: Type,
191191
requestBody: String? = null,
@@ -207,7 +207,7 @@ class NylasClient(
207207
* @suppress Not for public use.
208208
*/
209209
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
210-
fun <T> executePatch(
210+
open fun <T> executePatch(
211211
path: String,
212212
resultType: Type,
213213
requestBody: String? = null,
@@ -229,7 +229,7 @@ class NylasClient(
229229
* @suppress Not for public use.
230230
*/
231231
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
232-
fun <T> executePost(
232+
open fun <T> executePost(
233233
path: String,
234234
resultType: Type,
235235
requestBody: String? = null,
@@ -253,7 +253,7 @@ class NylasClient(
253253
* @suppress Not for public use.
254254
*/
255255
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
256-
fun <T> executeDelete(
256+
open fun <T> executeDelete(
257257
path: String,
258258
resultType: Type,
259259
queryParams: IQueryParams? = null,
@@ -274,7 +274,7 @@ class NylasClient(
274274
* @suppress Not for public use.
275275
*/
276276
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
277-
fun <T> executeFormRequest(
277+
open fun <T> executeFormRequest(
278278
path: String,
279279
method: HttpMethod,
280280
requestBody: RequestBody,
@@ -318,7 +318,7 @@ class NylasClient(
318318
* @suppress Not for public use.
319319
*/
320320
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
321-
fun <T> executeRequest(
321+
open fun <T> executeRequest(
322322
url: HttpUrl.Builder,
323323
method: HttpMethod,
324324
body: RequestBody?,
@@ -333,7 +333,7 @@ class NylasClient(
333333
}
334334

335335
@Throws(AbstractNylasApiError::class, NylasSdkTimeoutError::class)
336-
fun downloadResponse(
336+
open fun downloadResponse(
337337
path: String,
338338
queryParams: IQueryParams? = null,
339339
overrides: RequestOverrides? = null,

0 commit comments

Comments
 (0)