NowDataSDK classe - Android
. NowDataSDK A classe fornece funções que permitem a criação e inicialização de vários serviços de recursos, como NowGraphQLService, NowAttachmentService, NowTableService e NowAPIService.
NowDataSDK - makeGraphQLService(instanceURL: URL)
Cria e inicializa uma instância do recurso NowGraphQLService. Este serviço permite o acesso ao GraphQL API em seu ServiceNowinstância.
Para obter informações adicionais sobre ServiceNowGraphQL API, consulte Consulte dados de registro usando a estrutura da API GraphQL.
| Nome | Tipo | Descrição |
|---|---|---|
| InstanceURL | URL | URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com" |
| Tipo | Descrição |
|---|---|
| <NowGraphQLService> | Objeto NowGraphQLService encapsulado em A. Objeto de resultado de Kotlin . |
O exemplo de código a seguir mostra como chamar esta função.
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)
Cria e inicializa uma instância do serviço NowAPIService. Este serviço permite que você acesse as APIs REST públicas expostas pelo ServiceNowinstância.
Além disso, você pode desenvolver APIs REST com script personalizadas em seu ServiceNowe acesse-as em seu Androidaplicação que usa o. NowAPIService API. Para obter informações adicionais sobre ServiceNowREST APIs, consulte Scripted REST APIs.
| Nome | Tipo | Descrição |
|---|---|---|
| InstanceURL | URL | URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com" |
| Tipo | Descrição |
|---|---|
| <NowAPIService> | NowAPIService envolto em A. Objeto de resultado de Kotlin . |
O exemplo de código a seguir mostra como chamar esta função.
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)
Cria e inicializa uma instância do recurso NowAttachmentService.
Este serviço permite carregar, baixar e excluir arquivos de anexo do ServiceNowinstância. Depois de carregar um anexo para sua instância, ele gera metadados para o anexo que você pode baixar em seu Androidaplicação.
Para obter informações adicionais sobre ServiceNowanexos, consulte API de anexo.
| Nome | Tipo | Descrição |
|---|---|---|
| InstanceURL | URL | URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com" |
| Tipo | Descrição |
|---|---|
| <NowAttachmentService> | Objeto NowAttachmentService encapsulado em A. Objeto de resultado de Kotlin . |
O exemplo de código a seguir mostra como chamar este método.
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)
Cria e inicializa uma instância do recurso NowTableService.
Este serviço permite que você acesse O RESTANTE Tabela API em um ServiceNowinstância. Para obter informações adicionais sobre o RESTANTE Tabela API, consulte API de tabela .
| Nome | Tipo | Descrição |
|---|---|---|
| InstanceURL | URL | URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com" |
| Tipo | Descrição |
|---|---|
| <NowTableService> | Objeto NowTableService encapsulado em A. Objeto de resultado de Kotlin . |
O exemplo de código a seguir mostra como chamar esta função.
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 }
}