NowDataSDK classe - Android

  • Versão de lançamento: Yokohama
  • Atualizado 30 de jan. de 2025
  • 3 min. de leitura
  • . 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.

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    InstanceURL URL URL do ServiceNowinstâ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 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.

    Tabela 3. Parâmetros
    Nome Tipo Descrição
    InstanceURL URL URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 4. Retornos
    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.

    Tabela 5. Parâmetros
    Nome Tipo Descrição
    InstanceURL URL URL do ServiceNowinstância a ser acessada. Por exemplo, "https://instance.servicenow.com"
    Tabela 6. Retornos
    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 .

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