@@ -53,6 +53,7 @@ export class Client {
5353 tokenContainer : TokenContainer | null ,
5454 posToken : PosToken | null ,
5555 environment ?: Environment ,
56+ platformInfo ?: string ,
5657 bitPayClient ?: BitPayClient , // using for tests
5758 guidGenerator ?: GuidGenerator // using for tests
5859 ) {
@@ -82,13 +83,18 @@ export class Client {
8283 const ecKey = this . getEcKeyByPrivateKey ( privateKey ) ;
8384 this . guidGenerator = new GuidGenerator ( ) ;
8485 this . tokenContainer = tokenContainer ;
85- this . bitPayClient = new BitPayClient ( Client . getBaseUrl ( environment ) , ecKey , this . getIdentity ( ecKey ) ) ;
86+ this . bitPayClient = new BitPayClient (
87+ Client . getBaseUrl ( environment ) ,
88+ ecKey ,
89+ this . getIdentity ( ecKey ) ,
90+ platformInfo
91+ ) ;
8692 return ;
8793 }
8894
8995 this . tokenContainer = tokenContainer ;
9096 this . guidGenerator = new GuidGenerator ( ) ;
91- this . bitPayClient = new BitPayClient ( Client . getBaseUrl ( environment ) , null , null ) ;
97+ this . bitPayClient = new BitPayClient ( Client . getBaseUrl ( environment ) , null , null , platformInfo ) ;
9298
9399 if ( posToken !== null ) {
94100 this . tokenContainer . addPos ( posToken . getValue ( ) ) ;
@@ -101,17 +107,17 @@ export class Client {
101107 * @param posToken
102108 * @param environment
103109 */
104- public static createPosClient ( posToken : string , environment ?: Environment ) : Client {
105- return new Client ( null , null , null , new PosToken ( posToken ) , environment ) ;
110+ public static createPosClient ( posToken : string , environment ?: Environment , platformInfo ?: string ) : Client {
111+ return new Client ( null , null , null , new PosToken ( posToken ) , environment , platformInfo ) ;
106112 }
107113
108114 /**
109115 * Client factory based on config file
110116 *
111117 * @param configFilePath
112118 */
113- public static createClientByConfig ( configFilePath : string ) : Client {
114- return new Client ( configFilePath , null , null , null ) ;
119+ public static createClientByConfig ( configFilePath : string , platformInfo ?: string ) : Client {
120+ return new Client ( configFilePath , null , null , null , undefined , platformInfo ) ;
115121 }
116122
117123 /**
@@ -123,9 +129,10 @@ export class Client {
123129 public static createClientByPrivateKey (
124130 privateKey : string ,
125131 tokenContainer : TokenContainer ,
126- environment ?: Environment
132+ environment ?: Environment ,
133+ platformInfo ?: string
127134 ) {
128- return new Client ( null , new PrivateKey ( privateKey ) , tokenContainer , null , environment ) ;
135+ return new Client ( null , new PrivateKey ( privateKey ) , tokenContainer , null , environment , platformInfo ) ;
129136 }
130137
131138 public getToken ( facade : Facade ) {
@@ -811,7 +818,7 @@ export class Client {
811818 return date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
812819 }
813820
814- private initByConfigFilePath ( configFilePath : string ) : void {
821+ private initByConfigFilePath ( configFilePath : string , platformInfo ?: string ) : void {
815822 if ( ! fs . existsSync ( configFilePath ) ) {
816823 BitPayExceptionProvider . throwGenericExceptionWithMessage ( 'Configuration file not found' ) ;
817824 }
@@ -823,7 +830,12 @@ export class Client {
823830 const tokens = envConfig [ 'ApiTokens' ] ;
824831 this . tokenContainer = new TokenContainer ( tokens ) ;
825832 const ecKey = this . getEcKeyByConfig ( envConfig ) ;
826- this . bitPayClient = new BitPayClient ( Client . getBaseUrl ( environment ) , ecKey , this . getIdentity ( ecKey ) ) ;
833+ this . bitPayClient = new BitPayClient (
834+ Client . getBaseUrl ( environment ) ,
835+ ecKey ,
836+ this . getIdentity ( ecKey ) ,
837+ platformInfo
838+ ) ;
827839 this . guidGenerator = new GuidGenerator ( ) ;
828840 } catch ( e : any ) {
829841 BitPayExceptionProvider . throwGenericExceptionWithMessage ( 'Error when reading configuration file' ) ;
0 commit comments