-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support V2 endpoints #33
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Improved LoggingBeforeimport Printify, { Webhook } from 'printify-sdk-js';
const printify = new Printify({
shopId: '12345',
accessToken: '{{API_KEY}},
enableLogging: true,
});
(async () => {
const webhooks: Webhook[] = await printify.webhooks.list();
console.log(webhooks[0]); // { "topic": "order:created", "url": "https://example.com/webhooks/order/created", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec4" }
})(); # request log
$ tsc && node app.js
Requesting GET https://api.printify.com/v1/shops/12345/webhooks.json # request error
$ tsc && node app.js
Printify SDK Error: 401 Unauthorized - Requested URL: https://api.printify.com/v1/shops/123456/webhooks.json
/workspaces/printify-sdk-js/examples/typescript/node_modules/printify-sdk-js/dist/index.cjs.js:1
//...
{super(t),this.list=nt.bind(this),this.create=it.bind(this),this.updateOne=ot.bind(this),this.deleteOne=rt.bind(this)}}module.exports=class{constructor(t){if(!t.accessToken)throw new Error("accessToken is required");this.shopId=t.shopId,this.catalog=new S(t),this.v2={catalog:new N(t)},this.orders=new G(t),this.products=new K(t),this.shops=new Z(t),this.uploads=new et(t),this.webhooks=new ht(t)}};
Error: Printify SDK Error: 401 Unauthorized - Requested URL: https://api.printify.com/v1/shops/123456/webhooks.json
at ht.request (/workspaces/printify-sdk-js/examples/typescript/node_modules/printify-sdk-js/dist/index.cjs.js:1:5029)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.18.1
error Command failed with exit code 1. Afterimport Printify, { Webhook } from 'printify-sdk-js';
const printify = new Printify({
shopId: '12345',
accessToken: '{{API_KEY}},
enableLogging: true,
});
(async () => {
const webhooks: Webhook[] = await printify.webhooks.list();
console.log(webhooks[0]); // { "topic": "order:created", "url": "https://example.com/webhooks/order/created", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec4" }
})(); # request log
$ tsc && node app.js
[2025-01-06T11:51:56.573Z] Request: GET https://api.printify.com/v1/shops/12345/webhooks.json # request error
$ tsc && node app.js
$ tsc && node app.js
[2025-01-06T12:35:13.540Z] Request: GET https://api.printify.com/v1/shops/123456/webhooks.json
Printify SDK Error: 401 Unauthorized - Requested URL: https://api.printify.com/v1/shops/123456/webhooks.json
[Error: Printify SDK Error: 401 Unauthorized - Requested URL: https://api.printify.com/v1/shops/123456/webhooks.json]
Done in 2.54s. |
5962584
to
6d0be7f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
1.3.0
minor bump (+CHANGELOG)