@hirosystems/token-metadata-api-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ 3.0.41
@@ -0,0 +1,24 @@
1
+ # Swagger Codegen Ignore
2
+ # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3
+
4
+ # Use this file to prevent files from being overwritten by the generator.
5
+ # The patterns follow closely to .gitignore or .dockerignore.
6
+
7
+ # As an example, the C# client generator defines ApiClient.cs.
8
+ # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9
+ #ApiClient.cs
10
+
11
+ # You can match any string of characters against a directory, file or extension with a single asterisk (*):
12
+ #foo/*/qux
13
+ # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14
+
15
+ # You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16
+ #foo/**/qux
17
+ # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18
+
19
+ # You can also negate patterns with an exclamation (!).
20
+ # For example, you can ignore all files in a docs folder with the file extension .md:
21
+ #docs/*.md
22
+ # Then explicitly reverse the ignore rule for a single file:
23
+ #!docs/README.md
24
+ package.json
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ ## @hirosystems/token-metadata-api-client@1.0.0
2
+
3
+ This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
4
+
5
+ Environment
6
+ * Node.js
7
+ * Webpack
8
+ * Browserify
9
+
10
+ Language level
11
+ * ES5 - you must have a Promises/A+ library installed
12
+ * ES6
13
+
14
+ Module system
15
+ * CommonJS
16
+ * ES6 module system
17
+
18
+ It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
19
+
20
+ ### Building
21
+
22
+ To build an compile the typescript sources to javascript use:
23
+ ```
24
+ npm install
25
+ npm run build
26
+ ```
27
+
28
+ ### Publishing
29
+
30
+ First build the package then run ```npm publish```
31
+
32
+ ### Consuming
33
+
34
+ navigate to the folder of your consuming project and run one of the following commands.
35
+
36
+ _published:_
37
+
38
+ ```
39
+ npm install @hirosystems/token-metadata-api-client@1.0.0 --save
40
+ ```
41
+
42
+ _unPublished (not recommended):_
43
+
44
+ ```
45
+ npm install PATH_TO_GENERATED_PACKAGE --save
package/api.ts ADDED
@@ -0,0 +1,842 @@
1
+ /// <reference path="./custom.d.ts" />
2
+ // tslint:disable
3
+ /**
4
+ * Token Metadata API
5
+ * Service that indexes metadata for every SIP-009, SIP-010, and SIP-013 Token in the Stacks blockchain and exposes it via REST API endpoints.
6
+ *
7
+ * OpenAPI spec version: v0.1.0
8
+ *
9
+ *
10
+ * NOTE: This file is auto generated by the swagger code generator program.
11
+ * https://github.com/swagger-api/swagger-codegen.git
12
+ * Do not edit the file manually.
13
+ */
14
+
15
+ import * as url from "url";
16
+ import * as isomorphicFetch from "isomorphic-fetch";
17
+ import { Configuration } from "./configuration";
18
+
19
+ const BASE_PATH = "https://api.hiro.so/".replace(/\/+$/, "");
20
+
21
+ /**
22
+ *
23
+ * @export
24
+ */
25
+ export const COLLECTION_FORMATS = {
26
+ csv: ",",
27
+ ssv: " ",
28
+ tsv: "\t",
29
+ pipes: "|",
30
+ };
31
+
32
+ /**
33
+ *
34
+ * @export
35
+ * @interface FetchAPI
36
+ */
37
+ export interface FetchAPI {
38
+ (url: string, init?: any): Promise<Response>;
39
+ }
40
+
41
+ /**
42
+ *
43
+ * @export
44
+ * @interface FetchArgs
45
+ */
46
+ export interface FetchArgs {
47
+ url: string;
48
+ options: any;
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @export
54
+ * @class BaseAPI
55
+ */
56
+ export class BaseAPI {
57
+ protected configuration: Configuration;
58
+
59
+ constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = isomorphicFetch) {
60
+ if (configuration) {
61
+ this.configuration = configuration;
62
+ this.basePath = configuration.basePath || this.basePath;
63
+ }
64
+ }
65
+ };
66
+
67
+ /**
68
+ *
69
+ * @export
70
+ * @class RequiredError
71
+ * @extends {Error}
72
+ */
73
+ export class RequiredError extends Error {
74
+ name: "RequiredError"
75
+ constructor(public field: string, msg?: string) {
76
+ super(msg);
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @export
83
+ * @interface ApiJobCount
84
+ */
85
+ export interface ApiJobCount {
86
+ /**
87
+ *
88
+ * @type {number}
89
+ * @memberof ApiJobCount
90
+ */
91
+ pending?: number;
92
+ /**
93
+ *
94
+ * @type {number}
95
+ * @memberof ApiJobCount
96
+ */
97
+ queued?: number;
98
+ /**
99
+ *
100
+ * @type {number}
101
+ * @memberof ApiJobCount
102
+ */
103
+ done?: number;
104
+ /**
105
+ *
106
+ * @type {number}
107
+ * @memberof ApiJobCount
108
+ */
109
+ failed?: number;
110
+ }
111
+ /**
112
+ *
113
+ * @export
114
+ * @interface ApiStatusResponse
115
+ */
116
+ export interface ApiStatusResponse {
117
+ /**
118
+ *
119
+ * @type {string}
120
+ * @memberof ApiStatusResponse
121
+ */
122
+ serverVersion: string;
123
+ /**
124
+ *
125
+ * @type {string}
126
+ * @memberof ApiStatusResponse
127
+ */
128
+ status: string;
129
+ /**
130
+ *
131
+ * @type {ApiTokenCount}
132
+ * @memberof ApiStatusResponse
133
+ */
134
+ tokens?: ApiTokenCount;
135
+ /**
136
+ *
137
+ * @type {ApiTokenContractCount}
138
+ * @memberof ApiStatusResponse
139
+ */
140
+ tokenContracts?: ApiTokenContractCount;
141
+ /**
142
+ *
143
+ * @type {ApiJobCount}
144
+ * @memberof ApiStatusResponse
145
+ */
146
+ jobQueue?: ApiJobCount;
147
+ }
148
+ /**
149
+ *
150
+ * @export
151
+ * @interface ApiTokenContractCount
152
+ */
153
+ export interface ApiTokenContractCount {
154
+ /**
155
+ *
156
+ * @type {number}
157
+ * @memberof ApiTokenContractCount
158
+ */
159
+ sip009?: number;
160
+ /**
161
+ *
162
+ * @type {number}
163
+ * @memberof ApiTokenContractCount
164
+ */
165
+ sip010?: number;
166
+ /**
167
+ *
168
+ * @type {number}
169
+ * @memberof ApiTokenContractCount
170
+ */
171
+ sip013?: number;
172
+ }
173
+ /**
174
+ *
175
+ * @export
176
+ * @interface ApiTokenCount
177
+ */
178
+ export interface ApiTokenCount {
179
+ /**
180
+ *
181
+ * @type {number}
182
+ * @memberof ApiTokenCount
183
+ */
184
+ ft?: number;
185
+ /**
186
+ *
187
+ * @type {number}
188
+ * @memberof ApiTokenCount
189
+ */
190
+ nft?: number;
191
+ /**
192
+ *
193
+ * @type {number}
194
+ * @memberof ApiTokenCount
195
+ */
196
+ sft?: number;
197
+ }
198
+ /**
199
+ *
200
+ * @export
201
+ * @interface FtMetadataResponse
202
+ */
203
+ export interface FtMetadataResponse {
204
+ /**
205
+ *
206
+ * @type {string}
207
+ * @memberof FtMetadataResponse
208
+ */
209
+ name?: string;
210
+ /**
211
+ *
212
+ * @type {string}
213
+ * @memberof FtMetadataResponse
214
+ */
215
+ symbol?: string;
216
+ /**
217
+ *
218
+ * @type {number}
219
+ * @memberof FtMetadataResponse
220
+ */
221
+ decimals?: number;
222
+ /**
223
+ *
224
+ * @type {string}
225
+ * @memberof FtMetadataResponse
226
+ */
227
+ totalSupply?: string;
228
+ /**
229
+ *
230
+ * @type {string}
231
+ * @memberof FtMetadataResponse
232
+ */
233
+ tokenUri?: string;
234
+ /**
235
+ *
236
+ * @type {string}
237
+ * @memberof FtMetadataResponse
238
+ */
239
+ description?: string;
240
+ /**
241
+ *
242
+ * @type {string}
243
+ * @memberof FtMetadataResponse
244
+ */
245
+ imageUri?: string;
246
+ /**
247
+ *
248
+ * @type {string}
249
+ * @memberof FtMetadataResponse
250
+ */
251
+ imageCanonicalUri?: string;
252
+ /**
253
+ *
254
+ * @type {string}
255
+ * @memberof FtMetadataResponse
256
+ */
257
+ txId: string;
258
+ /**
259
+ *
260
+ * @type {string}
261
+ * @memberof FtMetadataResponse
262
+ */
263
+ senderAddress: string;
264
+ /**
265
+ *
266
+ * @type {Metadata}
267
+ * @memberof FtMetadataResponse
268
+ */
269
+ metadata?: Metadata;
270
+ }
271
+ /**
272
+ *
273
+ * @export
274
+ * @interface Metadata
275
+ */
276
+ export interface Metadata {
277
+ /**
278
+ *
279
+ * @type {number}
280
+ * @memberof Metadata
281
+ */
282
+ sip: number;
283
+ /**
284
+ *
285
+ * @type {string}
286
+ * @memberof Metadata
287
+ */
288
+ name?: string;
289
+ /**
290
+ *
291
+ * @type {string}
292
+ * @memberof Metadata
293
+ */
294
+ description?: string;
295
+ /**
296
+ *
297
+ * @type {string}
298
+ * @memberof Metadata
299
+ */
300
+ image?: string;
301
+ /**
302
+ *
303
+ * @type {string}
304
+ * @memberof Metadata
305
+ */
306
+ cachedImage?: string;
307
+ /**
308
+ *
309
+ * @type {Array<MetadataAttribute>}
310
+ * @memberof Metadata
311
+ */
312
+ attributes?: Array<MetadataAttribute>;
313
+ /**
314
+ *
315
+ * @type {{ [key: string]: any; }}
316
+ * @memberof Metadata
317
+ */
318
+ properties?: { [key: string]: any; };
319
+ /**
320
+ *
321
+ * @type {MetadataLocalization}
322
+ * @memberof Metadata
323
+ */
324
+ localization?: MetadataLocalization;
325
+ }
326
+ /**
327
+ *
328
+ * @export
329
+ * @interface MetadataAttribute
330
+ */
331
+ export interface MetadataAttribute {
332
+ /**
333
+ *
334
+ * @type {string}
335
+ * @memberof MetadataAttribute
336
+ */
337
+ traitType: string;
338
+ /**
339
+ *
340
+ * @type {string}
341
+ * @memberof MetadataAttribute
342
+ */
343
+ displayType?: string;
344
+ /**
345
+ *
346
+ * @type {any}
347
+ * @memberof MetadataAttribute
348
+ */
349
+ value: any;
350
+ }
351
+ /**
352
+ *
353
+ * @export
354
+ * @interface MetadataLocalization
355
+ */
356
+ export interface MetadataLocalization {
357
+ /**
358
+ *
359
+ * @type {string}
360
+ * @memberof MetadataLocalization
361
+ */
362
+ uri: string;
363
+ /**
364
+ *
365
+ * @type {string}
366
+ * @memberof MetadataLocalization
367
+ */
368
+ _default: string;
369
+ /**
370
+ *
371
+ * @type {Array<string>}
372
+ * @memberof MetadataLocalization
373
+ */
374
+ locales: Array<string>;
375
+ }
376
+ /**
377
+ *
378
+ * @export
379
+ * @interface NftMetadataResponse
380
+ */
381
+ export interface NftMetadataResponse {
382
+ /**
383
+ *
384
+ * @type {string}
385
+ * @memberof NftMetadataResponse
386
+ */
387
+ tokenUri?: string;
388
+ /**
389
+ *
390
+ * @type {Metadata}
391
+ * @memberof NftMetadataResponse
392
+ */
393
+ metadata?: Metadata;
394
+ }
395
+ /**
396
+ *
397
+ * @export
398
+ * @interface SftMetadataResponse
399
+ */
400
+ export interface SftMetadataResponse {
401
+ /**
402
+ *
403
+ * @type {string}
404
+ * @memberof SftMetadataResponse
405
+ */
406
+ tokenUri?: string;
407
+ /**
408
+ *
409
+ * @type {number}
410
+ * @memberof SftMetadataResponse
411
+ */
412
+ decimals?: number;
413
+ /**
414
+ *
415
+ * @type {string}
416
+ * @memberof SftMetadataResponse
417
+ */
418
+ totalSupply?: string;
419
+ /**
420
+ *
421
+ * @type {Metadata}
422
+ * @memberof SftMetadataResponse
423
+ */
424
+ metadata?: Metadata;
425
+ }
426
+ /**
427
+ *
428
+ * @export
429
+ * @interface TokenErrorResponse
430
+ */
431
+ export interface TokenErrorResponse {
432
+ }
433
+ /**
434
+ *
435
+ * @export
436
+ * @interface TokenNotFoundResponse
437
+ */
438
+ export interface TokenNotFoundResponse {
439
+ /**
440
+ *
441
+ * @type {string}
442
+ * @memberof TokenNotFoundResponse
443
+ */
444
+ error: TokenNotFoundResponse.ErrorEnum;
445
+ }
446
+
447
+ /**
448
+ * @export
449
+ * @namespace TokenNotFoundResponse
450
+ */
451
+ export namespace TokenNotFoundResponse {
452
+ /**
453
+ * @export
454
+ * @enum {string}
455
+ */
456
+ export enum ErrorEnum {
457
+ TokenNotFound = <any> 'Token not found'
458
+ }
459
+ }
460
+ /**
461
+ * StatusApi - fetch parameter creator
462
+ * @export
463
+ */
464
+ export const StatusApiFetchParamCreator = function (configuration?: Configuration) {
465
+ return {
466
+ /**
467
+ * Displays the status of the API and its current workload
468
+ * @summary API Status
469
+ * @param {*} [options] Override http request option.
470
+ * @throws {RequiredError}
471
+ */
472
+ getApiStatus(options: any = {}): FetchArgs {
473
+ const localVarPath = `/metadata/v1/`;
474
+ const localVarUrlObj = url.parse(localVarPath, true);
475
+ const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
476
+ const localVarHeaderParameter = {} as any;
477
+ const localVarQueryParameter = {} as any;
478
+
479
+ localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
480
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
481
+ delete localVarUrlObj.search;
482
+ localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
483
+
484
+ return {
485
+ url: url.format(localVarUrlObj),
486
+ options: localVarRequestOptions,
487
+ };
488
+ },
489
+ }
490
+ };
491
+
492
+ /**
493
+ * StatusApi - functional programming interface
494
+ * @export
495
+ */
496
+ export const StatusApiFp = function(configuration?: Configuration) {
497
+ return {
498
+ /**
499
+ * Displays the status of the API and its current workload
500
+ * @summary API Status
501
+ * @param {*} [options] Override http request option.
502
+ * @throws {RequiredError}
503
+ */
504
+ getApiStatus(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<ApiStatusResponse> {
505
+ const localVarFetchArgs = StatusApiFetchParamCreator(configuration).getApiStatus(options);
506
+ return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
507
+ return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
508
+ if (response.status >= 200 && response.status < 300) {
509
+ return response.json();
510
+ } else {
511
+ throw response;
512
+ }
513
+ });
514
+ };
515
+ },
516
+ }
517
+ };
518
+
519
+ /**
520
+ * StatusApi - factory interface
521
+ * @export
522
+ */
523
+ export const StatusApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) {
524
+ return {
525
+ /**
526
+ * Displays the status of the API and its current workload
527
+ * @summary API Status
528
+ * @param {*} [options] Override http request option.
529
+ * @throws {RequiredError}
530
+ */
531
+ getApiStatus(options?: any) {
532
+ return StatusApiFp(configuration).getApiStatus(options)(fetch, basePath);
533
+ },
534
+ };
535
+ };
536
+
537
+ /**
538
+ * StatusApi - object-oriented interface
539
+ * @export
540
+ * @class StatusApi
541
+ * @extends {BaseAPI}
542
+ */
543
+ export class StatusApi extends BaseAPI {
544
+ /**
545
+ * Displays the status of the API and its current workload
546
+ * @summary API Status
547
+ * @param {*} [options] Override http request option.
548
+ * @throws {RequiredError}
549
+ * @memberof StatusApi
550
+ */
551
+ public getApiStatus(options?: any) {
552
+ return StatusApiFp(this.configuration).getApiStatus(options)(this.fetch, this.basePath);
553
+ }
554
+
555
+ }
556
+ /**
557
+ * TokensApi - fetch parameter creator
558
+ * @export
559
+ */
560
+ export const TokensApiFetchParamCreator = function (configuration?: Configuration) {
561
+ return {
562
+ /**
563
+ * Retrieves metadata for a SIP-010 Fungible Token
564
+ * @summary Fungible Token Metadata
565
+ * @param {string} principal Principal for the contract which owns the SIP-010 token
566
+ * @param {string} [locale] Metadata localization to retrieve
567
+ * @param {*} [options] Override http request option.
568
+ * @throws {RequiredError}
569
+ */
570
+ getFtMetadata(principal: string, locale?: string, options: any = {}): FetchArgs {
571
+ // verify required parameter 'principal' is not null or undefined
572
+ if (principal === null || principal === undefined) {
573
+ throw new RequiredError('principal','Required parameter principal was null or undefined when calling getFtMetadata.');
574
+ }
575
+ const localVarPath = `/metadata/v1/ft/{principal}`
576
+ .replace(`{${"principal"}}`, encodeURIComponent(String(principal)));
577
+ const localVarUrlObj = url.parse(localVarPath, true);
578
+ const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
579
+ const localVarHeaderParameter = {} as any;
580
+ const localVarQueryParameter = {} as any;
581
+
582
+ if (locale !== undefined) {
583
+ localVarQueryParameter['locale'] = locale;
584
+ }
585
+
586
+ localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
587
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
588
+ delete localVarUrlObj.search;
589
+ localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
590
+
591
+ return {
592
+ url: url.format(localVarUrlObj),
593
+ options: localVarRequestOptions,
594
+ };
595
+ },
596
+ /**
597
+ * Retrieves metadata for a SIP-009 Non-Fungible Token
598
+ * @summary Non-Fungible Token Metadata
599
+ * @param {string} principal SIP-009 compliant smart contract principal
600
+ * @param {number} tokenId Token ID to retrieve
601
+ * @param {string} [locale] Metadata localization to retrieve
602
+ * @param {*} [options] Override http request option.
603
+ * @throws {RequiredError}
604
+ */
605
+ getNftMetadata(principal: string, tokenId: number, locale?: string, options: any = {}): FetchArgs {
606
+ // verify required parameter 'principal' is not null or undefined
607
+ if (principal === null || principal === undefined) {
608
+ throw new RequiredError('principal','Required parameter principal was null or undefined when calling getNftMetadata.');
609
+ }
610
+ // verify required parameter 'tokenId' is not null or undefined
611
+ if (tokenId === null || tokenId === undefined) {
612
+ throw new RequiredError('tokenId','Required parameter tokenId was null or undefined when calling getNftMetadata.');
613
+ }
614
+ const localVarPath = `/metadata/v1/nft/{principal}/{token_id}`
615
+ .replace(`{${"principal"}}`, encodeURIComponent(String(principal)))
616
+ .replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)));
617
+ const localVarUrlObj = url.parse(localVarPath, true);
618
+ const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
619
+ const localVarHeaderParameter = {} as any;
620
+ const localVarQueryParameter = {} as any;
621
+
622
+ if (locale !== undefined) {
623
+ localVarQueryParameter['locale'] = locale;
624
+ }
625
+
626
+ localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
627
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
628
+ delete localVarUrlObj.search;
629
+ localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
630
+
631
+ return {
632
+ url: url.format(localVarUrlObj),
633
+ options: localVarRequestOptions,
634
+ };
635
+ },
636
+ /**
637
+ * Retrieves metadata for a SIP-013 Semi-Fungible Token
638
+ * @summary Semi-Fungible Token Metadata
639
+ * @param {string} principal SIP-013 compliant smart contract principal
640
+ * @param {number} tokenId Token ID to retrieve
641
+ * @param {string} [locale] Metadata localization to retrieve
642
+ * @param {*} [options] Override http request option.
643
+ * @throws {RequiredError}
644
+ */
645
+ getSftMetadata(principal: string, tokenId: number, locale?: string, options: any = {}): FetchArgs {
646
+ // verify required parameter 'principal' is not null or undefined
647
+ if (principal === null || principal === undefined) {
648
+ throw new RequiredError('principal','Required parameter principal was null or undefined when calling getSftMetadata.');
649
+ }
650
+ // verify required parameter 'tokenId' is not null or undefined
651
+ if (tokenId === null || tokenId === undefined) {
652
+ throw new RequiredError('tokenId','Required parameter tokenId was null or undefined when calling getSftMetadata.');
653
+ }
654
+ const localVarPath = `/metadata/v1/sft/{principal}/{token_id}`
655
+ .replace(`{${"principal"}}`, encodeURIComponent(String(principal)))
656
+ .replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)));
657
+ const localVarUrlObj = url.parse(localVarPath, true);
658
+ const localVarRequestOptions = Object.assign({ method: 'GET' }, options);
659
+ const localVarHeaderParameter = {} as any;
660
+ const localVarQueryParameter = {} as any;
661
+
662
+ if (locale !== undefined) {
663
+ localVarQueryParameter['locale'] = locale;
664
+ }
665
+
666
+ localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
667
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
668
+ delete localVarUrlObj.search;
669
+ localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
670
+
671
+ return {
672
+ url: url.format(localVarUrlObj),
673
+ options: localVarRequestOptions,
674
+ };
675
+ },
676
+ }
677
+ };
678
+
679
+ /**
680
+ * TokensApi - functional programming interface
681
+ * @export
682
+ */
683
+ export const TokensApiFp = function(configuration?: Configuration) {
684
+ return {
685
+ /**
686
+ * Retrieves metadata for a SIP-010 Fungible Token
687
+ * @summary Fungible Token Metadata
688
+ * @param {string} principal Principal for the contract which owns the SIP-010 token
689
+ * @param {string} [locale] Metadata localization to retrieve
690
+ * @param {*} [options] Override http request option.
691
+ * @throws {RequiredError}
692
+ */
693
+ getFtMetadata(principal: string, locale?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<FtMetadataResponse> {
694
+ const localVarFetchArgs = TokensApiFetchParamCreator(configuration).getFtMetadata(principal, locale, options);
695
+ return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
696
+ return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
697
+ if (response.status >= 200 && response.status < 300) {
698
+ return response.json();
699
+ } else {
700
+ throw response;
701
+ }
702
+ });
703
+ };
704
+ },
705
+ /**
706
+ * Retrieves metadata for a SIP-009 Non-Fungible Token
707
+ * @summary Non-Fungible Token Metadata
708
+ * @param {string} principal SIP-009 compliant smart contract principal
709
+ * @param {number} tokenId Token ID to retrieve
710
+ * @param {string} [locale] Metadata localization to retrieve
711
+ * @param {*} [options] Override http request option.
712
+ * @throws {RequiredError}
713
+ */
714
+ getNftMetadata(principal: string, tokenId: number, locale?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<NftMetadataResponse> {
715
+ const localVarFetchArgs = TokensApiFetchParamCreator(configuration).getNftMetadata(principal, tokenId, locale, options);
716
+ return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
717
+ return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
718
+ if (response.status >= 200 && response.status < 300) {
719
+ return response.json();
720
+ } else {
721
+ throw response;
722
+ }
723
+ });
724
+ };
725
+ },
726
+ /**
727
+ * Retrieves metadata for a SIP-013 Semi-Fungible Token
728
+ * @summary Semi-Fungible Token Metadata
729
+ * @param {string} principal SIP-013 compliant smart contract principal
730
+ * @param {number} tokenId Token ID to retrieve
731
+ * @param {string} [locale] Metadata localization to retrieve
732
+ * @param {*} [options] Override http request option.
733
+ * @throws {RequiredError}
734
+ */
735
+ getSftMetadata(principal: string, tokenId: number, locale?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<SftMetadataResponse> {
736
+ const localVarFetchArgs = TokensApiFetchParamCreator(configuration).getSftMetadata(principal, tokenId, locale, options);
737
+ return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
738
+ return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
739
+ if (response.status >= 200 && response.status < 300) {
740
+ return response.json();
741
+ } else {
742
+ throw response;
743
+ }
744
+ });
745
+ };
746
+ },
747
+ }
748
+ };
749
+
750
+ /**
751
+ * TokensApi - factory interface
752
+ * @export
753
+ */
754
+ export const TokensApiFactory = function (configuration?: Configuration, fetch?: FetchAPI, basePath?: string) {
755
+ return {
756
+ /**
757
+ * Retrieves metadata for a SIP-010 Fungible Token
758
+ * @summary Fungible Token Metadata
759
+ * @param {string} principal Principal for the contract which owns the SIP-010 token
760
+ * @param {string} [locale] Metadata localization to retrieve
761
+ * @param {*} [options] Override http request option.
762
+ * @throws {RequiredError}
763
+ */
764
+ getFtMetadata(principal: string, locale?: string, options?: any) {
765
+ return TokensApiFp(configuration).getFtMetadata(principal, locale, options)(fetch, basePath);
766
+ },
767
+ /**
768
+ * Retrieves metadata for a SIP-009 Non-Fungible Token
769
+ * @summary Non-Fungible Token Metadata
770
+ * @param {string} principal SIP-009 compliant smart contract principal
771
+ * @param {number} tokenId Token ID to retrieve
772
+ * @param {string} [locale] Metadata localization to retrieve
773
+ * @param {*} [options] Override http request option.
774
+ * @throws {RequiredError}
775
+ */
776
+ getNftMetadata(principal: string, tokenId: number, locale?: string, options?: any) {
777
+ return TokensApiFp(configuration).getNftMetadata(principal, tokenId, locale, options)(fetch, basePath);
778
+ },
779
+ /**
780
+ * Retrieves metadata for a SIP-013 Semi-Fungible Token
781
+ * @summary Semi-Fungible Token Metadata
782
+ * @param {string} principal SIP-013 compliant smart contract principal
783
+ * @param {number} tokenId Token ID to retrieve
784
+ * @param {string} [locale] Metadata localization to retrieve
785
+ * @param {*} [options] Override http request option.
786
+ * @throws {RequiredError}
787
+ */
788
+ getSftMetadata(principal: string, tokenId: number, locale?: string, options?: any) {
789
+ return TokensApiFp(configuration).getSftMetadata(principal, tokenId, locale, options)(fetch, basePath);
790
+ },
791
+ };
792
+ };
793
+
794
+ /**
795
+ * TokensApi - object-oriented interface
796
+ * @export
797
+ * @class TokensApi
798
+ * @extends {BaseAPI}
799
+ */
800
+ export class TokensApi extends BaseAPI {
801
+ /**
802
+ * Retrieves metadata for a SIP-010 Fungible Token
803
+ * @summary Fungible Token Metadata
804
+ * @param {string} principal Principal for the contract which owns the SIP-010 token
805
+ * @param {string} [locale] Metadata localization to retrieve
806
+ * @param {*} [options] Override http request option.
807
+ * @throws {RequiredError}
808
+ * @memberof TokensApi
809
+ */
810
+ public getFtMetadata(principal: string, locale?: string, options?: any) {
811
+ return TokensApiFp(this.configuration).getFtMetadata(principal, locale, options)(this.fetch, this.basePath);
812
+ }
813
+
814
+ /**
815
+ * Retrieves metadata for a SIP-009 Non-Fungible Token
816
+ * @summary Non-Fungible Token Metadata
817
+ * @param {string} principal SIP-009 compliant smart contract principal
818
+ * @param {number} tokenId Token ID to retrieve
819
+ * @param {string} [locale] Metadata localization to retrieve
820
+ * @param {*} [options] Override http request option.
821
+ * @throws {RequiredError}
822
+ * @memberof TokensApi
823
+ */
824
+ public getNftMetadata(principal: string, tokenId: number, locale?: string, options?: any) {
825
+ return TokensApiFp(this.configuration).getNftMetadata(principal, tokenId, locale, options)(this.fetch, this.basePath);
826
+ }
827
+
828
+ /**
829
+ * Retrieves metadata for a SIP-013 Semi-Fungible Token
830
+ * @summary Semi-Fungible Token Metadata
831
+ * @param {string} principal SIP-013 compliant smart contract principal
832
+ * @param {number} tokenId Token ID to retrieve
833
+ * @param {string} [locale] Metadata localization to retrieve
834
+ * @param {*} [options] Override http request option.
835
+ * @throws {RequiredError}
836
+ * @memberof TokensApi
837
+ */
838
+ public getSftMetadata(principal: string, tokenId: number, locale?: string, options?: any) {
839
+ return TokensApiFp(this.configuration).getSftMetadata(principal, tokenId, locale, options)(this.fetch, this.basePath);
840
+ }
841
+
842
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Token Metadata API
3
+ * Service that indexes metadata for every SIP-009, SIP-010, and SIP-013 Token in the Stacks blockchain and exposes it via REST API endpoints.
4
+ *
5
+ * OpenAPI spec version: v0.1.0
6
+ *
7
+ *
8
+ * NOTE: This file is auto generated by the swagger code generator program.
9
+ * https://github.com/swagger-api/swagger-codegen.git
10
+ * Do not edit the file manually.
11
+ */
12
+
13
+ import * as api from "./api"
14
+ import { Configuration } from "./configuration"
15
+
16
+ const config: Configuration = {}
17
+
18
+ describe("StatusApi", () => {
19
+ let instance: api.StatusApi
20
+ beforeEach(function() {
21
+ instance = new api.StatusApi(config)
22
+ });
23
+
24
+ test("getApiStatus", () => {
25
+ return expect(instance.getApiStatus({})).resolves.toBe(null)
26
+ })
27
+ })
28
+
29
+ describe("TokensApi", () => {
30
+ let instance: api.TokensApi
31
+ beforeEach(function() {
32
+ instance = new api.TokensApi(config)
33
+ });
34
+
35
+ test("getFtMetadata", () => {
36
+ const principal: string = "principal_example"
37
+ const locale: string = "locale_example"
38
+ return expect(instance.getFtMetadata(principal, locale, {})).resolves.toBe(null)
39
+ })
40
+ test("getNftMetadata", () => {
41
+ const principal: string = "principal_example"
42
+ const tokenId: number = 56
43
+ const locale: string = "locale_example"
44
+ return expect(instance.getNftMetadata(principal, tokenId, locale, {})).resolves.toBe(null)
45
+ })
46
+ test("getSftMetadata", () => {
47
+ const principal: string = "principal_example"
48
+ const tokenId: number = 56
49
+ const locale: string = "locale_example"
50
+ return expect(instance.getSftMetadata(principal, tokenId, locale, {})).resolves.toBe(null)
51
+ })
52
+ })
53
+
@@ -0,0 +1,65 @@
1
+ // tslint:disable
2
+ /**
3
+ * Token Metadata API
4
+ * Service that indexes metadata for every SIP-009, SIP-010, and SIP-013 Token in the Stacks blockchain and exposes it via REST API endpoints.
5
+ *
6
+ * OpenAPI spec version: v0.1.0
7
+ *
8
+ *
9
+ * NOTE: This file is auto generated by the swagger code generator program.
10
+ * https://github.com/swagger-api/swagger-codegen.git
11
+ * Do not edit the file manually.
12
+ */
13
+
14
+ export interface ConfigurationParameters {
15
+ apiKey?: string | ((name: string) => string);
16
+ username?: string;
17
+ password?: string;
18
+ accessToken?: string | ((name: string, scopes?: string[]) => string);
19
+ basePath?: string;
20
+ }
21
+
22
+ export class Configuration {
23
+ /**
24
+ * parameter for apiKey security
25
+ * @param name security name
26
+ * @memberof Configuration
27
+ */
28
+ apiKey?: string | ((name: string) => string);
29
+ /**
30
+ * parameter for basic security
31
+ *
32
+ * @type {string}
33
+ * @memberof Configuration
34
+ */
35
+ username?: string;
36
+ /**
37
+ * parameter for basic security
38
+ *
39
+ * @type {string}
40
+ * @memberof Configuration
41
+ */
42
+ password?: string;
43
+ /**
44
+ * parameter for oauth2 security
45
+ * @param name security name
46
+ * @param scopes oauth2 scope
47
+ * @memberof Configuration
48
+ */
49
+ accessToken?: string | ((name: string, scopes?: string[]) => string);
50
+ /**
51
+ * override base path
52
+ *
53
+ * @type {string}
54
+ * @memberof Configuration
55
+ */
56
+ basePath?: string;
57
+
58
+ constructor(param: ConfigurationParameters = {}) {
59
+ this.apiKey = param.apiKey;
60
+ this.username = param.username;
61
+ this.password = param.password;
62
+ this.accessToken = param.accessToken;
63
+ this.basePath = param.basePath;
64
+ }
65
+ }
package/custom.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare module 'isomorphic-fetch';
2
+ declare module 'url';
package/git_push.sh ADDED
@@ -0,0 +1,51 @@
1
+ #!/bin/sh
2
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
+ #
4
+ # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
5
+
6
+ git_user_id=$1
7
+ git_repo_id=$2
8
+ release_note=$3
9
+
10
+ if [ "$git_user_id" = "" ]; then
11
+ git_user_id="GIT_USER_ID"
12
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
13
+ fi
14
+
15
+ if [ "$git_repo_id" = "" ]; then
16
+ git_repo_id="GIT_REPO_ID"
17
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
18
+ fi
19
+
20
+ if [ "$release_note" = "" ]; then
21
+ release_note="Minor update"
22
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
23
+ fi
24
+
25
+ # Initialize the local directory as a Git repository
26
+ git init
27
+
28
+ # Adds the files in the local repository and stages them for commit.
29
+ git add .
30
+
31
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
32
+ git commit -m "$release_note"
33
+
34
+ # Sets the new remote
35
+ git_remote=`git remote`
36
+ if [ "$git_remote" = "" ]; then # git remote not defined
37
+
38
+ if [ "$GIT_TOKEN" = "" ]; then
39
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
40
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
41
+ else
42
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
43
+ fi
44
+
45
+ fi
46
+
47
+ git pull origin master
48
+
49
+ # Pushes (Forces) the changes in the local repository up to the remote repository
50
+ echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
51
+ git push origin master 2>&1 | grep -v 'To https'
package/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ // tslint:disable
2
+ /**
3
+ * Token Metadata API
4
+ * Service that indexes metadata for every SIP-009, SIP-010, and SIP-013 Token in the Stacks blockchain and exposes it via REST API endpoints.
5
+ *
6
+ * OpenAPI spec version: v0.1.0
7
+ *
8
+ *
9
+ * NOTE: This file is auto generated by the swagger code generator program.
10
+ * https://github.com/swagger-api/swagger-codegen.git
11
+ * Do not edit the file manually.
12
+ */
13
+
14
+ export * from "./api";
15
+ export * from "./configuration";
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@hirosystems/token-metadata-api-client",
3
+ "version": "1.0.0",
4
+ "description": "Client for @hirosystems/token-metadata-api",
5
+ "author": "Hiro Systems PBC <engineering@hiro.so> (https://hiro.so)",
6
+ "keywords": [
7
+ "fetch",
8
+ "typescript",
9
+ "swagger-client",
10
+ "@hirosystems/token-metadata-api-client"
11
+ ],
12
+ "license": "GPL-3.0",
13
+ "main": "./dist/index.js",
14
+ "typings": "./dist/index.d.ts",
15
+ "scripts" : {
16
+ "build": "tsc --outDir dist/",
17
+ "test": "jest",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "dependencies": {
21
+ "isomorphic-fetch": "^3.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/jest": "^25.2.1",
25
+ "@types/node": "^13.13.0",
26
+ "@types/babel__core": "7.1.18",
27
+ "@types/babel__traverse": "7.14.2",
28
+ "jest": "^25.4.0",
29
+ "ts-jest": "^25.4.0",
30
+ "typescript": "^3.8.3"
31
+ },
32
+ "jest": {
33
+ "transform": {
34
+ "^.+\\.tsx?$": "ts-jest"
35
+ },
36
+ "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
37
+ "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
38
+ }}
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "es5",
5
+ "module": "commonjs",
6
+ "noImplicitAny": true,
7
+ "outDir": "dist",
8
+ "rootDir": ".",
9
+ "lib": [
10
+ "es6",
11
+ "dom"
12
+ ]
13
+ },
14
+ "exclude": [
15
+ "dist",
16
+ "node_modules",
17
+ "**/*.spec.ts"
18
+ ]
19
+ }