WIP
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import { RESTDataSource } from 'apollo-datasource-rest';
|
||||||
|
|
||||||
|
/*
|
||||||
|
https://wE4D45790.api.esales.apptus.cloud/api/v2/panels/category
|
||||||
|
?esales.market=SE&
|
||||||
|
esales.customerKey=471c09ac-a775-4dd2-8bfc-041bfbb6d7b7&
|
||||||
|
esales.sessionKey=b106299c-eac0-4f6f-96d2-93e57c255784&
|
||||||
|
window_first=1&
|
||||||
|
window_last=10&
|
||||||
|
selected_category=categories_SE:'root/animals'&
|
||||||
|
root_category=categories_SE:'root'
|
||||||
|
&max_facets=50
|
||||||
|
&filter=blacklisted:'0' AND visible_in_listing:'1' AND visible_in_shop:'1' AND (group:'poster' OR group:'framed-print')
|
||||||
|
blacklisted:'0'%20AND%20visible_in_listing:'1'%20AND%20visible_in_shop:'1'%20AND%20(group:'poster'%20OR%20group:'framed-print')
|
||||||
|
|
||||||
|
*/
|
||||||
|
export class Api2DataSource extends RESTDataSource {
|
||||||
|
authHeader: string;
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.baseURL = 'https://api-staging.photowall.com/';
|
||||||
|
this.authHeader =
|
||||||
|
'Basic ZGExNzU5ZWEtOTBiNC00OTNjLWJjYWItNjAwNDg1NjA5YjkyOg==';
|
||||||
|
}
|
||||||
|
|
||||||
|
willSendRequest(request) {
|
||||||
|
request.headers.set('Authorization', this.authHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPrice(market, width, height, sku) {
|
||||||
|
return await this.get(
|
||||||
|
'prices/wallpaper?' +
|
||||||
|
new URLSearchParams({
|
||||||
|
width: '200',
|
||||||
|
height: '200',
|
||||||
|
market: '1',
|
||||||
|
product: '58941',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
function isNumeric(n: any) {
|
||||||
|
return !isNaN(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isBoolean(n: any) {
|
||||||
|
if (typeof n === 'boolean') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
n = new String(n).toLowerCase();
|
||||||
|
if (n === 'true' || n == 'false') {
|
||||||
|
return Boolean(n);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function convertToPossibleType(n: any) {
|
||||||
|
if (isBoolean(n)) return Boolean('false');
|
||||||
|
if (isNumeric(n)) return Number(n);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user