Skip to content

Java イベント報告インターフェース

報告されたイベントタイプのデータは、システムの統計データに反映されます。

リクエストパラメータ一覧

パラメータ名説明
requestAppReportRequest特定のインターフェースリクエストパラメータを設定します。イベント報告を参照してください

戻り値一覧

戻り値名説明
resultAppReportResponseインターフェースの戻り値、err が nil の場合に有効、具体的なインターフェースの戻りパラメータについては、イベント報告を参照してください

ユニットテストコードの場所

サンプルコード

以下のコードを使用して、最新のアップグレード戦略を取得できます。

java
package com.toolsetlink.upgradelink.api;  // パッケージ名はテスト対象のクラスと同じでなければなりません

import com.toolsetlink.upgradelink.api.models.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ClientTest {  // クラス名 = テスト対象のクラス名 + Test

    private final String accessKey = "mui2W50H1j-OC4xD6PgQag";
    private final String accessSecret = "PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc";
    private Client client;

    @BeforeEach
    void setUp() throws Exception {
        Config config = new Config();
        config.setAccessKey(accessKey);
        config.setAccessSecret(accessSecret);
        client = new Client(config);
    }

    // イベント報告インターフェースの取得をテスト
    // /* app_start アプリケーション - 起動イベント */
    @Test
    public void testPostAppReport() throws Exception {

        /*  app_start アプリケーション - 起動イベント */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_START);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setLaunchTime(Tools.timeRFC3339())
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }

    // イベント報告インターフェースの取得をテスト
    // /* app_upgrade_download アプリケーションアップグレード - ダウンロードイベント */
    @Test
    public void testPostAppReport1() throws Exception {

        /*  app_upgrade_download アプリケーションアップグレード - ダウンロードイベント */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_UPGRADE_DOWNLOAD);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setDownloadVersionCode(2)
                .setCode(0)
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }

    // イベント報告インターフェースの取得をテスト
    // /* app_upgrade_upgrade アプリケーションアップグレード - アップグレードイベント */
    @Test
    public void testPostAppReport2() throws Exception {

        /*  app_upgrade_upgrade アプリケーションアップグレード - アップグレードイベント */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_UPGRADE_UPGRADE);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setUpgradeVersionCode(2)
                .setCode(0)
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }
}

toolsetlink@163.com