Classe NowDataSDK : Android
La classe NowDataSDK fournit des fonctions qui permettent la création et l’initialisation de divers services de fonctionnalités tels que NowGraphQLService, NowAttachmentService, NowTableService et NowAPIService.
NowDataSDK : makeGraphQLService(instanceURL : URL)
Crée et initialise une instance de la fonctionnalité NowGraphQLService. Ce service permet d’accéder à l’API GraphQL sur votre ServiceNow instance.
Pour plus d’informations sur l’API ServiceNow GraphQL, reportez-vous à la section Interroger les données d’enregistrement à l’aide du cadre de travail d’API GraphQL.
| Nom | Type | Description |
|---|---|---|
| instanceURL | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowGraphQLService> | Objet NowGraphQLService enveloppé dans un objet de résultat Kotlin. |
L’exemple de code suivant montre comment appeler cette fonction.
private var nowGraphQLService: NowGraphQLService? = null
/**
* Create the NowGraphQLService once in the lifetime of the application, inside the Application class
* or another manager class that will be injected into other classes via dagger/hilt.
* NowGraphQLService should be created after initializing the NowSDK.
*/
suspend fun getNowGraphQLService(): NowGraphQLService? {
if (nowGraphQLService != null) return nowGraphQLService
return NowDataSDK.makeGraphQLService(URL("https://instance-name.service-now.com")).getOrThrow()
.also { this.nowGraphQLService = it }
}
NowDataSDK : makeNowAPIService(instanceURL : URL)
Crée et initialise une instance du service NowAPIService. Ce service vous permet d’accéder aux API REST publiques exposées par votre ServiceNow instance.
En outre, vous pouvez développer des API REST scriptées personnalisées au sein de votre ServiceNow instance et y accéder au sein de votre Android application à l’aide de l’API NowAPIService . Pour plus d’informations sur ServiceNow les API REST, reportez-vous à la section API REST basées sur un script.
| Nom | Type | Description |
|---|---|---|
| instanceURL | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat<ServiceNow APIS> | NowAPIService encapsulé dans un objet de résultat Kotlin. |
L’exemple de code suivant montre comment appeler cette fonction.
private var nowApiService: NowAPIService? = null
/**
* Create the NowAPIService once in the lifetime of the application inside the Application class
* or another manager class that will be injected into other classes via dagger/hilt.
* NowAPIService should be created after initializing the NowSDK
*/
suspend fun getNowApiService(): NowAPIService? {
if (nowApiService != null) return nowApiService
return NowDataSDK.makeAPIService(URL("https://instance-name.service-now.com")).getOrThrow()
.also { this.nowApiService = it }
}
NowDataSDK : makeNowAttachmentService(instanceURL : URL)
Crée et initialise une instance de la fonctionnalité NowAttachmentService.
Ce service vous permet de charger, de télécharger et de supprimer des fichiers de pièce jointe de votre ServiceNow instance. Une fois que vous avez chargé une pièce jointe sur votre instance, elle génère des métadonnées pour la pièce jointe que vous pouvez ensuite télécharger dans votre Android application.
Pour plus d’informations sur ServiceNow les pièces jointes, reportez-vous à la section API de pièce jointe.
| Nom | Type | Description |
|---|---|---|
| instanceURL | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowAttachmentService> | Objet NowAttachmentService enveloppé dans un objet de résultat Kotlin. |
L’exemple de code suivant montre comment appeler cette méthode.
private var nowAttachmentService: NowAttachmentService? = null
/**
* Create the NowAttachmentService once in the lifetime of the application inside the Application
* class or another manager class that will be injected into other classes via dagger/hilt.
* NowAttachmentService should be created after initializing the NowSDK.
*/
suspend fun getNowAttachmentService(): NowAttachmentService? {
if (nowAttachmentService != null) return nowAttachmentService
return NowDataSDK.makeAttachmentService(URL("https://instance-name.service-now.com"))
.getOrThrow()
.also { this.nowAttachmentService = it }
}
NowDataSDK : makeTableService(instanceURL : URL)
Crée et initialise une instance de la fonctionnalité NowTableService.
Ce service vous permet d’accéder à l’API de table REST sur une ServiceNow instance. Pour plus d’informations sur l’API de table REST, consultez API de table.
| Nom | Type | Description |
|---|---|---|
| instanceURL | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowTableService> | Objet NowTableService intégré dans un objet de résultat Kotlin. |
L’exemple de code suivant montre comment appeler cette fonction.
private var nowTableService: NowTableService? = null
/**
* Create the NowTableService once in the lifetime of the application inside the Application
* class or another manager class that will be injected into other classes via dagger/hilt.
* NowTableService should be created after initializing the NowSDK.
*/
suspend fun getNowTableService(): NowTableService? {
if (nowTableService != null) return nowTableService
return NowDataSDK.makeTableService(URL("https://instance-name.service-now.com")).getOrThrow()
.also { this.nowTableService = it }
}