From e8966d50427bac1bc09b46cb1463999fe7383f96 Mon Sep 17 00:00:00 2001 From: Kevin O'Sullivan Date: Wed, 10 May 2023 15:59:53 +0000 Subject: [PATCH 1/2] Add changeset file --- .changeset/sour-paws-tap.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sour-paws-tap.md diff --git a/.changeset/sour-paws-tap.md b/.changeset/sour-paws-tap.md new file mode 100644 index 000000000..70ce7f520 --- /dev/null +++ b/.changeset/sour-paws-tap.md @@ -0,0 +1,5 @@ +--- +'@shopify/shopify-api': patch +--- + +Restoring REST resources for 2022-04, updates to certain resources for other API versions From ae0f2712cd9f3273ba38b2c146579ba7dc778307 Mon Sep 17 00:00:00 2001 From: Kevin O'Sullivan Date: Wed, 10 May 2023 18:25:20 +0000 Subject: [PATCH 2/2] Add updates to OrderRisk --- rest/admin/2022-04/order_risk.ts | 2 +- rest/admin/2022-07/order_risk.ts | 2 +- rest/admin/2022-10/order_risk.ts | 2 +- rest/admin/2023-01/order_risk.ts | 2 +- rest/admin/2023-04/order_risk.ts | 2 +- rest/admin/__tests__/2022-04/order_risk.test.ts | 12 ++++++------ rest/admin/__tests__/2022-07/order_risk.test.ts | 12 ++++++------ rest/admin/__tests__/2022-10/order_risk.test.ts | 12 ++++++------ rest/admin/__tests__/2023-01/order_risk.test.ts | 12 ++++++------ rest/admin/__tests__/2023-04/order_risk.test.ts | 12 ++++++------ 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/rest/admin/2022-04/order_risk.ts b/rest/admin/2022-04/order_risk.ts index 3163fa922..0b7eb8343 100644 --- a/rest/admin/2022-04/order_risk.ts +++ b/rest/admin/2022-04/order_risk.ts @@ -100,6 +100,6 @@ export class OrderRisk extends Base { public message: string | null; public order_id: number | null; public recommendation: string | null; - public score: number | null; + public score: string | null; public source: string | null; } diff --git a/rest/admin/2022-07/order_risk.ts b/rest/admin/2022-07/order_risk.ts index 206bfc632..77253c1cf 100644 --- a/rest/admin/2022-07/order_risk.ts +++ b/rest/admin/2022-07/order_risk.ts @@ -100,6 +100,6 @@ export class OrderRisk extends Base { public message: string | null; public order_id: number | null; public recommendation: string | null; - public score: number | null; + public score: string | null; public source: string | null; } diff --git a/rest/admin/2022-10/order_risk.ts b/rest/admin/2022-10/order_risk.ts index a4b34eae7..c4f7e6fd2 100644 --- a/rest/admin/2022-10/order_risk.ts +++ b/rest/admin/2022-10/order_risk.ts @@ -100,6 +100,6 @@ export class OrderRisk extends Base { public message: string | null; public order_id: number | null; public recommendation: string | null; - public score: number | null; + public score: string | null; public source: string | null; } diff --git a/rest/admin/2023-01/order_risk.ts b/rest/admin/2023-01/order_risk.ts index 9a77ea73b..eddfc38e9 100644 --- a/rest/admin/2023-01/order_risk.ts +++ b/rest/admin/2023-01/order_risk.ts @@ -100,6 +100,6 @@ export class OrderRisk extends Base { public message: string | null; public order_id: number | null; public recommendation: string | null; - public score: number | null; + public score: string | null; public source: string | null; } diff --git a/rest/admin/2023-04/order_risk.ts b/rest/admin/2023-04/order_risk.ts index a32a5a4b0..4e2072572 100644 --- a/rest/admin/2023-04/order_risk.ts +++ b/rest/admin/2023-04/order_risk.ts @@ -100,6 +100,6 @@ export class OrderRisk extends Base { public message: string | null; public order_id: number | null; public recommendation: string | null; - public score: number | null; + public score: string | null; public source: string | null; } diff --git a/rest/admin/__tests__/2022-04/order_risk.test.ts b/rest/admin/__tests__/2022-04/order_risk.test.ts index e75ac3c81..2ba82c843 100644 --- a/rest/admin/__tests__/2022-04/order_risk.test.ts +++ b/rest/admin/__tests__/2022-04/order_risk.test.ts @@ -31,13 +31,13 @@ describe('OrderRisk resource', () => { session.accessToken = 'this_is_a_test_token'; it('test_1', async () => { - queueMockResponse(JSON.stringify({"risk": {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); + queueMockResponse(JSON.stringify({"risk": {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); const order_risk = new shopify.rest.OrderRisk({session: session}); order_risk.order_id = 450789469; order_risk.message = "This order came from an anonymous proxy"; order_risk.recommendation = "cancel"; - order_risk.score = 1.0; + order_risk.score = "1.0"; order_risk.source = "External"; order_risk.cause_cancel = true; order_risk.display = true; @@ -49,12 +49,12 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-04/orders/450789469/risks.json', query: '', headers, - data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": 1.0, "source": "External", "cause_cancel": true, "display": true} } + data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": "1.0", "source": "External", "cause_cancel": true, "display": true} } }).toMatchMadeHttpRequest(); }); it('test_2', async () => { - queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); + queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); await shopify.rest.OrderRisk.all({ session: session, @@ -100,7 +100,7 @@ describe('OrderRisk resource', () => { order_risk.recommendation = "accept"; order_risk.source = "External"; order_risk.cause_cancel = false; - order_risk.score = 0.0; + order_risk.score = "0.0"; await order_risk.save({}); expect({ @@ -109,7 +109,7 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-04/orders/450789469/risks/284138680.json', query: '', headers, - data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": 0.0} } + data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": "0.0"} } }).toMatchMadeHttpRequest(); }); diff --git a/rest/admin/__tests__/2022-07/order_risk.test.ts b/rest/admin/__tests__/2022-07/order_risk.test.ts index 62772acbe..38dfe6b7b 100644 --- a/rest/admin/__tests__/2022-07/order_risk.test.ts +++ b/rest/admin/__tests__/2022-07/order_risk.test.ts @@ -31,13 +31,13 @@ describe('OrderRisk resource', () => { session.accessToken = 'this_is_a_test_token'; it('test_1', async () => { - queueMockResponse(JSON.stringify({"risk": {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); + queueMockResponse(JSON.stringify({"risk": {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); const order_risk = new shopify.rest.OrderRisk({session: session}); order_risk.order_id = 450789469; order_risk.message = "This order came from an anonymous proxy"; order_risk.recommendation = "cancel"; - order_risk.score = 1.0; + order_risk.score = "1.0"; order_risk.source = "External"; order_risk.cause_cancel = true; order_risk.display = true; @@ -49,12 +49,12 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-07/orders/450789469/risks.json', query: '', headers, - data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": 1.0, "source": "External", "cause_cancel": true, "display": true} } + data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": "1.0", "source": "External", "cause_cancel": true, "display": true} } }).toMatchMadeHttpRequest(); }); it('test_2', async () => { - queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); + queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); await shopify.rest.OrderRisk.all({ session: session, @@ -100,7 +100,7 @@ describe('OrderRisk resource', () => { order_risk.recommendation = "accept"; order_risk.source = "External"; order_risk.cause_cancel = false; - order_risk.score = 0.0; + order_risk.score = "0.0"; await order_risk.save({}); expect({ @@ -109,7 +109,7 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-07/orders/450789469/risks/284138680.json', query: '', headers, - data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": 0.0} } + data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": "0.0"} } }).toMatchMadeHttpRequest(); }); diff --git a/rest/admin/__tests__/2022-10/order_risk.test.ts b/rest/admin/__tests__/2022-10/order_risk.test.ts index 08dc0e284..5dc4a48a9 100644 --- a/rest/admin/__tests__/2022-10/order_risk.test.ts +++ b/rest/admin/__tests__/2022-10/order_risk.test.ts @@ -31,13 +31,13 @@ describe('OrderRisk resource', () => { session.accessToken = 'this_is_a_test_token'; it('test_1', async () => { - queueMockResponse(JSON.stringify({"risk": {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); + queueMockResponse(JSON.stringify({"risk": {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); const order_risk = new shopify.rest.OrderRisk({session: session}); order_risk.order_id = 450789469; order_risk.message = "This order came from an anonymous proxy"; order_risk.recommendation = "cancel"; - order_risk.score = 1.0; + order_risk.score = "1.0"; order_risk.source = "External"; order_risk.cause_cancel = true; order_risk.display = true; @@ -49,12 +49,12 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-10/orders/450789469/risks.json', query: '', headers, - data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": 1.0, "source": "External", "cause_cancel": true, "display": true} } + data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": "1.0", "source": "External", "cause_cancel": true, "display": true} } }).toMatchMadeHttpRequest(); }); it('test_2', async () => { - queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); + queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); await shopify.rest.OrderRisk.all({ session: session, @@ -100,7 +100,7 @@ describe('OrderRisk resource', () => { order_risk.recommendation = "accept"; order_risk.source = "External"; order_risk.cause_cancel = false; - order_risk.score = 0.0; + order_risk.score = "0.0"; await order_risk.save({}); expect({ @@ -109,7 +109,7 @@ describe('OrderRisk resource', () => { path: '/admin/api/2022-10/orders/450789469/risks/284138680.json', query: '', headers, - data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": 0.0} } + data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": "0.0"} } }).toMatchMadeHttpRequest(); }); diff --git a/rest/admin/__tests__/2023-01/order_risk.test.ts b/rest/admin/__tests__/2023-01/order_risk.test.ts index f73116a2e..de04ea7e8 100644 --- a/rest/admin/__tests__/2023-01/order_risk.test.ts +++ b/rest/admin/__tests__/2023-01/order_risk.test.ts @@ -31,13 +31,13 @@ describe('OrderRisk resource', () => { session.accessToken = 'this_is_a_test_token'; it('test_1', async () => { - queueMockResponse(JSON.stringify({"risk": {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); + queueMockResponse(JSON.stringify({"risk": {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); const order_risk = new shopify.rest.OrderRisk({session: session}); order_risk.order_id = 450789469; order_risk.message = "This order came from an anonymous proxy"; order_risk.recommendation = "cancel"; - order_risk.score = 1.0; + order_risk.score = "1.0"; order_risk.source = "External"; order_risk.cause_cancel = true; order_risk.display = true; @@ -49,12 +49,12 @@ describe('OrderRisk resource', () => { path: '/admin/api/2023-01/orders/450789469/risks.json', query: '', headers, - data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": 1.0, "source": "External", "cause_cancel": true, "display": true} } + data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": "1.0", "source": "External", "cause_cancel": true, "display": true} } }).toMatchMadeHttpRequest(); }); it('test_2', async () => { - queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); + queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); await shopify.rest.OrderRisk.all({ session: session, @@ -100,7 +100,7 @@ describe('OrderRisk resource', () => { order_risk.recommendation = "accept"; order_risk.source = "External"; order_risk.cause_cancel = false; - order_risk.score = 0.0; + order_risk.score = "0.0"; await order_risk.save({}); expect({ @@ -109,7 +109,7 @@ describe('OrderRisk resource', () => { path: '/admin/api/2023-01/orders/450789469/risks/284138680.json', query: '', headers, - data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": 0.0} } + data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": "0.0"} } }).toMatchMadeHttpRequest(); }); diff --git a/rest/admin/__tests__/2023-04/order_risk.test.ts b/rest/admin/__tests__/2023-04/order_risk.test.ts index 9145da789..b69213cd7 100644 --- a/rest/admin/__tests__/2023-04/order_risk.test.ts +++ b/rest/admin/__tests__/2023-04/order_risk.test.ts @@ -31,13 +31,13 @@ describe('OrderRisk resource', () => { session.accessToken = 'this_is_a_test_token'; it('test_1', async () => { - queueMockResponse(JSON.stringify({"risk": {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); + queueMockResponse(JSON.stringify({"risk": {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}})); const order_risk = new shopify.rest.OrderRisk({session: session}); order_risk.order_id = 450789469; order_risk.message = "This order came from an anonymous proxy"; order_risk.recommendation = "cancel"; - order_risk.score = 1.0; + order_risk.score = "1.0"; order_risk.source = "External"; order_risk.cause_cancel = true; order_risk.display = true; @@ -49,12 +49,12 @@ describe('OrderRisk resource', () => { path: '/admin/api/2023-04/orders/450789469/risks.json', query: '', headers, - data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": 1.0, "source": "External", "cause_cancel": true, "display": true} } + data: { "risk": {"message": "This order came from an anonymous proxy", "recommendation": "cancel", "score": "1.0", "source": "External", "cause_cancel": true, "display": true} } }).toMatchMadeHttpRequest(); }); it('test_2', async () => { - queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151490, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); + queueMockResponse(JSON.stringify({"risks": [{"id": 284138680, "order_id": 450789469, "checkout_id": null, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order was placed from a proxy IP", "merchant_message": "This order was placed from a proxy IP"}, {"id": 1029151489, "order_id": 450789469, "checkout_id": 901414060, "source": "External", "score": "1.0", "recommendation": "cancel", "display": true, "cause_cancel": true, "message": "This order came from an anonymous proxy", "merchant_message": "This order came from an anonymous proxy"}]})); await shopify.rest.OrderRisk.all({ session: session, @@ -100,7 +100,7 @@ describe('OrderRisk resource', () => { order_risk.recommendation = "accept"; order_risk.source = "External"; order_risk.cause_cancel = false; - order_risk.score = 0.0; + order_risk.score = "0.0"; await order_risk.save({}); expect({ @@ -109,7 +109,7 @@ describe('OrderRisk resource', () => { path: '/admin/api/2023-04/orders/450789469/risks/284138680.json', query: '', headers, - data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": 0.0} } + data: { "risk": {"message": "After further review, this is a legitimate order", "recommendation": "accept", "source": "External", "cause_cancel": false, "score": "0.0"} } }).toMatchMadeHttpRequest(); });