NowDataSDK 클래스 - Android

  • 릴리스 버전: Washingtondc
  • 업데이트 날짜 2024년 02월 01일
  • 읽기7분
  • NowDataSDK 클래스는 NowGraphQLService, NowAttachmentService, NowTableService, NowAPIService 등 다양한 기능 서비스를 생성하고 초기화할 수 있는 함수를 제공합니다.

    NowDataSDK - makeGraphQLService(instanceURL: URL)

    NowGraphQLService 기능의 인스턴스를 만들고 초기화합니다. 이 서비스를 사용하면 인스턴스의 GraphQL API에 액세스할 수 있습니다 ServiceNow .

    GraphQL API에 ServiceNow 대한 자세한 내용은 을 참조하십시오 GraphQL API 프레임워크를 사용하여 기록 데이터 쿼리.

    표 1. 매개변수
    이름 유형 설명
    인스턴스URL URL ServiceNow 액세스할 인스턴스의 URL입니다. 예: " https://instance.servicenow.com"
    표 2. 반환
    유형 설명
    결과<NowGraphQLService> Kotlin Result 객체에 래핑된 NowGraphQLService 객체입니다.

    다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.

    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)

    NowAPIService 서비스의 인스턴스를 만들고 초기화합니다. 이 서비스를 사용하면 인스턴스에서 노출하는 공용 REST API에 액세스할 수 있습니다 ServiceNow .

    또한 인스턴스 내에서 사용자 지정 스크립트 REST API를 개발하고 NowAPIService API를 사용하여 애플리케이션 내에서 액세스할 수 있습니다 ServiceNowAndroid. REST API에 대한 ServiceNow 자세한 내용은 을 참조하십시오 스크립트 기반 REST API.

    표 3. 매개변수
    이름 유형 설명
    인스턴스URL URL ServiceNow 액세스할 인스턴스의 URL입니다. 예: " https://instance.servicenow.com"
    표 4. 반환
    유형 설명
    결과<NowAPIService> NowAPIService가 Kotlin Result 객체에 래핑되어 있습니다.

    다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.

    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)

    NowAttachmentService 기능의 인스턴스를 만들고 초기화합니다.

    이 서비스를 사용하면 인스턴스에서 첨부 파일을 업로드, 다운로드, 삭제할 수 있습니다 ServiceNow . 인스턴스에 첨부 파일을 업로드하면 애플리케이션에 다운로드할 Android 수 있는 첨부 파일에 대한 메타데이터가 생성됩니다.

    첨부 파일에 대한 ServiceNow 자세한 내용은 을 참조하십시오 첨부 파일 API.

    표 5. 매개변수
    이름 유형 설명
    인스턴스URL URL ServiceNow 액세스할 인스턴스의 URL입니다. 예: " https://instance.servicenow.com"
    표 6. 반환
    유형 설명
    결과<NowAttachmentService> Kotlin Result 객체에 래핑된 NowAttachmentService 객체입니다.

    다음 코드 예제에서는 이 메서드를 호출하는 방법을 보여 줍니다.

    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)

    NowTableService 기능의 인스턴스를 만들고 초기화합니다.

    이 서비스를 사용하면 인스턴스의 REST 테이블 API에 액세스할 수 있습니다 ServiceNow . REST 테이블 API에 대한 자세한 내용은 테이블 API를 참조하세요.

    표 7. 매개변수
    이름 유형 설명
    인스턴스URL URL ServiceNow 액세스할 인스턴스의 URL입니다. 예: " https://instance.servicenow.com"
    표 8. 반환
    유형 설명
    결과<NowTableService> Kotlin Result 객체에 래핑된 NowTableService 객체입니다.

    다음 코드 예제에서는 이 함수를 호출하는 방법을 보여 줍니다.

    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 }
    }