Skip to content

open-dataspaces/SDK-client-library-java

Repository files navigation

open-data-spaces-sdk-client-library-java

ODS SDK for Onboarding - Java client library

概要

このリポジトリには、apidoc フォルダ配下にある複数の OpenAPI 仕様書(L3 および payment)から Java SDK を生成するための手順と成果物が含まれています。

前提条件

  • Java 11 以上がインストールされていること。

  • Apache Maven がインストールされていること。

  • リポジトリ内に apidoc/L3/api-docs.yaml および apidoc/payment/openapi.json が存在すること。

  • 動作確認時の環境情報:

    • Node.js: v25.6.0
    • npm: 11.8.0
    • @openapitools/openapi-generator-cli: 7.20.0

SDK 生成手順

Step 1 — OpenAPI Generator CLI を入手

OpenAPI Generator は npm でインストールされていることを前提としています。以下のコマンドでバージョンを確認できます。

npx @openapitools/openapi-generator-cli version

もしインストールされていない場合は、以下のコマンドでインストールできます。

npm install -g @openapitools/openapi-generator-cli

Step 2 — (任意)仕様の検証

npx @openapitools/openapi-generator-cli validate -i apidoc/L3/api-docs.yaml
npx @openapitools/openapi-generator-cli validate -i apidoc/payment/openapi.json

検証でエラーが出た場合は生成前に修正してください。

Step 3 — Java SDK の生成

以下のコマンドを実行して、L3 および payment の各仕様から SDK を生成します。生成設定は configs/ 配下の YAML ファイルに記述されており、openapitools.json を通じて管理されています。 コードは generated/java-sdk に生成され、パッケージ名はそれぞれ io.github.open_dataspaces.l3 および io.github.open_dataspaces.payment となります。

# L3 SDK の生成
npx @openapitools/openapi-generator-cli generate --generator-key l3-sdk

# payment SDK の生成
npx @openapitools/openapi-generator-cli generate --generator-key payment-sdk

設定ファイルについて:

  • L3 用設定: configs/l3-sdk-config.yaml
  • Payment 用設定: configs/payment-sdk-config.yaml
  • 共通管理ファイル: openapitools.json

Step 4 — 生成した SDK をビルド

cd generated/java-sdk
mvn clean package

成功すれば target/ に JAR が出力されます。

Step 5 — ローカル Maven リポジトリへインストール

mvn install

これで他のローカルプロジェクトから groupId/artifactId で使用できます。

Step 6 — 別プロジェクトでの利用例

消費側プロジェクトの pom.xml に依存を追加します。

<dependency>
  <groupId>io.github.open_dataspaces</groupId>
  <artifactId>java-sdk</artifactId>
  <version>1.0.0</version>
</dependency>

サンプルコード

L3 API の利用例 (アクセストークンの取得)

L3 API を使用してアクセストークンを取得する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.AuthTokenControllerApi;
import io.github.open_dataspaces.l3.model.AuthTokenRequest;
import io.github.open_dataspaces.l3.model.APIResponseAuthTokenResponse;

public class L3Sample {
    public static void main(String[] args) {
        // クライアントの初期化
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        AuthTokenControllerApi apiInstance = new AuthTokenControllerApi(client);

        // リクエストの構築
        AuthTokenRequest request = new AuthTokenRequest()
            .clientId("your-client-id")
            .clientSecret("your-client-secret")
            .code("auth-code")
            .redirectUri("https://your-app.example.com/callback")
            .codeVerifier("code-verifier");

        try {
            // API呼び出し
            APIResponseAuthTokenResponse result = apiInstance.accessToken(request);
            if (result.getData() != null) {
                System.out.println("Access Token: " + result.getData().getAccessToken());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling AuthTokenControllerApi#accessToken");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (クライアントの登録)

L3 API を使用して新しいクライアントを登録する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.ClientsControllerApi;
import io.github.open_dataspaces.l3.model.PostClientsRequest;
import io.github.open_dataspaces.l3.model.APIResponsePostClientsResponse;

public class L3ClientRegistration {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        ClientsControllerApi apiInstance = new ClientsControllerApi(client);

        PostClientsRequest request = new PostClientsRequest()
            .clientName("My New Client")
            .redirectUris(java.util.Arrays.asList("https://app.example.com/callback"));

        try {
            APIResponsePostClientsResponse result = apiInstance.postClients(request);
            if (result.getData() != null) {
                System.out.println("Client UUID: " + result.getData().getClientUuid());
                System.out.println("Client ID: " + result.getData().getClientId());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling ClientsControllerApi#postClients");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (API キーの検証)

API キーが有効かどうかを検証する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.ApiKeyControllerApi;
import io.github.open_dataspaces.l3.model.APIKeyVerifyRequest;
import io.github.open_dataspaces.l3.model.APIResponseAPIKeyVerifyResponse;

public class L3ApiKeyVerify {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        ApiKeyControllerApi apiInstance = new ApiKeyControllerApi(client);

        APIKeyVerifyRequest request = new APIKeyVerifyRequest()
            .apiKey("your-api-key-to-verify");

        try {
            APIResponseAPIKeyVerifyResponse result = apiInstance.verifyAPIKey(request);
            if (result.getData() != null) {
                System.out.println("Is Valid: " + result.getData().getIsValid());
                System.out.println("Client ID: " + result.getData().getClientId());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling ApiKeyControllerApi#verifyAPIKey");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (オペレーターの一覧取得)

登録されているオペレーターの一覧を検索・取得する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.OperatorControllerApi;
import io.github.open_dataspaces.l3.model.APIResponseListGetOperatorResponse;

public class L3OperatorList {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        OperatorControllerApi apiInstance = new OperatorControllerApi(client);

        // 検索条件をJSON形式の文字列で指定します(空オブジェクトは全件検索の例)
        String queryBody = "{}";

        try {
            APIResponseListGetOperatorResponse result = apiInstance.listOperator(queryBody);
            if (result.getData() != null) {
                result.getData().forEach(operator -> {
                    System.out.println("Operator Name: " + operator.getOperatorName());
                    System.out.println("Operator ID: " + operator.getOperatorId());
                });
            }
        } catch (Exception e) {
            System.err.println("Exception when calling OperatorControllerApi#listOperator");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (ユーザーの登録)

新しいユーザーアカウントを作成する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.UserControllerApi;
import io.github.open_dataspaces.l3.model.APIResponsePostUserResponse;

public class L3UserRegistration {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        UserControllerApi apiInstance = new UserControllerApi(client);

        // ユーザー情報をJSON形式の文字列で指定します
        String userJson = "{\"username\": \"newuser\", \"email\": \"user@example.com\"}";

        try {
            APIResponsePostUserResponse result = apiInstance.postUser(userJson);
            if (result.getData() != null) {
                System.out.println("User UUID: " + result.getData().getUserUuid());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling UserControllerApi#postUser");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (認可情報の取得・登録)

ストアの認可情報を取得したり、新しい認可設定を登録したりする例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.AuthorizationControllerApi;
import io.github.open_dataspaces.l3.model.APIResponseObject;

public class L3AuthorizationSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        AuthorizationControllerApi apiInstance = new AuthorizationControllerApi(client);

        String storeId = "store-123";

        try {
            // 認可情報の取得
            APIResponseObject getResult = apiInstance.getApi(storeId);
            System.out.println("Get Result: " + getResult.getData());

            // 認可情報の登録 (JSON文字列で指定)
            String body = "{\"permission\": \"read\", \"resource\": \"data1\"}";
            APIResponseObject postResult = apiInstance.postApi(storeId, body);
            System.out.println("Post Result: " + postResult.getData());
        } catch (Exception e) {
            System.err.println("Exception when calling AuthorizationControllerApi");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (認可 URL の取得)

認可エンドポイントの URL を取得する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.AuthUrlControllerApi;
import io.github.open_dataspaces.l3.model.AuthUrlRequest;
import io.github.open_dataspaces.l3.model.APIResponseAuthUrlResponse;

public class L3AuthUrlSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        AuthUrlControllerApi apiInstance = new AuthUrlControllerApi(client);

        AuthUrlRequest request = new AuthUrlRequest()
            .clientId("your-client-id")
            .scope("openid profile")
            .state("random-state")
            .codeChallenge("challenge")
            .codeChallengeMethod("S256");

        try {
            APIResponseAuthUrlResponse result = apiInstance.url(request);
            if (result.getData() != null) {
                System.out.println("Auth URL: " + result.getData().getUrl());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling AuthUrlControllerApi#url");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (クライアント認証トークンの取得)

クライアント認証(Client Credentials)を使用してトークンを取得する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.TokenClientControllerApi;
import io.github.open_dataspaces.l3.model.TokenClientRequest;
import io.github.open_dataspaces.l3.model.APIResponseTokenClientResponse;

public class L3TokenClientSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        TokenClientControllerApi apiInstance = new TokenClientControllerApi(client);

        TokenClientRequest request = new TokenClientRequest()
            .clientId("your-client-id")
            .clientSecret("your-client-secret")
            .scope("api-scope");

        try {
            APIResponseTokenClientResponse result = apiInstance.client(request);
            if (result.getData() != null) {
                System.out.println("Access Token: " + result.getData().getAccessToken());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling TokenClientControllerApi#client");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (パスワード認証によるログイン)

ユーザー名とパスワードを使用してログインし、トークンを取得する例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.TokenPasswordControllerApi;
import io.github.open_dataspaces.l3.model.TokenPasswordRequest;
import io.github.open_dataspaces.l3.model.APIResponseTokenPasswordResponse;

public class L3LoginSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        TokenPasswordControllerApi apiInstance = new TokenPasswordControllerApi(client);

        TokenPasswordRequest request = new TokenPasswordRequest()
            .username("user@example.com")
            .password("your-password")
            .clientId("your-client-id");

        try {
            APIResponseTokenPasswordResponse result = apiInstance.login(request);
            if (result.getData() != null) {
                System.out.println("Access Token: " + result.getData().getAccessToken());
            }
        } catch (Exception e) {
            System.err.println("Exception when calling TokenPasswordControllerApi#login");
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (トークンのリフレッシュ・状態確認)

既存のトークンを更新したり、有効性を確認したりする例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.TokenRefreshControllerApi;
import io.github.open_dataspaces.l3.api.TokenIntrospectionControllerApi;
import io.github.open_dataspaces.l3.model.*;

public class L3TokenOpsSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        TokenRefreshControllerApi refreshApi = new TokenRefreshControllerApi(client);
        TokenIntrospectionControllerApi introApi = new TokenIntrospectionControllerApi(client);

        try {
            // トークンのリフレッシュ
            TokenRefreshRequest refreshReq = new TokenRefreshRequest()
                .refreshToken("your-refresh-token")
                .clientId("your-client-id");
            APIResponseTokenRefreshResponse refreshRes = refreshApi.refresh(refreshReq);
            System.out.println("New Access Token: " + refreshRes.getData().getAccessToken());

            // トークンのイントロスペクション (状態確認)
            TokenIntrospectionRequest introReq = new TokenIntrospectionRequest()
                .token("access-token-to-check");
            APIResponseTokenIntrospectionResponse introRes = introApi.tokenIntrospection(introReq);
            System.out.println("Is Token Active: " + introRes.getData().getActive());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (オペレーターの登録・状態更新)

オペレーター(管理者など)を新しく登録したり、そのステータスを変更したりする例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.OperatorControllerApi;
import io.github.open_dataspaces.l3.model.*;

public class L3OperatorSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        OperatorControllerApi apiInstance = new OperatorControllerApi(client);

        try {
            // オペレーターの登録
            PostOperatorRequest postReq = new PostOperatorRequest()
                .operatorName("Admin User")
                .email("admin@example.com");
            APIResponsePostOperatorResponse postRes = apiInstance.postOperator(postReq);
            System.out.println("New Operator UUID: " + postRes.getData().getOperatorUuid());

            // オペレーターの状態更新
            PutOperatorStatusRequest statusReq = new PutOperatorStatusRequest()
                .status("ACTIVE");
            APIResponseObject statusRes = apiInstance.putOperatorStatus(postRes.getData().getOperatorUuid(), statusReq);
            System.out.println("Status Update Result: " + statusRes.getData());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (パスワードの変更・リセット)

オペレーターのパスワードを変更したり、リセット用 URL を取得したりする例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.PasswordControllerApi;
import io.github.open_dataspaces.l3.api.PasswordUrlControllerApi;
import io.github.open_dataspaces.l3.model.*;

public class L3PasswordSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        PasswordControllerApi pwdApi = new PasswordControllerApi(client);
        PasswordUrlControllerApi urlApi = new PasswordUrlControllerApi(client);

        try {
            // パスワード変更
            PasswordRequest pwdReq = new PasswordRequest()
                .oldPassword("old-secret")
                .newPassword("new-secret");
            pwdApi.changePassword("operator-uuid", pwdReq);

            // リセットURL取得
            PasswordUrlRequest urlReq = new PasswordUrlRequest().email("user@example.com");
            APIResponsePasswordUrlResponse urlRes = urlApi.url1(urlReq);
            System.out.println("Reset URL: " + urlRes.getData().getUrl());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

L3 API の利用例 (プラントの一覧取得・管理)

プラント(拠点や設備)の一覧取得、登録、更新などを行う例です。

import io.github.open_dataspaces.l3.ApiClient;
import io.github.open_dataspaces.l3.Configuration;
import io.github.open_dataspaces.l3.api.PlantControllerApi;
import io.github.open_dataspaces.l3.model.*;

public class L3PlantSample {
    public static void main(String[] args) {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://l3.example.com");

        PlantControllerApi apiInstance = new PlantControllerApi(client);

        try {
            // プラントの一覧取得 (空クエリ)
            APIResponseListGetPlantResponse listRes = apiInstance.listPlant("{}");
            System.out.println("Plants count: " + listRes.getData().size());

            // プラントの登録
            PostPlantRequest postReq = new PostPlantRequest()
                .plantName("Main Factory")
                .location("Tokyo");
            APIResponsePlantResponse postRes = apiInstance.postPlant(postReq);
            String plantId = postRes.getData().getPlantId();

            // プラントの詳細取得
            Object detail = apiInstance.getPlant(plantId);
            System.out.println("Plant Detail: " + detail);

            // プラントの状態更新
            PutPlantStatusRequest statusReq = new PutPlantStatusRequest().status("MAINTENANCE");
            apiInstance.putPlantStatus(plantId, statusReq);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (データ交換ステータスの登録・更新)

Payment API を使用してデータ交換のステータスを登録、または更新する例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.DataExchangeRequest;
import io.github.open_dataspaces.payment.model.DataExchangeStatusRequest;
import io.github.open_dataspaces.payment.model.DataExchangeStatusResponse;
import io.github.open_dataspaces.payment.model.DataExchangeStatus;
import java.util.Arrays;

public class PaymentStatusSample {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);

        String userAgent = "ExampleApp/1.0";
        String xTrace = "trace-001";
        String xKey = "your-api-key";

        try {
            // ステータスの登録
            DataExchangeRequest regReq = new DataExchangeRequest()
                .trackingId("track-1")
                .providerId("prov-1")
                .consumerId("cons-1")
                .dataIdList(Arrays.asList("d1"))
                .status(DataExchangeStatus.COMPLETED);
            
            apiInstance.registerDataExchangeStatusApiV1DataExchangeStatusPost(
                userAgent, xTrace, "application/json", xKey, regReq, "ja"
            );

            // ステータスの更新
            DataExchangeStatusRequest upReq = new DataExchangeStatusRequest()
                .status(DataExchangeStatus.COMPLETED);
            apiInstance.updateDataExchangeStatusApiV1DataExchangeStatusPut(
                userAgent, xTrace, "application/json", xKey, upReq, "ja"
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (手数料モデルの管理)

手数料モデルの一覧取得、登録、更新、削除を行う例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.*;
import java.time.OffsetDateTime;

public class PaymentFeeModelSample {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);
        String xKey = "your-api-key";

        try {
            // 一覧取得
            FeeModelListResponse list = apiInstance.listFeeModelsApiV1FeeModelGet("App", "t1", "app/json", xKey, "ja");
            
            // 登録
            FeeModelCreateRequest createReq = new FeeModelCreateRequest()
                .feeModelName("New Plan")
                .providerId("p1")
                .validFrom(OffsetDateTime.now());
            FeeModelResponse created = apiInstance.createFeeModelApiV1FeeModelPost("App", "t2", "app/json", xKey, createReq, "ja");

            // 更新
            FeeModelUpdateRequest updateReq = new FeeModelUpdateRequest().feeModelName("Updated Plan");
            apiInstance.updateFeeModelApiV1FeeModelFeeModelIdPut(created.getFeeModelId(), "App", "t3", "app/json", xKey, updateReq, "ja");

            // 削除
            apiInstance.deleteFeeModelApiV1FeeModelFeeModelIdDelete(created.getFeeModelId(), "App", "t4", "app/json", xKey, "ja");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (請求・支払スケジュールの取得)

請求予定および支払予定を取得する例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.*;
import java.time.LocalDate;

public class PaymentScheduleSample {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);
        String xKey = "your-api-key";

        try {
            // 請求スケジュール
            BillingScheduleRequest billReq = new BillingScheduleRequest()
                .consumerId("c1").startDate(LocalDate.now()).endDate(LocalDate.now().plusMonths(1));
            apiInstance.getBillingScheduleApiV1BillingPost("App", "t1", "app/json", xKey, billReq, "ja");

            // 支払スケジュール
            PaymentScheduleRequest payReq = new PaymentScheduleRequest()
                .providerId("p1").startDate(LocalDate.now()).endDate(LocalDate.now().plusMonths(1));
            apiInstance.getPaymentScheduleApiV1PaymentPost("App", "t2", "app/json", xKey, payReq, "ja");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (取引資格の確認)

データ交換の取引が可能かどうかを確認する例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.TransactionEligibilityRequest;
import io.github.open_dataspaces.payment.model.TransactionEligibilityResponse;
import java.util.Arrays;

public class PaymentCheckEligibility {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);

        TransactionEligibilityRequest request = new TransactionEligibilityRequest()
            .providerId("provider-123")
            .consumerId("consumer-456")
            .dataIdList(Arrays.asList("data-001"));

        try {
            TransactionEligibilityResponse result = apiInstance.checkTransactionEligibilityApiV1DataExchangeTransactionEligibilityPost(
                "ExampleApp/1.0", "trace-004", "application/json", "your-api-key", request, "ja"
            );
            System.out.println("Is Eligible: " + result.getIsEligible());
        } catch (Exception e) {
            System.err.println("Exception when calling DefaultApi#checkTransactionEligibilityApiV1DataExchangeTransactionEligibilityPost");
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (取引資格の確認)

データ交換の取引が可能かどうかを確認する例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.TransactionEligibilityRequest;
import io.github.open_dataspaces.payment.model.TransactionEligibilityResponse;
import java.util.Arrays;

public class PaymentCheckEligibility {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);

        TransactionEligibilityRequest request = new TransactionEligibilityRequest()
            .providerId("provider-123")
            .consumerId("consumer-456")
            .dataIdList(Arrays.asList("data-001"));

        try {
            TransactionEligibilityResponse result = apiInstance.checkTransactionEligibilityApiV1DataExchangeTransactionEligibilityPost(
                "ExampleApp/1.0", "trace-004", "application/json", "your-api-key", request, "ja"
            );
            System.out.println("Is Eligible: " + result.getIsEligible());
        } catch (Exception e) {
            System.err.println("Exception when calling DefaultApi#checkTransactionEligibilityApiV1DataExchangeTransactionEligibilityPost");
            e.printStackTrace();
        }
    }
}

Payment API の利用例 (非手数料モデル取引)

手数料が発生しないモデルでの取引資格確認とデータ交換確定の例です。

import io.github.open_dataspaces.payment.ApiClient;
import io.github.open_dataspaces.payment.api.DefaultApi;
import io.github.open_dataspaces.payment.model.*;
import java.util.Arrays;

public class PaymentNonFeeSample {
    public static void main(String[] args) {
        ApiClient client = new ApiClient();
        client.setBasePath("https://payment.example.com");

        DefaultApi apiInstance = new DefaultApi(client);
        String xKey = "your-api-key";

        try {
            // 取引資格確認 (非手数料)
            TransactionEligibilityNonFeeModelRequest eligReq = new TransactionEligibilityNonFeeModelRequest()
                .providerId("p1").consumerId("c1").dataIdList(Arrays.asList("d1"));
            apiInstance.checkTransactionEligibilityNonFeeModelApiV1DataExchangeNonFeeModelTransactionEligibilityPost(
                "App", "t1", "app/json", xKey, eligReq, "ja"
            );

            // データ交換の確定
            DataExchangeNonFeeModelConfirmRequest confReq = new DataExchangeNonFeeModelConfirmRequest()
                .trackingId("tr-100").providerId("p1").consumerId("c1").dataIdList(Arrays.asList("d1"));
            // ※メソッド名は仕様により異なります
            apiInstance.confirmDataExchangeApiV1DataExchangeNonFeeModelConfirmPost(
                "App", "t2", "app/json", xKey, confReq, "ja"
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

トラブルシューティング & ヒント

  • 生成コードが Java 11 以上を要求する場合、ビルドに使う JDK のバージョンを確認してください。

ライセンス

  • 本リポジトリはMITライセンスで提供されています。
  • ソースコードおよび関連ドキュメントの著作権は株式会社NTTデータグループ、株式会社NTTデータに帰属します。

免責事項

  • 本リポジトリの内容は予告なく変更・削除する可能性があります。
  • 本リポジトリの利用により生じた損失及び損害等について、いかなる責任も負わないものとします。

About

ODS SDK for Onboarding - Java client library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages