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