1- import { EU_CONSTANTS , EU_BASE_URL } from './../constants/europe' ;
1+ import { EU_CONSTANTS , EU_BASE_URL , EU_API_HOST , EU_CLIENT_ID } from './../constants/europe' ;
22import { BlueLinkyConfig , Session } from './../interfaces/common.interfaces' ;
33import * as pr from 'push-receiver' ;
44import got from 'got' ;
@@ -27,7 +27,7 @@ export class EuropeanController extends SessionController {
2727 controlToken : undefined ,
2828 deviceId : this . uuidv4 ( ) ,
2929 tokenExpiresAt : 0 ,
30- controlTokenExpiresAt : 0
30+ controlTokenExpiresAt : 0 ,
3131 } ;
3232
3333 private vehicles : Array < EuropeanVehicle > = [ ] ;
@@ -80,15 +80,15 @@ export class EuropeanController extends SessionController {
8080 method : 'POST' ,
8181 json : true ,
8282 body : {
83- " email" : this . userConfig . username ,
84- " password" : this . userConfig . password ,
83+ ' email' : this . userConfig . username ,
84+ ' password' : this . userConfig . password ,
8585 } ,
8686 cookieJar,
8787 } ) ;
8888
89- if ( authCodeResponse ) {
89+ if ( authCodeResponse ) {
9090 const regexMatch = / c o d e = ( [ ^ & ] * ) / g. exec ( authCodeResponse . body . redirectUrl ) ;
91- if ( regexMatch !== null ) {
91+ if ( regexMatch !== null ) {
9292 this . session . refreshToken = regexMatch [ 1 ] ;
9393 } else {
9494 throw new Error ( '@EuropeControllerLogin: AuthCode was not found' ) ;
@@ -99,10 +99,9 @@ export class EuropeanController extends SessionController {
9999 const notificationReponse = await got ( `${ EU_BASE_URL } /api/v1/spa/notifications/register` , {
100100 method : 'POST' ,
101101 headers : {
102- 'ccsp-service-id' : '6d477c38-3ca4-4cf3-9557-2a1929a94654' ,
102+ 'ccsp-service-id' : EU_CLIENT_ID ,
103103 'Content-Type' : 'application/json;charset=UTF-8' ,
104- 'Content-Length' : '231' ,
105- 'Host' : 'prd.eu-ccapi.hyundai.com:8080' ,
104+ 'Host' : EU_API_HOST ,
106105 'Connection' : 'Keep-Alive' ,
107106 'Accept-Encoding' : 'gzip' ,
108107 'User-Agent' : 'okhttp/3.10.0' ,
@@ -115,15 +114,15 @@ export class EuropeanController extends SessionController {
115114 json : true ,
116115 } ) ;
117116
118- if ( notificationReponse ) {
117+ if ( notificationReponse ) {
119118 this . session . deviceId = notificationReponse . body . resMsg . deviceId ;
120119 }
121120
122121 const formData = new URLSearchParams ( ) ;
123122 formData . append ( 'grant_type' , 'authorization_code' ) ;
124123 formData . append ( 'redirect_uri' , ALL_ENDPOINTS . EU . redirectUri ) ;
125124
126- if ( this . session . refreshToken ) {
125+ if ( this . session . refreshToken ) {
127126 formData . append ( 'code' , this . session . refreshToken ) ;
128127 }
129128
@@ -132,8 +131,7 @@ export class EuropeanController extends SessionController {
132131 headers : {
133132 'Authorization' : EU_CONSTANTS . basicToken ,
134133 'Content-Type' : 'application/x-www-form-urlencoded' ,
135- 'Content-Length' : '154' ,
136- 'Host' : 'prd.eu-ccapi.hyundai.com:8080' ,
134+ 'Host' : EU_API_HOST ,
137135 'Connection' : 'Keep-Alive' ,
138136 'Accept-Encoding' : 'gzip' ,
139137 'User-Agent' : 'okhttp/3.10.0' ,
@@ -146,7 +144,7 @@ export class EuropeanController extends SessionController {
146144 Promise . reject ( `Get token failed: ${ err } ` ) ;
147145 } ) ;
148146
149- if ( response ) {
147+ if ( response ) {
150148 const responseBody = JSON . parse ( response . body ) ;
151149 this . session . accessToken = 'Bearer ' + responseBody . access_token ;
152150 }
0 commit comments