-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathConnector.kt
More file actions
82 lines (76 loc) · 2.37 KB
/
Connector.kt
File metadata and controls
82 lines (76 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.nylas.models
import com.squareup.moshi.Json
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
/**
* Class representation of the Nylas connector response.
*/
sealed class Connector(
/**
* The provider type
*/
@Json(name = "provider")
val provider: AuthProvider,
/**
* The ID of the active credential for this connector (for multi-credential setups).
*/
@Json(name = "active_credential_id")
open val activeCredentialId: String? = null,
) {
/**
* Class representing a Google connector creation request.
*/
data class Google(
/**
* The Google OAuth provider credentials and settings
*/
@Json(name = "settings")
val settings: GoogleConnectorSettings,
/**
* The Google OAuth scopes
*/
@Json(name = "scope")
val scope: List<String>? = null,
/**
* The ID of the active credential for this connector
*/
@Json(name = "active_credential_id")
override val activeCredentialId: String? = null,
) : Connector(AuthProvider.GOOGLE, activeCredentialId)
/**
* Class representing a Microsoft connector creation request.
*/
data class Microsoft(
/**
* The Microsoft OAuth provider credentials and settings
*/
@Json(name = "settings")
val settings: MicrosoftConnectorSettings,
/**
* The Microsoft OAuth scopes
*/
@Json(name = "scope")
val scope: List<String>? = null,
/**
* The ID of the active credential for this connector
*/
@Json(name = "active_credential_id")
override val activeCredentialId: String? = null,
) : Connector(AuthProvider.MICROSOFT, activeCredentialId)
/**
* Class representing an IMAP connector creation request.
*/
class Imap : Connector(AuthProvider.IMAP)
/**
* Class representing a virtual calendar connector creation request.
*/
class VirtualCalendar : Connector(AuthProvider.VIRTUAL_CALENDAR)
companion object {
@JvmStatic
val CONNECTOR_JSON_ADAPTER_FACTORY: PolymorphicJsonAdapterFactory<Connector> =
PolymorphicJsonAdapterFactory.of(Connector::class.java, "provider")
.withSubtype(Google::class.java, AuthProvider.GOOGLE.value)
.withSubtype(Microsoft::class.java, AuthProvider.MICROSOFT.value)
.withSubtype(Imap::class.java, AuthProvider.IMAP.value)
.withSubtype(VirtualCalendar::class.java, AuthProvider.VIRTUAL_CALENDAR.value)
}
}