Classe NowDataSDK - Android

  • Versão de lançamento: Washingtondc
  • Atualizado 1 de fev. de 2024
  • 3 min. de leitura
  • A classe NowDataSDK 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 à GraphQL API na sua instância ServiceNow.

    Para obter informações adicionais sobre a ServiceNow GraphQL API, consulte Consultar dados de registro usando a estrutura da GraphQL API.

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    URL da instância URL URL da instância ServiceNow a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 2. Retorna
    Tipo Descrição
    Resultado<NowGraphQLService> Objeto NowGraphQLService encapsulado em um objeto Resultado do 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 REST APIs públicas expostas pela sua instância ServiceNow.

    Além disso, você pode desenvolver REST APIs com script personalizadas em sua instância ServiceNow e acessá-las em sua aplicação Android usando a API NowAPIService. Para obter informações adicionais sobre ServiceNow REST APIs, consulte Scripted REST APIs.

    Tabela 3. Parâmetros
    Nome Tipo Descrição
    URL da instância URL URL da instância ServiceNow a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 4. Retorna
    Tipo Descrição
    Resultado<NowAPIService> NowAPIService encapsulado em um objeto de resultado do 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 da sua instância ServiceNow. Depois de carregar um anexo para sua instância, ele gera metadados para o anexo que você pode baixar para sua aplicação Android.

    Para obter informações adicionais sobre ServiceNow anexos, consulte API de anexos.

    Tabela 5. Parâmetros
    Nome Tipo Descrição
    URL da instância URL URL da instância ServiceNow a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 6. Retorna
    Tipo Descrição
    Resultado<NowAttachmentService> Objeto NowAttachmentService encapsulado em um objeto Resultado do 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 a REST Table API em uma instância ServiceNow. Para obter informações adicionais sobre a REST Table API, consulte API da tabela.

    Tabela 7. Parâmetros
    Nome Tipo Descrição
    URL da instância URL URL da instância ServiceNow a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 8. Retorna
    Tipo Descrição
    Resultado<NowTableService> Objeto NowTableService encapsulado em um objeto Resultado do 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 }
    }