Skip to content

TypeScript SDK Quick Start

This document provides a quick start guide for using TypeScript SDK for 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 make requests using TypeScript SDK, you need to initialize a Client instance. This article creates a Client by loading default configurations. For more configuration options for the client, please refer to Configure Client.

Prerequisites

  • Registered upgradeLink account.
  • Obtained AccessKey and AccessSecret.
  • Configured URL application upgrade strategy.

Obtain Credentials

img.jpg

Install SDK

Execute the following command to install the SDK:

npm install @toolsetlink/upgradelink-api-typescript

Verify SDK

You can use the following command to verify the installation and check its version:

 npm view @toolsetlink/upgradelink-api-typescript versions

A successful return example is shown below, which indicates that you have successfully installed:

 1.5.0

Quick Usage

The following example program demonstrates how to initialize a Client and retrieve the latest upgrade information for a URL application.

Get URL Application Latest Upgrade Information

typescript
const {
    default: Client,
    Config,
    UrlUpgradeRequest,
} = require('@toolsetlink/upgradelink-api-typescript');


// Test getting URL upgrade information
async function testGetUrlUpgrade() {
    try {
         // Initialize client
        const config = new Config({
            accessKey:  'mui2W50H1j-OC4xD6PgQag',
            accessSecret: 'PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc',
        });
        const client = new Client(config);

        // Construct request parameters
        const request = new UrlUpgradeRequest({
            urlKey: 'uJ47NPeT7qjLa1gL3sVHqw',
            versionCode: 1,
            appointVersionCode: 0,
            devModelKey: '',
            devKey: ''
        });

        // Send request
        const response = await client.UrlUpgrade(request);

        // Print response results
        console.log('\nURL upgrade information response:');
        console.log(`code: ${response.code}`);
        console.log(`msg: ${response.msg}`);
        console.log('data:');
        console.log(`  urlKey: ${response.data.urlKey}`);
        console.log(`  versionName: ${response.data.versionName}`);
        console.log(`  versionCode: ${response.data.versionCode}`);
        console.log(`  urlPath: ${response.data.urlPath}`);
        console.log(`  upgradeType: ${response.data.upgradeType}`);
        console.log(`  promptUpgradeContent: ${response.data.promptUpgradeContent}`);
    } catch (error) {
        console.error('\nFailed to get URL upgrade information:', error);
    }
}

toolsetlink@163.com