• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

proximax-storage / tsjs-xpx-chain-sdk / 5722694066

pending completion
5722694066

push

github

web-flow
Merge pull request #159 from proximax-storage/next

add storage transactions support

1167 of 2568 branches covered (45.44%)

Branch coverage included in aggregate %.

1604 of 1604 new or added lines in 66 files covered. (100.0%)

8621 of 11167 relevant lines covered (77.2%)

155987.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.71
/src/infrastructure/DownloadChannelQueryParams.ts
1
/*
2
 * Copyright 2023 ProximaX
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
import { PublicAccount } from "../model/account/PublicAccount";
18
import { Address } from "../model/account/Address";
19
import { Order_v2 } from "./QueryParams";
1✔
20
import { UInt64 } from "../model/model";
1✔
21
import { MosaicId, NamespaceId } from "../model/model";
22
import { PaginationQueryParams } from "./PaginationQueryParams";
1✔
23

24
export enum DownloadChannelSortingField{
1✔
25

26
    ID = "id"
1✔
27
}
28

29
export class DownloadChannelFieldOrder{
1✔
30

31
    constructor(public orderBy: DownloadChannelSortingField | string, public order: Order_v2){
×
32
    }
33

34
    static setAscending(orderBy: DownloadChannelSortingField | string){
35
        return new DownloadChannelFieldOrder(orderBy, Order_v2.ASC);
×
36
    }
37

38
    static setDescending(orderBy: DownloadChannelSortingField | string){
39
        return new DownloadChannelFieldOrder(orderBy, Order_v2.DESC);
×
40
    }
41
}
42

43
export class DownloadChannelQueryParams extends PaginationQueryParams{
1✔
44

45
    /**
46
    * Download size in MB.
47
    */
48
    downloadSize?: number | UInt64 | bigint;;
49
    /**
50
    * From download size in MB.
51
    */
52
    fromDownloadSize?: number | UInt64 | bigint;;
53
    /**
54
    * To download size in MB.
55
    */
56
    toDownloadSize?: number | UInt64 | bigint;;
57
    /**
58
    * Number of completed download approval transactions.
59
    */
60
    downloadApprovalCount?: number;
61
    /**
62
    * From number of completed download approval transactions.
63
    */
64
    fromDownloadApprovalCount?: number;
65
    /**
66
    * To number of completed download approval transactions.
67
    */
68
    toDownloadApprovalCount?: number;
69
    consumerKey?: string;
70
    order?: Order_v2;
71
    orderBy?: string;
72
    offset?: string;
73

74
    /**
75
     * Constructor
76
     */
77
    constructor() {
78
        super();
×
79
    }
80

81
    updateFieldOrder(DownloadChannelFieldOrder: DownloadChannelFieldOrder){
82
        this.orderBy = DownloadChannelFieldOrder.orderBy;
×
83
        this.order = DownloadChannelFieldOrder.order;
×
84
    }
85

86
    buildQueryParams(): object{
87
        let queryParams = Object.assign({}, this);
×
88

89
        DownloadChannelQueryParams.adjustNonComplianceParams(queryParams);
×
90
        DownloadChannelQueryParams.convertToPrimitiveType(queryParams);
×
91

92
        let flattenedQueryParams = super.buildQueryParams(queryParams);
×
93

94
        return flattenedQueryParams;
×
95
    }
96

97
    buildQueryParamsString(): string{
98
        let queryParams = this.buildQueryParams();
×
99

100
        const entries = Object.entries(queryParams);
×
101

102
        let queryParamsArray = entries.map(data=>{
×
103

104
            if(data[1] instanceof Array){
×
105
                return data[1].map(arrayData=>{
×
106
                    return data[0] + "[]" + "=" + arrayData
×
107
                }).join("&");
108
            }
109
            return data[0] + "=" + data[1]
×
110
        })
111

112
        return queryParamsArray.join("&")
×
113
    }
114

115
    static convertToPrimitiveType(queryParams: DownloadChannelQueryParams){
116
        if(queryParams.downloadSize){
×
117
            if(queryParams.downloadSize instanceof UInt64){
×
118
                queryParams.downloadSize = queryParams.downloadSize.toBigInt();
×
119
            }
120
        }
121

122
        if(queryParams.fromDownloadSize){
×
123
            if(queryParams.fromDownloadSize instanceof UInt64){
×
124
                queryParams.fromDownloadSize = queryParams.fromDownloadSize.toBigInt();
×
125
            }
126
        }
127

128
        if(queryParams.toDownloadSize){
×
129
            if(queryParams.toDownloadSize instanceof UInt64){
×
130
                queryParams.toDownloadSize = queryParams.toDownloadSize.toBigInt();
×
131
            }
132
        }
133
    }
134

135
    static adjustNonComplianceParams(queryParams: DownloadChannelQueryParams){
136
        if(queryParams.downloadApprovalCount){
×
137
            if(queryParams.toDownloadApprovalCount){
×
138
                delete queryParams.toDownloadApprovalCount;
×
139
            }
140

141
            if(queryParams.fromDownloadApprovalCount){
×
142
                delete queryParams.fromDownloadApprovalCount;
×
143
            }
144
        }
145

146
        if(queryParams.pageSize){
×
147
            if(queryParams.pageSize < 0){
×
148
                delete queryParams.pageSize; // default to 20
×
149
            } else if(queryParams.pageSize < 10){
×
150
                queryParams.pageSize = 10;
×
151
            } else if(queryParams.pageSize > 100){
×
152
                queryParams.pageSize = 100;
×
153
            }
154
        }
155

156
        if(queryParams.pageNumber){
×
157
            if(queryParams.pageNumber <= 0){
×
158
                queryParams.pageNumber = 1;
×
159
            }
160
        }
161
    }
162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc