1.27.0 • Published 9 months ago

@merokudao/storekit-sdk v1.27.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@merokudao/storekit-sdk

This is the NodeJS Typescript SDK for API described at https://github.com/merokudao/storekit/blob/main/apps/docs/public/api-specs/meroku-server.yml and hosted at https://docs.meroku.store.

This package is generated using Swagger CodeGen. More details on that follows the usage section.

The versioning of this package is consistent with the API spec version. So if you are using OpenAPI Spec v 1.21, then the package should be 1.21.

T O C

Install

npm install @merokudao/storekit-sdk

or

yarn add @merokudao/storekit-sdk

Registry Use

import {
  DAppRegistryApi,
  Dapp,
  DappAvailableOnPlatformEnum,
  StoreRegistryApi,
  DappCategoryEnum,
  DappWithDevCreds,
  DeveloperProfilesApi,
} from '@merokudao/storekit-sdk';

const baseURL = process.env.STOREKIT_API_URL as string | 'https://api.meroku.store';

// Configure the API and instantiate
const dAppRegistryAPI = new DAppRegistryApi(
  {
    basePath: baseURL
  },
  undefined,
  undefined
);

// Get the dApps list
const dApps: Dapp[] = await dAppRegistryAPI.searchDapps();

Analytics

There are URLs that support visit to an app's webapp or download the build for an app. These methods should be used instead of raw linking, because these store details about visits, downloads, installs and uninstalls. These metrics are used to prepare trending dapps.

Getting a dapp will always send it's global metrics.

Visit a dApp's Home Page

The URL to visit a dapp's home page should be constructed as below. The return value of getViewURL should be shown on the UI. When user clicks on it, they will be redirected to the dapp home page.

const basePath = process.env.STOREKIT_API_URL as string | 'https://api.meroku.store';

const dappId = "example.app";

const getViewURL = (base_path: string,
  dappId: string,
  userId: string | undefined,
  userAddress: string | undefined) => {
    if (!userId && !userAddress) {
      throw Error("One of userId or userAddress must be defined");
    }

    if (userId) {
      return `${base_path}/api/v1/o/view/${dappId}?userId=${userId}`;
    } else if (userAddress) {
      return `${base_path}/api/v1/o/view/${dappId}?userAddress=${userAddress}`;
    }
}

Download a dApp's Build

AnalyticsApi.new()

const getDownloadURL = (base_path: string,
  dappId: string,
  userId: string | undefined,
  userAddress: string | undefined) => {
    if (!userId && !userAddress) {
      throw Error("One of userId or userAddress must be defined");
    }

    if (userId) {
      return `${base_path}/api/v1/o/download/${dappId}?userId=${userId}`;
    } else if (userAddress) {
      return `${base_path}/api/v1/o/download/${dappId}?userAddress=${userAddress}`;
    }
}

In the UI the return value of getDownloadURL should be shown. When user clicks on it, they will be redirected to the download URL and the file will be automatically downloaded.

Post a rating for dapp by user

const analyticsApi = new AnalyticsApi({
    basePath: baseURL
});

const body: DappRating = {
  dappId: 'test_example.app',
  rating: 4,
  comment: 'comment from user',
  userId: 12
};
const response: DappRating = await analyticsApi.apiV1DappRatePost(body)

Get a rating for dapp by user

const dappId = 'test_example.dapp';
const userId = 2;
const userAddress = undefined;
const response: DappRating = await analyticsApi.apiV1DappRateGet(dappId, userId, userAddress);

Featured Section

Initialise the API as below.

const featuredApi = new FeaturedSectionApi({
	    basePath: baseURL
	});

Get Featured Sections and the dapps in them.

const featuredSections: Array<FeaturedSection> = await featuredApi.getFeaturedDAppsV1()

This should be iterated and shown on ui.

Get Store Title

Gets the title of the registry

const title: string = await featuredApi.getStoreTitleV1()

AppStores

  const storeApi = new StoreRegistryApi()

APis to interact with appStore's

Get/Search appStore's

const stores = await storeApi.searchStores()

Search store by storeId/key

const stores = await storeApi.searchStoresByStoreId('kailash')

Get appStore's by owner address

const stores = await storeApi.searchStoresByOwnerAddress('0xA0B867319e3fBb15181D118097b1069C6380222E')

Search for Autocomplete appStore's search

const stores = await storeApi.autocompleteStores('unstoppable')

Developers

  const developerApi = new DeveloperProfilesApi()

APis to interact with developer's

Get/Search developer's

const developers = await developerApi.searchDeveloperProfile()

Search store by storeId/key

const developers = await developerApi.searchDeveloperByDevId('kai.dev')

Get developer's by owner address

const developers = await developerApi.searchDeveloperByOwnerAddress('0xA0B867319e3fBb15181D118097b1069C6380222E')

Search for Autocomplete developer's search

const developers = await developerApi.autocompleteDeveloper('kai')
1.27.0

9 months ago

0.0.14

12 months ago

1.21.0

11 months ago

1.20.0

11 months ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago