All files / src/endpoints/tools v1.ts

100% Statements 15/15
87.5% Branches 7/8
100% Functions 7/7
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 9275x     1x 1x   1x                                         1x 12x     1x   1x                   1x   1x                   11x                                 1x   1x                   1x           1x  
import type {APIClient} from '@wharfkit/antelope'
import type {NameType, PublicKeyType, UInt64Type} from '@wharfkit/antelope'
import type {LinkState} from '../../types'
import {CountResponseStruct} from '../../types'
import * as Tools from './types'
import type {ActionNames as ActionType} from '../../contracts/atomictoolsx'
import {buildBodyParams, pathSegment} from '../utils'
 
export interface GetLinksOptions {
    creator?: NameType[]
    claimer?: NameType[]
    public_key?: PublicKeyType
    state?: LinkState[]
    collection_blacklist?: NameType[]
    collection_whitelist?: NameType[]
    link_id?: UInt64Type[]
    ids?: UInt64Type[]
    lower_bound?: string
    upper_bound?: string
    before?: number
    after?: number
    page?: number
    limit?: number
    order?: 'asc' | 'desc'
    sort?: 'created'
}
 
export class ToolsV1APIClient {
    constructor(private client: APIClient) {}
 
    async get_links(options?: GetLinksOptions) {
        const bodyParams = buildBodyParams(options)
 
        return this.client.call({
            path: `/atomictools/v1/links`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: Tools.GetLinksResponse,
        })
    }
 
    async get_links_count(options?: GetLinksOptions) {
        const bodyParams = buildBodyParams(options)
 
        return this.client.call({
            path: `/atomictools/v1/links/_count`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: CountResponseStruct,
        })
    }
 
    async get_link(link_id: UInt64Type) {
        return this.client.call({
            path: `/atomictools/v1/links/${pathSegment(link_id)}`,
            method: 'GET',
            responseType: Tools.GetLinkResponse,
        })
    }
 
    async get_link_logs(
        link_id: UInt64Type,
        options?: {
            page?: number
            limit?: number
            order?: 'asc' | 'desc'
            action_whitelist?: ActionType[]
            action_blacklist?: ActionType[]
        }
    ) {
        const bodyParams = buildBodyParams(options)
 
        return this.client.call({
            path: `/atomictools/v1/links/${pathSegment(link_id)}/logs`,
            method: 'POST',
            params: bodyParams,
            headers: {'Content-Type': 'application/json'},
            responseType: Tools.ActionLogsResponse,
        })
    }
 
    async get_config() {
        return this.client.call({
            path: '/atomictools/v1/config',
            method: 'GET',
            responseType: Tools.GetConfigResponse,
        })
    }
}