Skip to content

Java SDK Quick Start

This document provides a quick start guide for using Java SDK to perform common operations. You will learn how to install the SDK, configure access credentials, and perform basic operations such as retrieving the latest upgrade information.

Notes

  • To initiate requests using Java SDK, you need to initialize a Client instance. This document creates a Client by loading default configurations. For more configuration options for the client, please refer to Configuring Client.

Prerequisites

  • Have registered an upgradeLink account.
  • Obtained AccessKey and AccessSecret.
  • Configured URL application upgrade strategy.

Obtain Credentials

img.jpg

Install SDK

  • Java 7 or above has been installed. Check the Java version using the following command.
shell
  java -version

If there is no Java or the version is lower than Java 7 in the current computing environment, please download Java.

  • Add dependencies in Maven project (recommended method) To use Java SDK in Maven project, just add the corresponding dependency in pom.xml. Take adding dependency of version 1.0.0 in <dependencies> as an example:
xml
  <dependency>
    <groupId>io.github.toolsetlink</groupId>
    <artifactId>upgradelink-api-java</artifactId>
    <version>1.6.0</version>
  </dependency>

Quick Usage

The following sample program demonstrates how to initialize Clint and retrieve the latest upgrade information for URL applications.

Get URL Application Latest Upgrade Information

java
package com.toolsetlink.upgradelink.api;

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

public class ClientTest {

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

    @Test
    public void testGetUrlUpgrade() throws Exception {
        // Create Client object
        Client client = new Client(accessKeyId, accessKeySecret);

        UrlUpgradeRequest request = new UrlUpgradeRequest();
        request.setUrlKey("uJ47NPeT7qjLa1gL3sVHqw");
        request.setVersionCode(1);
        request.setAppointVersionCode(0);
        request.setDevKey("");
        request.setDevModelKey("");

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

        System.out.println("testGetUrlUpgrade end");

    }

}

A successful return example is as follows:

0
Already the latest version
null
testGetUrlUpgrade end

toolsetlink@163.com