Skip to content

Commit 572d795

Browse files
authored
Merge pull request #602 from Shopify/rename-discount-schema
Rename discount schema properties
2 parents 43c003d + 7eaea91 commit 572d795

17 files changed

+276
-265
lines changed

Diff for: discounts/javascript/discount/default/src/discount.test.liquid

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("discount", () => {
2727

2828
expect(result.operations.length).toBe(2);
2929
expect(result.operations[0]).toMatchObject({
30-
addOrderDiscounts: {
30+
orderDiscountsAdd: {
3131
candidates: [
3232
{
3333
message: "10% OFF ORDER",
@@ -50,7 +50,7 @@ describe("discount", () => {
5050
});
5151

5252
expect(result.operations[1]).toMatchObject({
53-
addProductDiscounts: {
53+
productDiscountsAdd: {
5454
candidates: [
5555
{
5656
message: "20% OFF PRODUCT",
@@ -88,7 +88,7 @@ describe("discount", () => {
8888

8989
expect(result.operations.length).toBe(1);
9090
expect(result.operations[0]).toMatchObject({
91-
addDeliveryDiscounts: {
91+
deliveryDiscountsAdd: {
9292
candidates: [
9393
{
9494
message: "FREE DELIVERY",

Diff for: discounts/javascript/discount/default/src/generate_cart_run.liquid

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88

99
/**
1010
* @typedef {import("../generated/api").CartInput} CartInput
11-
* @typedef {import("../generated/api").FunctionCartRunResult} FunctionCartRunResult
11+
* @typedef {import("../generated/api").CartLinesDiscountsGenerateRunResult} CartLinesDiscountsGenerateRunResult
1212
*/
1313

1414
/**
1515
* generateCartRun
1616
* @param {CartInput} input - The CartInput
17-
* @returns {FunctionCartRunResult} - The function result with discounts.
17+
* @returns {CartLinesDiscountsGenerateRunResult} - The function result with discounts.
1818
*/
1919
export function generateCartRun(input) {
2020
if (!input.cart.lines.length) {
@@ -29,7 +29,7 @@ export function generateCartRun(input) {
2929
return {
3030
operations: [
3131
{
32-
addOrderDiscounts: {
32+
orderDiscountsAdd: {
3333
candidates: [
3434
{
3535
message: '10% OFF ORDER',
@@ -51,7 +51,7 @@ export function generateCartRun(input) {
5151
},
5252
},
5353
{
54-
addProductDiscounts: {
54+
productDiscountsAdd: {
5555
candidates: [
5656
{
5757
message: '20% OFF PRODUCT',
@@ -80,10 +80,10 @@ import {
8080
OrderDiscountSelectionStrategy,
8181
ProductDiscountSelectionStrategy,
8282
CartInput,
83-
FunctionCartRunResult,
83+
CartLinesDiscountsGenerateRunResult,
8484
} from '../generated/api';
8585

86-
export function generateCartRun(input: CartInput): FunctionCartRunResult {
86+
export function generateCartRun(input: CartInput): CartLinesDiscountsGenerateRunResult {
8787
if (!input.cart.lines.length) {
8888
throw new Error('No cart lines found');
8989
}
@@ -98,7 +98,7 @@ export function generateCartRun(input: CartInput): FunctionCartRunResult {
9898
return {
9999
operations: [
100100
{
101-
addOrderDiscounts: {
101+
orderDiscountsAdd: {
102102
candidates: [
103103
{
104104
message: '10% OFF ORDER',
@@ -120,7 +120,7 @@ export function generateCartRun(input: CartInput): FunctionCartRunResult {
120120
},
121121
},
122122
{
123-
addProductDiscounts: {
123+
productDiscountsAdd: {
124124
candidates: [
125125
{
126126
message: '20% OFF PRODUCT',

Diff for: discounts/javascript/discount/default/src/generate_delivery_run.liquid

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { DeliveryDiscountSelectionStrategy} from '../generated/api';
55

66
/**
77
* @typedef {import("../generated/api").DeliveryInput} RunInput
8-
* @typedef {import("../generated/api").FunctionDeliveryRunResult} FunctionDeliveryRunResult
8+
* @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
99
*/
1010
/**
1111
* generateDeliveryRun
1212
* @param {RunInput} input - The DeliveryInput
13-
* @returns {FunctionDeliveryRunResult} - The function result with discounts.
13+
* @returns {CartDeliveryOptionsDiscountsGenerateRunResult} - The function result with discounts.
1414
*/
1515
export function generateDeliveryRun(input) {
1616
const firstDeliveryGroup = input.cart.deliveryGroups[0];
@@ -20,7 +20,7 @@ export function generateDeliveryRun(input) {
2020
return {
2121
operations: [
2222
{
23-
addDeliveryDiscounts: {
23+
deliveryDiscountsAdd: {
2424
candidates: [
2525
{
2626
message: 'FREE DELIVERY',
@@ -48,12 +48,12 @@ export function generateDeliveryRun(input) {
4848
import {
4949
DeliveryDiscountSelectionStrategy,
5050
DeliveryInput,
51-
FunctionDeliveryRunResult,
51+
CartDeliveryOptionsDiscountsGenerateRunResult,
5252
} from '../generated/api';
5353

5454
export function generateDeliveryRun(
5555
input: DeliveryInput,
56-
): FunctionDeliveryRunResult {
56+
): CartDeliveryOptionsDiscountsGenerateRunResult {
5757
const firstDeliveryGroup = input.cart.deliveryGroups[0];
5858
if (!firstDeliveryGroup) {
5959
throw new Error('No delivery groups found');
@@ -62,7 +62,7 @@ export function generateDeliveryRun(
6262
return {
6363
operations: [
6464
{
65-
addDeliveryDiscounts: {
65+
deliveryDiscountsAdd: {
6666
candidates: [
6767
{
6868
message: 'FREE DELIVERY',

Diff for: discounts/javascript/network/default/src/generate_cart_fetch.liquid

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {HttpRequestMethod} from '../generated/api';
55

66
/**
77
* @typedef {import("../generated/api").InputCartFetch} InputCartFetch
8-
* @typedef {import("../generated/api").FunctionCartFetchResult} FunctionCartFetchResult
8+
* @typedef {import("../generated/api").CartLinesDiscountsGenerateFetchResult} CartLinesDiscountsGenerateFetchResult
99
*/
1010
/**
1111
* Generates a network request to fetch cart discount information
1212
* @param {InputCartFetch} input - The cart fetch input data
13-
* @returns {FunctionCartFetchResult} - The function result with network request configuration
13+
* @returns {CartLinesDiscountsGenerateFetchResult} - The function result with network request configuration
1414
*/
1515
export function generateCartFetch(input) {
1616
const { enteredDiscountCodes } = input;
@@ -36,12 +36,12 @@ export function generateCartFetch(input) {
3636
import {
3737
HttpRequestMethod,
3838
InputCartFetch,
39-
FunctionCartFetchResult,
39+
CartLinesDiscountsGenerateFetchResult,
4040
} from '../generated/api';
4141

4242
export function generateCartFetch(
4343
input: InputCartFetch,
44-
): FunctionCartFetchResult {
44+
): CartLinesDiscountsGenerateFetchResult {
4545
const {enteredDiscountCodes} = input;
4646
const jsonBody = {enteredDiscountCodes};
4747
const request = {

Diff for: discounts/javascript/network/default/src/generate_cart_run.liquid

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// @ts-check
33
/**
44
* @typedef {import("../generated/api").InputCartRun} InputCartRun
5-
* @typedef {import("../generated/api").FunctionCartRunResult} FunctionCartRunResult
5+
* @typedef {import("../generated/api").CartLinesDiscountsGenerateRunResult} CartLinesDiscountsGenerateRunResult
66
*/
77
/**
88
* Processes the fetched cart discount data and generates operations
99
* @param {InputCartRun} input - The cart run input data including fetch results
10-
* @returns {FunctionCartRunResult} - The function result with discount operations
10+
* @returns {CartLinesDiscountsGenerateRunResult} - The function result with discount operations
1111
*/
1212
export function generateCartRun(input) {
1313
const { fetchResult } = input;
@@ -20,9 +20,9 @@ export function generateCartRun(input) {
2020
return { operations };
2121
}
2222
{%- elsif flavor contains "typescript" -%}
23-
import {InputCartRun, FunctionCartRunResult} from '../generated/api';
23+
import {InputCartRun, CartLinesDiscountsGenerateRunResult} from '../generated/api';
2424

25-
export function generateCartRun(input: InputCartRun): FunctionCartRunResult {
25+
export function generateCartRun(input: InputCartRun): CartLinesDiscountsGenerateRunResult {
2626
const {fetchResult} = input;
2727
const body = fetchResult?.body;
2828

Diff for: discounts/javascript/network/default/src/generate_delivery_fetch.liquid

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import {HttpRequestMethod} from '../generated/api';
44

55
/**
66
* @typedef {import("../generated/api").InputDeliveryFetch} InputDeliveryFetch
7-
* @typedef {import("../generated/api").FunctionDeliveryFetchResult} FunctionDeliveryFetchResult
7+
* @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateFetchResult} CartDeliveryOptionsDiscountsGenerateFetchResult
88
*/
99
/**
1010
* Generates a network request to fetch delivery discount information
1111
* @param {InputDeliveryFetch} input - The delivery fetch input data
12-
* @returns {FunctionDeliveryFetchResult} - The function result with network request configuration
12+
* @returns {CartDeliveryOptionsDiscountsGenerateFetchResult} - The function result with network request configuration
1313
*/
1414
export function generateDeliveryFetch(input) {
1515
const { enteredDiscountCodes } = input;
@@ -35,11 +35,11 @@ export function generateDeliveryFetch(input) {
3535
import {
3636
HttpRequestMethod,
3737
InputDeliveryFetch,
38-
FunctionDeliveryFetchResult,
38+
CartDeliveryOptionsDiscountsGenerateFetchResult,
3939
} from '../generated/api';
4040
export function generateDeliveryFetch(
4141
input: InputDeliveryFetch,
42-
): FunctionDeliveryFetchResult {
42+
): CartDeliveryOptionsDiscountsGenerateFetchResult {
4343
const {enteredDiscountCodes} = input;
4444
const jsonBody = {enteredDiscountCodes};
4545

Diff for: discounts/javascript/network/default/src/generate_delivery_run.liquid

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// @ts-check
33
/**
44
* @typedef {import("../generated/api").InputDeliveryRun} InputDeliveryRun
5-
* @typedef {import("../generated/api").FunctionDeliveryRunResult} FunctionDeliveryRunResult
5+
* @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult
66
*/
77
/**
88
* Processes the fetched delivery discount data and generates operations
99
* @param {InputDeliveryRun} input - The delivery run input data including fetch results
10-
* @returns {FunctionDeliveryRunResult} - The function result with discount operations
10+
* @returns {CartDeliveryOptionsDiscountsGenerateRunResult} - The function result with discount operations
1111
*/
1212
export function generateDeliveryRun(input) {
1313
const { fetchResult } = input;
@@ -20,11 +20,11 @@ export function generateDeliveryRun(input) {
2020
return { operations };
2121
}
2222
{%- elsif flavor contains "typescript" -%}
23-
import {InputDeliveryRun, FunctionDeliveryRunResult} from '../generated/api';
23+
import {InputDeliveryRun, CartDeliveryOptionsDiscountsGenerateRunResult} from '../generated/api';
2424

2525
export function generateDeliveryRun(
2626
input: InputDeliveryRun,
27-
): FunctionDeliveryRunResult {
27+
): CartDeliveryOptionsDiscountsGenerateRunResult {
2828
const {fetchResult} = input;
2929
const body = fetchResult?.body;
3030

Diff for: discounts/javascript/network/default/src/network.test.liquid

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ describe("discount", () => {
6262
it("cart.lines.discounts.generate.run returns a list of operations", () => {
6363
const operations = [
6464
{
65-
addDiscountCodeValidations: {
65+
enteredDiscountCodesAccept: {
6666
codes: ["10% OFF ORDER", "20% OFF PRODUCT"],
6767
},
6868
},
6969
{
70-
addOrderDiscounts: {
70+
orderDiscountsAdd: {
7171
candidates: [
7272
{
7373
message: "10% OFF ORDER",
@@ -89,7 +89,7 @@ describe("discount", () => {
8989
},
9090
},
9191
{
92-
addProductDiscounts: {
92+
productDiscountsAdd: {
9393
candidates: [
9494
{
9595
message: "20% OFF PRODUCT",
@@ -126,12 +126,12 @@ describe("discount", () => {
126126
it("cart.delivery-options.discounts.generate.run returns a list of operations", () => {
127127
const operations = [
128128
{
129-
addDiscountCodeValidations: {
129+
enteredDiscountCodesAccept: {
130130
codes: ["FREE_DELIVERY"],
131131
},
132132
},
133133
{
134-
addDeliveryDiscounts: {
134+
deliveryDiscountsAdd: {
135135
candidates: [
136136
{
137137
message: "FREE DELIVERY",

0 commit comments

Comments
 (0)