NowDataSDK クラス: Android
NowDataSDK クラスは、NowGraphQLService、NowAttachmentService、NowTableService、NowAPIService などのさまざまな機能サービスの作成と初期化を可能にする関数を提供します。
NowDataSDK - makeGraphQLService(instanceURL: URL)
NowGraphQLService 機能のインスタンスを作成して初期化します。このサービスにより、ServiceNow インスタンスで GraphQL API にアクセスできます。
ServiceNow GraphQL API の詳細については、「GraphQL API フレームワークを使用したレコードデータのクエリ」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| インスタンス URL | URL | アクセスする ServiceNow インスタンスの URL。例: 「https://instance.servicenow.com」 |
| タイプ | 説明 |
|---|---|
| 結果<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 サービスのインスタンスを作成して初期化します。このサービスを使用すると、 ServiceNow インスタンスで公開されているパブリック REST API にアクセスできます。
さらに、ServiceNow インスタンス内でカスタムスクリプト済み REST API を開発し、NowAPIService API を使用して Android アプリケーション内でそれらにアクセスできます。ServiceNow REST API の詳細については、「Scripted REST APIs」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| インスタンス URL | URL | アクセスする ServiceNow インスタンスの URL。例: 「https://instance.servicenow.com」 |
| タイプ | 説明 |
|---|---|
| 結果<NowAPIService> | Kotlin Result オブジェクトにラップされた NowAPIService です。 |
次のコード例は、この関数を呼び出す方法を示しています。
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」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| インスタンス URL | URL | アクセスする ServiceNow インスタンスの URL。例: 「https://instance.servicenow.com」 |
| タイプ | 説明 |
|---|---|
| 結果<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 機能のインスタンスを作成して初期化します。
このサービスを使用すると、ServiceNowインスタンスで REST Table API にアクセスできます。REST テーブル API の詳細については、「 テーブル API」を参照してください。
| 名前 | タイプ | 説明 |
|---|---|---|
| インスタンス URL | URL | アクセスする ServiceNow インスタンスの URL。例: 「https://instance.servicenow.com」 |
| タイプ | 説明 |
|---|---|
| 結果<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 }
}