← back to Dw Signup Fulfillment
verification/tk10836/verify-3free.js
42 lines
'use strict';
const config = require('../../lib/config');
const shop = config.SHOP_DOMAIN, token = config.SHOPIFY_FULFILLMENT_TOKEN;
const Q = `
query GetCode($code: String!) {
codeDiscountNodeByCode(code: $code) {
id
codeDiscount {
__typename
... on DiscountCodeBasic {
title
status
startsAt
endsAt
appliesOncePerCustomer
usageLimit
asyncUsageCount
combinesWith { orderDiscounts productDiscounts shippingDiscounts }
customerSelection { __typename }
minimumRequirement { __typename }
customerGets {
appliesOnOneTimePurchase
value {
__typename
... on DiscountAmount { amount { amount currencyCode } appliesOnEachItem }
... on DiscountPercentage { percentage }
}
items { __typename }
}
codes(first: 5) { nodes { code } }
}
}
}
}`;
(async () => {
const r = await fetch(`https://${shop}/admin/api/2024-10/graphql.json`, {
method: 'POST', headers: { 'X-Shopify-Access-Token': token, 'Content-Type': 'application/json' },
body: JSON.stringify({ query: Q, variables: { code: '3FREE' } }) });
const j = await r.json();
console.log(JSON.stringify(j, null, 2));
})().catch(e => { console.error('ERR', e.message); process.exit(1); });