import { UnreachableCaseError } from '../../types';
import { CustomerTypeName } from './Customer';
import { InventoryLevelTypeName } from './InventoryLevel';
import { LineItemTypeName } from './LineItem';
import { LocationTypeName } from './Location';
import { OrderTypeName } from './Order';
import { ProductTypeName } from './Product';
import { ProductVariantTypeName } from './ProductVariant';
export function isProductType(sot) {
    if (sot !== ProductVariantTypeName) {
        throw `Not ${ProductTypeName}`;
    }
    return sot;
}
export function getRestId(graphqlId) {
    const idParts = graphqlId.split('/');
    return parseInt(idParts[idParts.length - 1]);
}
export function getGraphqlId(restId, shopifyObjectType) {
    const gidPrefix = 'gid://shopify/';
    switch (shopifyObjectType) {
        case OrderTypeName: {
            return `${gidPrefix}Order/${restId}`;
        }
        case ProductTypeName: {
            return `${gidPrefix}Product/${restId}`;
        }
        case ProductVariantTypeName: {
            return `${gidPrefix}ProductVariant/${restId}`;
        }
        case LocationTypeName: {
            return `${gidPrefix}Location/${restId}`;
        }
        case InventoryLevelTypeName: {
            return `${gidPrefix}InventoryLevel/${restId}`;
        }
        case LineItemTypeName: {
            return `${gidPrefix}LineItem/${restId}`;
        }
        case CustomerTypeName: {
            return `${gidPrefix}Customer/${restId}`;
        }
        default: {
            throw new UnreachableCaseError(shopifyObjectType);
        }
    }
}
//# sourceMappingURL=shopifyModelUtil.js.map