NowDataSDK classe - Android

  • Versão de lançamento: Zurich
  • Atualizado 31 de jul. de 2025
  • 3 min. de leitura
  • . NowDataSDK A classe fornece funções que permitem a criação e a 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 ServiceNow instância.

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

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    InstanceURL URL URL do ServiceNow instância a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 2. Retornos
    Tipo Descrição
    <NowGraphQLService> Objeto NowGraphQLService encapsulado em A. Objeto de 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 REST APIs públicas expostas por seu ServiceNow instância.

    Além disso, você pode desenvolver REST APIs de script personalizadas em seu ServiceNow e acesse-as em seu Android aplicação usando NowAPIService API. Para obter informações adicionais sobre ServiceNow REST APIs, consulte Scripted REST APIs.

    Tabela 3. Parâmetros
    Nome Tipo Descrição
    InstanceURL URL URL do ServiceNow instância a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 4. Retornos
    Tipo Descrição
    <NowAPIService> NowAPIService encapsulado em A. 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 que você carregue, baixe e exclua arquivos de anexo do seu ServiceNow instância. Depois que você carrega um anexo para sua instância, ele gera metadados para o anexo que você pode baixar em seu Android aplicação.

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

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

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