Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

779 sdk readme fixes #781

Merged
merged 8 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 127 additions & 72 deletions packages/restapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,11 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
- [Push core contract address](#push-core-contract-address)
- [Push communicator contract address](#push-communicator-contract-address)
- [SDK Features](#sdk-features)
- [For Video](#for-video)
- [Instance Variables](#instance-variables)
- [peerInstance](#peerinstance)
- [signer](#signer)
- [chainId](#chainid)
- [pgpPrivateKey](#pgpprivatekey)
- [env](#env)
- [data](#data)
- [setData](#setdata)
- [Methods](#methods)
- [constructor](#constructor)
- [create](#create)
- [request](#request)
- [acceptRequest](#acceptrequest)
- [connect](#connect)
- [disconnect](#disconnect)
- [enableVideo](#enablevideo)
- [enableAudio](#enableaudio)
- [isInitiator](#isinitiator)
- [For Spaces](#for-spaces)
- [To create a space](#to-create-a-space)
- [To create a token gated space](#to-create-a-token-gated-space)
- [To check user access of a token gated space](#to-check-user-access-of-a-token-gated-space)
- [To update space details](#to-update-space-details)
- [To update token gated space details](#to-update-token-gated-space-details)
- [To get space details by spaceId](#to-get-space-details-by-spaceid)
- [To start a space](#to-start-a-space)
- [To stop a space](#to-stop-a-space)
- [To approve a space request](#to-approve-a-space-request)
- [To add listeners to space](#to-add-listeners-to-space)
- [To remove listeners from space](#to-remove-listeners-from-space)
- [To add speakers to space](#to-add-speakers-to-space)
- [To remove speakers from space](#to-remove-speakers-from-space)
- [Fetching list of user spaces](#fetching-list-of-user-spaces)
- [Fetching list of user space requests](#fetching-list-of-user-space-requests)
- [Fetching list of trending spaces](#fetching-list-of-trending-spaces)
- [PushChat Class](#pushapi-class)
- [PushChat Class](#pushchat-class)
- [Initialize](#initialize)
- [Fetch Info](#fetch-info)
- [Fetch Profile Info](#fetch-profile-info)
- [Update Profile Info](#update-profile)
- [Update Profile Info](#update-profile-info)
- [Fetch Latest Chat](#fetch-latest-chat)
- [Fetch Chat History](#fetch-chat-history)
- [Send Message](#send-message)
Expand All @@ -67,9 +31,9 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
- [Block Chat User](#block-chat-user)
- [Unblock Chat User](#unblock-chat-user)
- [Create Group](#create-group)
- [Fetch Group Info](#fetcg-group-info)
- [Fetch Group Info](#fetch-group-info)
- [Fetch Group Permission](#fetch-group-permissions)
- [Update Group Info](#update-group-info)
- [Update Group](#update-group)
- [Add To Group](#add-to-group)
- [Remove From Group](#remove-from-group)
- [Join Group](#join-group)
Expand All @@ -92,13 +56,48 @@ This package gives access to Push Protocol (Push Nodes) APIs. Visit [Developer D
- [Create a channel](#create-a-channel)
- [Update channel information](#update-channel-information)
- [Verify a channel](#verify-a-channel)
- [Create channel Setting (WIP)](#create-channel-setting-(wip))
- [Create channel Setting (WIP)](#create-channel-setting)
- [Get delegators information](#get-delegators-information)
- [Add delegator to a channel or alias](#add-delegator-to-a-channel-or-alias)
- [Remove delegator from a channel or alias](#remove-delegator-from-a-channel-or-alias)
- [Alias Information](#alias-information)
- [Stream Notifications](#stream-notifications)

- [For Video](#for-video)
- [Instance Variables](#instance-variables)
- [peerInstance](#peerinstance)
- [signer](#signer)
- [chainId](#chainid)
- [pgpPrivateKey](#pgpprivatekey)
- [env](#env)
- [data](#data)
- [setData](#setdata)
- [Methods](#methods)
- [constructor](#constructor)
- [create](#create)
- [request](#request)
- [acceptRequest](#acceptrequest)
- [connect](#connect)
- [disconnect](#disconnect)
- [enableVideo](#enablevideo)
- [enableAudio](#enableaudio)
- [isInitiator](#isinitiator)
- [For Spaces](#for-spaces)
- [To create a space](#to-create-a-space)
- [To create a token gated space](#to-create-a-token-gated-space)
- [To check user access of a token gated space](#to-check-user-access-of-a-token-gated-space)
- [To update space details](#to-update-space-details)
- [To update token gated space details](#to-update-token-gated-space-details)
- [To get space details by spaceId](#to-get-space-details-by-spaceid)
- [To start a space](#to-start-a-space)
- [To stop a space](#to-stop-a-space)
- [To approve a space request](#to-approve-a-space-request)
- [To add listeners to space](#to-add-listeners-to-space)
- [To remove listeners from space](#to-remove-listeners-from-space)
- [To add speakers to space](#to-add-speakers-to-space)
- [To remove speakers from space](#to-remove-speakers-from-space)
- [Fetching list of user spaces](#fetching-list-of-user-spaces)
- [Fetching list of user space requests](#fetching-list-of-user-space-requests)
- [Fetching list of trending spaces](#fetching-list-of-trending-spaces)
# How to use in your app?

## Installation
Expand Down Expand Up @@ -783,7 +782,7 @@ export interface Rules {

---

### **To check user access of a token gated group**
### **To check user access of a token gated space**

```typescript

Expand Down Expand Up @@ -2587,23 +2586,51 @@ const spaces = await PushAPI.space.trending({

```typescript
// Initialize PushAPI class instance
const userAlice = await PushAPI.initialize(signer);
const userAlice = await PushAPI.initialize(signer, {
env: ENV.LOCAL,
streamOptions: { raw: true },
});
```

| Param | Type | Default | Remarks |
| ------------------------ | -------------------------------------- | ------------- | -------------------------------------------------------------------------------------- |
| `signer` | `SignerType` | - | EthersV5 or Viem Signer |
| `options` \* | `PushAPIInitializeProps` | - | Optional configuration properties for initializing the PushAPI. |
| `options.env` \* | `ENV` | `staging` | API env - 'prod', 'staging', 'dev' |
| `options.progressHook`\* | `(progress: ProgressHookType) => void` | - | A callback function to receive progress updates during initialization. |
| `options.account` \* | `string` | - | The account to associate with the PushAPI. If not provided, it is derived from signer. |
| `options.version` \* | `string` | `ENC_TYPE_V3` | The encryption version to use for the PushAPI |
| `options.versionMeta` \* | `{ NFTPGP_V1 ?: password: string }` | - | Metadata related to the encryption version, including a password if needed. |
| `options.autoUpgrade` \* | `boolean` | `true` | If `true`, upgrades encryption keys to latest encryption version |
| `options.origin` \* | `string` | - | Specify origin or source while creating a Push Profile |


## Parameters

| Param | Type | Default | Remarks |
| --------------------------------------- | ------------------------------------------------- | ------------- | -------------------------------------------------------------------------------------- |
| `signer` | `SignerType` | - | EthersV5 or Viem Signer. |
| `options` \* | `PushAPIInitializeProps` | - | Optional configuration properties for initializing the PushAPI. |
| `options.env` \* | `ENV` | `staging` | API env - 'prod', 'staging', 'dev'. |
| `options.progressHook`\* | `(progress: ProgressHookType) => void` | - | A callback function to receive progress updates during initialization. |
| `options.account` \* | `string` | - | The account to associate with the PushAPI. If not provided, it is derived from signer. |
| `options.version` \* | `string` | `ENC_TYPE_V3` | The encryption version to use for the PushAPI. |
| `options.versionMeta` \* | `{ NFTPGP_V1 ?: password: string }` | - | Metadata related to the encryption version, including a password if needed. |
| `options.autoUpgrade` \* | `boolean` | `true` | If `true`, upgrades encryption keys to the latest encryption version. |
| `options.origin` \* | `string` | - | Specify origin or source while creating a Push Profile. |
| `options.streamOptions` \* | `PushStreamInitializeProps` | - | Configuration options for the stream. |
| `options.streamOptions.listen` \* | `STREAM[]` | - | Specifies which streams to listen to. |
| `options.streamOptions.filter` \* | `{ channels?: string[]; chats?: string[]; }` | - | Specifies which channels or chats to filter for. |
| `options.streamOptions.connection` \* | `{ auto?: boolean; retries?: number; }` | - | Connection settings, including auto-connect and number of retries. |
| `options.streamOptions.raw` \* | `boolean` | - | If set to `true`, will provide raw stream data. |
| `options.streamOptions.enabled` \* | `boolean` | - | Specifies if the stream is enabled or not. |




\* - Optional

## STREAM Options

| Option | Value |
|-----------------------|------------------------|
| `PROFILE` | `STREAM.PROFILE` |
| `ENCRYPTION` | `STREAM.ENCRYPTION` |
| `NOTIF` | `STREAM.NOTIF` |
| `NOTIF_OPS` | `STREAM.NOTIF_OPS` |
| `CHAT` | `STREAM.CHAT` |
| `CHAT_OPS` | `STREAM.CHAT_OPS` |


---

### **Fetch Info**
Expand Down Expand Up @@ -5465,23 +5492,51 @@ const aliceUpdateEncryption = await userAlice.encryption.update(

```typescript
// Initialize PushAPI class instance
const userAlice = await PushAPI.initialize(signer);
const userAlice = await PushAPI.initialize(signer, {
env: ENV.LOCAL,
streamOptions: { raw: true },
});
```

| Param | Type | Default | Remarks |
| ------------------------ | -------------------------------------- | ------------- | -------------------------------------------------------------------------------------- |
| `signer` | `SignerType` | - | EthersV5 or Viem Signer |
| `options` \* | `PushAPIInitializeProps` | - | Optional configuration properties for initializing the PushAPI. |
| `options.env` \* | `ENV` | `staging` | API env - 'prod', 'staging', 'dev' |
| `options.progressHook`\* | `(progress: ProgressHookType) => void` | - | A callback function to receive progress updates during initialization. |
| `options.account` \* | `string` | - | The account to associate with the PushAPI. If not provided, it is derived from signer. |
| `options.version` \* | `string` | `ENC_TYPE_V3` | The encryption version to use for the PushAPI |
| `options.versionMeta` \* | `{ NFTPGP_V1 ?: password: string }` | - | Metadata related to the encryption version, including a password if needed. |
| `options.autoUpgrade` \* | `boolean` | `true` | If `true`, upgrades encryption keys to latest encryption version |
| `options.origin` \* | `string` | - | Specify origin or source while creating a Push Profile |


## Parameters

| Param | Type | Default | Remarks |
| --------------------------------------- | ------------------------------------------------- | ------------- | -------------------------------------------------------------------------------------- |
| `signer` | `SignerType` | - | EthersV5 or Viem Signer. |
| `options` \* | `PushAPIInitializeProps` | - | Optional configuration properties for initializing the PushAPI. |
| `options.env` \* | `ENV` | `staging` | API env - 'prod', 'staging', 'dev'. |
| `options.progressHook`\* | `(progress: ProgressHookType) => void` | - | A callback function to receive progress updates during initialization. |
| `options.account` \* | `string` | - | The account to associate with the PushAPI. If not provided, it is derived from signer. |
| `options.version` \* | `string` | `ENC_TYPE_V3` | The encryption version to use for the PushAPI. |
| `options.versionMeta` \* | `{ NFTPGP_V1 ?: password: string }` | - | Metadata related to the encryption version, including a password if needed. |
| `options.autoUpgrade` \* | `boolean` | `true` | If `true`, upgrades encryption keys to the latest encryption version. |
| `options.origin` \* | `string` | - | Specify origin or source while creating a Push Profile. |
| `options.streamOptions` \* | `PushStreamInitializeProps` | - | Configuration options for the stream. |
| `options.streamOptions.listen` \* | `STREAM[]` | - | Specifies which streams to listen to. |
| `options.streamOptions.filter` \* | `{ channels?: string[]; chats?: string[]; }` | - | Specifies which channels or chats to filter for. |
| `options.streamOptions.connection` \* | `{ auto?: boolean; retries?: number; }` | - | Connection settings, including auto-connect and number of retries. |
| `options.streamOptions.raw` \* | `boolean` | - | If set to `true`, will provide raw stream data. |
| `options.streamOptions.enabled` \* | `boolean` | - | Specifies if the stream is enabled or not. |




\* - Optional

## STREAM Options

| Option | Value |
|-----------------------|------------------------|
| `PROFILE` | `STREAM.PROFILE` |
| `ENCRYPTION` | `STREAM.ENCRYPTION` |
| `NOTIF` | `STREAM.NOTIF` |
| `NOTIF_OPS` | `STREAM.NOTIF_OPS` |
| `CHAT` | `STREAM.CHAT` |
| `CHAT_OPS` | `STREAM.CHAT_OPS` |


---

### **Fetch Inbox Or Spam notifications**
Expand Down Expand Up @@ -6328,7 +6383,7 @@ const searchResult = await userAlice.channel.search("push")

---

### **Get a channel's subscribers**
### **Get Subscribers Of A Channel**

```tsx
// fetches subscribers of a channel
Expand Down Expand Up @@ -6451,7 +6506,7 @@ const createChannelRes = await userAlice.channel.create({name: channelName, desc

---

### **Update a channel's information**
### **Update channel information**

```tsx
// updates channel info
Expand Down Expand Up @@ -6509,7 +6564,7 @@ const verifyChannelRes = await userAlice.channel.verify(channelToBeVerified)

---

### **Create channel Setting (WIP)**
### **Create channel Setting**

```tsx
// creates channel settings
Expand Down Expand Up @@ -6571,7 +6626,7 @@ const delegatorsInfo = userAlice.channel.delegate.get()

---

### **Add delegator to a channel/alias**
### **Add delegator to a channel or alias**

```tsx
// adds a delegate
Expand All @@ -6597,7 +6652,7 @@ const addDelegatorRes = userAlice.channel.delegate.add(delegatorAddressInCAIP)

---

### **Remove delegator from a channel/alias**
### **Remove delegator from a channel or alias**

```tsx
// removes a delegate
Expand Down
5 changes: 4 additions & 1 deletion packages/restapi/src/lib/pushapi/PushAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ export class PushAPI {
decryptedPGPPrivateKey,
signer,
settings.progressHook,
settings.streamOptions
{
...settings.streamOptions,
env: settings.env, // Use the env from the top-level PushAPIInitializeProps
}
);
if (streamInstance) {
api.stream = streamInstance;
Expand Down