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, consultez Interroger les données d’enregistrement à l’aide de l’infrastructure de l’API GraphQL.
| Nom | Type | Description |
|---|---|---|
| URL d’instance | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat<NowGraphQLService> | 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 en savoir plus sur les API REST, reportez-vous ServiceNow à la section API REST basées sur un script.
| Nom | Type | Description |
|---|---|---|
| URL d’instance | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowAPIService> | 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, télécharger et supprimer des fichiers en pièce jointe de votre ServiceNow instance. Une fois que vous avez chargé une pièce jointe dans 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 en savoir plus sur les pièces jointes, reportez-vous ServiceNow à API de pièce jointe.
| Nom | Type | Description |
|---|---|---|
| URL d’instance | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowAttachmentService> | NowAttachmentService encapsulé 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 |
|---|---|---|
| URL d’instance | URL | URL de l’instance ServiceNow à laquelle accéder. Par exemple, « https://instance.servicenow.com » |
| Type | Description |
|---|---|
| Résultat <NowTableService> | NowTableService encapsulé 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 }
}