Skip to content

Commit

Permalink
Merge pull request #2 from kailash-bitpack/SKIT-188
Browse files Browse the repository at this point in the history
added deprecated apis and new api versions
  • Loading branch information
r4881t authored Jun 15, 2023
2 parents fc58e4d + a49559d commit 22a9714
Show file tree
Hide file tree
Showing 120 changed files with 5,300 additions and 1,103 deletions.
210 changes: 20 additions & 190 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
## @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](https://github.com/merokudao/storekit/blob/main/apps/docs/public/api-specs/meroku-server.yml) and hosted at [https://docs-a.meroku.store](https://docs-a.meroku.store).
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](https://github.com/merokudao/storekit/blob/main/apps/docs/public/api-specs/meroku-server.yml) and hosted at [https://docs.meroku.store](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.20, then the package should be `1.20`.
v 1.21, then the package should be `1.21`.

**T O C**

- [Install](#install)
- [Check Permissions](#check-permissions)
* [Initialize](#initialize)
* [Get the app install URL](#get-the-app-install-url)
* [Check if the user has installed app](#check-if-the-user-has-installed-app)
- [Registry Use](#registry-use)
- [Analytics](#analytics)
* [Visit a dApp's Home Page](#visit-a-dapp-s-home-page)
* [Download a dApp's Build](#download-a-dapp-s-build)
* [Post a rating for dapp by user](#post-a-rating-for-dapp-by-user)
* [Get a rating for dapp by user](#get-a-rating-for-dapp-by-user)
- [Featured Section](#featured-section)
* [Add a featured section](#add-a-featured-section)
* [Delete a featured section](#delete-a-featured-section)
* [Get Featured Sections and the dapps in them.](#get-featured-sections-and-the-dapps-in-them)
* [Get Store Title](#get-store-title)
* [Toggle dapps in a featured section.](#toggle-dapps-in-a-featured-section)


# Install

Expand All @@ -36,51 +30,6 @@ or
`yarn add @merokudao/storekit-sdk`


# Check Permissions

You should check if the user has installed github app or not.

## Initialize

```typescript
import { UserPermissionsApi } from '@merokudao/storekit-sdk';

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

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

```

## Get the app install URL

```typescript

const installURL = await userPermissionsApi.appInstallUrlGet();

// installURL -> { "url": "https://github.com/apps/app-name/installations/new" }
```

## Check if the user has installed app

```typescript
const githubID = "get-this-from-logged-in-user";
const installed = await userPermissionsApi.appGhIDInstalledGet(githubID);

// installed -> { "isInstalled": true }

if (installed.isInstalled) {
// all good
} else {
redirect_to(installURL)
}
```

# Registry Use

Expand All @@ -95,7 +44,7 @@ import {
DappWithDevCreds
} from '@merokudao/storekit-sdk';

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

// Configure the API and instantiate
const dAppRegistryAPI = new DAppRegistryApi(
Expand All @@ -107,79 +56,16 @@ const dAppRegistryAPI = new DAppRegistryApi(
);

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

// Search for dApps using a search string
const dApps: Dapp[] = await dAppRegistryAPI.getDApp("nft marketplace");
const dApps: Dapp[] = await dAppRegistryAPI.getDAppV1("nft marketplace");

// Optionally provide filters for search
const dApps: Dapp[] = await dAppRegistryAPI.getDApp("nft marketplace", chainId: 137);

// Add a dApp to registry
const dev: DappDeveloper = {
legalName: 'John Doe & Sons',
logo: 'https://www.example.com/some-image.png',
website: 'https://www.example.com',
privacyPolicyUrl: 'https://www.example.com/privacy',
support: {
url: 'https://www.example.com/support'
},
githubID: 'github-id-of-dev'
};

const dApp: Dapp = {
name: 'Coolest NFT Maker Place',
description: 'A really cool NFT Maker site that you will love.',
dappId: 'example.merokudao.dapp',
minAge: 18,
isMatureForAudience: false,
isSelfModerated: true,
language: 'en',
version: '0.0.1',
isListed: true,
listDate: (new Date()).toISOString(),
availableOnPlatform: DappAvailableOnPlatformEnum.Web,
developer: dev,
tags: ['nft-maker', 'polygon'],
chains: [1],
category: DappCategoryEnum.SocialNetworking
};

const name = 'github-dev-name';
const email = 'github-dev-email';
const token = 'github-jwt-access-token';
const githubID = 'github-id-of-dev';

const reqBody: DappWithDevCreds = {
name: name,
email: email,
accessToken: token,
githubID: githubID,
dapp: dApp
};

const prURL = await dAppRegistryAPI.addDApp(reqBody);

// prURL contains a URL which will lead to creation of PR. The user should be shown this URL on UI
// and asked to click it.


// Update dApp also has similar req body. So if you want to update the name
reqBody.dapp.name = 'new Name';
const prURL = await dAppRegistryAPI.updateDApp(reqBody);

// Delete dApp has a diff req body
reqBodyDel: DappIdWithDevCreds = {
name: name,
email: email,
accessToken: token,
githubID: githubID,
dappId: '.dapp ID to delete'
};
const prURL = await dAppRegistryAPI.deleteDApp(reqBodyDel)

const dApps: Dapp[] = await dAppRegistryAPI.getDAppV1("nft marketplace", chainId: 137);
```


# Analytics

There are URLs that support visit to an app's webapp or download the
Expand All @@ -200,9 +86,9 @@ they will be redirected to the dapp home page.
```typescript


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

const dappId = "dapp.example.dapp";
const dappId = "example.app";

const getViewURL = (base_path: string,
dappId: string,
Expand All @@ -213,9 +99,9 @@ const getViewURL = (base_path: string,
}

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

Expand All @@ -237,9 +123,9 @@ const getDownloadURL = (base_path: string,
}

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

Expand All @@ -261,23 +147,23 @@ const analyticsApi = new AnalyticsApi({
});

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

```

## Get a rating for dapp by user

```typescript

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

```

Expand All @@ -292,44 +178,10 @@ const featuredApi = new FeaturedSectionApi({

```

## Add a featured section

```typescript
const body: FeaturedSectionAddReq = {
name: '',
email: '',
accessToken: '',
githubID: '',
sectionTitle: '' // title of the section to be added,
description: '',
dappIds: [
''
]
}
const prURL = await featuredApi.putFeaturedSection(body);
```

Once the PR is merged, a "key" of the section will be generated. This is
essentially `slugify(sectionTitle)`. In any call to update / delete the
featured section, key must be provided.

## Delete a featured section

```typescript
const body: FeaturedSectionDelReq = {
name: '',
email: '',
accessToken: '',
githubID: '',
sectionKey: '' // key of the section to be deleted
};
await featuredApi.deleteFeaturedSection(body);
```

## Get Featured Sections and the dapps in them.

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

This should be iterated and shown on ui.
Expand All @@ -339,27 +191,5 @@ This should be iterated and shown on ui.
Gets the title of the registry

```typescript
const title: string = await featuredApi.getStoreTitle()
```

## Toggle dapps in a featured section.

Note that this is a toggle function. If the dapps provided
by field `dappIds` does not exist in this section, they will be added.
If they exist, they will be removed.

```typescript

const body: FeaturedDAppsAddReq = {
name: '',
email: '',
accessToken: '',
githubID: '',
sectionKey: '',
dappIds: [
''
]

};
const prURL = await featuredApi.putFeaturedDApps(body);
const title: string = await featuredApi.getStoreTitleV1()
```
3 changes: 2 additions & 1 deletion api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* Meroku API Documentation
* Open API specs for Meroku APIs. These APIs are required to inteact with the registry in a safe, easy way. The recommended way to use in a project is to use the npm package published at [@merokudao/storekit-sdk](https://www.npmjs.com/package/@merokudao/storekit-sdk). This npmjs package is a wrapper around the api. You would still want to use the APIs if you're building on a different platform. # Authentication - To learn more on Authentication and the benefits of using higher rate limit, [read this Meroku.xyz blog post](https://meroku.xyz/2023/06/08/meroku-api-updates/). - To request an API key [fill this developer access form](https://form.jotform.com/231576486954067) - You can try this UI without getting any API Key as well # Learn More - [How to build a dApp Store using Meroku APIs](https://docs.meroku.org/dapp-store-kit-docs/for-dapp-store-builders#api--sdk-1) - [Meroku Blog](https://meroku.xyz) # Support - [Support Discourse Group](https://meroku.discourse.group) # Stay Connected - [Follow us on Github](https://github.com/merokudao) - [Follow us on Twitter](https://twitter.com/MerokuStore)
*
* OpenAPI spec version: 1.20
* OpenAPI spec version: 1.21
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/export * from './apis/analytics-api';
export * from './apis/dapp-registry-api';
export * from './apis/deprecated-apiapi';
export * from './apis/domain-verification-api';
export * from './apis/featured-section-api';
export * from './apis/store-registry-api';
Expand Down
Loading

0 comments on commit 22a9714

Please sign in to comment.