Class ContentModule

ContentApi provide methods to communication with content stored in DCore network.

Hierarchy

Index

Constructors

constructor

Methods

addContent

buyContent

  • buyContent(contentId: string, buyerId: string, elGammalPub: string, privateKey: string, broadcast?: boolean): Promise<Operation>
  • Parameters

    • contentId: string

      Id of content to be bought in format '2.13.X'. Example: '2.13.456'

    • buyerId: string

      Account id of user buying content in format '1.2.X'. Example: '1.2.345'

    • elGammalPub: string

      ElGammal public key which will be used to identify users bought content

    • privateKey: string

      Private key to sign broadcasted transaction in WIF(hex) (Wallet Import Format) format.

    • Default value broadcast: boolean = true

      Transaction is broadcasted if set to 'true'. Default value is 'true'.

    Returns Promise<Operation>

    Value confirming successful transaction broadcasting.

generateContentKeys

  • generateContentKeys(seeders: string[]): Promise<ContentKeys>

getAuthorCoAuthors

  • getAuthorCoAuthors(URI: string): Promise<[string, string[]] | null>
  • Get author and co-authors of content.

    Parameters

    • URI: string

      Content URI. Example 'ipfs:QmQ9MBkzt6QcDtBhg7qenDcXtm1s6VVSogtSHa2zbXKsFb'

    Returns Promise<[string, string[]] | null>

getBuyingByConsumerURI

  • getBuyingByConsumerURI(accountId: string, URI: string, convertAsset?: boolean): Promise<BuyingContent[] | null>

getBuyingHistoryObjectsByConsumer

  • getBuyingHistoryObjectsByConsumer(accountId: string, convertAsset?: boolean): Promise<BuyingContent[]>

getContent

  • getContent(id: string, convertAsset?: boolean): Promise<ContentObject>
  • Get content object from blockchain for given content id

    Parameters

    • id: string

      Id of content to get. Example: '2.13.345'

    • Default value convertAsset: boolean = false

      Optional parameter to convert amounts and fees of Content from blockchain asset amount format to right precision format of asset. Example: 100000000 => 1 DCT. Default: false.

    Returns Promise<ContentObject>

    Content object.

getContentURI

  • getContentURI(URI: string, convertAsset?: boolean): Promise<ContentObject | null>

getOpenBuying

  • getOpenBuying(convertAsset?: boolean): Promise<BuyingContent[]>

getOpenBuyingByConsumer

  • getOpenBuyingByConsumer(accountId: string, convertAsset?: boolean): Promise<BuyingContent[]>

getOpenBuyingByURI

  • getOpenBuyingByURI(URI: string, convertAsset?: boolean): Promise<BuyingContent[]>

getPurchasedContent

  • getPurchasedContent(accountId: string, order?: SearchParamsOrder, startObjectId?: string, term?: string, resultSize?: number): Promise<Content[]>

getRating

  • getRating(contentId: string, forUser: string, ratingStartId?: string, count?: number): Promise<Array<BuyingContent>>
  • List rating for given content id.

    Parameters

    • contentId: string

      Content if in format '2.13.X'. Example '2.13.456'

    • forUser: string

      Account id to search for user's ratings for conentnt, in format '1.2.X'. Example '1.2.345'.

    • Default value ratingStartId: string = ""

      Rating id to start list from.

    • Default value count: number = 100

    Returns Promise<Array<BuyingContent>>

getSeeders

  • getSeeders(resultSize?: number): Promise<Seeder[]>

leaveCommentAndRating

  • leaveCommentAndRating(contentURI: string, consumer: string, comment: string, rating: number, consumerPKey: string, broadcast?: boolean): Promise<Operation>

removeContent

  • removeContent(contentId: string, authorId: string, privateKey: string, broadcast?: boolean): Promise<Operation>

restoreContentKeys

  • restoreContentKeys(contentId: string, accountId: string, ...elGamalKeys: KeyPair[]): Promise<string>
  • Restores key to decrypt downloaded content.

    ElGamalPrivate contains keys used to identify if user have bought content. May contains older keys, if elGamal keys pair were changed, to restore content bought before keys have been changed. Otherwise content keys would not be restored. https://docs.decent.ch/developer/group___database_a_p_i___decent.html#gaa952f1c2adc2781d42a3f457e2d18d09

    Parameters

    • contentId: string

      Content id in format '2.13.X', Example: '2.13.453'

    • accountId: string

      Account if in format '1.2.X'. Example: '1.2.345'

    • Rest ...elGamalKeys: KeyPair[]

      El Gamal keys to identify that user bought content. May contains older keys, if el gamal keys pair were changed, to restore content bought before keys have been changed. Otherwise content keys would not be restored.

    Returns Promise<string>

    Content key to decrypt content.

searchContent

searchFeedback

  • searchFeedback(accountId: string, contentURI: string, ratingStartId: string, count?: number): Promise<Array<BuyingContent>>

Powered by DECENT