All files / src ABaseShoptet.ts

84.61% Statements 11/13
100% Branches 4/4
50% Functions 1/2
84.61% Lines 11/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36  12x   12x   12x   12x               6x 2x   4x 4x 4x 2x     4x                      
import WebhookSubscription from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Webhook/WebhookSubscription';
import { ABasicApplication } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
 
export const BASE_URL = 'https://api.myshoptet.com';
 
export const PRODUCTS_IN_PROGRESS_KEY = 'productsInProgress';
 
export default abstract class ABaseShoptet extends ABasicApplication {
 
    protected abstract authorizationHeader: string;
 
    public static shoptetDateISO(
        date: Date | string,
        hourOffset?: number,
    ): string {
        if (!date) {
            return '';
        }
        try {
            const newDate = new Date(date);
            if (hourOffset) {
                newDate.setMinutes(newDate.getMinutes() + hourOffset * 60);
            }
 
            return `${newDate.toISOString().split('.')[0]}Z`;
        } catch (e) {
            throw new Error(`${date} is not in the correct format`, { cause: e });
        }
    }
 
    public getWebhookSubscriptions(): WebhookSubscription[] {
        return [];
    }
 
}