Web SDK
  • Home
  • Overview
  • Getting started
  • References
    • Authentication
    • Account
      • Users
    • Notifications
    • Bookmark
    • 2FA
    • Collection
    • Connection filters
    • Feed
    • File Upload
    • Invite
    • Messaging
    • Payment
    • Reviews
    • Search
    • Verification
      • Supported document type
      • List of expected ISO countries
    • Wallet
      • Withdrawal
  • Tutorial
  • Web API
Powered by GitBook
On this page
  • Create a collection
  • CreateCollectionDto
  • ICollectionDto
  • Create many collections
  • CreateManyCollectionDto
  • Get all collections
  • filterCollectionDto
  • FindCollectionDto
  • Get a collection by ID
  • Get collections by types
  • FindCollectionTypeDto
  • ICollectionTypeDto
  • Get a collection by type
  • Update a collection
  • UpdateCollectionDto
  • Update many collections
  • Delete a collection
  1. References

Collection

Collection refers to a dictionary of information that can be adjusted to meet the needs of the Chainsite business logic.

Previous2FANextConnection filters

Collections are grouped by types, and classified by categories. Collections can have a parent-child relationship, that way, you can set up a tree of information, mapped according to your preferences.

The following features are available to modify Collections to your taste:

The collection feature requires an authorization token.

Create a collection

Creating a collection requires CreateCollectionDto.

CreateCollectionDto

Field
Description
Type
Optional

name

The appellation given to the collection

string

false

category

The classification of the collection

string

true

type

The group that the collection belongs to

string

false

description

Detailed explanation of what the collection is about

string

false

isPrivate

Identifier to check if the collection is private

boolean

false

deliveryDate

Timestamp for the requirements of completing the collection to be met

string

true

tags

Array of labels of the collection

string[]

true

attachments

Array of the identifiers of files uploaded for the collection. To add attachments to a collection, ensure the files have been uploaded to the chainsite storage and append the _id of the uploaded file to this field.

string[]

true

meta

Object that can be customised to suit the business logic and/or user preferences

Record<string, any>

true

paymentFee

For a collection that requires payment to be made, funds to be transferred, this field is key. Enter the amount required to complete the collection

number

parent

Collections can have a parent-child relationship and when such relationship are required, the identifier for the collection, marked as parent is necessary.

string

The authenticated user jwt token is required. Returns ICollectionDto.

ICollectionDto

The ICollectionDto is the model that contains the information that makes up the Collection.

Field
Description
Type

_id

Identification of the collection record

string

creator

User details of the account that created the collection

string | IUser

owner

User details of the account that is a beneficiary to the collection

string | IUser

receiver

User details of the account that accepted an invite to the collection

string | IUser

owners

Array of User details that are beneficiaries to the collection

IUser[]

name

The appellation given to the collection

string

description

Detailed explanation of what the collection is about

string

type

The group that the collection belongs to

string

category

The classification of the collection

string

parent

The Identification of the parent collection in the collection tree. Note that not all collection will need a parent-child relationship, but for collections that do need, this field is for the _id of the collection that is the parent

string

collections

The collections record that belong to this collection in the parent-child

string[] | ICollectionDto[]

image

An uploaded image url of the collection

string

invite

Identifier for the invite sent to another user to be a participant and/or beneficiary of a collection

string | IInviteDto

invites

Array of identifiers of invitation sent out to other users to be participants

string[] | InviteDto[]

wallet

The identifier for the wallet details of the collection, meaning an escrow setup. All and any transaction that is occur with this collection is carried with this wallet. See WalletDto in Wallet for more information

string | WalletDto

attachments

An array of uploaded files for the collection

IAttachmentDto

attachmentData

A string array of identification of the uploaded files

string[]

status

The classification of the collection

ICollectionStatus

inviteAccepted

Identifier to indicate that a user(s) approached to this collection has accepted the invite

boolean

isPrivate

Identifier to indicate the privacy of the collection

boolean

ratings

The identifier for the rankings given to a creator and the participant(s)

string[] | IReviewDto[]

score

The total accumulation of points accrued for the collection

number

progress

The level of growth achieved so far for the collection, based on set objectives and deliverables. The progress is maxed at 100.

number

isDeleted

Identifier to indicate if the collection is deleted

boolean

charges

Identifier to indicate the duties accrued to be transferred to the chainsite wallet address

string

expectedAmount

Value determined to be paid

string

usdExpectedAmount

USD equivalent determined to be paid

string

usdExpectedFee

USD equivalent of the duties to be transferred to the chainsite wallet address

string

rate

The exchange rate for which the fee, value for the collection is determined

string

cancellationReason

Identifier that details the explanation as to why the collection was cancelled or ended.

string

completed

Identifer to indicate whether the collection has met the set objectives or a similar conclusion

boolean

meta

Custom Object that can be updated with information peculiar to the chainsite

Record<string, any>

IAttachmentDto

Field
Description

_id

Identifier for the file uploaded as attachment

string

url

URL of the file uploaded

string

ICollectionStatus

Field
Description

pending

Collection is in its initial state

ongoing

A user invited to the collection has accepted the invite and is now a participant of the collection

waiting

The collection is waiting for the escrow payout to be completed

cancelled

The collection is terminated

completed

Set objectives for the collection is met and achieved

reprocessing

The collection is at the state of executing the escrow transaction

Here is an example of implementing this function:

export const createCollection = async (payload: CreateCollectionDto) => {
  const create: ResponseDto<ICollectionDto> = await sdkInit.collection.create(payload);
};

Create many collections

Users can create many collections, this requires the parent collection id, forming the parent-child relationship.

The CreateManyCollectionDto payload is required, as well as the authenticated user jwt token.

CreateManyCollectionDto

Field
Description
Optional
Type

type

The group that the collection belongs to

false

string

parent

The Identification of the parent collection in the collection tree. Note that not all collection will need a parent-child relationship, but for collections that do need, this field is for the _id of the collection that is the parent

false

string

collections

List of collections to be created

false

CreateCollectionDto[]


export const createManyCollection = async (authToken: string, payload: CreateManyCollectionDto) => {
  const create: ResponseDto<ICollectionDto> = await sdkInit.collection.createMany(authToken, payload);
};

Get all collections

Get all Collections corresponding to an optional filter, otherwise, return ALL collections.

Search using the filterCollectionDto.

filterCollectionDto

The filterCollectionDto is an extension of the ICollectionDto, filter results with the details from ICollectionDto, for brevity, are not detailed here. See ICollectionDto above.

Field
Description

page

The desired page for the list of collections

number

limit

The total required number of collection document

number

receiver

the id of the user that accepted the invite to this collection

string

When a collection is created, the authenticated user is the of the collection. However, invite(s) sent to and accepted by another user, such user is now marked as the owner and can be filtered as the receiver.

Upon success, the feature returns FindCollectionDto.

FindCollectionDto

Field
Description
Type

page

The desired page for the list of collections

number

pages

All count of lists based on the collection query

number

total

The complete count of collection records based on the query

number

limit

The total required number of collection document

number

data

The list of collection records

ICollectionDto[]

/**
 * Search by the creator, recipient and/or owner of a collection
 *
 * When a collection is created, the logged-in user is the `creator` of the collection.
 *
 * When an invite is sent to and accepted by another user, such user is now marked as the `owner` and can be filtered as the `receiver`
 *
 * */
export const getAllCollections = async (authToken: string, filter?: filterCollectionDto) => {
  const sampleCollectionFilter: filterCollectionDto  = {
    page: 1,
    limit: 50,
    creator: "user_id",
    receiver: "user_id",
    status: ICollectionStatus <=> //Check the SDK for the type of status to be filtered by
  };
  const collections: ResponseDto<FindCollectionDto> = await sdkInit.collections.getAll(authToken, filter);
};

Get a collection by ID

Get a collection by ID, and return the ICollectionDto. The authenticated user jwt token is required.

export const getACollection = async (authToken, id: string) => {
  const collections: ResponseDto<ICollectionDto> = await sdkInit.collections.getById(authToken, id);
};

Get collections by types

Collection types refer to the style of the collection and are used to differentiate collections.

The authenticated jwt user token is required to execute this feature.

Upon success, returns FindCollectionTypeDto

FindCollectionTypeDto

Field
Description
Type

page

The desired page for the list of collection types

number

pages

All count of lists based on the query

number

total

The complete count of collection types records based on the query

number

limit

The total required number of collection type document

number

data

The list of collection type records

ICollectionTypeDto[]

ICollectionTypeDto

Field
Description
Type

_id

Identifier for the collection type record

string

name

Designation given as the collection type

string

value

Designation marked as the collection type

string

Here is an example depicting how to fetch collection types

export const getCollectionTypes = async (authToken: string, filter: filterCollectionDto) => {
  const collections: ResponseDto<FindCollectionTypeDto> = await sdkInit.collections.getTypes(authToken, filter);
};

Get a collection by type

Get a collection type. The authenticated user jwt token is required.

Upon success, returns ICollectionTypeDto.

export const getACollection = async (authToken: string, filter: filterDto) => {
  const collections: ResponseDto<ICollectionTypeDto> = await sdkInit.collections.getTypes(authToken, filter);
};

Update a collection

A collection can be updated. The authenticated user jwt token is required.

Use the payload UpdateCollectionDto to modify the collection.

The user's authenticated jwt token is required.

UpdateCollectionDto

Field
Description
Type
Optional

name

The appellation given to the collection

string

false

category

The classification of the collection

string

true

type

The group that the collection belongs to

string

false

description

Detailed explanation of what the collection is about

string

false

isPrivate

Identifier to check if the collection is private

boolean

false

deliveryDate

Timestamp for the requirements of completing the collection to be met

string

true

tags

Array of labels of the collection

string[]

true

attachments

Array of urls of files uploaded for the collection

string[]

true

meta

Object that can be customised to suit the business logic and/or user preferences

Record<string, any>

true

export const updateASingleCollection = async (authToken: string, id: string, payload?: UpdateCollectionDto) => {
  const collection: ResponseDto<{}> = await sdkInit.collection.updateCollection(authToken, id, filter);
};

Update many collections

A list of collections can be updated together, they need not belong to the same parent.

The UpdateManyCollectionsDto is a list of UpdateCollectionDto

export const updateManyCollections = async (authToken: string, collections: UpdateManyCollectionsDto) => {
  const update: ResponseDto<{}> = await sdkInit.collection.updateManyCollections(authToken, collections);
};

Delete a collection

Deleting a collection is easy. The _id as seen in ICollectionDto is required as well as the authenticated user jwt token.

export const deleteACollection = async (authToken: string, collectionId: string) => {
  const deleted: ResponseDto<{}> = await sdkInit.collection.deleteACollection(authToken, collectionId);
};
Create a collection
Create many collections
Get all collections
Get a collection by the id
Update a collection
Update many collections
Get collections by types
Get a collection type
Delete a collection