@synonymdev/blocktank-client
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -1,6 +0,8 @@ | ||
import { IBuyChannelRequest, IBuyChannelResponse, IGetInfoResponse, IGetOrderResponse } from './types'; | ||
import { IBuyChannelRequest, IBuyChannelResponse, IGetInfoResponse, IGetOrderResponse, IHeaders } from './types'; | ||
declare class Blocktank { | ||
private host; | ||
private additionalHeaders; | ||
constructor(); | ||
setNetwork(network: 'mainnet' | 'testnet' | 'regtest'): void; | ||
setHeaders(headers: IHeaders): void; | ||
static getStateMessage(code: number): string; | ||
@@ -7,0 +9,0 @@ call(path: string, method: 'GET' | 'POST', request?: any): Promise<any>; |
@@ -63,2 +63,3 @@ "use strict"; | ||
this.host = ''; | ||
this.additionalHeaders = {}; | ||
this.setNetwork('testnet'); | ||
@@ -82,2 +83,5 @@ } | ||
}; | ||
Blocktank.prototype.setHeaders = function (headers) { | ||
this.additionalHeaders = headers; | ||
}; | ||
Blocktank.getStateMessage = function (code) { | ||
@@ -102,3 +106,3 @@ switch (code) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, headers, fetchRes, body; | ||
var url, fetchRes, body; | ||
return __generator(this, function (_a) { | ||
@@ -108,10 +112,5 @@ switch (_a.label) { | ||
url = "" + this.host + path; | ||
headers = { Accept: 'application/json' }; | ||
//Temp fix for cors error in browsers. | ||
if (typeof window !== 'undefined' && typeof window.document !== 'undefined') { | ||
headers['Content-Type'] = 'application/json'; | ||
} | ||
return [4 /*yield*/, fetch(url, { | ||
method: method, | ||
headers: headers, | ||
headers: __assign({ Accept: 'application/json' }, this.additionalHeaders), | ||
body: request ? JSON.stringify(request) : undefined | ||
@@ -118,0 +117,0 @@ })]; |
@@ -86,2 +86,5 @@ export declare type IService = { | ||
}; | ||
export declare type IHeaders = { | ||
[key: string]: string; | ||
}; | ||
export {}; |
{ | ||
"name": "@synonymdev/blocktank-client", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "LSP client library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
12888
291