Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Frigyes Bartha committed Jun 30, 2020
1 parent 76a25b3 commit a75b6ac
Showing 1 changed file with 41 additions and 24 deletions.
65 changes: 41 additions & 24 deletions carelink.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ var Client = exports.Client = function (options) {
return new URL(url).host;
}

function getPath(url) {
let u = new URL(url);
return `${u.pathname}${u.search}`;
}

function doLogin(next) {
let url = CARELINK_SECURITY_URL;
logger.log('POST ' + url);
Expand All @@ -118,9 +123,10 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
form: {
j_username: options.username,
j_password: options.password,
Expand All @@ -138,9 +144,10 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
}),
checkResponseThen(next)
);
Expand All @@ -165,12 +172,12 @@ var Client = exports.Client = function (options) {
logger.log('GET ' + url);

request.get(
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
}),
checkResponseThen(next)
);
Expand All @@ -185,9 +192,10 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
}),
checkResponseThen(next)
);
Expand All @@ -205,9 +213,10 @@ var Client = exports.Client = function (options) {
reqOptions({
jar: jar,
gzip: true,
headers: {
host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
form: {
sessionID: uriParam.get('sessionID'),
sessionData: uriParam.get('sessionData'),
Expand Down Expand Up @@ -237,9 +246,10 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
form: {
action: "consent",
sessionID: ps.sessionID,
Expand All @@ -261,9 +271,10 @@ var Client = exports.Client = function (options) {
url,
reqOptions({
jar: jar,
headers: {
Host: getHost(url),
},
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
}),
checkResponseThen(next)
);
Expand All @@ -279,8 +290,11 @@ var Client = exports.Client = function (options) {
jar: jar,
gzip: true,
json: true,
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
headers: {
Host: getHost(url),
Authorization: "Bearer " + _.get(getCookie(CARELINKEU_TOKEN_COOKIE), 'value', ''),
},
}),
Expand All @@ -305,8 +319,11 @@ var Client = exports.Client = function (options) {
var reqO = {
jar: jar,
gzip: true,
uri: url,
host: getHost(url),
path: getPath(url),
port: 443,
headers: {
Host: getHost(url),
},
};
if (CARELINK_EU) {
Expand Down

0 comments on commit a75b6ac

Please sign in to comment.