From 73353a820ff6e15c8e18c60f490953f6c88a022a Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 11:03:27 +0200 Subject: [PATCH 01/55] added changes to swap and notification service --- docs/api/admin-spec3.json | 1524 +++++------ docs/api/admin-spec3.yaml | 2235 +++++++++-------- docs/api/store-spec3.json | 561 +++-- docs/api/store-spec3.yaml | 142 +- packages/medusa-payment-klarna/yarn.lock | 211 +- packages/medusa-plugin-add-ons/yarn.lock | 206 +- packages/medusa-plugin-mailchimp/yarn.lock | 201 +- packages/medusa-plugin-segment/yarn.lock | 201 +- packages/medusa-plugin-sendgrid/yarn.lock | 201 +- packages/medusa-plugin-twilio-sms/yarn.lock | 208 +- packages/medusa-plugin-wishlist/yarn.lock | 206 +- packages/medusa-test-utils/yarn.lock | 53 - .../api/routes/admin/orders/create-swap.js | 7 +- .../api/routes/store/returns/create-return.js | 6 + .../src/services/__tests__/notification.js | 65 +- .../medusa/src/services/__tests__/swap.js | 24 + packages/medusa/src/services/notification.js | 3 + packages/medusa/src/services/swap.js | 3 + 18 files changed, 2370 insertions(+), 3687 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index 5da7fcc4b6..de03c84c1d 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -145,6 +145,183 @@ } } }, + "/customers": { + "post": { + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer.", + "parameters": [], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } + } + }, + "get": { + "operationId": "GetCustomers", + "summary": "List Customers", + "description": "Retrieves a list of Customers.", + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}": { + "get": { + "operationId": "GetCustomersCustomer", + "summary": "Retrieve a Customer", + "description": "Retrieves a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomer", + "summary": "Update a Customer", + "description": "Updates a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "description": "The Customer's phone number.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, "/collections": { "post": { "operationId": "PostCollections", @@ -357,14 +534,47 @@ } } }, - "/customers": { + "/gift-cards": { "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer.", - "parameters": [], + "operationId": "PostGiftCards", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "value": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -373,54 +583,22 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } } } } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } } }, "get": { - "operationId": "GetCustomers", - "summary": "List Customers", - "description": "Retrieves a list of Customers.", + "operationId": "GetGiftCards", + "summary": "List Gift Cards", + "description": "Retrieves a list of Gift Cards.", "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -429,8 +607,11 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } } } } @@ -440,24 +621,24 @@ } } }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieve a Customer", - "description": "Retrieves a Customer.", + "/gift-cards/{id}": { + "delete": { + "operationId": "DeleteGiftCardsGiftCard", + "summary": "Delete a Gift Card", + "description": "Deletes a Gift Card", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card to delete.", "schema": { "type": "string" } } ], "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -466,8 +647,51 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "id": { + "type": "string", + "description": "The id of the deleted Gift Card" + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCardsGiftCard", + "summary": "Retrieve a Gift Card", + "description": "Retrieves a Gift Card.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -477,15 +701,15 @@ } }, "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update a Customer", - "description": "Updates a Customer.", + "operationId": "PostGiftCardsGiftCard", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card.", "schema": { "type": "string" } @@ -496,16 +720,28 @@ "application/json": { "schema": { "properties": { - "first_name": { - "type": "string", - "description": "The Customer's first name." + "balance": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." }, - "last_name": { - "type": "string", - "description": "The Customer's last name." + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." }, - "phone": { - "description": "The Customer's phone number.", + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", "type": "object" } } @@ -514,7 +750,7 @@ } }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -523,8 +759,8 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -717,6 +953,10 @@ "type": "string" } }, + "usage_limit": { + "type": "number", + "description": "Maximum times the discount can be used" + }, "metadata": { "description": "An optional set of key-value pairs to hold additional information.", "type": "object" @@ -1038,242 +1278,6 @@ } } }, - "/gift-cards": { - "post": { - "operationId": "PostGiftCards", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "value": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCards", - "summary": "List Gift Cards", - "description": "Retrieves a list of Gift Cards.", - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - } - }, - "/gift-cards/{id}": { - "delete": { - "operationId": "DeleteGiftCardsGiftCard", - "summary": "Delete a Gift Card", - "description": "Deletes a Gift Card", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card to delete.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Gift Card" - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCardsGiftCard", - "summary": "Retrieve a Gift Card", - "description": "Retrieves a Gift Card.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostGiftCardsGiftCard", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "balance": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - }, "/notifications": { "get": { "operationId": "GetNotifications", @@ -1960,6 +1964,10 @@ } } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -2265,82 +2273,6 @@ } } }, - "/orders/{id}/returns/{return_id}/receive": { - "post": { - "operationId": "PostOrdersOrderReturnsReturnReceive", - "summary": "Receive a Return", - "description": "Registers a Return as received.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "return_id", - "required": true, - "description": "The id of the Return.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "items": { - "description": "The Line Items that have been received.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Line Item.", - "type": "integer" - } - } - } - }, - "refund": { - "description": "The amount to refund.", - "type": "integer" - } - } - } - } - } - }, - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, "/orders/{id}/swaps/{swap_id}/receive": { "post": { "operationId": "PostOrdersOrderSwapsSwapReceive", @@ -3926,6 +3858,183 @@ } } }, + "/return-reasons": { + "post": { + "operationId": "PostReturnReasons", + "summary": "Create a Return Reason", + "description": "Creates a Return Reason", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostReturnReasonsReason", + "summary": "Update a Return Reason", + "description": "Updates a Return Reason", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, "/regions/{id}/countries": { "post": { "operationId": "PostRegionsRegionCountries", @@ -4565,183 +4674,6 @@ } } }, - "/return-reasons": { - "post": { - "operationId": "PostReturnReasons", - "summary": "Create a Return Reason", - "description": "Creates a Return Reason", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostReturnReasonsReason", - "summary": "Update a Return Reason", - "description": "Updates a Return Reason", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, "/returns": { "get": { "operationId": "GetReturns", @@ -4771,6 +4703,269 @@ } } }, + "/returns/{id}receive": { + "post": { + "operationId": "PostReturnsReturnReceive", + "summary": "Receive a Return", + "description": "Registers a Return as received. Updates statuses on Orders and Swaps accordingly.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "items": { + "description": "The Line Items that have been received.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Line Item.", + "type": "integer" + } + } + } + }, + "refund": { + "description": "The amount to refund.", + "type": "integer" + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, + "/shipping-profiles": { + "post": { + "operationId": "PostShippingProfiles", + "summary": "Create a Shipping Profile", + "description": "Creates a Shipping Profile", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfiles", + "summary": "List Shipping Profiles", + "description": "Retrieves a list of Shipping Profile.", + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + } + }, + "/shipping-profiles/{id}": { + "delete": { + "operationId": "DeleteShippingProfilesProfile", + "summary": "Delete a Shipping Profile", + "description": "Deletes a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Shipping Profile." + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfilesProfile", + "summary": "Retrieve a Shipping Profile", + "description": "Retrieves a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostShippingProfilesProfile", + "summary": "Update a Shipping Profiles", + "description": "Updates a Shipping Profile", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + }, "/shipping-options": { "post": { "operationId": "PostShippingOptions", @@ -5043,202 +5238,6 @@ } } }, - "/shipping-profiles": { - "post": { - "operationId": "PostShippingProfiles", - "summary": "Create a Shipping Profile", - "description": "Creates a Shipping Profile", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfiles", - "summary": "List Shipping Profiles", - "description": "Retrieves a list of Shipping Profile.", - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - } - }, - "/shipping-profiles/{id}": { - "delete": { - "operationId": "DeleteShippingProfilesProfile", - "summary": "Delete a Shipping Profile", - "description": "Deletes a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Shipping Profile." - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfilesProfile", - "summary": "Retrieve a Shipping Profile", - "description": "Retrieves a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostShippingProfilesProfile", - "summary": "Update a Shipping Profiles", - "description": "Updates a Shipping Profile", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - }, "/store/currencies/{code}": { "post": { "operationId": "PostStoreCurrenciesCode", @@ -6020,10 +6019,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6095,6 +6090,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6869,6 +6872,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 048de24094..01407368f2 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,6 +85,119 @@ paths: properties: user: $ref: '#/components/schemas/user' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + get: + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieve a Customer + description: Retrieves a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + description: The Customer's phone number. + type: object + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' /collections: post: operationId: PostCollections @@ -227,119 +340,6 @@ paths: properties: collection: $ref: '#/components/schemas/product_collection' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieve a Customer - description: Retrieves a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - description: The Customer's phone number. - type: object - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -478,6 +478,9 @@ paths: type: array items: type: string + usage_limit: + type: number + description: Maximum times the discount can be used metadata: description: >- An optional set of key-value pairs to hold additional @@ -910,266 +913,34 @@ paths: properties: notification: $ref: '#/components/schemas/notification' - '/orders/{id}/shipping-methods': + /return-reasons: post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason requestBody: content: application/json: schema: properties: - fulfillment_id: - description: The id of the Fulfillment. + label: + description: The label to display to the Customer. type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: + value: description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1177,317 +948,14 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': + return_reason: + $ref: '#/components/schemas/return_reason' get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. tags: - - Order + - Return Reason responses: '200': description: OK @@ -1495,49 +963,24 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: + return_reasons: type: array items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string tags: - - Order + - Return Reason responses: '200': description: OK @@ -1545,24 +988,17 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns/{return_id}/receive': + return_reason: + $ref: '#/components/schemas/return_reason' post: - operationId: PostOrdersOrderReturnsReturnReceive - summary: Receive a Return - description: Registers a Return as received. + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: return_id - required: true - description: The id of the Return. + description: The id of the Return Reason. schema: type: string requestBody: @@ -1570,269 +1006,24 @@ paths: application/json: schema: properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. + label: + description: The label to display to the Customer. type: string - note: - description: A not with additional details about the Refund. + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1840,8 +1031,8 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + return_reason: + $ref: '#/components/schemas/return_reason' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -3159,126 +2350,6 @@ paths: properties: region: $ref: '#/components/schemas/region' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' /returns: get: operationId: GetReturns @@ -3297,6 +2368,937 @@ paths: type: array items: $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: If set to true no notification will be send + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' /shipping-options: post: operationId: PostShippingOptions @@ -3608,6 +3610,24 @@ paths: properties: shipping_profiles: $ref: '#/components/schemas/shipping_profile' + /swaps: + get: + operationId: GetSwaps + summary: List Swaps + description: Retrieves a list of Swaps. + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swaps: + type: array + items: + $ref: '#/components/schemas/swap' '/store/currencies/{code}': post: operationId: PostStoreCurrenciesCode @@ -3718,24 +3738,6 @@ paths: type: array items: $ref: '#/components/schemas/store' - /swaps: - get: - operationId: GetSwaps - summary: List Swaps - description: Retrieves a list of Swaps. - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swaps: - type: array - items: - $ref: '#/components/schemas/swap' /variants: get: operationId: GetVariants @@ -4167,9 +4169,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4232,6 +4231,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4865,6 +4870,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 5727ac1234..545a298abd 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -976,6 +976,55 @@ } } }, + "/gift-cards/{code}": { + "get": { + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", + "parameters": [ + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Gift Card code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, "/customers/{id}/addresses": { "post": { "operationId": "PostCustomersCustomerAddresses", @@ -1481,277 +1530,6 @@ } } }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", - "parameters": [ - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Gift Card code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/products/{id}": { - "get": { - "operationId": "GetProductsProduct", - "summary": "Retrieves a Product", - "description": "Retrieves a Product.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Product.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "product": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - }, - "/products": { - "get": { - "operationId": "GetProducts", - "summary": "List Products", - "description": "Retrieves a list of Products.", - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of Products.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of Products to return,", - "type": "integer" - }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, - "/return-reasons": { - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/regions/{id}": { - "get": { - "operationId": "GetRegionsRegion", - "summary": "Retrieves a Region", - "description": "Retrieves a Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Region.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/regions": { - "get": { - "operationId": "GetRegions", - "summary": "List Regions", - "description": "Retrieves a list of Regions.", - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of regions.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of regions to return,", - "type": "integer" - }, - "regions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - } - }, "/orders/cart/{cart_id}": { "get": { "operationId": "GetOrdersOrderCartId", @@ -1872,6 +1650,162 @@ } } }, + "/products/{id}": { + "get": { + "operationId": "GetProductsProduct", + "summary": "Retrieves a Product", + "description": "Retrieves a Product.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Product.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "product": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + }, + "/products": { + "get": { + "operationId": "GetProducts", + "summary": "List Products", + "description": "Retrieves a list of Products.", + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of Products.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of Products to return,", + "type": "integer" + }, + "products": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + } + }, + "/regions/{id}": { + "get": { + "operationId": "GetRegionsRegion", + "summary": "Retrieves a Region", + "description": "Retrieves a Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Region.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/regions": { + "get": { + "operationId": "GetRegions", + "summary": "List Regions", + "description": "Retrieves a list of Regions.", + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of regions.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of regions to return,", + "type": "integer" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + } + }, "/returns": { "post": { "operationId": "PostReturns", @@ -1911,6 +1845,10 @@ "description": "The id of the Shipping Option to create the Shipping Method from." } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -1938,6 +1876,72 @@ } } }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, + "/return-reasons": { + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, "/shipping-options": { "get": { "operationId": "GetShippingOptions", @@ -2696,10 +2700,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2771,6 +2771,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -3545,6 +3553,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 43e7a49d17..5f6fd465cf 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -1147,47 +1147,6 @@ paths: type: array items: $ref: '#/components/schemas/product' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' '/regions/{id}': get: operationId: GetRegionsRegion @@ -1238,6 +1197,47 @@ paths: type: array items: $ref: '#/components/schemas/region' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' /returns: post: operationId: PostReturns @@ -1274,6 +1274,9 @@ paths: description: >- The id of the Shipping Option to create the Shipping Method from. + no_notification: + description: If set to true no notification will be send + type: boolean tags: - Return responses: @@ -1285,6 +1288,29 @@ paths: properties: return: $ref: '#/components/schemas/return' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' /shipping-options: get: operationId: GetShippingOptions @@ -1346,29 +1372,6 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1829,9 +1832,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1894,6 +1894,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -2527,6 +2533,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/packages/medusa-payment-klarna/yarn.lock b/packages/medusa-payment-klarna/yarn.lock index f4737aefd3..7ea0e85647 100644 --- a/packages/medusa-payment-klarna/yarn.lock +++ b/packages/medusa-payment-klarna/yarn.lock @@ -964,18 +964,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/hoek@^9.0.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6" - integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw== - -"@hapi/topo@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" - integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== - dependencies: - "@hapi/hoek" "^9.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz#10602de5570baea82f8afbfa2630b24e7a8cfe5b" @@ -1159,23 +1147,6 @@ "@types/yargs" "^15.0.0" chalk "^3.0.0" -"@sideway/address@^4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.0.tgz#0b301ada10ac4e0e3fa525c90615e0b61a72b78d" - integrity sha512-wAH/JYRXeIFQRsxerIuLjgUu2Xszam+O5xKeatJ4oudShOOirfmsQ1D6LL54XOU2tizpCYku+s1wmU0SYdpoSA== - dependencies: - "@hapi/hoek" "^9.0.0" - -"@sideway/formula@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c" - integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg== - -"@sideway/pinpoint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" - integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== - "@sinonjs/commons@^1.7.0": version "1.7.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.2.tgz#505f55c74e0272b43f6c52d81946bed7058fc0e2" @@ -1580,19 +1551,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.0.tgz#e1a574cdf528e4053019bb800b041c0ac88da493" - integrity sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1668,11 +1626,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" - integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -2005,13 +1958,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -2073,11 +2019,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3590,22 +3531,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - -joi@^17.2.1, joi@^17.3.0: - version "17.3.0" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.3.0.tgz#f1be4a6ce29bc1716665819ac361dfa139fff5d2" - integrity sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg== - dependencies: - "@hapi/hoek" "^9.0.0" - "@hapi/topo" "^5.0.0" - "@sideway/address" "^4.1.0" - "@sideway/formula" "^3.0.0" - "@sideway/pinpoint" "^2.0.0" - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3715,11 +3640,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - keygrip@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.3.tgz#399d709f0aed2bab0a059e0cdd3a5023a053e1dc" @@ -3857,36 +3777,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.0.11: - version "1.0.11" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.11.tgz#c77685c4b637f6aebe808e82dc4f7739c2f9ff79" - integrity sha512-Nnp7RCWsR4MJNrslC0YB/wMO1Wf2QJH0aras+tjRdymXfR/ySn2/0+v8pyXxhY8XXYzOZknnjdCB8KI9+PHlsA== - dependencies: - joi "^17.2.1" - joi-objectid "^3.0.1" - -medusa-core-utils@^1.0.12-alpha.787+0646bd3: - version "1.0.12-alpha.801" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.12-alpha.801.tgz#0a7d0b5d4b2290d9a2f7afb35ab1f0bec666dbb0" - integrity sha512-1ppxgl8noZfO3JLLHeLj4eEMOwTI/LcCxWwwD7AUp5uP1brPmctthDTM/pOMrEuytKWIqaNXCRohvAlgDr0vYA== - dependencies: - joi "^17.3.0" - joi-objectid "^3.0.1" - -medusa-test-utils@^1.0.12-alpha.176+0646bd3: - version "1.0.13" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.13.tgz#f728b8dacb1ba64d85529e3f2e9dba6c7e315416" - integrity sha512-EBbjGLHFEG/Fnqneire/bNCPeseo1ZFF3n3yMUfp0JDmBAVgE8L52wJa8Zeu36TL/rbQsQAsTAS6La46A8IJgg== - dependencies: - "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.0.11" - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3988,57 +3878,6 @@ mkdirp@^0.5.1: dependencies: minimist "0.0.8" -mongodb@3.5.7: - version "3.5.7" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.7.tgz#6dcfff3bdbf67a53263dcca1647c265eea1d065d" - integrity sha512-lMtleRT+vIgY/JhhTn1nyGwnSMmJkJELp+4ZbrjctrnBxuLbj6rmLuJFz8W2xUzUqWmqoyVxJLYuC58ZKpcTYQ== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.9.13" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.13.tgz#fa4af761a0b1d10471daa23aafcc775b04b6db42" - integrity sha512-MsFdJAaCTVbDA3gYskUEpUN1kThL7sp4zh8N9rGt0+9vYMn28q92NLK90vGssM9qjOGWp8HqLeT1fBgfMZDnKA== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.5.7" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.1.2" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4049,7 +3888,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.1.1: +ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4544,7 +4383,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4603,11 +4442,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4704,14 +4538,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4719,11 +4545,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4807,7 +4628,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.0.1, safe-buffer@^5.1.1: +safe-buffer@^5.0.1: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4844,13 +4665,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4858,7 +4672,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4951,11 +4765,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -4990,11 +4799,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -5064,13 +4868,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" diff --git a/packages/medusa-plugin-add-ons/yarn.lock b/packages/medusa-plugin-add-ons/yarn.lock index 6c668e808f..24a368e099 100644 --- a/packages/medusa-plugin-add-ons/yarn.lock +++ b/packages/medusa-plugin-add-ons/yarn.lock @@ -913,35 +913,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-4.1.0.tgz#d60c5c0d930e77456fdcde2598e77302e2955e1d" - integrity sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ== - dependencies: - "@hapi/hoek" "^9.0.0" - -"@hapi/formula@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-2.0.0.tgz#edade0619ed58c8e4f164f233cda70211e787128" - integrity sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A== - -"@hapi/hoek@^9.0.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6" - integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw== - -"@hapi/pinpoint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-2.0.0.tgz#805b40d4dbec04fc116a73089494e00f073de8df" - integrity sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw== - -"@hapi/topo@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" - integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== - dependencies: - "@hapi/hoek" "^9.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1516,19 +1487,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.1.tgz#8c11a7b730655c5d56898cdc871224f40fd901d5" - integrity sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1605,11 +1563,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.5.tgz#2aaae98fcdf6750c0848b0cba1ddec3c73060a34" - integrity sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1958,13 +1911,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -3533,22 +3479,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - -joi@^17.2.1: - version "17.2.1" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.2.1.tgz#e5140fdf07e8fecf9bc977c2832d1bdb1e3f2a0a" - integrity sha512-YT3/4Ln+5YRpacdmfEfrrKh50/kkgX3LgBltjqnlMPIYiZ4hxXZuVJcxmsvxsdeHg9soZfE3qXxHC2tMpCCBOA== - dependencies: - "@hapi/address" "^4.1.0" - "@hapi/formula" "^2.0.0" - "@hapi/hoek" "^9.0.0" - "@hapi/pinpoint" "^2.0.0" - "@hapi/topo" "^5.0.0" - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3651,11 +3581,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - keygrip@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.3.tgz#399d709f0aed2bab0a059e0cdd3a5023a053e1dc" @@ -3793,36 +3718,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.1.tgz#5df4a60623e6916c6c2219eecbdbf07b84bfbfd9" - integrity sha512-rUyTGYotR2XrVa7TIy04kdNwY7RH25lW3Byltrp34a8Uj9QgSmC74/YAoSrs1yDAjzNFGmSFrRa7SOCU9559mg== - dependencies: - joi "^17.2.1" - joi-objectid "^3.0.1" - -medusa-core-utils@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.10.tgz#6175f1e428318205742621f78d387254fc85b8a1" - integrity sha512-z12ITzPl5UpDJTILNXcMGD4yujSRkuvVtxkrvqCmA44IEyRj1hWZ0dGbVzuHj2wIahDHFFg66oq91IQH5QVsyg== - dependencies: - joi "^17.2.1" - joi-objectid "^3.0.1" - -medusa-test-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.1.tgz#3b407a18ab57e63b62e1d878d5a3da659ff60bb1" - integrity sha512-val+Z7gDS1WBs/ilYnBeVlisUWcSOC5ieUZXuCJkeJV/sNpo0EMEfIwpk0njNhMF4akWWCtiMZgdG0GS02d7cg== - dependencies: - "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.0.1" - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3914,57 +3809,6 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.6.1: - version "3.6.1" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.1.tgz#2c5cc2a81456ba183e8c432d80e78732cc72dabd" - integrity sha512-uH76Zzr5wPptnjEKJRQnwTsomtFOU/kQEU8a9hKHr2M7y9qVk7Q4Pkv0EQVp88742z9+RwvsdTw6dRjDZCNu1g== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.10.3" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.10.3.tgz#ef28cda3f11e5bf75a309a25e9899f856a5a5370" - integrity sha512-FLemltuzcsCHlFpEZ3bYOiNhJfHful+GoS+3uRgdEWGlY0HKfOjm9xsISM/tql8vRvhjr7qveuRfoBBGO3xNtw== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.6.1" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.2.1" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -3975,7 +3819,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.1.1: +ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4468,7 +4312,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4554,11 +4398,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4655,14 +4494,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4670,11 +4501,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4751,7 +4577,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4783,13 +4609,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4797,7 +4616,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4890,11 +4709,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4924,11 +4738,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -4998,13 +4807,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-plugin-mailchimp/yarn.lock b/packages/medusa-plugin-mailchimp/yarn.lock index 5cc9ec4f4f..d20d730cf9 100644 --- a/packages/medusa-plugin-mailchimp/yarn.lock +++ b/packages/medusa-plugin-mailchimp/yarn.lock @@ -913,35 +913,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-4.1.0.tgz#d60c5c0d930e77456fdcde2598e77302e2955e1d" - integrity sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ== - dependencies: - "@hapi/hoek" "^9.0.0" - -"@hapi/formula@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-2.0.0.tgz#edade0619ed58c8e4f164f233cda70211e787128" - integrity sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A== - -"@hapi/hoek@^9.0.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6" - integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw== - -"@hapi/pinpoint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-2.0.0.tgz#805b40d4dbec04fc116a73089494e00f073de8df" - integrity sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw== - -"@hapi/topo@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" - integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== - dependencies: - "@hapi/hoek" "^9.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1516,19 +1487,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.1.tgz#8c11a7b730655c5d56898cdc871224f40fd901d5" - integrity sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - bluebird@^3.4.0: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" @@ -1610,11 +1568,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.5.tgz#2aaae98fcdf6750c0848b0cba1ddec3c73060a34" - integrity sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1968,13 +1921,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" @@ -2036,11 +1982,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3573,22 +3514,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - -joi@^17.2.1: - version "17.2.1" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.2.1.tgz#e5140fdf07e8fecf9bc977c2832d1bdb1e3f2a0a" - integrity sha512-YT3/4Ln+5YRpacdmfEfrrKh50/kkgX3LgBltjqnlMPIYiZ4hxXZuVJcxmsvxsdeHg9soZfE3qXxHC2tMpCCBOA== - dependencies: - "@hapi/address" "^4.1.0" - "@hapi/formula" "^2.0.0" - "@hapi/hoek" "^9.0.0" - "@hapi/pinpoint" "^2.0.0" - "@hapi/topo" "^5.0.0" - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3691,11 +3616,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - keygrip@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.3.tgz#399d709f0aed2bab0a059e0cdd3a5023a053e1dc" @@ -3843,28 +3763,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.10.tgz#6175f1e428318205742621f78d387254fc85b8a1" - integrity sha512-z12ITzPl5UpDJTILNXcMGD4yujSRkuvVtxkrvqCmA44IEyRj1hWZ0dGbVzuHj2wIahDHFFg66oq91IQH5QVsyg== - dependencies: - joi "^17.2.1" - joi-objectid "^3.0.1" - -medusa-test-utils@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.10.tgz#8c1e9046a81cd3afa4c32c6d0d8af7e1f33bd039" - integrity sha512-CTzlVVTEOIFh3iRsjJqt4JYtEFP+2gVZF0jXGYdhCgAxd5mFKVuE+QzLLtvTCHlT7TI7rYgPfEWCcj9LPh2vVQ== - dependencies: - "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.0.10" - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3971,57 +3869,6 @@ mkdirp@^0.5.0, mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.6.2: - version "3.6.2" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.6.2.tgz#1154a4ac107bf1375112d83a29c5cf97704e96b6" - integrity sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA== - dependencies: - bl "^2.2.1" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.10.7" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.10.7.tgz#5590037f4d9078f4d4edac5c77f27b53829b1c94" - integrity sha512-oiofFrD4I5p3PhJXn49QyrU1nX5CY01qhPkfMMrXYPhkfGLEJVwFVO+0PsCxD91A2kQP+d/iFyk5U8e86KI8eQ== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.6.2" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.2.1" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4525,7 +4372,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4584,11 +4431,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4685,14 +4527,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4700,11 +4534,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4781,7 +4610,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4813,13 +4642,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4827,7 +4649,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4920,11 +4742,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4954,11 +4771,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -5028,13 +4840,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-plugin-segment/yarn.lock b/packages/medusa-plugin-segment/yarn.lock index fef8329e04..a20c2e86f7 100644 --- a/packages/medusa-plugin-segment/yarn.lock +++ b/packages/medusa-plugin-segment/yarn.lock @@ -879,44 +879,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^2.1.2": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" - integrity sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ== - -"@hapi/formula@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-1.2.0.tgz#994649c7fea1a90b91a0a1e6d983523f680e10cd" - integrity sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA== - -"@hapi/hoek@^8.2.4", "@hapi/hoek@^8.3.0": - version "8.5.1" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.5.1.tgz#fde96064ca446dec8c55a8c2f130957b070c6e06" - integrity sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow== - -"@hapi/joi@^16.1.8": - version "16.1.8" - resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-16.1.8.tgz#84c1f126269489871ad4e2decc786e0adef06839" - integrity sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg== - dependencies: - "@hapi/address" "^2.1.2" - "@hapi/formula" "^1.2.0" - "@hapi/hoek" "^8.2.4" - "@hapi/pinpoint" "^1.0.2" - "@hapi/topo" "^3.1.3" - -"@hapi/pinpoint@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-1.0.2.tgz#025b7a36dbbf4d35bf1acd071c26b20ef41e0d13" - integrity sha512-dtXC/WkZBfC5vxscazuiJ6iq4j9oNx1SHknmIr8hofarpKUZKmlUVYVIhNVzIEgK5Wrc4GMHL5lZtt1uS2flmQ== - -"@hapi/topo@^3.1.3": - version "3.1.6" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-3.1.6.tgz#68d935fa3eae7fdd5ab0d7f953f3205d8b2bfc29" - integrity sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ== - dependencies: - "@hapi/hoek" "^8.3.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1527,19 +1489,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.0.tgz#e1a574cdf528e4053019bb800b041c0ac88da493" - integrity sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1616,11 +1565,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" - integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1961,7 +1905,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0, debug@=3.1.0: +debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -2029,11 +1973,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3548,11 +3487,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - join-component@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5" @@ -3660,11 +3594,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -3811,33 +3740,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-0.1.39.tgz#d57816c9bd43f9a92883650c1e66add1665291df" - integrity sha512-R8+U1ile7if+nR6Cjh5exunx0ETV0OfkWUUBUpz1KmHSDv0V0CcvQqU9lcZesPFDEbu3Y2iEjsCqidVA4nG2nQ== - dependencies: - "@hapi/joi" "^16.1.8" - joi-objectid "^3.0.1" - -medusa-interfaces@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-0.1.39.tgz#633db3c8c6afd7fec9ae24496737369d840105cf" - integrity sha512-byKIcK7o3L4shmGn+pgZAUyLrT991zCqK4jWXIleQJbGImQy6TmdXido+tEzFptVBJWMIQ8BWnP/b7r29D8EXA== - dependencies: - mongoose "^5.8.0" - -medusa-test-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-0.1.39.tgz#b7c166006a2fa4f02e52ab3bfafc19a3ae787f3e" - integrity sha512-M/Br8/HYvl7x2oLnme4NxdQwoyV0XUyOWiCyvPp7q1HUTB684lhJf1MikZVrcSjsh2L1rpyi3GRbKdf4cpJWvw== - dependencies: - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3929,57 +3831,6 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.5.9: - version "3.5.9" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.9.tgz#799b72be8110b7e71a882bb7ce0d84d05429f772" - integrity sha512-vXHBY1CsGYcEPoVWhwgxIBeWqP3dSu9RuRDsoLRPTITrcrgm1f0Ubu1xqF9ozMwv53agmEiZm0YGo+7WL3Nbug== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.9.24" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.24.tgz#ba7f95529da8fa2160d9b4d708b3fe9856c56636" - integrity sha512-uxTLy/ExYmOfKvvbjn1PHbjSJg0SQzff+dW6jbnywtbBcfPRC/3etnG9hPv6KJe/5TFZQGxCyiSezkqa0+iJAQ== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.5.9" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.2.1" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -3990,7 +3841,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.0.0, ms@^2.1.1: +ms@^2.0.0, ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4478,7 +4329,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4537,11 +4388,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4643,14 +4489,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4658,11 +4496,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4739,7 +4572,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4771,13 +4604,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4785,7 +4611,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4878,11 +4704,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4912,11 +4733,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -4986,13 +4802,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-plugin-sendgrid/yarn.lock b/packages/medusa-plugin-sendgrid/yarn.lock index 6b172a8326..c75a6f6409 100644 --- a/packages/medusa-plugin-sendgrid/yarn.lock +++ b/packages/medusa-plugin-sendgrid/yarn.lock @@ -874,44 +874,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^2.1.2": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" - integrity sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ== - -"@hapi/formula@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-1.2.0.tgz#994649c7fea1a90b91a0a1e6d983523f680e10cd" - integrity sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA== - -"@hapi/hoek@^8.2.4", "@hapi/hoek@^8.3.0": - version "8.5.1" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.5.1.tgz#fde96064ca446dec8c55a8c2f130957b070c6e06" - integrity sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow== - -"@hapi/joi@^16.1.8": - version "16.1.8" - resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-16.1.8.tgz#84c1f126269489871ad4e2decc786e0adef06839" - integrity sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg== - dependencies: - "@hapi/address" "^2.1.2" - "@hapi/formula" "^1.2.0" - "@hapi/hoek" "^8.2.4" - "@hapi/pinpoint" "^1.0.2" - "@hapi/topo" "^3.1.3" - -"@hapi/pinpoint@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-1.0.2.tgz#025b7a36dbbf4d35bf1acd071c26b20ef41e0d13" - integrity sha512-dtXC/WkZBfC5vxscazuiJ6iq4j9oNx1SHknmIr8hofarpKUZKmlUVYVIhNVzIEgK5Wrc4GMHL5lZtt1uS2flmQ== - -"@hapi/topo@^3.1.3": - version "3.1.6" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-3.1.6.tgz#68d935fa3eae7fdd5ab0d7f953f3205d8b2bfc29" - integrity sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ== - dependencies: - "@hapi/hoek" "^8.3.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1516,19 +1478,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.0.tgz#e1a574cdf528e4053019bb800b041c0ac88da493" - integrity sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1605,11 +1554,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" - integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1942,7 +1886,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0, debug@=3.1.0: +debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -2010,11 +1954,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3526,11 +3465,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3633,11 +3567,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - keygrip@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.3.tgz#399d709f0aed2bab0a059e0cdd3a5023a053e1dc" @@ -3783,33 +3712,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-0.1.39.tgz#d57816c9bd43f9a92883650c1e66add1665291df" - integrity sha512-R8+U1ile7if+nR6Cjh5exunx0ETV0OfkWUUBUpz1KmHSDv0V0CcvQqU9lcZesPFDEbu3Y2iEjsCqidVA4nG2nQ== - dependencies: - "@hapi/joi" "^16.1.8" - joi-objectid "^3.0.1" - -medusa-interfaces@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-0.1.39.tgz#633db3c8c6afd7fec9ae24496737369d840105cf" - integrity sha512-byKIcK7o3L4shmGn+pgZAUyLrT991zCqK4jWXIleQJbGImQy6TmdXido+tEzFptVBJWMIQ8BWnP/b7r29D8EXA== - dependencies: - mongoose "^5.8.0" - -medusa-test-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-0.1.39.tgz#b7c166006a2fa4f02e52ab3bfafc19a3ae787f3e" - integrity sha512-M/Br8/HYvl7x2oLnme4NxdQwoyV0XUyOWiCyvPp7q1HUTB684lhJf1MikZVrcSjsh2L1rpyi3GRbKdf4cpJWvw== - dependencies: - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3901,57 +3803,6 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.5.8: - version "3.5.8" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.8.tgz#34550856449b745d145873734bf922c12d6b9caa" - integrity sha512-jz7mR58z66JKL8Px4ZY+FXbgB7d0a0hEGCT7kw8iye46/gsqPrOEpZOswwJ2BQlfzsrCLKdsF9UcaUfGVN2HrQ== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.9.18" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.18.tgz#d031ed53b1e60ba4a1491fb5419068acb1f33d00" - integrity sha512-agZbIuQcN1gZ12BJn6KesA+bgsvoLVjCwhfPw88hggxX8O24SWK4EJwN35GEZKDej9AHUZKNAPgmdeXCVQxviA== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.5.8" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.1.2" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -3962,7 +3813,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.1.1: +ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4481,7 +4332,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4541,11 +4392,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4642,14 +4488,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4657,11 +4495,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4738,7 +4571,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4770,13 +4603,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4784,7 +4610,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4877,11 +4703,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4911,11 +4732,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -4985,13 +4801,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-plugin-twilio-sms/yarn.lock b/packages/medusa-plugin-twilio-sms/yarn.lock index 3de92b8fb0..0dd28374ac 100644 --- a/packages/medusa-plugin-twilio-sms/yarn.lock +++ b/packages/medusa-plugin-twilio-sms/yarn.lock @@ -874,35 +874,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^4.1.0": - version "4.1.0" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-4.1.0.tgz#d60c5c0d930e77456fdcde2598e77302e2955e1d" - integrity sha512-SkszZf13HVgGmChdHo/PxchnSaCJ6cetVqLzyciudzZRT0jcOouIF/Q93mgjw8cce+D+4F4C1Z/WrfFN+O3VHQ== - dependencies: - "@hapi/hoek" "^9.0.0" - -"@hapi/formula@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-2.0.0.tgz#edade0619ed58c8e4f164f233cda70211e787128" - integrity sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A== - -"@hapi/hoek@^9.0.0": - version "9.1.0" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6" - integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw== - -"@hapi/pinpoint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-2.0.0.tgz#805b40d4dbec04fc116a73089494e00f073de8df" - integrity sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw== - -"@hapi/topo@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" - integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== - dependencies: - "@hapi/hoek" "^9.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1532,19 +1503,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.0.tgz#e1a574cdf528e4053019bb800b041c0ac88da493" - integrity sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1621,11 +1579,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" - integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== - buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" @@ -1936,7 +1889,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0, debug@=3.1.0: +debug@=3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== @@ -2004,11 +1957,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3432,22 +3380,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - -joi@^17.2.1: - version "17.2.1" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.2.1.tgz#e5140fdf07e8fecf9bc977c2832d1bdb1e3f2a0a" - integrity sha512-YT3/4Ln+5YRpacdmfEfrrKh50/kkgX3LgBltjqnlMPIYiZ4hxXZuVJcxmsvxsdeHg9soZfE3qXxHC2tMpCCBOA== - dependencies: - "@hapi/address" "^4.1.0" - "@hapi/formula" "^2.0.0" - "@hapi/hoek" "^9.0.0" - "@hapi/pinpoint" "^2.0.0" - "@hapi/topo" "^5.0.0" - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3583,11 +3515,6 @@ jws@^3.2.2: jwa "^1.4.1" safe-buffer "^5.0.1" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -3768,28 +3695,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.0.7.tgz#e5e1cfe0164f7ed470b5b82a22d0dfc5075d4328" - integrity sha512-ghmkYlPhtYXuEJgdZEFBCG8wpAgebAPajmHQB8GIX3Gp47Kj4c0D0vZmow27FxMqM5Mv6o3Rqi3CdTIR+t9Whw== - dependencies: - joi "^17.2.1" - joi-objectid "^3.0.1" - -medusa-test-utils@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.0.7.tgz#0b11429896533e00fa0f27c978f5cd1c75b784eb" - integrity sha512-MWd2Eyqh+oztc1iPPFREtuHQpLX+ewZMQQtPvJzyi2tzW7IY5M7BeFs2K9y/wmFdb0BSphbKcKMuCxOwV2H1gg== - dependencies: - "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.0.7" - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -3866,63 +3771,12 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.5.8: - version "3.5.8" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.8.tgz#34550856449b745d145873734bf922c12d6b9caa" - integrity sha512-jz7mR58z66JKL8Px4ZY+FXbgB7d0a0hEGCT7kw8iye46/gsqPrOEpZOswwJ2BQlfzsrCLKdsF9UcaUfGVN2HrQ== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.9.18" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.18.tgz#d031ed53b1e60ba4a1491fb5419068acb1f33d00" - integrity sha512-agZbIuQcN1gZ12BJn6KesA+bgsvoLVjCwhfPw88hggxX8O24SWK4EJwN35GEZKDej9AHUZKNAPgmdeXCVQxviA== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.5.8" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.1.2" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= -ms@2.1.2, ms@^2.1.1: +ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4437,7 +4291,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4497,11 +4351,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4598,14 +4447,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -4618,11 +4459,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4699,16 +4535,16 @@ rxjs@^6.5.3: dependencies: tslib "^1.9.0" -safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" @@ -4736,13 +4572,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4755,7 +4584,7 @@ scmp@^2.1.0: resolved "https://registry.yarnpkg.com/scmp/-/scmp-2.1.0.tgz#37b8e197c425bdeb570ab91cc356b311a11f9c9a" integrity sha512-o/mRQGk9Rcer/jEEw/yw4mwo3EU/NvYvp577/Btqrym9Qy5/MdWGBqipbALgd2lrdWTJ5/gqDusxfnQBxOxT2Q== -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4819,11 +4648,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4853,11 +4677,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -4927,13 +4746,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-plugin-wishlist/yarn.lock b/packages/medusa-plugin-wishlist/yarn.lock index 70ce790092..87cddac33e 100644 --- a/packages/medusa-plugin-wishlist/yarn.lock +++ b/packages/medusa-plugin-wishlist/yarn.lock @@ -879,44 +879,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/address@^2.1.2": - version "2.1.4" - resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" - integrity sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ== - -"@hapi/formula@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@hapi/formula/-/formula-1.2.0.tgz#994649c7fea1a90b91a0a1e6d983523f680e10cd" - integrity sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA== - -"@hapi/hoek@^8.2.4", "@hapi/hoek@^8.3.0": - version "8.5.1" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.5.1.tgz#fde96064ca446dec8c55a8c2f130957b070c6e06" - integrity sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow== - -"@hapi/joi@^16.1.8": - version "16.1.8" - resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-16.1.8.tgz#84c1f126269489871ad4e2decc786e0adef06839" - integrity sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg== - dependencies: - "@hapi/address" "^2.1.2" - "@hapi/formula" "^1.2.0" - "@hapi/hoek" "^8.2.4" - "@hapi/pinpoint" "^1.0.2" - "@hapi/topo" "^3.1.3" - -"@hapi/pinpoint@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@hapi/pinpoint/-/pinpoint-1.0.2.tgz#025b7a36dbbf4d35bf1acd071c26b20ef41e0d13" - integrity sha512-dtXC/WkZBfC5vxscazuiJ6iq4j9oNx1SHknmIr8hofarpKUZKmlUVYVIhNVzIEgK5Wrc4GMHL5lZtt1uS2flmQ== - -"@hapi/topo@^3.1.3": - version "3.1.6" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-3.1.6.tgz#68d935fa3eae7fdd5ab0d7f953f3205d8b2bfc29" - integrity sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ== - dependencies: - "@hapi/hoek" "^8.3.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1491,19 +1453,6 @@ bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bl@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-2.2.0.tgz#e1a574cdf528e4053019bb800b041c0ac88da493" - integrity sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA== - dependencies: - readable-stream "^2.3.5" - safe-buffer "^5.1.1" - -bluebird@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" - integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== - body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" @@ -1580,11 +1529,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/bson/-/bson-1.1.4.tgz#f76870d799f15b854dffb7ee32f0a874797f7e89" - integrity sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q== - buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1910,13 +1854,6 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== - dependencies: - ms "2.0.0" - debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -1978,11 +1915,6 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -denque@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" - integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== - depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" @@ -3485,11 +3417,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3592,11 +3519,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -kareem@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/kareem/-/kareem-2.3.1.tgz#def12d9c941017fabfb00f873af95e9c99e1be87" - integrity sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw== - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -3729,33 +3651,6 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-0.1.39.tgz#d57816c9bd43f9a92883650c1e66add1665291df" - integrity sha512-R8+U1ile7if+nR6Cjh5exunx0ETV0OfkWUUBUpz1KmHSDv0V0CcvQqU9lcZesPFDEbu3Y2iEjsCqidVA4nG2nQ== - dependencies: - "@hapi/joi" "^16.1.8" - joi-objectid "^3.0.1" - -medusa-interfaces@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-0.1.39.tgz#633db3c8c6afd7fec9ae24496737369d840105cf" - integrity sha512-byKIcK7o3L4shmGn+pgZAUyLrT991zCqK4jWXIleQJbGImQy6TmdXido+tEzFptVBJWMIQ8BWnP/b7r29D8EXA== - dependencies: - mongoose "^5.8.0" - -medusa-test-utils@^0.3.0: - version "0.1.39" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-0.1.39.tgz#b7c166006a2fa4f02e52ab3bfafc19a3ae787f3e" - integrity sha512-M/Br8/HYvl7x2oLnme4NxdQwoyV0XUyOWiCyvPp7q1HUTB684lhJf1MikZVrcSjsh2L1rpyi3GRbKdf4cpJWvw== - dependencies: - mongoose "^5.8.0" - -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-descriptors@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" @@ -3847,57 +3742,6 @@ mkdirp@^0.5.1: dependencies: minimist "^1.2.5" -mongodb@3.5.9: - version "3.5.9" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-3.5.9.tgz#799b72be8110b7e71a882bb7ce0d84d05429f772" - integrity sha512-vXHBY1CsGYcEPoVWhwgxIBeWqP3dSu9RuRDsoLRPTITrcrgm1f0Ubu1xqF9ozMwv53agmEiZm0YGo+7WL3Nbug== - dependencies: - bl "^2.2.0" - bson "^1.1.4" - denque "^1.4.1" - require_optional "^1.0.1" - safe-buffer "^5.1.2" - optionalDependencies: - saslprep "^1.0.0" - -mongoose-legacy-pluralize@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz#3ba9f91fa507b5186d399fb40854bff18fb563e4" - integrity sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ== - -mongoose@^5.8.0: - version "5.9.25" - resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-5.9.25.tgz#620da737ec9a667f84404ad4f35bb60338dd0b4b" - integrity sha512-vz/DqJ3mrHqEIlfRbKmDZ9TzQ1a0hCtSQpjHScIxr4rEtLs0tjsXDeEWcJ/vEEc3oLfP6vRx9V+uYSprXDUvFQ== - dependencies: - bson "^1.1.4" - kareem "2.3.1" - mongodb "3.5.9" - mongoose-legacy-pluralize "1.0.2" - mpath "0.7.0" - mquery "3.2.2" - ms "2.1.2" - regexp-clone "1.0.0" - safe-buffer "5.2.1" - sift "7.0.1" - sliced "1.0.1" - -mpath@0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/mpath/-/mpath-0.7.0.tgz#20e8102e276b71709d6e07e9f8d4d0f641afbfb8" - integrity sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg== - -mquery@3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/mquery/-/mquery-3.2.2.tgz#e1383a3951852ce23e37f619a9b350f1fb3664e7" - integrity sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q== - dependencies: - bluebird "3.5.1" - debug "3.1.0" - regexp-clone "^1.0.0" - safe-buffer "5.1.2" - sliced "1.0.1" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -3908,7 +3752,7 @@ ms@2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@2.1.2, ms@^2.1.1: +ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -4396,7 +4240,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.2, readable-stream@^2.3.5: +readable-stream@^2.0.2: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4455,11 +4299,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp-clone@1.0.0, regexp-clone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" - integrity sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -4556,14 +4395,6 @@ require-main-filename@^2.0.0: resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== -require_optional@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e" - integrity sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g== - dependencies: - resolve-from "^2.0.0" - semver "^5.1.0" - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -4571,11 +4402,6 @@ resolve-cwd@^3.0.0: dependencies: resolve-from "^5.0.0" -resolve-from@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57" - integrity sha1-lICrIOlP+h2egKgEx+oUdhGWa1c= - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -4652,7 +4478,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -4684,13 +4510,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -saslprep@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/saslprep/-/saslprep-1.0.3.tgz#4c02f946b56cf54297e347ba1093e7acac4cf226" - integrity sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag== - dependencies: - sparse-bitfield "^3.0.3" - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -4698,7 +4517,7 @@ saxes@^3.1.9: dependencies: xmlchars "^2.1.1" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -4791,11 +4610,6 @@ shellwords@^0.1.1: resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== -sift@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/sift/-/sift-7.0.1.tgz#47d62c50b159d316f1372f8b53f9c10cd21a4b08" - integrity sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g== - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -4825,11 +4639,6 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" -sliced@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sliced/-/sliced-1.0.1.tgz#0b3a662b5d04c3177b1926bea82b03f837a2ef41" - integrity sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E= - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -4899,13 +4708,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha1-/0rm5oZWBWuks+eSqzM004JzyhE= - dependencies: - memory-pager "^1.0.2" - spdx-correct@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" diff --git a/packages/medusa-test-utils/yarn.lock b/packages/medusa-test-utils/yarn.lock index 40e6f0c616..b1d23c2262 100644 --- a/packages/medusa-test-utils/yarn.lock +++ b/packages/medusa-test-utils/yarn.lock @@ -857,18 +857,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@hapi/hoek@^9.0.0": - version "9.1.1" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.1.tgz#9daf5745156fd84b8e9889a2dc721f0c58e894aa" - integrity sha512-CAEbWH7OIur6jEOzaai83jq3FmKmv4PmX1JYfs9IrYcGEVI/lyL1EXJGCj7eFVJ0bg5QR8LMxBlEtA+xKiLpFw== - -"@hapi/topo@^5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" - integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== - dependencies: - "@hapi/hoek" "^9.0.0" - "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1070,23 +1058,6 @@ readdirp "^2.2.1" upath "^1.1.1" -"@sideway/address@^4.1.0": - version "4.1.1" - resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.1.tgz#9e321e74310963fdf8eebfbee09c7bd69972de4d" - integrity sha512-+I5aaQr3m0OAmMr7RQ3fR9zx55sejEYR2BFJaxL+zT3VM2611X0SHvPWIbAUBZVTn/YzYKbV8gJ2oT/QELknfQ== - dependencies: - "@hapi/hoek" "^9.0.0" - -"@sideway/formula@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c" - integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg== - -"@sideway/pinpoint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" - integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== - "@sinonjs/commons@^1.7.0": version "1.8.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b" @@ -3196,22 +3167,6 @@ jest@^25.5.2: import-local "^3.0.2" jest-cli "^25.5.4" -joi-objectid@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/joi-objectid/-/joi-objectid-3.0.1.tgz#63ace7860f8e1a993a28d40c40ffd8eff01a3668" - integrity sha512-V/3hbTlGpvJ03Me6DJbdBI08hBTasFOmipsauOsxOSnsF1blxV537WTl1zPwbfcKle4AK0Ma4OPnzMH4LlvTpQ== - -joi@^17.3.0: - version "17.4.0" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.4.0.tgz#b5c2277c8519e016316e49ababd41a1908d9ef20" - integrity sha512-F4WiW2xaV6wc1jxete70Rw4V/VuMd6IN+a5ilZsxG4uYtUXWu2kq9W5P2dz30e7Gmw8RCbY/u/uk+dMPma9tAg== - dependencies: - "@hapi/hoek" "^9.0.0" - "@hapi/topo" "^5.0.0" - "@sideway/address" "^4.1.0" - "@sideway/formula" "^3.0.0" - "@sideway/pinpoint" "^2.0.0" - js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -3424,14 +3379,6 @@ math-random@^1.0.1: resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c" integrity sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A== -medusa-core-utils@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.0.tgz#0641b365b769dbf99856025d935eef5cf5d81f2c" - integrity sha512-zocRthKhLK3eSjrXbAhZZkIMBRxyvU7GcAMFh5UCEgfe7f935vjE7r5lGTr5jTEwgwaoTUk9ep0VBekz0SEdyw== - dependencies: - joi "^17.3.0" - joi-objectid "^3.0.1" - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 7782400eaa..f81c02b35f 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -45,6 +45,9 @@ import { defaultFields, defaultRelations } from "./" * quantity: * description: The quantity of the Product Variant to ship. * type: integer + * no_notification: + * description: If set to true no notification will be send. + * type: boolean * tags: * - Order * responses: @@ -65,7 +68,7 @@ export default async (req, res) => { .items({ item_id: Validator.string().required(), quantity: Validator.number().required(), - }) + }) .required(), return_shipping: Validator.object() .keys({ @@ -79,6 +82,7 @@ export default async (req, res) => { variant_id: Validator.string().required(), quantity: Validator.number().required(), }), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -134,6 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, + no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index e04bf44037..c61727c4c5 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,6 +31,10 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. + * no_notification: + * description: If set to true no notification will be send + * type: boolean + * * tags: * - Return * responses: @@ -59,6 +63,7 @@ export default async (req, res) => { option_id: Validator.string().optional(), }) .optional(), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -132,6 +137,7 @@ export default async (req, res) => { .emit("order.return_requested", { id: value.order_id, return_id: createdReturn.id, + no_notification: no_notification }) return { diff --git a/packages/medusa/src/services/__tests__/notification.js b/packages/medusa/src/services/__tests__/notification.js index f26ab26d15..64b6361b65 100644 --- a/packages/medusa/src/services/__tests__/notification.js +++ b/packages/medusa/src/services/__tests__/notification.js @@ -1,30 +1,31 @@ import NotificationService from "../notification" -import { IdMap, MockManager, MockRepository } from "medusa-test-utils" +import { MockManager, MockRepository } from "medusa-test-utils" describe("NotificationService", () => { - describe("send", () => { - const notificationRepository = MockRepository({ create: c => c }) + const notificationRepository = MockRepository({ create: c => c }) - const container = { - manager: MockManager, - notificationRepository, - noti_test: { - sendNotification: jest.fn(() => - Promise.resolve({ - to: "test@mail.com", - data: { id: "something" }, - }) - ), - }, - } + const container = { + manager: MockManager, + notificationRepository, + noti_test: { + sendNotification: jest.fn(() => + Promise.resolve({ + to: "test@mail.com", + data: { id: "something" }, + }) + ), + }, + } - const notificationService = new NotificationService(container) + beforeEach(() => { + jest.clearAllMocks() + }) - beforeEach(() => { - jest.clearAllMocks() - }) + describe("send", () =>{ it("successfully calls provider and saves noti", async () => { + const notificationService = new NotificationService(container) + await notificationService.send("event.test", { id: "test" }, "test") expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) @@ -51,4 +52,30 @@ describe("NotificationService", () => { expect(notificationRepository.save).toHaveBeenCalledWith(constructed) }) }) + + describe("handleEvent", () => { + + it("cancels notification if no_notification is set", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", + return_id: "id", + no_notification: true}) + + expect(container.noti_test.sendNotification).not.toHaveBeenCalled() + }) + + it("if no_notification is not set notification is send", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", return_id: "id"}) + + expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) + }) + + }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index cbbc61fc85..695583da6a 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -338,6 +338,28 @@ describe("SwapService", () => { expect(returnService.create).toHaveBeenCalledTimes(1) }) + + it.each([ + [true, true], + [false, false], + [undefined, undefined] + ])( "passes correct notification to eventBus with %s", async (input, expected) => { + + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + }, + input + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": expected}) + }) }) }) @@ -918,4 +940,6 @@ describe("SwapService", () => { }) }) }) + + }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index df75b7fdc0..e0165ef952 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -164,6 +164,9 @@ class NotificationService extends BaseService { if (!subs) { return } + if(data['no_notification'] === true) { + return + } return Promise.all( subs.map(async providerId => { diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index fef1599ceb..6c7ca61ec2 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,6 +204,7 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. + * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap * @returns {Promise} the newly created swap. */ async create( @@ -211,6 +212,7 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, + noNotification, custom = {} ) { return this.atomicPhase_(async manager => { @@ -256,6 +258,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, + no_notification: noNotification, }) return result From b47be51d16cf7b34670554d732f70d7e8bfb7561 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 12:07:03 +0200 Subject: [PATCH 02/55] began impl. of no_notification --- .../src/api/routes/store/returns/create-return.js | 9 ++------- .../src/migrations/1622713782458-no_notification.ts | 11 +++++++++++ packages/medusa/src/models/claim-order.ts | 3 +++ packages/medusa/src/models/order.ts | 3 +++ packages/medusa/src/models/return.ts | 3 +++ packages/medusa/src/models/swap.ts | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index c61727c4c5..1101dbd08e 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,9 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * no_notification: - * description: If set to true no notification will be send - * type: boolean * * tags: * - Return @@ -62,8 +59,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional(), - no_notification: Validator.boolean().optional() + .optional() }) const { value, error } = schema.validate(req.body) @@ -136,8 +132,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id, - no_notification: no_notification + return_id: createdReturn.id }) return { diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts new file mode 100644 index 0000000000..0e0ac4ef00 --- /dev/null +++ b/packages/medusa/src/migrations/1622713782458-no_notification.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1622713782458 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 547245544f..dea06419f1 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,6 +134,9 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index 178374186d..4d7c8615ad 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -237,6 +237,9 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ nullable: true }) idempotency_key: string diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index 77cd1d2837..b3bdc6b8bf 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,6 +99,9 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 606bdfade7..37708b6b94 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,6 +130,9 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any From 49c4ce2c7a843d634c8b54eb4f16c82d2d415090 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 11:03:27 +0200 Subject: [PATCH 03/55] added changes to swap and notification service --- docs/api/admin-spec3.json | 1524 +++++------ docs/api/admin-spec3.yaml | 2235 +++++++++-------- docs/api/store-spec3.json | 561 +++-- docs/api/store-spec3.yaml | 142 +- .../api/routes/admin/orders/create-swap.js | 7 +- .../api/routes/store/returns/create-return.js | 6 + .../src/services/__tests__/notification.js | 65 +- .../medusa/src/services/__tests__/swap.js | 24 + packages/medusa/src/services/notification.js | 3 + packages/medusa/src/services/swap.js | 3 + 10 files changed, 2335 insertions(+), 2235 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index 5da7fcc4b6..de03c84c1d 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -145,6 +145,183 @@ } } }, + "/customers": { + "post": { + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer.", + "parameters": [], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } + } + }, + "get": { + "operationId": "GetCustomers", + "summary": "List Customers", + "description": "Retrieves a list of Customers.", + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}": { + "get": { + "operationId": "GetCustomersCustomer", + "summary": "Retrieve a Customer", + "description": "Retrieves a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomer", + "summary": "Update a Customer", + "description": "Updates a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "description": "The Customer's phone number.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, "/collections": { "post": { "operationId": "PostCollections", @@ -357,14 +534,47 @@ } } }, - "/customers": { + "/gift-cards": { "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer.", - "parameters": [], + "operationId": "PostGiftCards", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "value": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -373,54 +583,22 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } } } } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } } }, "get": { - "operationId": "GetCustomers", - "summary": "List Customers", - "description": "Retrieves a list of Customers.", + "operationId": "GetGiftCards", + "summary": "List Gift Cards", + "description": "Retrieves a list of Gift Cards.", "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -429,8 +607,11 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } } } } @@ -440,24 +621,24 @@ } } }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieve a Customer", - "description": "Retrieves a Customer.", + "/gift-cards/{id}": { + "delete": { + "operationId": "DeleteGiftCardsGiftCard", + "summary": "Delete a Gift Card", + "description": "Deletes a Gift Card", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card to delete.", "schema": { "type": "string" } } ], "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -466,8 +647,51 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "id": { + "type": "string", + "description": "The id of the deleted Gift Card" + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCardsGiftCard", + "summary": "Retrieve a Gift Card", + "description": "Retrieves a Gift Card.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -477,15 +701,15 @@ } }, "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update a Customer", - "description": "Updates a Customer.", + "operationId": "PostGiftCardsGiftCard", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card.", "schema": { "type": "string" } @@ -496,16 +720,28 @@ "application/json": { "schema": { "properties": { - "first_name": { - "type": "string", - "description": "The Customer's first name." + "balance": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." }, - "last_name": { - "type": "string", - "description": "The Customer's last name." + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." }, - "phone": { - "description": "The Customer's phone number.", + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", "type": "object" } } @@ -514,7 +750,7 @@ } }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -523,8 +759,8 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -717,6 +953,10 @@ "type": "string" } }, + "usage_limit": { + "type": "number", + "description": "Maximum times the discount can be used" + }, "metadata": { "description": "An optional set of key-value pairs to hold additional information.", "type": "object" @@ -1038,242 +1278,6 @@ } } }, - "/gift-cards": { - "post": { - "operationId": "PostGiftCards", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "value": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCards", - "summary": "List Gift Cards", - "description": "Retrieves a list of Gift Cards.", - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - } - }, - "/gift-cards/{id}": { - "delete": { - "operationId": "DeleteGiftCardsGiftCard", - "summary": "Delete a Gift Card", - "description": "Deletes a Gift Card", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card to delete.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Gift Card" - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCardsGiftCard", - "summary": "Retrieve a Gift Card", - "description": "Retrieves a Gift Card.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostGiftCardsGiftCard", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "balance": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - }, "/notifications": { "get": { "operationId": "GetNotifications", @@ -1960,6 +1964,10 @@ } } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -2265,82 +2273,6 @@ } } }, - "/orders/{id}/returns/{return_id}/receive": { - "post": { - "operationId": "PostOrdersOrderReturnsReturnReceive", - "summary": "Receive a Return", - "description": "Registers a Return as received.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "return_id", - "required": true, - "description": "The id of the Return.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "items": { - "description": "The Line Items that have been received.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Line Item.", - "type": "integer" - } - } - } - }, - "refund": { - "description": "The amount to refund.", - "type": "integer" - } - } - } - } - } - }, - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, "/orders/{id}/swaps/{swap_id}/receive": { "post": { "operationId": "PostOrdersOrderSwapsSwapReceive", @@ -3926,6 +3858,183 @@ } } }, + "/return-reasons": { + "post": { + "operationId": "PostReturnReasons", + "summary": "Create a Return Reason", + "description": "Creates a Return Reason", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostReturnReasonsReason", + "summary": "Update a Return Reason", + "description": "Updates a Return Reason", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, "/regions/{id}/countries": { "post": { "operationId": "PostRegionsRegionCountries", @@ -4565,183 +4674,6 @@ } } }, - "/return-reasons": { - "post": { - "operationId": "PostReturnReasons", - "summary": "Create a Return Reason", - "description": "Creates a Return Reason", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostReturnReasonsReason", - "summary": "Update a Return Reason", - "description": "Updates a Return Reason", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, "/returns": { "get": { "operationId": "GetReturns", @@ -4771,6 +4703,269 @@ } } }, + "/returns/{id}receive": { + "post": { + "operationId": "PostReturnsReturnReceive", + "summary": "Receive a Return", + "description": "Registers a Return as received. Updates statuses on Orders and Swaps accordingly.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "items": { + "description": "The Line Items that have been received.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Line Item.", + "type": "integer" + } + } + } + }, + "refund": { + "description": "The amount to refund.", + "type": "integer" + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, + "/shipping-profiles": { + "post": { + "operationId": "PostShippingProfiles", + "summary": "Create a Shipping Profile", + "description": "Creates a Shipping Profile", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfiles", + "summary": "List Shipping Profiles", + "description": "Retrieves a list of Shipping Profile.", + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + } + }, + "/shipping-profiles/{id}": { + "delete": { + "operationId": "DeleteShippingProfilesProfile", + "summary": "Delete a Shipping Profile", + "description": "Deletes a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Shipping Profile." + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfilesProfile", + "summary": "Retrieve a Shipping Profile", + "description": "Retrieves a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostShippingProfilesProfile", + "summary": "Update a Shipping Profiles", + "description": "Updates a Shipping Profile", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + }, "/shipping-options": { "post": { "operationId": "PostShippingOptions", @@ -5043,202 +5238,6 @@ } } }, - "/shipping-profiles": { - "post": { - "operationId": "PostShippingProfiles", - "summary": "Create a Shipping Profile", - "description": "Creates a Shipping Profile", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfiles", - "summary": "List Shipping Profiles", - "description": "Retrieves a list of Shipping Profile.", - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - } - }, - "/shipping-profiles/{id}": { - "delete": { - "operationId": "DeleteShippingProfilesProfile", - "summary": "Delete a Shipping Profile", - "description": "Deletes a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Shipping Profile." - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfilesProfile", - "summary": "Retrieve a Shipping Profile", - "description": "Retrieves a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostShippingProfilesProfile", - "summary": "Update a Shipping Profiles", - "description": "Updates a Shipping Profile", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - }, "/store/currencies/{code}": { "post": { "operationId": "PostStoreCurrenciesCode", @@ -6020,10 +6019,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6095,6 +6090,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6869,6 +6872,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 048de24094..01407368f2 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,6 +85,119 @@ paths: properties: user: $ref: '#/components/schemas/user' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + get: + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieve a Customer + description: Retrieves a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + description: The Customer's phone number. + type: object + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' /collections: post: operationId: PostCollections @@ -227,119 +340,6 @@ paths: properties: collection: $ref: '#/components/schemas/product_collection' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieve a Customer - description: Retrieves a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - description: The Customer's phone number. - type: object - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -478,6 +478,9 @@ paths: type: array items: type: string + usage_limit: + type: number + description: Maximum times the discount can be used metadata: description: >- An optional set of key-value pairs to hold additional @@ -910,266 +913,34 @@ paths: properties: notification: $ref: '#/components/schemas/notification' - '/orders/{id}/shipping-methods': + /return-reasons: post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason requestBody: content: application/json: schema: properties: - fulfillment_id: - description: The id of the Fulfillment. + label: + description: The label to display to the Customer. type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: + value: description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1177,317 +948,14 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': + return_reason: + $ref: '#/components/schemas/return_reason' get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. tags: - - Order + - Return Reason responses: '200': description: OK @@ -1495,49 +963,24 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: + return_reasons: type: array items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string tags: - - Order + - Return Reason responses: '200': description: OK @@ -1545,24 +988,17 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns/{return_id}/receive': + return_reason: + $ref: '#/components/schemas/return_reason' post: - operationId: PostOrdersOrderReturnsReturnReceive - summary: Receive a Return - description: Registers a Return as received. + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: return_id - required: true - description: The id of the Return. + description: The id of the Return Reason. schema: type: string requestBody: @@ -1570,269 +1006,24 @@ paths: application/json: schema: properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. + label: + description: The label to display to the Customer. type: string - note: - description: A not with additional details about the Refund. + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1840,8 +1031,8 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + return_reason: + $ref: '#/components/schemas/return_reason' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -3159,126 +2350,6 @@ paths: properties: region: $ref: '#/components/schemas/region' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' /returns: get: operationId: GetReturns @@ -3297,6 +2368,937 @@ paths: type: array items: $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: If set to true no notification will be send + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' /shipping-options: post: operationId: PostShippingOptions @@ -3608,6 +3610,24 @@ paths: properties: shipping_profiles: $ref: '#/components/schemas/shipping_profile' + /swaps: + get: + operationId: GetSwaps + summary: List Swaps + description: Retrieves a list of Swaps. + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swaps: + type: array + items: + $ref: '#/components/schemas/swap' '/store/currencies/{code}': post: operationId: PostStoreCurrenciesCode @@ -3718,24 +3738,6 @@ paths: type: array items: $ref: '#/components/schemas/store' - /swaps: - get: - operationId: GetSwaps - summary: List Swaps - description: Retrieves a list of Swaps. - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swaps: - type: array - items: - $ref: '#/components/schemas/swap' /variants: get: operationId: GetVariants @@ -4167,9 +4169,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4232,6 +4231,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4865,6 +4870,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 5727ac1234..545a298abd 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -976,6 +976,55 @@ } } }, + "/gift-cards/{code}": { + "get": { + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", + "parameters": [ + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Gift Card code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, "/customers/{id}/addresses": { "post": { "operationId": "PostCustomersCustomerAddresses", @@ -1481,277 +1530,6 @@ } } }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", - "parameters": [ - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Gift Card code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/products/{id}": { - "get": { - "operationId": "GetProductsProduct", - "summary": "Retrieves a Product", - "description": "Retrieves a Product.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Product.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "product": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - }, - "/products": { - "get": { - "operationId": "GetProducts", - "summary": "List Products", - "description": "Retrieves a list of Products.", - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of Products.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of Products to return,", - "type": "integer" - }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, - "/return-reasons": { - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/regions/{id}": { - "get": { - "operationId": "GetRegionsRegion", - "summary": "Retrieves a Region", - "description": "Retrieves a Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Region.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/regions": { - "get": { - "operationId": "GetRegions", - "summary": "List Regions", - "description": "Retrieves a list of Regions.", - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of regions.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of regions to return,", - "type": "integer" - }, - "regions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - } - }, "/orders/cart/{cart_id}": { "get": { "operationId": "GetOrdersOrderCartId", @@ -1872,6 +1650,162 @@ } } }, + "/products/{id}": { + "get": { + "operationId": "GetProductsProduct", + "summary": "Retrieves a Product", + "description": "Retrieves a Product.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Product.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "product": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + }, + "/products": { + "get": { + "operationId": "GetProducts", + "summary": "List Products", + "description": "Retrieves a list of Products.", + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of Products.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of Products to return,", + "type": "integer" + }, + "products": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + } + }, + "/regions/{id}": { + "get": { + "operationId": "GetRegionsRegion", + "summary": "Retrieves a Region", + "description": "Retrieves a Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Region.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/regions": { + "get": { + "operationId": "GetRegions", + "summary": "List Regions", + "description": "Retrieves a list of Regions.", + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of regions.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of regions to return,", + "type": "integer" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + } + }, "/returns": { "post": { "operationId": "PostReturns", @@ -1911,6 +1845,10 @@ "description": "The id of the Shipping Option to create the Shipping Method from." } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -1938,6 +1876,72 @@ } } }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, + "/return-reasons": { + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, "/shipping-options": { "get": { "operationId": "GetShippingOptions", @@ -2696,10 +2700,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2771,6 +2771,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -3545,6 +3553,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 43e7a49d17..5f6fd465cf 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -1147,47 +1147,6 @@ paths: type: array items: $ref: '#/components/schemas/product' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' '/regions/{id}': get: operationId: GetRegionsRegion @@ -1238,6 +1197,47 @@ paths: type: array items: $ref: '#/components/schemas/region' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' /returns: post: operationId: PostReturns @@ -1274,6 +1274,9 @@ paths: description: >- The id of the Shipping Option to create the Shipping Method from. + no_notification: + description: If set to true no notification will be send + type: boolean tags: - Return responses: @@ -1285,6 +1288,29 @@ paths: properties: return: $ref: '#/components/schemas/return' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' /shipping-options: get: operationId: GetShippingOptions @@ -1346,29 +1372,6 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1829,9 +1832,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1894,6 +1894,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -2527,6 +2533,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 7782400eaa..f81c02b35f 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -45,6 +45,9 @@ import { defaultFields, defaultRelations } from "./" * quantity: * description: The quantity of the Product Variant to ship. * type: integer + * no_notification: + * description: If set to true no notification will be send. + * type: boolean * tags: * - Order * responses: @@ -65,7 +68,7 @@ export default async (req, res) => { .items({ item_id: Validator.string().required(), quantity: Validator.number().required(), - }) + }) .required(), return_shipping: Validator.object() .keys({ @@ -79,6 +82,7 @@ export default async (req, res) => { variant_id: Validator.string().required(), quantity: Validator.number().required(), }), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -134,6 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, + no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index e04bf44037..c61727c4c5 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,6 +31,10 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. + * no_notification: + * description: If set to true no notification will be send + * type: boolean + * * tags: * - Return * responses: @@ -59,6 +63,7 @@ export default async (req, res) => { option_id: Validator.string().optional(), }) .optional(), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -132,6 +137,7 @@ export default async (req, res) => { .emit("order.return_requested", { id: value.order_id, return_id: createdReturn.id, + no_notification: no_notification }) return { diff --git a/packages/medusa/src/services/__tests__/notification.js b/packages/medusa/src/services/__tests__/notification.js index f26ab26d15..64b6361b65 100644 --- a/packages/medusa/src/services/__tests__/notification.js +++ b/packages/medusa/src/services/__tests__/notification.js @@ -1,30 +1,31 @@ import NotificationService from "../notification" -import { IdMap, MockManager, MockRepository } from "medusa-test-utils" +import { MockManager, MockRepository } from "medusa-test-utils" describe("NotificationService", () => { - describe("send", () => { - const notificationRepository = MockRepository({ create: c => c }) + const notificationRepository = MockRepository({ create: c => c }) - const container = { - manager: MockManager, - notificationRepository, - noti_test: { - sendNotification: jest.fn(() => - Promise.resolve({ - to: "test@mail.com", - data: { id: "something" }, - }) - ), - }, - } + const container = { + manager: MockManager, + notificationRepository, + noti_test: { + sendNotification: jest.fn(() => + Promise.resolve({ + to: "test@mail.com", + data: { id: "something" }, + }) + ), + }, + } - const notificationService = new NotificationService(container) + beforeEach(() => { + jest.clearAllMocks() + }) - beforeEach(() => { - jest.clearAllMocks() - }) + describe("send", () =>{ it("successfully calls provider and saves noti", async () => { + const notificationService = new NotificationService(container) + await notificationService.send("event.test", { id: "test" }, "test") expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) @@ -51,4 +52,30 @@ describe("NotificationService", () => { expect(notificationRepository.save).toHaveBeenCalledWith(constructed) }) }) + + describe("handleEvent", () => { + + it("cancels notification if no_notification is set", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", + return_id: "id", + no_notification: true}) + + expect(container.noti_test.sendNotification).not.toHaveBeenCalled() + }) + + it("if no_notification is not set notification is send", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", return_id: "id"}) + + expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) + }) + + }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index cbbc61fc85..695583da6a 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -338,6 +338,28 @@ describe("SwapService", () => { expect(returnService.create).toHaveBeenCalledTimes(1) }) + + it.each([ + [true, true], + [false, false], + [undefined, undefined] + ])( "passes correct notification to eventBus with %s", async (input, expected) => { + + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + }, + input + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": expected}) + }) }) }) @@ -918,4 +940,6 @@ describe("SwapService", () => { }) }) }) + + }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index df75b7fdc0..e0165ef952 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -164,6 +164,9 @@ class NotificationService extends BaseService { if (!subs) { return } + if(data['no_notification'] === true) { + return + } return Promise.all( subs.map(async providerId => { diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index fef1599ceb..6c7ca61ec2 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,6 +204,7 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. + * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap * @returns {Promise} the newly created swap. */ async create( @@ -211,6 +212,7 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, + noNotification, custom = {} ) { return this.atomicPhase_(async manager => { @@ -256,6 +258,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, + no_notification: noNotification, }) return result From ad7825ab1629cddd00c42e9c7cb65d1981d087cd Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 12:07:03 +0200 Subject: [PATCH 04/55] began impl. of no_notification --- .../src/api/routes/store/returns/create-return.js | 9 ++------- .../src/migrations/1622713782458-no_notification.ts | 11 +++++++++++ packages/medusa/src/models/claim-order.ts | 3 +++ packages/medusa/src/models/order.ts | 3 +++ packages/medusa/src/models/return.ts | 3 +++ packages/medusa/src/models/swap.ts | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index c61727c4c5..1101dbd08e 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,9 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * no_notification: - * description: If set to true no notification will be send - * type: boolean * * tags: * - Return @@ -62,8 +59,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional(), - no_notification: Validator.boolean().optional() + .optional() }) const { value, error } = schema.validate(req.body) @@ -136,8 +132,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id, - no_notification: no_notification + return_id: createdReturn.id }) return { diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts new file mode 100644 index 0000000000..0e0ac4ef00 --- /dev/null +++ b/packages/medusa/src/migrations/1622713782458-no_notification.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1622713782458 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 547245544f..dea06419f1 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,6 +134,9 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index a6d7be6ff0..95aad02d1d 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,6 +245,9 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ nullable: true }) idempotency_key: string diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index 77cd1d2837..b3bdc6b8bf 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,6 +99,9 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 606bdfade7..37708b6b94 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,6 +130,9 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any From 29ffae3b6bc8607cb7d98c2d0699a64ffc897c10 Mon Sep 17 00:00:00 2001 From: --list Date: Tue, 8 Jun 2021 16:00:58 +0200 Subject: [PATCH 05/55] removed not working migration --- .../src/migrations/1622713782458-no_notification.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts deleted file mode 100644 index 0e0ac4ef00..0000000000 --- a/packages/medusa/src/migrations/1622713782458-no_notification.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotification1622713782458 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} From b6b24e1c5ba9d576e77ccb16264e85d4652d9ec1 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:20:38 +0200 Subject: [PATCH 06/55] added no_notification to services and api endpoints --- .../api/routes/admin/orders/create-claim.js | 5 + .../api/routes/admin/orders/create-swap.js | 4 +- .../src/api/routes/admin/orders/index.js | 2 + .../api/routes/admin/orders/update-claim.js | 4 + .../api/routes/admin/orders/update-order.js | 2 +- .../1623164855464-no_notifications.ts | 134 ++++++++++++++++++ packages/medusa/src/models/claim-order.ts | 2 +- packages/medusa/src/models/order.ts | 2 +- packages/medusa/src/models/return.ts | 2 +- packages/medusa/src/models/swap.ts | 2 +- packages/medusa/src/services/claim.js | 10 ++ packages/medusa/src/services/order.js | 19 ++- packages/medusa/src/services/swap.js | 12 +- 13 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.js b/packages/medusa/src/api/routes/admin/orders/create-claim.js index ce77c090a4..5e0e207f58 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.js @@ -91,6 +91,9 @@ import { defaultRelations, defaultFields } from "./" * refund_amount: * description: The amount to refund the Customer when the Claim type is `refund`. * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -155,6 +158,7 @@ export default async (req, res) => { .integer() .optional(), shipping_address: Validator.object().optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) @@ -212,6 +216,7 @@ export default async (req, res) => { return_shipping: value.return_shipping, additional_items: value.additional_items, shipping_methods: value.shipping_methods, + no_notification: value.no_notification, metadata: value.metadata, }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index f81c02b35f..648aed1aab 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -46,7 +46,7 @@ import { defaultFields, defaultRelations } from "./" * description: The quantity of the Product Variant to ship. * type: integer * no_notification: - * description: If set to true no notification will be send. + * description: If set to true no notification will be send related to this Swap. * type: boolean * tags: * - Order @@ -138,7 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, - no_notification, + value.no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 98e72e599c..29ce86e109 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -237,6 +237,7 @@ export const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedFields = [ @@ -265,6 +266,7 @@ export const allowedFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedRelations = [ diff --git a/packages/medusa/src/api/routes/admin/orders/update-claim.js b/packages/medusa/src/api/routes/admin/orders/update-claim.js index ffbd4eae46..90346be45c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/update-claim.js @@ -62,6 +62,9 @@ import { defaultRelations, defaultFields } from "./" * price: * description: The price to charge for the Shipping Method * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -106,6 +109,7 @@ export default async (req, res) => { .optional(), }) .optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.js b/packages/medusa/src/api/routes/admin/orders/update-order.js index 37e321024b..ba1ed0bf8c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.js +++ b/packages/medusa/src/api/routes/admin/orders/update-order.js @@ -22,7 +22,7 @@ export default async (req, res) => { price: Validator.number(), data: Validator.object(), items: Validator.array(), - }), + }) }) const { value, error } = schema.validate(req.body) diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts new file mode 100644 index 0000000000..e24bbbff9a --- /dev/null +++ b/packages/medusa/src/migrations/1623164855464-no_notifications.ts @@ -0,0 +1,134 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotifications1623164855464 implements MigrationInterface { + name = 'noNotifications1623164855464' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index dea06419f1..91ab66b450 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,7 +134,7 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index 95aad02d1d..10258270d9 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,7 +245,7 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ nullable: true }) diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index b3bdc6b8bf..98a52122b9 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,7 +99,7 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 37708b6b94..e0c173c1ba 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,7 +130,7 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 758586815b..18ed345134 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -149,6 +149,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.UPDATED, { id: claim.id, + no_notification: claim.no_notification }) return claim @@ -174,6 +175,7 @@ class ClaimService extends BaseService { refund_amount, shipping_address, shipping_address_id, + no_notification, ...rest } = data @@ -233,6 +235,8 @@ class ClaimService extends BaseService { ) ) + const evaluatedNoNotification = noNotification ? noNotification : order.no_notification + const created = claimRepo.create({ shipping_address_id: addressId, payment_status: type === "refund" ? "not_refunded" : "na", @@ -241,6 +245,7 @@ class ClaimService extends BaseService { type, additional_items: newItems, order_id: order.id, + no_notification: evaluatedNoNotification }) const result = await claimRepo.save(created) @@ -288,6 +293,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, + no_notification: claim.no_notification }) return result @@ -395,6 +401,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.FULFILLMENT_CREATED, { id: id, fulfillment_id: fulfillment.id, + no_notification: claim.no_notification }) } @@ -430,6 +437,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, + no_notification: claim.no_notification }) return result @@ -474,6 +482,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, + no_notification: claim.no_notification }) return result @@ -524,6 +533,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, + no_notification: claim.no_notification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 5a096ac74f..cb9af46a5e 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -406,6 +406,7 @@ class OrderService extends BaseService { OrderService.Events.COMPLETED, { id: orderId, + no_notification: order.no_notification } ) @@ -550,7 +551,7 @@ class OrderService extends BaseService { await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.PLACED, { - id: result.id, + id: result.id }) return result @@ -612,6 +613,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.SHIPMENT_CREATED, { id: orderId, fulfillment_id: shipmentRes.id, + no_notification: order.no_notification }) return result @@ -632,6 +634,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PLACED, { id: result.id, + no_notification: order.no_notification }) return result }) @@ -819,6 +822,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.UPDATED, { id: orderId, + no_notification: order.no_notification }) return result }) @@ -869,6 +873,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.CANCELED, { id: order.id, + no_notification: order.no_notification }) return result }) @@ -896,7 +901,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.PAYMENT_CAPTURE_FAILED, { id: orderId, payment_id: p.id, - error: err, + error: err }) }) @@ -922,6 +927,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PAYMENT_CAPTURED, { id: result.id, + no_notification: order.no_notification }) } @@ -978,6 +984,7 @@ class OrderService extends BaseService { "tax_total", "gift_card_total", "total", + "no_notification" ], relations: [ "discounts", @@ -1050,6 +1057,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.FULFILLMENT_CREATED, { id: orderId, fulfillment_id: fulfillment.id, + no_notification: order.no_notification }) } @@ -1108,7 +1116,7 @@ class OrderService extends BaseService { async createRefund(orderId, refundAmount, reason, note) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["refundable_amount", "total", "refunded_total"], + select: ["refundable_amount", "total", "refunded_total", "no_notification"], relations: ["payments"], }) @@ -1127,6 +1135,7 @@ class OrderService extends BaseService { this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, + no_notification: order.no_notification }) return result }) @@ -1207,7 +1216,7 @@ class OrderService extends BaseService { async registerReturnReceived(orderId, receivedReturn, customRefundAmount) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["total", "refunded_total", "refundable_amount"], + select: ["total", "refunded_total", "refundable_amount", "no_notification"], relations: ["items", "returns", "payments"], }) @@ -1230,6 +1239,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.RETURN_ACTION_REQUIRED, { id: result.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result } @@ -1261,6 +1271,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.ITEMS_RETURNED, { id: order.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result }) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 6c7ca61ec2..07d017ee06 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,7 +204,9 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. - * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap + * @param {boolean?} noNotification - an optional flag to disable sending + * notification when creating swap. If set, it overrules the attribute inherited + * from the order. * @returns {Promise} the newly created swap. */ async create( @@ -236,6 +238,8 @@ class SwapService extends BaseService { }) ) + const evaluatedNoNotification = noNotification ? noNotification : order.noNotification + const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ ...custom, @@ -243,6 +247,7 @@ class SwapService extends BaseService { payment_status: "not_paid", order_id: order.id, additional_items: newItems, + no_notification: evaluatedNoNotification }) const result = await swapRepo.save(created) @@ -258,7 +263,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, - no_notification: noNotification, + no_notification: evaluatedNoNotification, }) return result @@ -559,6 +564,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.PAYMENT_COMPLETED, { id: swap.id, + no_notification: swap.no_notification }) return result @@ -750,6 +756,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.SHIPMENT_CREATED, { id: swapId, fulfillment_id: shipment.id, + no_notification: swap.no_notification }) return result }) @@ -806,6 +813,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.RECEIVED, { id: id, order_id: result.order_id, + no_notification: swap.no_notification }) return result From 61a8f53a79db8ea4e825e7d787f63cbd134a177c Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:54:42 +0200 Subject: [PATCH 07/55] removed wrong migration --- .../1623164855464-no_notifications.ts | 134 ------------------ 1 file changed, 134 deletions(-) delete mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts deleted file mode 100644 index e24bbbff9a..0000000000 --- a/packages/medusa/src/migrations/1623164855464-no_notifications.ts +++ /dev/null @@ -1,134 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotifications1623164855464 implements MigrationInterface { - name = 'noNotifications1623164855464' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} From 1f91c0ec7c2136c03c826c1301f0448a86476656 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 11:03:27 +0200 Subject: [PATCH 08/55] added changes to swap and notification service --- docs/api/admin-spec3.json | 1524 +++++------ docs/api/admin-spec3.yaml | 2235 +++++++++-------- docs/api/store-spec3.json | 561 +++-- docs/api/store-spec3.yaml | 142 +- .../api/routes/admin/orders/create-swap.js | 7 +- .../api/routes/store/returns/create-return.js | 6 + .../src/services/__tests__/notification.js | 65 +- .../medusa/src/services/__tests__/swap.js | 24 + packages/medusa/src/services/notification.js | 3 + packages/medusa/src/services/swap.js | 3 + 10 files changed, 2335 insertions(+), 2235 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index 5da7fcc4b6..de03c84c1d 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -145,6 +145,183 @@ } } }, + "/customers": { + "post": { + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer.", + "parameters": [], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } + } + }, + "get": { + "operationId": "GetCustomers", + "summary": "List Customers", + "description": "Retrieves a list of Customers.", + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}": { + "get": { + "operationId": "GetCustomersCustomer", + "summary": "Retrieve a Customer", + "description": "Retrieves a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomer", + "summary": "Update a Customer", + "description": "Updates a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "description": "The Customer's phone number.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, "/collections": { "post": { "operationId": "PostCollections", @@ -357,14 +534,47 @@ } } }, - "/customers": { + "/gift-cards": { "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer.", - "parameters": [], + "operationId": "PostGiftCards", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "value": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -373,54 +583,22 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } } } } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } } }, "get": { - "operationId": "GetCustomers", - "summary": "List Customers", - "description": "Retrieves a list of Customers.", + "operationId": "GetGiftCards", + "summary": "List Gift Cards", + "description": "Retrieves a list of Gift Cards.", "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -429,8 +607,11 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } } } } @@ -440,24 +621,24 @@ } } }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieve a Customer", - "description": "Retrieves a Customer.", + "/gift-cards/{id}": { + "delete": { + "operationId": "DeleteGiftCardsGiftCard", + "summary": "Delete a Gift Card", + "description": "Deletes a Gift Card", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card to delete.", "schema": { "type": "string" } } ], "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -466,8 +647,51 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "id": { + "type": "string", + "description": "The id of the deleted Gift Card" + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCardsGiftCard", + "summary": "Retrieve a Gift Card", + "description": "Retrieves a Gift Card.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -477,15 +701,15 @@ } }, "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update a Customer", - "description": "Updates a Customer.", + "operationId": "PostGiftCardsGiftCard", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card.", "schema": { "type": "string" } @@ -496,16 +720,28 @@ "application/json": { "schema": { "properties": { - "first_name": { - "type": "string", - "description": "The Customer's first name." + "balance": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." }, - "last_name": { - "type": "string", - "description": "The Customer's last name." + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." }, - "phone": { - "description": "The Customer's phone number.", + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", "type": "object" } } @@ -514,7 +750,7 @@ } }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -523,8 +759,8 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -717,6 +953,10 @@ "type": "string" } }, + "usage_limit": { + "type": "number", + "description": "Maximum times the discount can be used" + }, "metadata": { "description": "An optional set of key-value pairs to hold additional information.", "type": "object" @@ -1038,242 +1278,6 @@ } } }, - "/gift-cards": { - "post": { - "operationId": "PostGiftCards", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "value": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCards", - "summary": "List Gift Cards", - "description": "Retrieves a list of Gift Cards.", - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - } - }, - "/gift-cards/{id}": { - "delete": { - "operationId": "DeleteGiftCardsGiftCard", - "summary": "Delete a Gift Card", - "description": "Deletes a Gift Card", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card to delete.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Gift Card" - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCardsGiftCard", - "summary": "Retrieve a Gift Card", - "description": "Retrieves a Gift Card.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostGiftCardsGiftCard", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "balance": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - }, "/notifications": { "get": { "operationId": "GetNotifications", @@ -1960,6 +1964,10 @@ } } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -2265,82 +2273,6 @@ } } }, - "/orders/{id}/returns/{return_id}/receive": { - "post": { - "operationId": "PostOrdersOrderReturnsReturnReceive", - "summary": "Receive a Return", - "description": "Registers a Return as received.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "return_id", - "required": true, - "description": "The id of the Return.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "items": { - "description": "The Line Items that have been received.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Line Item.", - "type": "integer" - } - } - } - }, - "refund": { - "description": "The amount to refund.", - "type": "integer" - } - } - } - } - } - }, - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, "/orders/{id}/swaps/{swap_id}/receive": { "post": { "operationId": "PostOrdersOrderSwapsSwapReceive", @@ -3926,6 +3858,183 @@ } } }, + "/return-reasons": { + "post": { + "operationId": "PostReturnReasons", + "summary": "Create a Return Reason", + "description": "Creates a Return Reason", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostReturnReasonsReason", + "summary": "Update a Return Reason", + "description": "Updates a Return Reason", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, "/regions/{id}/countries": { "post": { "operationId": "PostRegionsRegionCountries", @@ -4565,183 +4674,6 @@ } } }, - "/return-reasons": { - "post": { - "operationId": "PostReturnReasons", - "summary": "Create a Return Reason", - "description": "Creates a Return Reason", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostReturnReasonsReason", - "summary": "Update a Return Reason", - "description": "Updates a Return Reason", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, "/returns": { "get": { "operationId": "GetReturns", @@ -4771,6 +4703,269 @@ } } }, + "/returns/{id}receive": { + "post": { + "operationId": "PostReturnsReturnReceive", + "summary": "Receive a Return", + "description": "Registers a Return as received. Updates statuses on Orders and Swaps accordingly.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "items": { + "description": "The Line Items that have been received.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Line Item.", + "type": "integer" + } + } + } + }, + "refund": { + "description": "The amount to refund.", + "type": "integer" + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, + "/shipping-profiles": { + "post": { + "operationId": "PostShippingProfiles", + "summary": "Create a Shipping Profile", + "description": "Creates a Shipping Profile", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfiles", + "summary": "List Shipping Profiles", + "description": "Retrieves a list of Shipping Profile.", + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + } + }, + "/shipping-profiles/{id}": { + "delete": { + "operationId": "DeleteShippingProfilesProfile", + "summary": "Delete a Shipping Profile", + "description": "Deletes a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Shipping Profile." + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfilesProfile", + "summary": "Retrieve a Shipping Profile", + "description": "Retrieves a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostShippingProfilesProfile", + "summary": "Update a Shipping Profiles", + "description": "Updates a Shipping Profile", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + }, "/shipping-options": { "post": { "operationId": "PostShippingOptions", @@ -5043,202 +5238,6 @@ } } }, - "/shipping-profiles": { - "post": { - "operationId": "PostShippingProfiles", - "summary": "Create a Shipping Profile", - "description": "Creates a Shipping Profile", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfiles", - "summary": "List Shipping Profiles", - "description": "Retrieves a list of Shipping Profile.", - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - } - }, - "/shipping-profiles/{id}": { - "delete": { - "operationId": "DeleteShippingProfilesProfile", - "summary": "Delete a Shipping Profile", - "description": "Deletes a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Shipping Profile." - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfilesProfile", - "summary": "Retrieve a Shipping Profile", - "description": "Retrieves a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostShippingProfilesProfile", - "summary": "Update a Shipping Profiles", - "description": "Updates a Shipping Profile", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - }, "/store/currencies/{code}": { "post": { "operationId": "PostStoreCurrenciesCode", @@ -6020,10 +6019,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6095,6 +6090,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6869,6 +6872,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 048de24094..01407368f2 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,6 +85,119 @@ paths: properties: user: $ref: '#/components/schemas/user' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + get: + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieve a Customer + description: Retrieves a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + description: The Customer's phone number. + type: object + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' /collections: post: operationId: PostCollections @@ -227,119 +340,6 @@ paths: properties: collection: $ref: '#/components/schemas/product_collection' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieve a Customer - description: Retrieves a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - description: The Customer's phone number. - type: object - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -478,6 +478,9 @@ paths: type: array items: type: string + usage_limit: + type: number + description: Maximum times the discount can be used metadata: description: >- An optional set of key-value pairs to hold additional @@ -910,266 +913,34 @@ paths: properties: notification: $ref: '#/components/schemas/notification' - '/orders/{id}/shipping-methods': + /return-reasons: post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason requestBody: content: application/json: schema: properties: - fulfillment_id: - description: The id of the Fulfillment. + label: + description: The label to display to the Customer. type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: + value: description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1177,317 +948,14 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': + return_reason: + $ref: '#/components/schemas/return_reason' get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. tags: - - Order + - Return Reason responses: '200': description: OK @@ -1495,49 +963,24 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: + return_reasons: type: array items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string tags: - - Order + - Return Reason responses: '200': description: OK @@ -1545,24 +988,17 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns/{return_id}/receive': + return_reason: + $ref: '#/components/schemas/return_reason' post: - operationId: PostOrdersOrderReturnsReturnReceive - summary: Receive a Return - description: Registers a Return as received. + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: return_id - required: true - description: The id of the Return. + description: The id of the Return Reason. schema: type: string requestBody: @@ -1570,269 +1006,24 @@ paths: application/json: schema: properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. + label: + description: The label to display to the Customer. type: string - note: - description: A not with additional details about the Refund. + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1840,8 +1031,8 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + return_reason: + $ref: '#/components/schemas/return_reason' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -3159,126 +2350,6 @@ paths: properties: region: $ref: '#/components/schemas/region' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' /returns: get: operationId: GetReturns @@ -3297,6 +2368,937 @@ paths: type: array items: $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: If set to true no notification will be send + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' /shipping-options: post: operationId: PostShippingOptions @@ -3608,6 +3610,24 @@ paths: properties: shipping_profiles: $ref: '#/components/schemas/shipping_profile' + /swaps: + get: + operationId: GetSwaps + summary: List Swaps + description: Retrieves a list of Swaps. + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swaps: + type: array + items: + $ref: '#/components/schemas/swap' '/store/currencies/{code}': post: operationId: PostStoreCurrenciesCode @@ -3718,24 +3738,6 @@ paths: type: array items: $ref: '#/components/schemas/store' - /swaps: - get: - operationId: GetSwaps - summary: List Swaps - description: Retrieves a list of Swaps. - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swaps: - type: array - items: - $ref: '#/components/schemas/swap' /variants: get: operationId: GetVariants @@ -4167,9 +4169,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4232,6 +4231,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4865,6 +4870,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 5727ac1234..545a298abd 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -976,6 +976,55 @@ } } }, + "/gift-cards/{code}": { + "get": { + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", + "parameters": [ + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Gift Card code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, "/customers/{id}/addresses": { "post": { "operationId": "PostCustomersCustomerAddresses", @@ -1481,277 +1530,6 @@ } } }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", - "parameters": [ - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Gift Card code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/products/{id}": { - "get": { - "operationId": "GetProductsProduct", - "summary": "Retrieves a Product", - "description": "Retrieves a Product.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Product.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "product": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - }, - "/products": { - "get": { - "operationId": "GetProducts", - "summary": "List Products", - "description": "Retrieves a list of Products.", - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of Products.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of Products to return,", - "type": "integer" - }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, - "/return-reasons": { - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/regions/{id}": { - "get": { - "operationId": "GetRegionsRegion", - "summary": "Retrieves a Region", - "description": "Retrieves a Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Region.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/regions": { - "get": { - "operationId": "GetRegions", - "summary": "List Regions", - "description": "Retrieves a list of Regions.", - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of regions.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of regions to return,", - "type": "integer" - }, - "regions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - } - }, "/orders/cart/{cart_id}": { "get": { "operationId": "GetOrdersOrderCartId", @@ -1872,6 +1650,162 @@ } } }, + "/products/{id}": { + "get": { + "operationId": "GetProductsProduct", + "summary": "Retrieves a Product", + "description": "Retrieves a Product.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Product.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "product": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + }, + "/products": { + "get": { + "operationId": "GetProducts", + "summary": "List Products", + "description": "Retrieves a list of Products.", + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of Products.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of Products to return,", + "type": "integer" + }, + "products": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + } + }, + "/regions/{id}": { + "get": { + "operationId": "GetRegionsRegion", + "summary": "Retrieves a Region", + "description": "Retrieves a Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Region.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/regions": { + "get": { + "operationId": "GetRegions", + "summary": "List Regions", + "description": "Retrieves a list of Regions.", + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of regions.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of regions to return,", + "type": "integer" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + } + }, "/returns": { "post": { "operationId": "PostReturns", @@ -1911,6 +1845,10 @@ "description": "The id of the Shipping Option to create the Shipping Method from." } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -1938,6 +1876,72 @@ } } }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, + "/return-reasons": { + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, "/shipping-options": { "get": { "operationId": "GetShippingOptions", @@ -2696,10 +2700,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2771,6 +2771,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -3545,6 +3553,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 43e7a49d17..5f6fd465cf 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -1147,47 +1147,6 @@ paths: type: array items: $ref: '#/components/schemas/product' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' '/regions/{id}': get: operationId: GetRegionsRegion @@ -1238,6 +1197,47 @@ paths: type: array items: $ref: '#/components/schemas/region' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' /returns: post: operationId: PostReturns @@ -1274,6 +1274,9 @@ paths: description: >- The id of the Shipping Option to create the Shipping Method from. + no_notification: + description: If set to true no notification will be send + type: boolean tags: - Return responses: @@ -1285,6 +1288,29 @@ paths: properties: return: $ref: '#/components/schemas/return' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' /shipping-options: get: operationId: GetShippingOptions @@ -1346,29 +1372,6 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1829,9 +1832,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1894,6 +1894,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -2527,6 +2533,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 7782400eaa..f81c02b35f 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -45,6 +45,9 @@ import { defaultFields, defaultRelations } from "./" * quantity: * description: The quantity of the Product Variant to ship. * type: integer + * no_notification: + * description: If set to true no notification will be send. + * type: boolean * tags: * - Order * responses: @@ -65,7 +68,7 @@ export default async (req, res) => { .items({ item_id: Validator.string().required(), quantity: Validator.number().required(), - }) + }) .required(), return_shipping: Validator.object() .keys({ @@ -79,6 +82,7 @@ export default async (req, res) => { variant_id: Validator.string().required(), quantity: Validator.number().required(), }), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -134,6 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, + no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index e04bf44037..c61727c4c5 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,6 +31,10 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. + * no_notification: + * description: If set to true no notification will be send + * type: boolean + * * tags: * - Return * responses: @@ -59,6 +63,7 @@ export default async (req, res) => { option_id: Validator.string().optional(), }) .optional(), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -132,6 +137,7 @@ export default async (req, res) => { .emit("order.return_requested", { id: value.order_id, return_id: createdReturn.id, + no_notification: no_notification }) return { diff --git a/packages/medusa/src/services/__tests__/notification.js b/packages/medusa/src/services/__tests__/notification.js index f26ab26d15..64b6361b65 100644 --- a/packages/medusa/src/services/__tests__/notification.js +++ b/packages/medusa/src/services/__tests__/notification.js @@ -1,30 +1,31 @@ import NotificationService from "../notification" -import { IdMap, MockManager, MockRepository } from "medusa-test-utils" +import { MockManager, MockRepository } from "medusa-test-utils" describe("NotificationService", () => { - describe("send", () => { - const notificationRepository = MockRepository({ create: c => c }) + const notificationRepository = MockRepository({ create: c => c }) - const container = { - manager: MockManager, - notificationRepository, - noti_test: { - sendNotification: jest.fn(() => - Promise.resolve({ - to: "test@mail.com", - data: { id: "something" }, - }) - ), - }, - } + const container = { + manager: MockManager, + notificationRepository, + noti_test: { + sendNotification: jest.fn(() => + Promise.resolve({ + to: "test@mail.com", + data: { id: "something" }, + }) + ), + }, + } - const notificationService = new NotificationService(container) + beforeEach(() => { + jest.clearAllMocks() + }) - beforeEach(() => { - jest.clearAllMocks() - }) + describe("send", () =>{ it("successfully calls provider and saves noti", async () => { + const notificationService = new NotificationService(container) + await notificationService.send("event.test", { id: "test" }, "test") expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) @@ -51,4 +52,30 @@ describe("NotificationService", () => { expect(notificationRepository.save).toHaveBeenCalledWith(constructed) }) }) + + describe("handleEvent", () => { + + it("cancels notification if no_notification is set", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", + return_id: "id", + no_notification: true}) + + expect(container.noti_test.sendNotification).not.toHaveBeenCalled() + }) + + it("if no_notification is not set notification is send", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", return_id: "id"}) + + expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) + }) + + }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index cbbc61fc85..695583da6a 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -338,6 +338,28 @@ describe("SwapService", () => { expect(returnService.create).toHaveBeenCalledTimes(1) }) + + it.each([ + [true, true], + [false, false], + [undefined, undefined] + ])( "passes correct notification to eventBus with %s", async (input, expected) => { + + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + }, + input + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": expected}) + }) }) }) @@ -918,4 +940,6 @@ describe("SwapService", () => { }) }) }) + + }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index df75b7fdc0..e0165ef952 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -164,6 +164,9 @@ class NotificationService extends BaseService { if (!subs) { return } + if(data['no_notification'] === true) { + return + } return Promise.all( subs.map(async providerId => { diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index fef1599ceb..6c7ca61ec2 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,6 +204,7 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. + * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap * @returns {Promise} the newly created swap. */ async create( @@ -211,6 +212,7 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, + noNotification, custom = {} ) { return this.atomicPhase_(async manager => { @@ -256,6 +258,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, + no_notification: noNotification, }) return result From c2623d869544dc12df161217bf51417a1a019120 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 12:07:03 +0200 Subject: [PATCH 09/55] began impl. of no_notification --- .../src/api/routes/store/returns/create-return.js | 9 ++------- .../src/migrations/1622713782458-no_notification.ts | 11 +++++++++++ packages/medusa/src/models/claim-order.ts | 3 +++ packages/medusa/src/models/order.ts | 3 +++ packages/medusa/src/models/return.ts | 3 +++ packages/medusa/src/models/swap.ts | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index c61727c4c5..1101dbd08e 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,9 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * no_notification: - * description: If set to true no notification will be send - * type: boolean * * tags: * - Return @@ -62,8 +59,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional(), - no_notification: Validator.boolean().optional() + .optional() }) const { value, error } = schema.validate(req.body) @@ -136,8 +132,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id, - no_notification: no_notification + return_id: createdReturn.id }) return { diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts new file mode 100644 index 0000000000..0e0ac4ef00 --- /dev/null +++ b/packages/medusa/src/migrations/1622713782458-no_notification.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1622713782458 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 547245544f..dea06419f1 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,6 +134,9 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index a6d7be6ff0..95aad02d1d 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,6 +245,9 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ nullable: true }) idempotency_key: string diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index 77cd1d2837..b3bdc6b8bf 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,6 +99,9 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 606bdfade7..37708b6b94 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,6 +130,9 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any From cfae9be8d8c15788fac2607e8a37816689e1c135 Mon Sep 17 00:00:00 2001 From: --list Date: Tue, 8 Jun 2021 16:00:58 +0200 Subject: [PATCH 10/55] removed not working migration --- .../src/migrations/1622713782458-no_notification.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts deleted file mode 100644 index 0e0ac4ef00..0000000000 --- a/packages/medusa/src/migrations/1622713782458-no_notification.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotification1622713782458 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} From 17e2ce96b2bfd77b95188366f47440ccff4c1d81 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:20:38 +0200 Subject: [PATCH 11/55] added no_notification to services and api endpoints --- .../api/routes/admin/orders/create-claim.js | 5 + .../api/routes/admin/orders/create-swap.js | 4 +- .../src/api/routes/admin/orders/index.js | 2 + .../api/routes/admin/orders/update-claim.js | 4 + .../api/routes/admin/orders/update-order.js | 2 +- .../1623164855464-no_notifications.ts | 134 ++++++++++++++++++ packages/medusa/src/models/claim-order.ts | 2 +- packages/medusa/src/models/order.ts | 2 +- packages/medusa/src/models/return.ts | 2 +- packages/medusa/src/models/swap.ts | 2 +- packages/medusa/src/services/claim.js | 10 ++ packages/medusa/src/services/order.js | 19 ++- packages/medusa/src/services/swap.js | 12 +- 13 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.js b/packages/medusa/src/api/routes/admin/orders/create-claim.js index ce77c090a4..5e0e207f58 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.js @@ -91,6 +91,9 @@ import { defaultRelations, defaultFields } from "./" * refund_amount: * description: The amount to refund the Customer when the Claim type is `refund`. * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -155,6 +158,7 @@ export default async (req, res) => { .integer() .optional(), shipping_address: Validator.object().optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) @@ -212,6 +216,7 @@ export default async (req, res) => { return_shipping: value.return_shipping, additional_items: value.additional_items, shipping_methods: value.shipping_methods, + no_notification: value.no_notification, metadata: value.metadata, }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index f81c02b35f..648aed1aab 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -46,7 +46,7 @@ import { defaultFields, defaultRelations } from "./" * description: The quantity of the Product Variant to ship. * type: integer * no_notification: - * description: If set to true no notification will be send. + * description: If set to true no notification will be send related to this Swap. * type: boolean * tags: * - Order @@ -138,7 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, - no_notification, + value.no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 98e72e599c..29ce86e109 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -237,6 +237,7 @@ export const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedFields = [ @@ -265,6 +266,7 @@ export const allowedFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedRelations = [ diff --git a/packages/medusa/src/api/routes/admin/orders/update-claim.js b/packages/medusa/src/api/routes/admin/orders/update-claim.js index ffbd4eae46..90346be45c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/update-claim.js @@ -62,6 +62,9 @@ import { defaultRelations, defaultFields } from "./" * price: * description: The price to charge for the Shipping Method * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -106,6 +109,7 @@ export default async (req, res) => { .optional(), }) .optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.js b/packages/medusa/src/api/routes/admin/orders/update-order.js index 37e321024b..ba1ed0bf8c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.js +++ b/packages/medusa/src/api/routes/admin/orders/update-order.js @@ -22,7 +22,7 @@ export default async (req, res) => { price: Validator.number(), data: Validator.object(), items: Validator.array(), - }), + }) }) const { value, error } = schema.validate(req.body) diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts new file mode 100644 index 0000000000..e24bbbff9a --- /dev/null +++ b/packages/medusa/src/migrations/1623164855464-no_notifications.ts @@ -0,0 +1,134 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotifications1623164855464 implements MigrationInterface { + name = 'noNotifications1623164855464' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index dea06419f1..91ab66b450 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,7 +134,7 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index 95aad02d1d..10258270d9 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,7 +245,7 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ nullable: true }) diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index b3bdc6b8bf..98a52122b9 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,7 +99,7 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 37708b6b94..e0c173c1ba 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,7 +130,7 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 758586815b..18ed345134 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -149,6 +149,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.UPDATED, { id: claim.id, + no_notification: claim.no_notification }) return claim @@ -174,6 +175,7 @@ class ClaimService extends BaseService { refund_amount, shipping_address, shipping_address_id, + no_notification, ...rest } = data @@ -233,6 +235,8 @@ class ClaimService extends BaseService { ) ) + const evaluatedNoNotification = noNotification ? noNotification : order.no_notification + const created = claimRepo.create({ shipping_address_id: addressId, payment_status: type === "refund" ? "not_refunded" : "na", @@ -241,6 +245,7 @@ class ClaimService extends BaseService { type, additional_items: newItems, order_id: order.id, + no_notification: evaluatedNoNotification }) const result = await claimRepo.save(created) @@ -288,6 +293,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, + no_notification: claim.no_notification }) return result @@ -395,6 +401,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.FULFILLMENT_CREATED, { id: id, fulfillment_id: fulfillment.id, + no_notification: claim.no_notification }) } @@ -430,6 +437,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, + no_notification: claim.no_notification }) return result @@ -474,6 +482,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, + no_notification: claim.no_notification }) return result @@ -524,6 +533,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, + no_notification: claim.no_notification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 5a096ac74f..cb9af46a5e 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -406,6 +406,7 @@ class OrderService extends BaseService { OrderService.Events.COMPLETED, { id: orderId, + no_notification: order.no_notification } ) @@ -550,7 +551,7 @@ class OrderService extends BaseService { await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.PLACED, { - id: result.id, + id: result.id }) return result @@ -612,6 +613,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.SHIPMENT_CREATED, { id: orderId, fulfillment_id: shipmentRes.id, + no_notification: order.no_notification }) return result @@ -632,6 +634,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PLACED, { id: result.id, + no_notification: order.no_notification }) return result }) @@ -819,6 +822,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.UPDATED, { id: orderId, + no_notification: order.no_notification }) return result }) @@ -869,6 +873,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.CANCELED, { id: order.id, + no_notification: order.no_notification }) return result }) @@ -896,7 +901,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.PAYMENT_CAPTURE_FAILED, { id: orderId, payment_id: p.id, - error: err, + error: err }) }) @@ -922,6 +927,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PAYMENT_CAPTURED, { id: result.id, + no_notification: order.no_notification }) } @@ -978,6 +984,7 @@ class OrderService extends BaseService { "tax_total", "gift_card_total", "total", + "no_notification" ], relations: [ "discounts", @@ -1050,6 +1057,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.FULFILLMENT_CREATED, { id: orderId, fulfillment_id: fulfillment.id, + no_notification: order.no_notification }) } @@ -1108,7 +1116,7 @@ class OrderService extends BaseService { async createRefund(orderId, refundAmount, reason, note) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["refundable_amount", "total", "refunded_total"], + select: ["refundable_amount", "total", "refunded_total", "no_notification"], relations: ["payments"], }) @@ -1127,6 +1135,7 @@ class OrderService extends BaseService { this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, + no_notification: order.no_notification }) return result }) @@ -1207,7 +1216,7 @@ class OrderService extends BaseService { async registerReturnReceived(orderId, receivedReturn, customRefundAmount) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["total", "refunded_total", "refundable_amount"], + select: ["total", "refunded_total", "refundable_amount", "no_notification"], relations: ["items", "returns", "payments"], }) @@ -1230,6 +1239,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.RETURN_ACTION_REQUIRED, { id: result.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result } @@ -1261,6 +1271,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.ITEMS_RETURNED, { id: order.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result }) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 6c7ca61ec2..07d017ee06 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,7 +204,9 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. - * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap + * @param {boolean?} noNotification - an optional flag to disable sending + * notification when creating swap. If set, it overrules the attribute inherited + * from the order. * @returns {Promise} the newly created swap. */ async create( @@ -236,6 +238,8 @@ class SwapService extends BaseService { }) ) + const evaluatedNoNotification = noNotification ? noNotification : order.noNotification + const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ ...custom, @@ -243,6 +247,7 @@ class SwapService extends BaseService { payment_status: "not_paid", order_id: order.id, additional_items: newItems, + no_notification: evaluatedNoNotification }) const result = await swapRepo.save(created) @@ -258,7 +263,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, - no_notification: noNotification, + no_notification: evaluatedNoNotification, }) return result @@ -559,6 +564,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.PAYMENT_COMPLETED, { id: swap.id, + no_notification: swap.no_notification }) return result @@ -750,6 +756,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.SHIPMENT_CREATED, { id: swapId, fulfillment_id: shipment.id, + no_notification: swap.no_notification }) return result }) @@ -806,6 +813,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.RECEIVED, { id: id, order_id: result.order_id, + no_notification: swap.no_notification }) return result From 0d4b6309d5080a65c6bcf65070bc25cce6de04c0 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:54:42 +0200 Subject: [PATCH 12/55] removed wrong migration --- .../1623164855464-no_notifications.ts | 134 ------------------ 1 file changed, 134 deletions(-) delete mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts deleted file mode 100644 index e24bbbff9a..0000000000 --- a/packages/medusa/src/migrations/1623164855464-no_notifications.ts +++ /dev/null @@ -1,134 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotifications1623164855464 implements MigrationInterface { - name = 'noNotifications1623164855464' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} From 9c3035b5d5fc1607ee6208f109c43e543712c9b4 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 11:54:12 +0200 Subject: [PATCH 13/55] trimmed migration --- docs/api/admin-spec3.yaml | 6541 +++++++++++++++++ docs/api/store-spec3.json | 4959 +++++++++++++ docs/api/store-spec3.yaml | 3822 ++++++++++ .../1622713782458-no_notification.ts | 11 - .../1623231564533-no_notification.ts | 20 + 5 files changed, 15342 insertions(+), 11 deletions(-) create mode 100644 docs/api/admin-spec3.yaml create mode 100644 docs/api/store-spec3.json create mode 100644 docs/api/store-spec3.yaml delete mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts create mode 100644 packages/medusa/src/migrations/1623231564533-no_notification.ts diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml new file mode 100644 index 0000000000..2301d0681f --- /dev/null +++ b/docs/api/admin-spec3.yaml @@ -0,0 +1,6541 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Medusa Admin API + license: + name: MIT +tags: + - name: Auth + description: >- + Auth endpoints allows authorization of admin Users and manages their + sessions. + - name: Collection + x-resourceId: product_collection + - name: Customer + x-resourceId: customer + - name: Discount + x-resourceId: discount + - name: Gift Card + x-resourceId: gift_card + - name: Notification + x-resourceId: notification + - name: Order + x-resourceId: order + - name: Product + x-resourceId: product + - name: Region + x-resourceId: region + - name: Return + x-resourceId: return + - name: Shipping Option + x-resourceId: shipping_option + - name: Shipping Profile + x-resourceId: shipping_profile + - name: Swap + x-resourceId: swap + - name: Product Variant + x-resourceId: product_variant +servers: + - url: 'https://api.medusa-commerce.com/admin' +paths: + /auth: + post: + operationId: PostAuth + summary: Authenticate a User + description: Logs a User in and authorizes them to manage Store settings. + parameters: [] + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + user: + $ref: '#/components/schemas/user' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - password + properties: + email: + type: string + description: The User's email. + password: + type: string + description: The User's password. + get: + operationId: GetAuth + summary: Get Session + description: Gets the currently logged in User. + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + user: + $ref: '#/components/schemas/user' + /collections: + post: + operationId: PostCollections + summary: Create a Product Collection + description: Creates a Product Collection. + requestBody: + content: + application/json: + schema: + required: + - title + properties: + title: + type: string + description: The title to identify the Collection by. + handle: + type: string + description: >- + An optional handle to be used in slugs, if none is provided + we will kebab-case the title. + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collection: + $ref: '#/components/schemas/product_collection' + get: + operationId: GetCollections + summary: List Product Collections + description: Retrieve a list of Product Collection. + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collection: + $ref: '#/components/schemas/product_collection' + '/collections/{id}': + delete: + operationId: DeleteCollectionsCollection + summary: Delete a Product Collection + description: Deletes a Product Collection. + parameters: + - in: path + name: id + required: true + description: The id of the Collection. + schema: + type: string + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Collection + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetCollectionsCollection + summary: Retrieve a Product Collection + description: Retrieves a Product Collection. + parameters: + - in: path + name: id + required: true + description: The id of the Product Collection + schema: + type: string + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collection: + $ref: '#/components/schemas/product_collection' + post: + operationId: PostCollectionsCollection + summary: Update a Product Collection + description: Updates a Product Collection. + parameters: + - in: path + name: id + required: true + description: The id of the Collection. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + type: string + description: The title to identify the Collection by. + handle: + type: string + description: >- + An optional handle to be used in slugs, if none is provided + we will kebab-case the title. + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Collection + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + collection: + $ref: '#/components/schemas/product_collection' + '/discounts/{id}/regions/{region_id}': + post: + operationId: PostDiscountsDiscountRegionsRegion + summary: Adds Region availability + description: Adds a Region to the list of Regions that a Discount can be used in. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + - in: path + name: region_id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + delete: + operationId: DeleteDiscountsDiscountRegionsRegion + summary: Remove Region availability + description: >- + Removes a Region from the list of Regions that a Discount can be used + in. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + - in: path + name: region_id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/products/{product_id}': + post: + operationId: DeleteDiscountsDiscountProductsProduct + summary: Remove Product availability + description: >- + Removes a Product from the list of Products that a Discount can be used + for. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + - in: path + name: product_id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + /discounts: + post: + operationId: PostDiscounts + summary: Creates a Discount + description: >- + Creates a Discount with a given set of rules that define how the + Discount behaves. + requestBody: + content: + application/json: + schema: + properties: + code: + type: string + description: A unique code that will be used to redeem the Discount + is_dynamic: + type: string + description: >- + Whether the Discount should have multiple instances of + itself, each with a different code. This can be useful for + automatically generated codes that all have to follow a + common set of rules. + rule: + description: The Discount Rule that defines how Discounts are calculated + oneOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + type: boolean + description: >- + Whether the Discount code is disabled on creation. You will + have to enable it later to make it available to Customers. + starts_at: + type: string + format: date-time + description: The time at which the Discount should be available. + ends_at: + type: string + format: date-time + description: >- + The time at which the Discount should no longer be + available. + regions: + description: >- + A list of Region ids representing the Regions in which the + Discount can be used. + type: array + items: + type: string + usage_limit: + type: number + description: Maximum times the discount can be used + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + get: + operationId: GetDiscounts + summary: List Discounts + description: Retrieves a list of Discounts + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/dynamic-codes': + post: + operationId: PostDiscountsDiscountDynamicCodes + summary: Create a dynamic Discount code + description: >- + Creates a unique code that can map to a parent Discount. This is useful + if you want to automatically generate codes with the same behaviour. + parameters: + - in: path + name: id + required: true + description: The id of the Discount to create the dynamic code from." + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + requestBody: + content: + application/json: + schema: + type: object + required: + - code + properties: + code: + type: string + description: The unique code that will be used to redeem the Discount. + metadata: + type: object + description: >- + An optional set of key-value paris to hold additional + information. + '/discounts/{id}': + delete: + operationId: DeleteDiscountsDiscount + summary: Delete a Discount + description: Deletes a Discount. + parameters: + - in: path + name: id + required: true + description: The id of the Discount + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Discount + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetDiscountsDiscount + summary: Retrieve a Discount + description: Retrieves a Discount + parameters: + - in: path + name: id + required: true + description: The id of the Discount + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + post: + operationId: PostDiscountsDiscount + summary: Update a Discount + description: >- + Updates a Discount with a given set of rules that define how the + Discount behaves. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + code: + type: string + description: A unique code that will be used to redeem the Discount + is_dynamic: + type: string + description: >- + Whether the Discount should have multiple instances of + itself, each with a different code. This can be useful for + automatically generated codes that all have to follow a + common set of rules. + rule: + description: The Discount Rule that defines how Discounts are calculated + oneOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + type: boolean + description: >- + Whether the Discount code is disabled on creation. You will + have to enable it later to make it available to Customers. + starts_at: + type: string + format: date-time + description: The time at which the Discount should be available. + ends_at: + type: string + format: date-time + description: >- + The time at which the Discount should no longer be + available. + regions: + description: >- + A list of Region ids representing the Regions in which the + Discount can be used. + type: array + items: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/dynamic-codes/{code}': + delete: + operationId: DeleteDiscountsDiscountDynamicCodesCode + summary: Delete a dynamic code + description: Deletes a dynamic code from a Discount. + parameters: + - in: path + name: id + required: true + description: The id of the Discount + schema: + type: string + - in: path + name: code + required: true + description: The id of the Discount + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/code/{id}': + get: + operationId: GetDiscountsDiscountCode + summary: Retrieve a Discount by code + description: Retrieves a Discount by its discount code + parameters: + - in: path + name: code + required: true + description: The code of the Discount + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + /gift-cards: + post: + operationId: PostGiftCards + summary: Create a Gift Card + description: >- + Creates a Gift Card that can redeemed by its unique code. The Gift Card + is only valid within 1 region. + requestBody: + content: + application/json: + schema: + properties: + value: + type: integer + description: >- + The value (excluding VAT) that the Gift Card should + represent. + is_disabled: + type: boolean + description: >- + Whether the Gift Card is disabled on creation. You will have + to enable it later to make it available to Customers. + ends_at: + type: string + format: date-time + description: >- + The time at which the Gift Card should no longer be + available. + region_id: + description: The id of the Region in which the Gift Card can be used. + type: array + items: + type: string + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + get: + operationId: GetGiftCards + summary: List Gift Cards + description: Retrieves a list of Gift Cards. + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + '/gift-cards/{id}': + delete: + operationId: DeleteGiftCardsGiftCard + summary: Delete a Gift Card + description: Deletes a Gift Card + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card to delete. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Gift Card + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetGiftCardsGiftCard + summary: Retrieve a Gift Card + description: Retrieves a Gift Card. + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + post: + operationId: PostGiftCardsGiftCard + summary: Create a Gift Card + description: >- + Creates a Gift Card that can redeemed by its unique code. The Gift Card + is only valid within 1 region. + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + balance: + type: integer + description: >- + The value (excluding VAT) that the Gift Card should + represent. + is_disabled: + type: boolean + description: >- + Whether the Gift Card is disabled on creation. You will have + to enable it later to make it available to Customers. + ends_at: + type: string + format: date-time + description: >- + The time at which the Gift Card should no longer be + available. + region_id: + description: The id of the Region in which the Gift Card can be used. + type: array + items: + type: string + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + get: + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieve a Customer + description: Retrieves a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + description: The Customer's phone number. + type: object + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + /draft-orders: + post: + operationId: PostDraftOrders + summary: Create a Draft Order + description: Creates a Draft Order + requestBody: + content: + application/json: + schema: + properties: + status: + description: The status of the draft order + type: string + email: + description: The email of the customer of the draft order + type: string + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + shipping_address: + description: The Address to be used for shipping. + anyOf: + - $ref: '#/components/schemas/address' + items: + description: The Line Items that have been received. + type: array + items: + properties: + variant_id: + description: >- + The id of the Product Variant to generate the Line + Item from. + type: string + unit_price: + description: The potential custom price of the item. + type: integer + title: + description: The potential custom title of the item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + metadata: + description: >- + The optional key-value map with additional details + about the Line Item. + type: object + region_id: + description: The id of the region for the draft order + type: string + discounts: + description: The discounts to add on the draft order + type: array + items: + properties: + code: + description: The code of the discount to apply + type: string + customer_id: + description: The id of the customer to add on the draft order + type: string + shipping_methods: + description: The shipping methods for the draft order + type: array + items: + properties: + option_id: + description: The id of the shipping option in use + type: string + data: + description: >- + The optional additional data needed for the shipping + method + type: object + price: + description: The potential custom price of the shipping + type: integer + metadata: + description: >- + The optional key-value map with additional details about the + Draft Order. + type: object + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + get: + operationId: GetDraftOrders + summary: List Draft Orders + description: Retrieves an list of Draft Orders + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + '/draft-orders/{id}/line-items': + post: + operationId: PostDraftOrdersDraftOrderLineItems + summary: Create a Line Item for Draft Order + description: Creates a Line Item for the Draft Order + requestBody: + content: + application/json: + schema: + properties: + variant_id: + description: >- + The id of the Product Variant to generate the Line Item + from. + type: string + unit_price: + description: The potential custom price of the item. + type: integer + title: + description: The potential custom title of the item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + metadata: + description: >- + The optional key-value map with additional details about the + Line Item. + type: object + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + '/draft-orders/{id}': + delete: + operationId: DeleteDraftOrdersDraftOrder + summary: Delete a Draft Order + description: Deletes a Draft Order + parameters: + - in: path + name: id + required: true + description: The id of the Draft Order. + schema: + type: string + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Draft Order. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetDraftOrdersDraftOrder + summary: Retrieve a Draft Order + description: Retrieves a Draft Order. + parameters: + - in: path + name: id + required: true + description: The id of the Draft Order. + schema: + type: string + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + '/draft-orders/{id}/line-items/{line_id}': + delete: + operationId: DeleteDraftOrdersDraftOrderLineItemsItem + summary: Delete a Line Item + description: Removes a Line Item from a Draft Order. + parameters: + - in: path + name: id + required: true + description: The id of the Draft Order. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Draft Order. + schema: + type: string + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + post: + operationId: PostDraftOrdersDraftOrderLineItemsItem + summary: Update a Line Item for a Draft Order + description: Updates a Line Item for a Draft Order + requestBody: + content: + application/json: + schema: + properties: + unit_price: + description: The potential custom price of the item. + type: integer + title: + description: The potential custom title of the item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + metadata: + description: >- + The optional key-value map with additional details about the + Line Item. + type: object + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + '/draft-orders/{id}/register-payment': + post: + summary: Registers a payment for a Draft Order + operationId: PostDraftOrdersDraftOrderRegisterPayment + description: Registers a payment for a Draft Order. + parameters: + - in: path + name: id + required: true + description: The Draft Order id. + schema: + type: string + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + '/admin/draft-orders/{id}': + post: + operationId: PostDraftOrdersDraftOrder + summary: Update a Draft Order" + description: Updates a Draft Order. + parameters: + - in: path + name: id + required: true + description: The id of the Draft Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Draft Order in. + email: + type: string + description: An email to be used on the Draft Order. + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + shipping_address: + description: The Address to be used for shipping. + anyOf: + - $ref: '#/components/schemas/address' + discounts: + description: An array of Discount codes to add to the Draft Order. + type: array + items: + properties: + code: + description: The code that a Discount is identifed by. + type: string + customer_id: + description: The id of the Customer to associate the Draft Order with. + type: string + tags: + - Draft Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + draft_order: + $ref: '#/components/schemas/draft-order' + /notifications: + get: + operationId: GetNotifications + summary: List Notifications + description: Retrieves a list of Notifications. + tags: + - Notification + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + notifications: + type: array + items: + $ref: '#/components/schemas/notification' + '/notifications/{id}/resend': + post: + operationId: PostNotificationsNotificationResend + summary: Resend Notification + description: >- + Resends a previously sent notifications, with the same data but + optionally to a different address + parameters: + - in: path + name: id + required: true + description: The id of the Notification + schema: + type: string + tags: + - Notification + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + notification: + $ref: '#/components/schemas/notification' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + shipping_address: + type: object + description: >- + An optional shipping address to send the claim to. Defaults + to the parent order's shipping address + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Claim. + type: boolean + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/regions/{id}/countries': + post: + operationId: PostRegionsRegionCountries + summary: Add Country + description: Adds a Country to the list of Countries in a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + country_code: + description: The 2 character ISO code for the Country. + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-providers': + post: + operationId: PostRegionsRegionFulfillmentProviders + summary: Add Fulfillment Provider + description: Adds a Fulfillment Provider to a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + provider_id: + description: The id of the Fulfillment Provider to add. + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/payment-providers': + post: + operationId: PostRegionsRegionPaymentProviders + summary: Add Payment Provider + description: Adds a Payment Provider to a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + provider_id: + description: The id of the Payment Provider to add. + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + /regions: + post: + operationId: PostRegions + summary: Create a Region + description: Creates a Region + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Region + type: string + currency_code: + description: The 3 character ISO currency code to use for the Region. + type: string + tax_code: + description: An optional tax code the Region. + type: string + tax_rate: + description: The tax rate to use on Orders in the Region. + type: number + payment_providers: + description: >- + A list of Payment Providers that should be enabled for the + Region + type: array + items: + type: string + fulfillment_providers: + description: >- + A list of Fulfillment Providers that should be enabled for + the Region + type: array + items: + type: string + countries: + description: A list of countries that should be included in the Region. + type: array + items: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + get: + operationId: GetRegions + summary: List Regions + description: Retrieves a list of Regions. + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + regions: + type: array + items: + $ref: '#/components/schemas/region' + '/regions/{id}/metadata/{key}': + delete: + operationId: DeleteRegionsRegionMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}': + delete: + operationId: DeleteRegionsRegion + summary: Delete a Region + description: Deletes a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Region. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetRegionsRegion + summary: Retrieve a Region + description: Retrieves a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + post: + operationId: PostRegionsRegion + summary: Update a Region + description: Updates a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Region + type: string + currency_code: + description: The 3 character ISO currency code to use for the Region. + type: string + tax_code: + description: An optional tax code the Region. + type: string + tax_rate: + description: The tax rate to use on Orders in the Region. + type: number + payment_providers: + description: >- + A list of Payment Providers that should be enabled for the + Region + type: array + items: + type: string + fulfillment_providers: + description: >- + A list of Fulfillment Providers that should be enabled for + the Region + type: array + items: + type: string + countries: + description: A list of countries that should be included in the Region. + type: array + items: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-options': + get: + operationId: GetRegionsRegionFulfillmentOptions + summary: List Fulfillment Options available in the Region + description: Gathers all the fulfillment options available to in the Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + fulfillment_options: + type: array + items: + type: object + '/regions/{id}/countries/{country_code}': + delete: + operationId: PostRegionsRegionCountriesCountry + summary: Remove Country + description: Removes a Country from the list of Countries in a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: country_code + required: true + description: The 2 character ISO code for the Country. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-providers/{provider_id}': + delete: + operationId: PostRegionsRegionFulfillmentProvidersProvider + summary: Remove Fulfillment Provider + description: Removes a Fulfillment Provider. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: provider_id + required: true + description: The id of the Fulfillment Provider. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/payment-providers/{provider_id}': + delete: + operationId: PostRegionsRegionPaymentProvidersProvider + summary: Remove Payment Provider + description: Removes a Payment Provider. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: provider_id + required: true + description: The id of the Payment Provider. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/products/{id}/options': + post: + operationId: PostProductsProductOptions + summary: Add an Option + description: Adds a Product Option to a Product + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + description: >- + The title the Product Option will be identified by i.e. + "Size" + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + /products: + post: + operationId: PostProducts + summary: Create a Product + description: Creates a Product + requestBody: + content: + application/json: + schema: + properties: + title: + description: The title of the Product + type: string + subtitle: + description: The subtitle of the Product + type: string + description: + description: A description of the Product. + type: string + is_giftcard: + description: >- + A flag to indicate if the Product represents a Gift Card. + Purchasing Products with this flag set to `true` will result + in a Gift Card being created. + type: boolean + images: + description: Images of the Product. + type: array + items: + type: string + thumbnail: + description: The thumbnail to use for the Product. + type: string + handle: + description: A unique handle to identify the Product by. + type: string + type: + description: The Product Type to associate the Product with. + type: object + properties: + value: + description: The value of the Product Type. + type: string + collection_id: + description: The id of the Collection the Product should belong to. + type: string + tags: + description: Tags to associate the Product with. + type: array + items: + properties: + id: + description: The id of an existing Tag. + type: string + value: + description: 'The value of the Tag, these will be upserted.' + type: string + options: + description: >- + The Options that the Product should have. These define on + which properties the Product's Product Variants will differ. + type: array + items: + properties: + title: + description: The title to identify the Product Option by. + type: string + variants: + description: A list of Product Variants to create with the Product. + type: array + items: + properties: + title: + description: The title to identify the Product Variant by. + type: string + sku: + description: The unique SKU for the Product Variant. + type: string + ean: + description: The EAN number of the item. + type: string + upc: + description: The UPC number of the item. + type: string + barcode: + description: A generic GTIN field for the Product Variant. + type: string + hs_code: + description: The Harmonized System code for the Product Variant. + type: string + inventory_quantity: + description: The amount of stock kept for the Product Variant. + type: integer + allow_backorder: + description: >- + Whether the Product Variant can be purchased when out + of stock. + type: boolean + manage_inventory: + description: >- + Whether Medusa should keep track of the inventory for + this Product Variant. + type: boolean + weight: + description: The wieght of the Product Variant. + type: string + length: + description: The length of the Product Variant. + type: string + height: + description: The height of the Product Variant. + type: string + width: + description: The width of the Product Variant. + type: string + origin_country: + description: The country of origin of the Product Variant. + type: string + mid_code: + description: >- + The Manufacturer Identification code for the Product + Variant. + type: string + material: + description: The material composition of the Product Variant. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + prices: + type: array + items: + properties: + region_id: + description: >- + The id of the Region for which the price is + used. + type: string + currency_code: + description: >- + The 3 character ISO currency code for which the + price will be used. + type: string + amount: + description: The amount to charge for the Product Variant. + type: integer + sale_amount: + description: >- + The sale amount to charge for the Product + Variant. + type: integer + options: + type: array + items: + properties: + value: + description: >- + The value to give for the Product Option at the + same index in the Product's `options` field. + type: string + weight: + description: The wieght of the Product. + type: string + length: + description: The length of the Product. + type: string + height: + description: The height of the Product. + type: string + width: + description: The width of the Product. + type: string + origin_country: + description: The country of origin of the Product. + type: string + mid_code: + description: The Manufacturer Identification code for the Product. + type: string + material: + description: The material composition of the Product. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + get: + operationId: GetProducts + summary: List Product + description: Retrieves a list of Product + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + count: + description: The number of Products. + type: integer + offset: + description: The offset of the Product query. + type: integer + limit: + description: The limit of the Product query. + type: integer + products: + type: array + items: + $ref: '#/components/schemas/product' + '/products/{id}/variants': + post: + operationId: PostProductsProductVariants + summary: Create a Product Variant + description: >- + Creates a Product Variant. Each Product Variant must have a unique + combination of Product Option Values. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + description: The title to identify the Product Variant by. + type: string + sku: + description: The unique SKU for the Product Variant. + type: string + ean: + description: The EAN number of the item. + type: string + upc: + description: The UPC number of the item. + type: string + barcode: + description: A generic GTIN field for the Product Variant. + type: string + hs_code: + description: The Harmonized System code for the Product Variant. + type: string + inventory_quantity: + description: The amount of stock kept for the Product Variant. + type: integer + allow_backorder: + description: >- + Whether the Product Variant can be purchased when out of + stock. + type: boolean + manage_inventory: + description: >- + Whether Medusa should keep track of the inventory for this + Product Variant. + type: boolean + weight: + description: The wieght of the Product Variant. + type: string + length: + description: The length of the Product Variant. + type: string + height: + description: The height of the Product Variant. + type: string + width: + description: The width of the Product Variant. + type: string + origin_country: + description: The country of origin of the Product Variant. + type: string + mid_code: + description: >- + The Manufacturer Identification code for the Product + Variant. + type: string + material: + description: The material composition of the Product Variant. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + prices: + type: array + items: + properties: + region_id: + description: The id of the Region for which the price is used. + type: string + currency_code: + description: >- + The 3 character ISO currency code for which the price + will be used. + type: string + amount: + description: The amount to charge for the Product Variant. + type: integer + sale_amount: + description: The sale amount to charge for the Product Variant. + type: integer + options: + type: array + items: + properties: + option_id: + description: The id of the Product Option to set the value for. + type: string + value: + description: The value to give for the Product Option. + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + get: + operationId: GetProductsProductVariants + summary: List a Product's Product Variants + description: Retrieves a list of the Product Variants associated with a Product. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + variants: + type: array + items: + $ref: '#/components/schemas/product_variant' + '/products/{id}/options/{option_id}': + delete: + operationId: DeleteProductsProductOptionsOption + summary: Delete a Product Option + description: >- + Deletes a Product Option. Before a Product Option can be deleted all + Option Values for the Product Option must be the same. You may, for + example, have to delete some of your variants prior to deleting the + Product Option + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + - in: path + name: option_id + required: true + description: The id of the Product Option. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Product Option + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + product: + $ref: '#/components/schemas/product' + post: + operationId: PostProductsProductOptionsOption + summary: Update a Product Option. + description: Updates a Product Option + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + - in: path + name: option_id + required: true + description: The id of the Product Option. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + description: The title of the Product Option + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + '/products/{id}': + delete: + operationId: DeleteProductsProduct + summary: Delete a Product + description: Deletes a Product and it's associated Product Variants. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Product. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetProductsProduct + summary: Retrieve a Product + description: Retrieves a Product. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + post: + operationId: PostProductsProduct + summary: Update a Product + description: Updates a Product + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + description: The title of the Product + type: string + subtitle: + description: The subtitle of the Product + type: string + description: + description: A description of the Product. + type: string + is_giftcard: + description: >- + A flag to indicate if the Product represents a Gift Card. + Purchasing Products with this flag set to `true` will result + in a Gift Card being created. + type: boolean + images: + description: Images of the Product. + type: array + items: + type: string + thumbnail: + description: The thumbnail to use for the Product. + type: string + handle: + description: A unique handle to identify the Product by. + type: string + type: + description: The Product Type to associate the Product with. + type: object + properties: + value: + description: The value of the Product Type. + type: string + collection_id: + description: The id of the Collection the Product should belong to. + type: string + tags: + description: Tags to associate the Product with. + type: array + items: + properties: + id: + description: The id of an existing Tag. + type: string + value: + description: 'The value of the Tag, these will be upserted.' + type: string + options: + description: >- + The Options that the Product should have. These define on + which properties the Product's Product Variants will differ. + type: array + items: + properties: + title: + description: The title to identify the Product Option by. + type: string + variants: + description: A list of Product Variants to create with the Product. + type: array + items: + properties: + title: + description: The title to identify the Product Variant by. + type: string + sku: + description: The unique SKU for the Product Variant. + type: string + ean: + description: The EAN number of the item. + type: string + upc: + description: The UPC number of the item. + type: string + barcode: + description: A generic GTIN field for the Product Variant. + type: string + hs_code: + description: The Harmonized System code for the Product Variant. + type: string + inventory_quantity: + description: The amount of stock kept for the Product Variant. + type: integer + allow_backorder: + description: >- + Whether the Product Variant can be purchased when out + of stock. + type: boolean + manage_inventory: + description: >- + Whether Medusa should keep track of the inventory for + this Product Variant. + type: boolean + weight: + description: The wieght of the Product Variant. + type: string + length: + description: The length of the Product Variant. + type: string + height: + description: The height of the Product Variant. + type: string + width: + description: The width of the Product Variant. + type: string + origin_country: + description: The country of origin of the Product Variant. + type: string + mid_code: + description: >- + The Manufacturer Identification code for the Product + Variant. + type: string + material: + description: The material composition of the Product Variant. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + prices: + type: array + items: + properties: + region_id: + description: >- + The id of the Region for which the price is + used. + type: string + currency_code: + description: >- + The 3 character ISO currency code for which the + price will be used. + type: string + amount: + description: The amount to charge for the Product Variant. + type: integer + sale_amount: + description: >- + The sale amount to charge for the Product + Variant. + type: integer + options: + type: array + items: + properties: + value: + description: >- + The value to give for the Product Option at the + same index in the Product's `options` field. + type: string + weight: + description: The wieght of the Product. + type: string + length: + description: The length of the Product. + type: string + height: + description: The height of the Product. + type: string + width: + description: The width of the Product. + type: string + origin_country: + description: The country of origin of the Product. + type: string + mid_code: + description: The Manufacturer Identification code for the Product. + type: string + material: + description: The material composition of the Product. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + '/products/{id}/variants/{variant_id}': + delete: + operationId: DeleteProductsProductVariantsVariant + summary: Delete a Product Variant + description: Deletes a Product Variant. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + - in: path + name: variant_id + required: true + description: The id of the Product Variant. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Product Variant. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + post: + operationId: PostProductsProductVariantsVariant + summary: Update a Product Variant + description: Update a Product Variant. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + - in: path + name: variant_id + required: true + description: The id of the Product Variant. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + title: + description: The title to identify the Product Variant by. + type: string + sku: + description: The unique SKU for the Product Variant. + type: string + ean: + description: The EAN number of the item. + type: string + upc: + description: The UPC number of the item. + type: string + barcode: + description: A generic GTIN field for the Product Variant. + type: string + hs_code: + description: The Harmonized System code for the Product Variant. + type: string + inventory_quantity: + description: The amount of stock kept for the Product Variant. + type: integer + allow_backorder: + description: >- + Whether the Product Variant can be purchased when out of + stock. + type: boolean + manage_inventory: + description: >- + Whether Medusa should keep track of the inventory for this + Product Variant. + type: boolean + weight: + description: The wieght of the Product Variant. + type: string + length: + description: The length of the Product Variant. + type: string + height: + description: The height of the Product Variant. + type: string + width: + description: The width of the Product Variant. + type: string + origin_country: + description: The country of origin of the Product Variant. + type: string + mid_code: + description: >- + The Manufacturer Identification code for the Product + Variant. + type: string + material: + description: The material composition of the Product Variant. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + prices: + type: array + items: + properties: + region_id: + description: The id of the Region for which the price is used. + type: string + currency_code: + description: >- + The 3 character ISO currency code for which the price + will be used. + type: string + amount: + description: The amount to charge for the Product Variant. + type: integer + sale_amount: + description: The sale amount to charge for the Product Variant. + type: integer + options: + type: array + items: + properties: + option_id: + description: The id of the Product Option to set the value for. + type: string + value: + description: The value to give for the Product Option. + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + /products/types: + get: + operationId: GetProductsTypes + summary: List Product Types + description: Retrieves a list of Product Types. + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + types: + type: array + items: + $ref: '#/components/schemas/product_type' + /return-reasons: + post: + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason + requestBody: + content: + application/json: + schema: + properties: + label: + description: The label to display to the Customer. + type: string + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + post: + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + label: + description: The label to display to the Customer. + type: string + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. + type: string + metadata: + description: >- + An optional set of key-value pairs with additional + information. + type: object + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /returns: + get: + operationId: GetReturns + summary: List Returns + description: Retrieves a list of Returns + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + returns: + type: array + items: + $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + /shipping-options: + post: + operationId: PostShippingOptions + summary: Create Shipping Option + description: Creates a Shipping Option + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Shipping Option + type: string + region_id: + description: >- + The id of the Region in which the Shipping Option will be + available. + type: string + provider_id: + description: >- + The id of the Fulfillment Provider that handles the Shipping + Option. + type: string + profile_id: + description: >- + The id of the Shipping Profile to add the Shipping Option + to. + type: number + data: + description: >- + The data needed for the Fulfillment Provider to handle + shipping with this Shipping Option. + type: object + price_type: + description: The type of the Shipping Option price. + type: string + enum: + - flat_rate + - calculated + amount: + description: The amount to charge for the Shipping Option. + type: integer + requirements: + description: >- + The requirements that must be satisfied for the Shipping + Option to be available. + type: array + items: + properties: + type: + description: The type of the requirement + type: string + enum: + - max_subtotal + - min_subtotal + amount: + description: The amount to compare with. + type: integer + is_return: + description: Whether the Shipping Option defines a return shipment. + type: boolean + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_option: + $ref: '#/components/schemas/shipping_option' + get: + operationId: GetShippingOptions + summary: List Shipping Options + description: Retrieves a list of Shipping Options. + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_options: + type: array + items: + $ref: '#/components/schemas/shipping_option' + '/shipping-options/{id}': + delete: + operationId: DeleteShippingOptionsOption + summary: Delete a Shipping Option + description: Deletes a Shipping Option. + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Option. + schema: + type: string + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Shipping Option. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetShippingOptionsOption + summary: Retrieve a Shipping Option + description: Retrieves a Shipping Option. + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Option. + schema: + type: string + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_option: + $ref: '#/components/schemas/shipping_option' + post: + operationId: PostShippingOptionsOption + summary: Update Shipping Option + description: Updates a Shipping Option + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Option. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Shipping Option + type: string + amount: + description: The amount to charge for the Shipping Option. + type: integer + requirements: + description: >- + The requirements that must be satisfied for the Shipping + Option to be available. + type: array + items: + properties: + type: + description: The type of the requirement + type: string + enum: + - max_subtotal + - min_subtotal + amount: + description: The amount to compare with. + type: integer + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_option: + $ref: '#/components/schemas/shipping_option' + /shipping-profiles: + post: + operationId: PostShippingProfiles + summary: Create a Shipping Profile + description: Creates a Shipping Profile + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Shipping Profile + type: string + tags: + - Shipping Profile + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_profile: + $ref: '#/components/schemas/shipping_profile' + get: + operationId: GetShippingProfiles + summary: List Shipping Profiles + description: Retrieves a list of Shipping Profile. + tags: + - Shipping Profile + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_profiles: + type: array + items: + $ref: '#/components/schemas/shipping_profile' + '/shipping-profiles/{id}': + delete: + operationId: DeleteShippingProfilesProfile + summary: Delete a Shipping Profile + description: Deletes a Shipping Profile. + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Profile. + schema: + type: string + tags: + - Shipping Profile + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Shipping Profile. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetShippingProfilesProfile + summary: Retrieve a Shipping Profile + description: Retrieves a Shipping Profile. + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Profile. + schema: + type: string + tags: + - Shipping Profile + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_profile: + $ref: '#/components/schemas/shipping_profile' + post: + operationId: PostShippingProfilesProfile + summary: Update a Shipping Profiles + description: Updates a Shipping Profile + parameters: + - in: path + name: id + required: true + description: The id of the Shipping Profile. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Shipping Profile + type: string + tags: + - Shipping Profile + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_profiles: + $ref: '#/components/schemas/shipping_profile' + '/store/currencies/{code}': + post: + operationId: PostStoreCurrenciesCode + summary: Add a Currency Code + description: Adds a Currency Code to the available currencies. + parameters: + - in: path + name: code + required: true + description: The 3 character ISO currency code. + schema: + type: string + tags: + - Store + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + store: + $ref: '#/components/schemas/store' + delete: + operationId: DeleteStoreCurrenciesCode + summary: Remvoe a Currency Code + description: Removes a Currency Code from the available currencies. + parameters: + - in: path + name: code + required: true + description: The 3 character ISO currency code. + schema: + type: string + tags: + - Store + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + store: + $ref: '#/components/schemas/store' + /store: + get: + operationId: GetStore + summary: Retrieve Store details. + description: Retrieves the Store details + tags: + - Store + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + store: + $ref: '#/components/schemas/store' + post: + operationId: PostStore + summary: Update Store details. + description: Updates the Store details + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Store + type: string + swap_link_template: + description: >- + A template for Swap links - use `{{cart_id}}` to insert the + Swap Cart id + type: string + default_currency_code: + description: The default currency code for the Store. + type: string + tags: + - Store + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + store: + $ref: '#/components/schemas/store' + /store/payment-providers: + get: + operationId: GetStorePaymentProviders + summary: Retrieve configured Payment Providers + description: Retrieves the configured Payment Providers + tags: + - Store + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + payment_providers: + type: array + items: + $ref: '#/components/schemas/store' + /swaps: + get: + operationId: GetSwaps + summary: List Swaps + description: Retrieves a list of Swaps. + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swaps: + type: array + items: + $ref: '#/components/schemas/swap' + /variants: + get: + operationId: GetVariants + summary: List Product Variants. + description: Retrieves a list of Product Variants + tags: + - Product Variant + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + variants: + type: array + items: + $ref: '#/components/schemas/product_variant' +components: + schemas: + address: + title: Address + description: An address. + x-resourceId: address + properties: + id: + type: string + customer_id: + type: string + company: + type: string + first_name: + type: string + last_name: + type: string + address_1: + type: string + address_2: + type: string + city: + type: string + country_code: + type: string + country: + $ref: '#/components/schemas/country' + cart: + title: Cart + description: Represents a user cart + x-resourceId: cart + properties: + id: + type: string + email: + type: string + billing_address_id: + type: string + billing_address: + $ref: '#/components/schemas/address' + shipping_address_id: + type: string + shipping_address: + $ref: '#/components/schemas/address' + items: + type: array + items: + $ref: '#/components/schemas/line_item' + region_id: + type: string + region: + $ref: '#/components/schemas/region' + discounts: + type: array + items: + $ref: '#/components/schemas/region' + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + customer_id: + type: string + customer: + $ref: '#/components/schemas/customer' + payment_session: + $ref: '#/components/schemas/payment_session' + payment_sessions: + type: array + items: + $ref: '#/components/schemas/payment_session' + payment: + $ref: '#/components/schemas/payment' + shipping_methods: + type: array + items: + $ref: '#/components/schemas/shipping_method' + type: + type: string + enum: + - default + - swap + - payment_link + completed_at: + type: string + format: date-time + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + shipping_total: + type: integer + discount_total: + type: integer + tax_total: + type: integer + subtotal: + type: integer + refundable_amount: + type: integer + gift_card_total: + type: integer + claim_image: + title: Claim Image + description: Represents photo documentation of a claim. + x-resourceId: claim_image + properties: + id: + type: string + claim_item_id: + type: string + url: + type: string + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + claim_item: + title: Claim Item + description: >- + Represents a claimed item along with information about the reasons for + the claim. + x-resourceId: claim_item + properties: + id: + type: string + images: + type: array + items: + $ref: '#/components/schemas/claim_image' + claim_order_id: + type: string + item_id: + type: string + item: + description: The Line Item that the claim refers to + $ref: '#/components/schemas/line_item' + variant_id: + type: string + variant: + description: The Product Variant that is claimed. + $ref: '#/components/schemas/product_variant' + reason: + description: The reason for the claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + note: + description: 'An optional note about the claim, for additional information' + type: string + quantity: + description: >- + The quantity of the item that is being claimed; must be less than or + equal to the amount purchased in the original order. + type: integer + tags: + description: User defined tags for easy filtering and grouping. + type: array + items: + $ref: '#/components/schemas/claim_tag' + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + claim_order: + title: Claim Order + description: >- + Claim Orders represent a group of faulty or missing items. Each claim + order consists of a subset of items associated with an original order, + and can contain additional information about fulfillments and returns. + x-resourceId: claim_order + properties: + id: + type: string + type: + type: string + enum: + - refund + - replace + payment_status: + type: string + enum: + - na + - not_refunded + - refunded + fulfillment_status: + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + claim_items: + description: The items that have been claimed + type: array + items: + $ref: '#/components/schemas/claim_item' + additional_items: + description: >- + Refers to the new items to be shipped when the claim order has the + type `replace` + type: array + items: + $ref: '#/components/schemas/line_item' + order_id: + description: The id of the order that the claim comes from. + type: string + return_order: + description: Holds information about the return if the claim is to be returned + $ref: '#/components/schemas/return' + shipping_address_id: + description: The id of the address that the new items should be shipped to + type: string + shipping_address: + description: The address that the new items should be shipped to + $ref: '#/components/schemas/address' + shipping_methods: + description: The shipping methods that the claim order will be shipped with. + type: array + items: + $ref: '#/components/schemas/shipping_method' + fulfillments: + description: The fulfillments of the new items to be shipped + type: array + items: + $ref: '#/components/schemas/fulfillment' + refund_amount: + description: The amount that will be refunded in conjunction with the claim + type: integer + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + no_notification: + type: boolean + metadata: + type: object + claim_tag: + title: Claim Tag + description: >- + Claim Tags are user defined tags that can be assigned to claim items for + easy filtering and grouping. + x-resourceId: claim_tag + properties: + id: + description: The id of the claim tag. Will be prefixed by `ctag_`. + type: string + value: + description: The value that the claim tag holds + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + country: + title: Country + description: Country details + x-resourceId: country + properties: + id: + description: The database id of the country + type: integer + iso_2: + description: The 2 character ISO code for the country. + type: string + iso_3: + description: The 3 character ISO code for the country. + type: string + num_code: + description: The numerical ISO code for the country. + type: string + name: + description: The normalized country name; in upper case. + type: string + display_name: + description: The country name appropriate for display. + type: string + currency: + title: Currency + description: Currency + x-resourceId: currency + properties: + code: + description: The 3 character ISO code for the currency. + type: string + symbol: + description: The symbol used to indicate the currency. + type: string + symbol_native: + description: The native symbol used to indicate the currency. + type: string + name: + description: The written name of the currency + type: string + customer: + title: Customer + description: Represents a customer + x-resourceId: customer + properties: + id: + type: string + email: + type: string + billing_address_id: + type: string + billing_address: + description: The Customer's billing address. + anyOf: + - $ref: '#/components/schemas/address' + shipping_addresses: + type: array + items: + $ref: '#/components/schemas/address' + first_name: + type: string + last_name: + type: string + phone: + type: string + has_account: + type: boolean + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + discount_rule: + title: Discount Rule + description: >- + Holds the rules that governs how a Discount is calculated when applied + to a Cart. + x-resourceId: discount_rule + properties: + id: + description: The id of the Discount Rule. Will be prefixed by `dru_`. + type: string + type: + description: >- + The type of the Discount, can be `fixed` for discounts that reduce + the price by a fixed amount, `percentage` for percentage reductions + or `free_shipping` for shipping vouchers. + type: string + enum: + - fixed + - percentage + - free_shipping + description: + description: A short description of the discount + type: string + value: + description: >- + The value that the discount represents; this will depend on the type + of the discount + type: integer + allocation: + description: The scope that the discount should apply to. + type: string + enum: + - total + - item + valid_for: + description: A set of Products that the discount can be used for. + type: array + items: + $ref: '#/components/schemas/product' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + discount: + title: Discount + description: >- + Represents a discount that can be applied to a cart for promotional + purposes. + x-resourceId: discount + properties: + id: + description: The id of the Discount. Will be prefixed by `disc_`. + type: string + code: + description: >- + A unique code for the discount - this will be used by the customer + to apply the discount + type: string + is_dynamic: + description: >- + A flag to indicate if multiple instances of the discount can be + generated. I.e. for newsletter discounts + type: boolean + rule: + description: The Discount Rule that governs the behaviour of the Discount + anyOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + description: >- + Whether the Discount has been disabled. Disabled discounts cannot be + applied to carts + type: boolean + parent_discount_id: + description: >- + The Discount that the discount was created from. This will always be + a dynamic discount + type: string + starts_at: + description: The time at which the discount can be used. + type: string + format: date-time + ends_at: + description: The time at which the discount can no longer be used. + type: string + format: date-time + regions: + description: The Regions in which the Discount can be used + type: array + items: + $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + draft-order: + title: DraftOrder + description: Represents a draft order + x-resourceId: draft-order + properties: + id: + type: string + status: + type: string + enum: + - open + - completed + display_id: + type: string + cart_id: + type: string + cart: + anyOf: + - $ref: '#/components/schemas/cart' + order_id: + type: string + order: + anyOf: + - $ref: '#/components/schemas/order' + canceled_at: + type: string + format: date-time + created_at: + type: string + format: date-time + update_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + completed_at: + type: string + format: date-time + metadata: + type: object + idempotency_key: + type: string + fulfillment_item: + title: Fulfillment Item + description: >- + Correlates a Line Item with a Fulfillment, keeping track of the quantity + of the Line Item. + x-resourceId: fulfillment_item + properties: + fulfillment_id: + description: The id of the Fulfillment that the Fulfillment Item belongs to. + type: string + item_id: + description: The id of the Line Item that the Fulfillment Item references. + type: string + item: + description: The Line Item that the Fulfillment Item references. + anyOf: + - $ref: '#/components/schemas/line_item' + quantity: + description: The quantity of the Line Item that is included in the Fulfillment. + type: integer + fulfillment_provider: + title: Fulfillment Provider + description: >- + Represents a fulfillment provider plugin and holds its installation + status. + x-resourceId: fulfillment_provider + properties: + id: + description: The id of the fulfillment provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + fulfillment: + title: Fulfillment + description: >- + Fulfillments are created once store operators can prepare the purchased + goods. Fulfillments will eventually be shipped and hold information + about how to track shipments. Fulfillments are created through a + provider, which is typically an external shipping aggregator, shipping + partner og 3PL, most plugins will have asynchronous communications with + these providers through webhooks in order to automatically update and + synchronize the state of Fulfillments. + x-resourceId: fulfillment + properties: + id: + description: The id of the Fulfillment. This value will be prefixed by `ful_`. + type: string + claim_order_id: + description: The id of the Claim that the Fulfillment belongs to. + type: string + swap_id: + description: The id of the Swap that the Fulfillment belongs to. + type: string + order_id: + description: The id of the Order that the Fulfillment belongs to. + type: string + provider_id: + description: >- + The id of the Fulfillment Provider responsible for handling the + fulfillment + type: string + items: + description: >- + The Fulfillment Items in the Fulfillment - these hold information + about how many of each Line Item has been fulfilled. + type: array + items: + $ref: '#/components/schemas/fulfillment_item' + tracking_links: + description: >- + The Tracking Links that can be used to track the status of the + Fulfillment, these will usually be provided by the Fulfillment + Provider. + type: array + items: + $ref: '#/components/schemas/tracking_link' + tracking_numbers: + deprecated: true + description: >- + The tracking numbers that can be used to track the status of the + fulfillment. + type: array + items: + type: string + shipped_at: + description: The date with timezone at which the Fulfillment was shipped. + type: string + format: date-time + canceled_at: + description: The date with timezone at which the Fulfillment was canceled. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + gift_card_transaction: + title: Gift Card Transaction + description: >- + Gift Card Transactions are created once a Customer uses a Gift Card to + pay for their Order + x-resourceId: gift_card_transaction + properties: + id: + description: >- + The id of the Gift Card Transaction. This value will be prefixed by + `gct_`. + type: string + gift_card_id: + description: The id of the Gift Card that was used in the transaction. + type: string + gift_card: + description: The Gift Card that was used in the transaction. + anyOf: + - $ref: '#/components/schemas/gift_card' + order_id: + description: The id of the Order that the Gift Card was used to pay for. + type: string + amount: + description: The amount that was used from the Gift Card. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + gift_card: + title: Gift Card + description: >- + Gift Cards are redeemable and represent a value that can be used towards + the payment of an Order. + x-resourceId: gift_card + properties: + id: + description: The id of the Gift Card. This value will be prefixed by `gift_`. + type: string + code: + description: >- + The unique code that identifies the Gift Card. This is used by the + Customer to redeem the value of the Gift Card. + type: string + value: + description: The value that the Gift Card represents. + type: integer + balance: + description: The remaining value on the Gift Card. + type: integer + region_id: + description: The id of the Region in which the Gift Card is available. + type: string + region: + description: The Region in which the Gift Card is available. + anyOf: + - $ref: '#/components/schemas/region' + order_id: + description: The id of the Order that the Gift Card was purchased in. + type: string + is_disabled: + description: >- + Whether the Gift Card has been disabled. Disabled Gift Cards cannot + be applied to carts. + type: boolean + ends_at: + description: The time at which the Gift Card can no longer be used. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + image: + title: Image + description: Images holds a reference to a URL at which the image file can be found. + x-resourceId: image + properties: + id: + description: The id of the Image. This value will be prefixed by `img_`. + type: string + url: + description: The URL at which the image file can be found. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + line_item: + title: Line Item + description: >- + Line Items represent purchasable units that can be added to a Cart for + checkout. When Line Items are purchased they will get copied to the + resulting order and can eventually be referenced in Fulfillments and + Returns. Line Items may also be created when processing Swaps and + Claims. + x-resourceId: line_item + properties: + id: + description: The id of the Line Item. This value will be prefixed by `item_`. + type: string + cart_id: + description: The id of the Cart that the Line Item belongs to. + type: string + order_id: + description: The id of the Order that the Line Item belongs to. + type: string + swap_id: + description: The id of the Swap that the Line Item belongs to. + type: string + claim_order_id: + description: The id of the Claim that the Line Item belongs to. + type: string + title: + description: >- + The title of the Line Item, this should be easily identifiable by + the Customer. + type: string + description: + description: A more detailed description of the contents of the Line Item. + type: string + thumbnail: + description: A URL string to a small image of the contents of the Line Item. + type: string + is_giftcard: + description: Flag to indicate if the Line Item is a Gift Card. + type: boolean + should_merge: + description: >- + Flag to indicate if new Line Items with the same variant should be + merged or added as an additional Line Item. + type: boolean + allow_discounts: + description: >- + Flag to indicate if the Line Item should be included when doing + discount calculations. + type: boolean + unit_price: + description: >- + The price of one unit of the content in the Line Item. This should + be in the currency defined by the Cart/Order/Swap/Claim that the + Line Item belongs to. + type: boolean + variant_id: + description: The id of the Product Variant contained in the Line Item. + type: string + variant: + description: The Product Variant contained in the Line Item. + anyOf: + - $ref: '#/components/schemas/product_variant' + quantity: + description: The quantity of the content in the Line Item. + type: integer + fulfilled_quantity: + description: The quantity of the Line Item that has been fulfilled. + type: integer + returned_quantity: + description: The quantity of the Line Item that has been returned. + type: integer + shipped_quantity: + description: The quantity of the Line Item that has been shipped. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + refundable: + description: >- + The amount that can be refunded from the given Line Item. Takes + taxes and discounts into consideration. + type: integer + money_amount: + title: Money Amount + description: >- + Money Amounts represents an amount that a given Product Variant can be + purcased for. Each Money Amount either has a Currency or Region + associated with it to indicate the pricing in a given Currency or, for + fully region-based pricing, the given price in a specific Region. If + region-based pricing is used the amount will be in the currency defined + for the Reigon. + x-resourceId: money_amount + properties: + id: + description: The id of the Money Amount. This value will be prefixed by `ma_`. + type: string + currency_code: + description: The 3 character currency code that the Money Amount is given in. + type: string + amount: + description: >- + The amount in the smallest currecny unit (e.g. cents 100 cents to + charge $1) that the Product Variant will cost. + type: integer + sale_amount: + description: >- + An optional sale amount that the Product Variant will be available + for when defined. + type: integer + variant_id: + description: The id of the Product Variant that the Money Amount belongs to. + type: string + region_id: + description: The id of the Region that the Money Amount is defined for. + type: string + region: + description: The Region that the Money Amount is defined for. + anyOf: + - $ref: '#/components/schemas/region' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + notification_provider: + title: Notification Provider + description: >- + Represents a notification provider plugin and holds its installation + status. + x-resourceId: notification_provider + properties: + id: + description: The id of the notification provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + notification: + title: Notification + description: >- + Notifications a communications sent via Notification Providers as a + reaction to internal events such as `order.placed`. Notifications can be + used to show a chronological timeline for communications sent to a + Customer regarding an Order, and enables resends. + x-resourceId: notification + properties: + id: + description: The id of the Notification. This value will be prefixed by `noti_`. + type: string + event_name: + description: The name of the event that the notification was sent for. + type: string + resource_type: + description: The type of resource that the Notification refers to. + type: string + resource_id: + description: The id of the resource that the Notification refers to. + type: string + customer_id: + description: The id of the Customer that the Notification was sent to. + type: string + customer: + description: The Customer that the Notification was sent to. + anyOf: + - $ref: '#/components/schemas/customer' + to: + description: >- + The address that the Notification was sent to. This will usually be + an email address, but represent other addresses such as a chat bot + user id + type: string + data: + description: >- + The data that the Notification was sent with. This contains all the + data necessary for the Notification Provider to initiate a resend. + type: object + parent_id: + description: The id of the Notification that was originally sent. + type: string + resends: + description: >- + The resends that have been completed after the original + Notification. + type: array + items: + $ref: '#/components/schemas/notification_resend' + provider_id: + description: The id of the Notification Provider that handles the Notification. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + notification_resend: + title: Notification Resend + description: A resend of a Notification. + x-resourceId: notification_resend + properties: + id: + description: The id of the Notification. This value will be prefixed by `noti_`. + type: string + event_name: + description: The name of the event that the notification was sent for. + type: string + resource_type: + description: The type of resource that the Notification refers to. + type: string + resource_id: + description: The id of the resource that the Notification refers to. + type: string + to: + description: >- + The address that the Notification was sent to. This will usually be + an email address, but represent other addresses such as a chat bot + user id + type: string + data: + description: >- + The data that the Notification was sent with. This contains all the + data necessary for the Notification Provider to initiate a resend. + type: object + parent_id: + description: The id of the Notification that was originally sent. + type: string + provider_id: + description: The id of the Notification Provider that handles the Notification. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + order: + title: Order + description: Represents an order + x-resourceId: order + properties: + id: + type: string + status: + type: string + enum: + - pending + - completed + - archived + - canceled + - requires_action + fulfillment_status: + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + payment_status: + type: string + enum: + - not_paid + - awaiting + - captured + - partially_refunded + - refuneded + - canceled + - requires_action + display_id: + type: integer + cart_id: + type: string + currency_code: + type: string + tax_rate: + type: integer + discounts: + type: array + items: + $ref: '#/components/schemas/discount' + email: + type: string + billing_address_id: + type: string + billing_address: + anyOf: + - $ref: '#/components/schemas/address' + shipping_address_id: + type: string + shipping_address: + anyOf: + - $ref: '#/components/schemas/address' + items: + type: array + items: + $ref: '#/components/schemas/line_item' + region_id: + type: string + region: + anyOf: + - $ref: '#/components/schemas/region' + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + customer_id: + type: string + customer: + anyOf: + - $ref: '#/components/schemas/customer' + payment_session: + anyOf: + - $ref: '#/components/schemas/payment_session' + payment_sessions: + type: array + items: + $ref: '#/components/schemas/payment_session' + payments: + type: array + items: + $ref: '#/components/schemas/payment' + shipping_methods: + type: array + items: + $ref: '#/components/schemas/shipping_method' + fulfillments: + type: array + items: + $ref: '#/components/schemas/fulfillment' + returns: + type: array + items: + $ref: '#/components/schemas/return' + claims: + type: array + items: + $ref: '#/components/schemas/claim_order' + refunds: + type: array + items: + $ref: '#/components/schemas/refund' + swaps: + type: array + items: + $ref: '#/components/schemas/refund' + gift_card_transactions: + type: array + items: + $ref: '#/components/schemas/gift_card_transaction' + canceled_at: + type: string + format: date-time + created_at: + type: string + format: date-time + update_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + shipping_total: + type: integer + discount_total: + type: integer + tax_total: + type: integer + subtotal: + type: integer + refundable_amount: + type: integer + gift_card_total: + type: integer + paid_total: + type: integer + no_notification: + type: boolean + payment_provider: + title: Payment Provider + description: Represents a Payment Provider plugin and holds its installation status. + x-resourceId: payment_provider + properties: + id: + description: The id of the payment provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + payment_session: + title: Payment Session + description: >- + Payment Sessions are created when a Customer initilizes the checkout + flow, and can be used to hold the state of a payment flow. Each Payment + Session is controlled by a Payment Provider, who is responsible for the + communication with external payment services. Authorized Payment + Sessions will eventually get promoted to Payments to indicate that they + are authorized for capture/refunds/etc. + x-resourceId: payment_session + properties: + id: + description: >- + The id of the Payment Session. This value will be prefixed with + `ps_`. + type: string + cart_id: + description: The id of the Cart that the Payment Session is created for. + type: string + provider_id: + description: >- + The id of the Payment Provider that is responsible for the Payment + Session + type: string + is_selected: + description: >- + A flag to indicate if the Payment Session has been selected as the + method that will be used to complete the purchase. + type: boolean + status: + description: >- + Indicates the status of the Payment Session. Will default to + `pending`, and will eventually become `authorized`. Payment Sessions + may have the status of `requires_more` to indicate that further + actions are to be completed by the Customer. + type: string + enum: + - authorized + - pending + - requires_more + - error + - canceled + data: + description: >- + The data required for the Payment Provider to identify, modify and + process the Payment Session. Typically this will be an object that + holds an id to the external payment session, but can be an empty + object if the Payment Provider doesn't hold any state. + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + payment: + title: Payment + description: >- + Payments represent an amount authorized with a given payment method, + Payments can be captured, canceled or refunded. + x-resourceId: payment + properties: + id: + description: The id of the Payment. This value will be prefixed with `pay_`. + type: string + swap_id: + description: The id of the Swap that the Payment is used for. + type: string + order_id: + description: The id of the Order that the Payment is used for. + type: string + cart_id: + description: The id of the Cart that the Payment Session is created for. + type: string + amount: + description: The amount that the Payment has been authorized for. + type: integer + currency_code: + description: The 3 character ISO currency code that the Payment is completed in. + type: string + amount_refunded: + description: >- + The amount of the original Payment amount that has been refunded + back to the Customer. + type: integer + provider_id: + description: The id of the Payment Provider that is responsible for the Payment + type: string + data: + description: >- + The data required for the Payment Provider to identify, modify and + process the Payment. Typically this will be an object that holds an + id to the external payment session, but can be an empty object if + the Payment Provider doesn't hold any state. + type: object + captured_at: + description: The date with timezone at which the Payment was captured. + type: string + format: date-time + canceled_at: + description: The date with timezone at which the Payment was canceled. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_collection: + title: Product Collection + description: Product Collections represents a group of Products that are related. + x-resourceId: product_collection + properties: + id: + description: >- + The id of the Product Collection. This value will be prefixed with + `pcol_`. + type: string + title: + description: The title that the Product Collection is identified by. + type: string + handle: + description: >- + A unique string that identifies the Product Collection - can for + example be used in slug structures. + type: string + products: + description: The Products contained in the Product Collection. + type: array + items: + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_option_value: + title: Product Option Value + description: >- + A value given to a Product Variant's option set. Product Variant have a + Product Option Value for each of the Product Options defined on the + Product. + x-resourceId: product_option_value + properties: + id: + description: >- + The id of the Product Option Value. This value will be prefixed with + `optval_`. + type: string + value: + description: >- + The value that the Product Variant has defined for the specific + Product Option (e.g. if the Product Option is "Size" this value + could be "Small", "Medium" or "Large"). + type: string + option_id: + description: >- + The id of the Product Option that the Product Option Value is + defined for. + type: string + variant_id: + description: >- + The id of the Product Variant that the Product Option Value is + defined for. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_option: + title: Product Option + description: >- + Product Options define properties that may vary between different + variants of a Product. Common Product Options are "Size" and "Color", + but Medusa doesn't limit what Product Options that can be defined. + x-resourceId: product_option + properties: + id: + description: >- + The id of the Product Option. This value will be prefixed with + `opt_`. + type: string + title: + description: The title that the Product Option is defined by (e.g. "Size"). + type: string + values: + description: The Product Option Values that are defined for the Product Option. + type: array + items: + $ref: '#/components/schemas/product_option_value' + product_id: + description: The id of the Product that the Product Option is defined for. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_tag: + title: Product Tag + description: Product Tags can be added to Products for easy filtering and grouping. + x-resourceId: product_tag + properties: + id: + description: The id of the Product Tag. This value will be prefixed with `ptag_`. + type: string + value: + description: The value that the Product Tag represents (e.g. "Pants"). + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_type: + title: Product Type + description: >- + Product Type can be added to Products for filtering and reporting + purposes. + x-resourceId: product_type + properties: + id: + description: >- + The id of the Product Type. This value will be prefixed with + `ptyp_`. + type: string + value: + description: The value that the Product Type represents (e.g. "Clothing"). + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_variant: + title: Product Variant + description: >- + Product Variants represent a Product with a specific set of Product + Option configurations. The maximum number of Product Variants that a + Product can have is given by the number of available Product Option + combinations. + x-resourceId: product_variant + properties: + id: + description: >- + The id of the Product Variant. This value will be prefixed with + `variant_`. + type: string + title: + description: >- + A title that can be displayed for easy identification of the Product + Variant. + type: string + product_id: + description: The id of the Product that the Product Variant belongs to. + type: string + prices: + description: >- + The Money Amounts defined for the Product Variant. Each Money Amount + represents a price in a given currency or a price in a specific + Region. + type: array + items: + $ref: '#/components/schemas/money_amount' + sku: + description: >- + The unique stock keeping unit used to identify the Product Variant. + This will usually be a unqiue identifer for the item that is to be + shipped, and can be referenced across multiple systems. + type: string + barcode: + description: >- + A generic field for a GTIN number that can be used to identify the + Product Variant. + type: string + ean: + description: >- + An EAN barcode number that can be used to identify the Product + Variant. + type: string + upc: + description: >- + A UPC barcode number that can be used to identify the Product + Variant. + type: string + inventory_quantity: + description: The current quantity of the item that is stocked. + type: integer + allow_backorder: + description: >- + Whether the Product Variant should be purchasable when + `inventory_quantity` is 0. + type: boolean + manage_inventory: + description: Whether Medusa should manage inventory for the Product Variant. + type: boolean + hs_code: + description: >- + The Harmonized System code of the Product Variant. May be used by + Fulfillment Providers to pass customs information to shipping + carriers. + type: string + origin_country: + description: >- + The country in which the Product Variant was produced. May be used + by Fulfillment Providers to pass customs information to shipping + carriers. + type: string + mid_code: + description: >- + The Manufacturers Identification code that identifies the + manufacturer of the Product Variant. May be used by Fulfillment + Providers to pass customs information to shipping carriers. + type: string + material: + description: >- + The material and composition that the Product Variant is made of, + May be used by Fulfillment Providers to pass customs information to + shipping carriers. + type: string + weight: + description: >- + The weight of the Product Variant. May be used in shipping rate + calculations. + type: string + height: + description: >- + The height of the Product Variant. May be used in shipping rate + calculations. + type: string + width: + description: >- + The width of the Product Variant. May be used in shipping rate + calculations. + type: string + length: + description: >- + The length of the Product Variant. May be used in shipping rate + calculations. + type: string + options: + description: The Product Option Values specified for the Product Variant. + type: array + items: + $ref: '#/components/schemas/product_option_value' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product: + title: Product + description: >- + Products are a grouping of Product Variants that have common properties + such as images and descriptions. Products can have multiple options + which define the properties that Product Variants differ by. + x-resourceId: product + properties: + id: + description: The id of the Product. This value will be prefixed with `prod_`. + type: string + title: + description: >- + A title that can be displayed for easy identification of the + Product. + type: string + subtitle: + description: >- + An optional subtitle that can be used to further specify the + Product. + type: string + description: + description: A short description of the Product. + type: string + handle: + description: A unique identifier for the Product (e.g. for slug structure). + type: string + is_giftcard: + description: >- + Whether the Product represents a Gift Card. Products that represent + Gift Cards will automatically generate a redeemable Gift Card code + once they are purchased. + type: boolean + images: + description: Images of the Product + type: array + items: + $ref: '#/components/schemas/image' + thumbnail: + description: A URL to an image file that can be used to identify the Product. + type: string + options: + description: >- + The Product Options that are defined for the Product. Product + Variants of the Product will have a unique combination of Product + Option Values. + type: array + items: + $ref: '#/components/schemas/product_option' + variants: + description: >- + The Product Variants that belong to the Product. Each will have a + unique combination of Product Option Values. + type: array + items: + $ref: '#/components/schemas/product_variant' + profile_id: + description: >- + The id of the Shipping Profile that the Product belongs to. Shipping + Profiles have a set of defined Shipping Options that can be used to + Fulfill a given set of Products. + type: string + hs_code: + description: >- + The Harmonized System code of the Product Variant. May be used by + Fulfillment Providers to pass customs information to shipping + carriers. + type: string + origin_country: + description: >- + The country in which the Product Variant was produced. May be used + by Fulfillment Providers to pass customs information to shipping + carriers. + type: string + mid_code: + description: >- + The Manufacturers Identification code that identifies the + manufacturer of the Product Variant. May be used by Fulfillment + Providers to pass customs information to shipping carriers. + type: string + material: + description: >- + The material and composition that the Product Variant is made of, + May be used by Fulfillment Providers to pass customs information to + shipping carriers. + type: string + weight: + description: >- + The weight of the Product Variant. May be used in shipping rate + calculations. + type: string + height: + description: >- + The height of the Product Variant. May be used in shipping rate + calculations. + type: string + width: + description: >- + The width of the Product Variant. May be used in shipping rate + calculations. + type: string + length: + description: >- + The length of the Product Variant. May be used in shipping rate + calculations. + type: string + type: + description: The Product Type of the Product (e.g. "Clothing") + anyOf: + - $ref: '#/components/schemas/product_type' + collection: + description: The Product Collection that the Product belongs to (e.g. "SS20") + anyOf: + - $ref: '#/components/schemas/product_collection' + tags: + description: The Product Tags assigned to the Product. + type: array + items: + $ref: '#/components/schemas/product_tag' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + refund: + title: Refund + description: >- + Refund represent an amount of money transfered back to the Customer for + a given reason. Refunds may occur in relation to Returns, Swaps and + Claims, but can also be initiated by a store operator. + x-resourceId: refund + properties: + id: + description: The id of the Refund. This value will be prefixed with `ref_`. + type: string + order_id: + description: The id of the Order that the Refund is related to. + type: string + amount: + description: The amount that has be refunded to the Customer. + type: integer + note: + description: An optional note explaining why the amount was refunded. + type: string + reason: + description: >- + The reason given for the Refund, will automatically be set when + processed as part of a Swap, Claim or Return. + type: string + enum: + - discount + - return + - swap + - claim + - other + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + region: + title: Region + description: >- + Regions hold settings for how Customers in a given geographical location + shop. The is, for example, where currencies and tax rates are defined. A + Region can consist of multiple countries to accomodate common shopping + settings across countries. + x-resourceId: region + properties: + id: + description: The id of the Region. This value will be prefixed with `reg_`. + type: string + name: + description: >- + The name of the region as displayed to the customer. If the Region + only has one country it is recommended to write the country name. + type: string + currency_code: + description: >- + The 3 character ISO currency code that Customers will shop in in the + Region. + type: string + tax_rate: + description: The tax rate that should be charged on purchases in the Region. + type: number + tax_code: + description: >- + The tax code used on purchases in the Region. This may be used by + other systems for accounting purposes. + type: string + countries: + description: The countries that are included in the Region. + type: array + items: + $ref: '#/components/schemas/country' + payment_providers: + description: >- + The Payment Providers that can be used to process Payments in the + Region. + type: array + items: + $ref: '#/components/schemas/payment_provider' + fulfillment_providers: + description: >- + The Fulfillment Providers that can be used to fulfill orders in the + Region. + type: array + items: + $ref: '#/components/schemas/fulfillment_provider' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + return_item: + title: Return Item + description: >- + Correlates a Line Item with a Return, keeping track of the quantity of + the Line Item that will be returned. + x-resourceId: return_item + properties: + return_id: + description: The id of the Return that the Return Item belongs to. + type: string + item_id: + description: The id of the Line Item that the Return Item references. + type: string + item: + description: The Line Item that the Return Item references. + anyOf: + - $ref: '#/components/schemas/line_item' + quantity: + description: The quantity of the Line Item that is included in the Return. + type: integer + is_requested: + description: >- + Whether the Return Item was requested initially or received + unexpectedly in the warehouse. + type: boolean + requested_quantity: + description: The quantity that was originally requested to be returned. + type: integer + recieved_quantity: + description: The quantity that was received in the warehouse. + type: integer + reason: + description: The reason for returning the item. + anyOf: + - $ref: '#/components/schemas/return_reason' + note: + description: An optional note with additional details about the Return. + type: string + metadata: + description: An optional key-value map with additional information. + type: object + return_reason: + title: Return Reason + description: >- + A Reason for why a given product is returned. A Return Reason can be + used on Return Items in order to indicate why a Line Item was returned. + x-resourceId: return_reason + properties: + id: + description: The id of the Return Reason will start with `rr_`. + type: string + description: + description: A description of the Reason. + type: string + label: + description: A text that can be displayed to the Customer as a reason. + type: string + value: + description: The value to identify the reason by. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + return: + title: Return + description: >- + Return orders hold information about Line Items that a Customer wishes + to send back, along with how the items will be returned. Returns can be + used as part of a Swap. + x-resourceId: return + properties: + id: + description: The id of the Return. This value will be prefixed with `ret_`. + type: string + status: + description: Status of the Return. + type: string + enum: + - requested + - received + - requires_action + items: + description: >- + The Return Items that will be shipped back to the warehouse. type: + array items: $ref: + swap_id: + description: The id of the Swap that the Return is a part of. + type: string + order_id: + description: The id of the Order that the Return is made from. + type: string + claim_order_id: + description: The id of the Claim that the Return is a part of. + type: string + shipping_method: + description: >- + The Shipping Method that will be used to send the Return back. Can + be null if the Customer facilitates the return shipment themselves. + anyOf: + - $ref: '#/components/schemas/shipping_method' + shipping_data: + description: >- + Data about the return shipment as provided by the Fulfilment + Provider that handles the return shipment. + type: object + refund_amount: + description: The amount that should be refunded as a result of the return. + type: integer + received_at: + description: The date with timezone at which the return was received. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + no_notification: + description: >- + When set to true, no notification will be sent related to this + return. + type: boolean + metadata: + description: An optional key-value map with additional information. + type: object + shipping_method: + title: Shipping Method + description: >- + Shipping Methods represent a way in which an Order or Return can be + shipped. Shipping Methods are built from a Shipping Option, but may + contain additional details, that can be necessary for the Fulfillment + Provider to handle the shipment. + x-resourceId: shipping_method + properties: + id: + description: >- + The id of the Shipping Method. This value will be prefixed with + `sm_`. + type: string + shipping_option_id: + description: >- + The id of the Shipping Option that the Shipping Method is built + from. + type: string + shipping_option: + description: The Shipping Option that the Shipping Method is built from. + anyOf: + - $ref: '#/components/schemas/shipping_option' + order_id: + description: The id of the Order that the Shipping Method is used on. + type: string + return_id: + description: The id of the Return that the Shipping Method is used on. + type: string + swap_id: + description: The id of the Swap that the Shipping Method is used on. + type: string + cart_id: + description: The id of the Cart that the Shipping Method is used on. + type: string + claim_order_id: + description: The id of the Claim that the Shipping Method is used on. + type: string + price: + description: >- + The amount to charge for the Shipping Method. The currency of the + price is defined by the Region that the Order that the Shipping + Method belongs to is a part of. + type: integer + data: + description: >- + Additional data that the Fulfillment Provider needs to fulfill the + shipment. This is used in combination with the Shipping Options + data, and may contain information such as a drop point id. + type: object + shipping_option_requirement: + title: Shipping Option Requirement + description: >- + A requirement that a Cart must satisfy for the Shipping Option to be + available to the Cart. + x-resourceId: shipping_option_requirement + properties: + id: + description: >- + The id of the Shipping Option Requirement. This value will be + prefixed with `sor_`. + type: string + shipping_option_id: + description: >- + The id of the Shipping Option that the Shipping Option Requirement + belongs to. + type: string + type: + description: >- + The type of the requirement, this defines how the value will be + compared to the Cart's total. `min_subtotal` requirements define the + minimum subtotal that is needed for the Shipping Option to be + available, while the `max_subtotal` defines the maximum subtotal + that the Cart can have for the Shipping Option to be available. + type: string + enum: + - min_subtotal + - max_subtotal + amount: + description: The amount to compare the Cart subtotal to. + type: integer + shipping_option: + title: Shipping Option + description: >- + Shipping Options represent a way in which an Order or Return can be + shipped. Shipping Options have an associated Fulfillment Provider that + will be used when the fulfillment of an Order is initiated. Shipping + Options themselves cannot be added to Carts, but serve as a template for + Shipping Methods. This distinction makes it possible to customize + individual Shipping Methods with additional information. + x-resourceId: shipping_option + properties: + id: + description: >- + The id of the Shipping Option. This value will be prefixed with + `so_`. + type: string + name: + description: >- + The name given to the Shipping Option - this may be displayed to the + Customer. + type: string + region_id: + description: The id of the Region that the Shipping Option belongs to. + type: string + region: + description: The id of the Region that the Shipping Option belongs to. + anyOf: + - $ref: '#/components/schemas/region' + profile_id: + description: >- + The id of the Shipping Profile that the Shipping Option belongs to. + Shipping Profiles have a set of defined Shipping Options that can be + used to Fulfill a given set of Products. + type: string + provider_id: + description: >- + The id of the Fulfillment Provider, that will be used to process + Fulfillments from the Shipping Option. + type: string + price_type: + description: >- + The type of pricing calculation that is used when creatin Shipping + Methods from the Shipping Option. Can be `flat_rate` for fixed + prices or `calculated` if the Fulfillment Provider can provide price + calulations. + type: string + enum: + - flat_rate + - calculated + amount: + description: >- + The amount to charge for shipping when the Shipping Option price + type is `flat_rate`. + type: integer + is_return: + description: >- + Flag to indicate if the Shipping Option can be used for Return + shipments. + type: boolean + requirements: + description: >- + The requirements that must be satisfied for the Shipping Option to + be available for a Cart. + type: array + items: + $ref: '#/components/schemas/shipping_option_requirement' + data: + description: >- + The data needed for the Fulfillment Provider to identify the + Shipping Option. + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + shipping_profile: + title: Shipping Profile + description: >- + Shipping Profiles have a set of defined Shipping Options that can be + used to fulfill a given set of Products. + x-resourceId: shipping_profile + properties: + id: + description: >- + The id of the Shipping Profile. This value will be prefixed with + `sp_`. + type: string + name: + description: >- + The name given to the Shipping profile - this may be displayed to + the Customer. + type: string + type: + description: >- + The type of the Shipping Profile, may be `default`, `gift_card` or + `custom`. + type: string + enum: + - default + - gift_card + - custom + products: + description: The Products that the Shipping Profile defines Shipping Options for. + type: array + items: + $ref: '#/components/schemas/product' + shipping_options: + description: >- + The Shipping Options that can be used to fulfill the Products in the + Shipping Profile. + type: array + items: + anyOf: + - $ref: '#/components/schemas/shipping_option' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + store: + title: Store + description: 'Holds settings for the Store, such as name, currencies, etc.' + x-resourceId: store + properties: + id: + description: The id of the Store. This value will be prefixed with `store_`. + type: string + name: + description: The name of the Store - this may be displayed to the Customer. + type: string + default_currency_code: + description: >- + The default currency code used when no other currency code is + specified. + type: string + currencies: + description: The currencies that are enabled for the Store. + type: array + items: + $ref: '#/components/schemas/currency' + swap_link_template: + description: >- + A template to generate Swap links from use {{cart_id}} to include + the Swap's `cart_id` in the link. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + swap: + title: Swap + description: >- + Swaps can be created when a Customer wishes to exchange Products that + they have purchased to different Products. Swaps consist of a Return of + previously purchased Products and a Fulfillment of new Products, the + amount paid for the Products being returned will be used towards payment + for the new Products. In the case where the amount paid for the the + Products being returned exceed the amount to be paid for the new + Products, a Refund will be issued for the difference. + x-resourceId: swap + properties: + id: + description: The id of the Swap. This value will be prefixed with `swap_`. + type: string + fulfillment_status: + description: The status of the Fulfillment of the Swap. + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + payment_status: + description: >- + The status of the Payment of the Swap. The payment may either refer + to the refund of an amount or the authorization of a new amount. + type: string + enum: + - not_paid + - awaiting + - captured + - canceled + - difference_refunded + - requires_action + order_id: + description: >- + The id of the Order where the Line Items to be returned where + purchased. + type: string + additional_items: + description: The new Line Items to ship to the Customer. + type: array + items: + $ref: '#/components/schemas/line_item' + return_order: + description: The Return that is issued for the return part of the Swap. + anyOf: + - $ref: '#/components/schemas/return' + fulfillments: + description: The Fulfillments used to send the new Line Items. + type: array + items: + $ref: '#/components/schemas/fulfillment' + payment: + description: >- + The Payment authorized when the Swap requires an additional amount + to be charged from the Customer. + anyOf: + - $ref: '#/components/schemas/payment' + difference_due: + description: >- + The difference that is paid or refunded as a result of the Swap. May + be negative when the amount paid for the returned items exceed the + total of the new Products. + type: integer + shipping_address: + description: >- + The Address to send the new Line Items to - in most cases this will + be the same as the shipping address on the Order. + anyOf: + - $ref: '#/components/schemas/address' + shipping_methods: + description: The Shipping Methods used to fulfill the addtional items purchased. + type: array + items: + $ref: '#/components/schemas/shipping_method' + cart_id: + description: The id of the Cart that the Customer will use to confirm the Swap. + type: string + confirmed_at: + description: >- + The date with timezone at which the Swap was confirmed by the + Customer. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + no_notification: + description: 'If set to true, no notification will be sent related to this swap' + type: boolean + metadata: + description: An optional key-value map with additional information. + type: object + tracking_link: + title: Tracking Link + description: >- + Tracking Link holds information about tracking numbers for a + Fulfillment. Tracking Links can optionally contain a URL that can be + visited to see the status of the shipment. + x-resourceId: tracking_link + properties: + id: + description: >- + The id of the Tracking Link. This value will be prefixed with + `tlink_`. + type: string + url: + description: The URL at which the status of the shipment can be tracked. + type: string + tracking_number: + description: The tracking number given by the shipping carrier. + type: string + fulfillment_id: + description: The id of the Fulfillment that the Tracking Link references. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + user: + title: User + description: Represents a User who can manage store settings. + x-resourceId: user + properties: + id: + description: The unique id of the User. This will be prefixed with `usr_` + type: string + email: + description: The email of the User + type: string + first_name: + type: string + last_name: + description: The Customer's billing address. + anyOf: + - $ref: '#/components/schemas/address' + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json new file mode 100644 index 0000000000..5f7a2b994d --- /dev/null +++ b/docs/api/store-spec3.json @@ -0,0 +1,4959 @@ +{ + "openapi": "3.0.0", + "info": { + "version": "1.0.0", + "title": "Medusa Storefront API", + "license": { + "name": "MIT" + } + }, + "tags": [ + { + "name": "Auth", + "description": "Auth endpoints allows authorization of admin Users and manages their sessions." + }, + { + "name": "Cart", + "x-resourceId": "cart" + }, + { + "name": "Collection", + "x-resourceId": "product_collection" + }, + { + "name": "Customer", + "x-resourceId": "customer" + }, + { + "name": "Discount", + "x-resourceId": "discount" + }, + { + "name": "Gift Card", + "x-resourceId": "gift_card" + }, + { + "name": "Notification", + "x-resourceId": "notification" + }, + { + "name": "Order", + "x-resourceId": "order" + }, + { + "name": "Product", + "x-resourceId": "product" + }, + { + "name": "Region", + "x-resourceId": "region" + }, + { + "name": "Return", + "x-resourceId": "return" + }, + { + "name": "Shipping Option", + "x-resourceId": "shipping_option" + }, + { + "name": "Shipping Profile", + "x-resourceId": "shipping_profile" + }, + { + "name": "Swap", + "x-resourceId": "swap" + }, + { + "name": "Product Variant", + "x-resourceId": "product_variant" + } + ], + "servers": [ + { + "url": "https://api.medusa-commerce.com/store" + } + ], + "paths": { + "/auth": { + "post": { + "operationId": "PostAuth", + "summary": "Authenticate Customer", + "description": "Logs a Customer in and authorizes them to view their details. Successful authentication will set a session cookie in the Customer's browser.", + "parameters": [], + "tags": [ + "Auth" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "password" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email." + }, + "password": { + "type": "string", + "description": "The Customer's password." + } + } + } + } + } + } + }, + "delete": { + "operationId": "DeleteAuth", + "summary": "Log out", + "description": "Destroys a Customer's authenticated session.", + "tags": [ + "Auth" + ], + "responses": { + "200": { + "description": "OK" + } + } + }, + "get": { + "operationId": "GetAuth", + "summary": "Get Session", + "description": "Gets the currently logged in Customer.", + "tags": [ + "Auth" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/auth/{email}": { + "get": { + "operationId": "GetAuthEmail", + "summary": "Check if email has account", + "description": "Checks if a Customer with the given email has signed up.", + "parameters": [ + { + "in": "path", + "name": "email", + "required": true, + "description": "The Customer's email.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Auth" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "exists": { + "type": "boolean" + } + } + } + } + } + } + } + } + }, + "/gift-cards/{code}": { + "get": { + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", + "parameters": [ + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Gift Card code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/customers/{id}/addresses": { + "post": { + "operationId": "PostCustomersCustomerAddresses", + "summary": "Add a Shipping Address", + "description": "Adds a Shipping Address to a Customer's saved addresses.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The Customer id.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "address": { + "description": "The Address to add to the Customer.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "A successful response", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers": { + "post": { + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer account.", + "parameters": [], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name", + "password" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "password": { + "type": "string", + "description": "The Customer's password for login." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } + } + } + }, + "/customers/{id}/addresses/{address_id}": { + "delete": { + "operationId": "DeleteCustomersCustomerAddressesAddress", + "summary": "Delete an Address", + "description": "Removes an Address from the Customer's saved addresse.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "address_id", + "required": true, + "description": "The id of the Address to remove.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomerAddressesAddress", + "summary": "Update a Shipping Address", + "description": "Updates a Customer's saved Shipping Address.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The Customer id.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "address_id", + "required": true, + "description": "The id of the Address to update.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "address": { + "description": "The updated Address.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}": { + "get": { + "operationId": "GetCustomersCustomer", + "summary": "Retrieves a Customer", + "description": "Retrieves a Customer - the Customer must be logged in to retrieve their details.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomer", + "summary": "Update Customer details", + "description": "Updates a Customer's saved details.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "first_name": { + "description": "The Customer's first name.", + "type": "string" + }, + "last_name": { + "description": "The Customer's last name.", + "type": "string" + }, + "password": { + "description": "The Customer's password.", + "type": "string" + }, + "phone": { + "description": "The Customer's phone number.", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}/payment-methods": { + "get": { + "operationId": "GetCustomersCustomerPaymentMethods", + "summary": "Retrieve saved payment methods", + "description": "Retrieves a list of a Customer's saved payment methods. Payment methods are saved with Payment Providers and it is their responsibility to fetch saved methods.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "payment_methods": { + "type": "array", + "items": { + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider where the payment method is saved." + }, + "data": { + "type": "object", + "description": "The data needed for the Payment Provider to use the saved payment method." + } + } + } + } + } + } + } + } + } + } + } + }, + "/customers/{id}/orders": { + "get": { + "operationId": "GetCustomersCustomerOrders", + "summary": "Retrieve Customer Orders", + "description": "Retrieves a list of a Customer's Orders.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "payment_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + } + }, + "/customers/{id}/password-token": { + "post": { + "operationId": "PostCustomersCustomerPasswordToken", + "summary": "Creates a reset password token", + "description": "Creates a reset password token to be used in a subsequent /reset-password request. The password token should be sent out of band e.g. via email and will not be returned.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "204": { + "description": "OK" + } + } + } + }, + "/customers/{id}/reset-password": { + "post": { + "operationId": "PostCustomersCustomerResetPassword", + "summary": "Resets Customer password", + "description": "Resets a Customer's password using a password token created by a previous /password-token request.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "token", + "password" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email." + }, + "token": { + "type": "string", + "description": "The password token created by a /password-token request." + }, + "password": { + "type": "string", + "description": "The new password to set for the Customer." + } + } + } + } + } + } + } + }, + "/carts/{id}/shipping-methods": { + "post": { + "operationId": "PostCartsCartShippingMethod", + "description": "Adds a Shipping Method to the Cart.", + "summary": "Add a Shipping Method", + "tags": [ + "Cart" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The cart id.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "A successful response", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "option_id" + ], + "properties": { + "option_id": { + "type": "string", + "description": "id of the shipping option to create the method from" + }, + "data": { + "type": "object", + "description": "Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send." + } + } + } + } + } + } + } + }, + "/carts/{id}/complete-cart": { + "post": { + "summary": "Complete a Cart", + "operationId": "PostCartsCartComplete", + "description": "Completes a cart. The following steps will be performed. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header `Idempotency-Key`. If not provided, we will generate one for the request.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The Cart id.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "If a cart was successfully authorized, but requires further action from the user the response body will contain the cart with an updated payment session. If the Cart was successfully completed the response body will contain the newly created Order.", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "type": "object", + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + }, + { + "type": "object", + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + ] + } + } + } + } + } + } + }, + "/carts": { + "post": { + "summary": "Create a Cart", + "operationId": "PostCart", + "description": "Creates a Cart within the given region and with the initial items. If no `region_id` is provided the cart will be associated with the first Region available. If no items are provided the cart will be empty after creation. If a user is logged in the cart's customer id and email will be set.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "region_id": { + "type": "string", + "description": "The id of the Region to create the Cart in." + }, + "country_code": { + "type": "string", + "description": "The 2 character ISO country code to create the Cart in." + }, + "items": { + "description": "An optional array of `variant_id`, `quantity` pairs to generate Line Items from.", + "type": "array", + "items": { + "properties": { + "variant_id": { + "description": "The id of the Product Variant to generate a Line Item from.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Product Variant to add", + "type": "integer" + } + } + } + }, + "context": { + "description": "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "Successfully created a new Cart", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/line-items": { + "post": { + "operationId": "PostCartsCartLineItems", + "summary": "Add a Line Item", + "description": "Generates a Line Item with a given Product Variant and adds it to the Cart", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart to add the Line Item to.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "variant_id", + "quantity" + ], + "properties": { + "variant_id": { + "type": "string", + "description": "The id of the Product Variant to generate the Line Item from." + }, + "quantity": { + "type": "integer", + "description": "The quantity of the Product Variant to add to the Line Item." + }, + "metadata": { + "type": "object", + "description": "An optional key-value map with additional details about the Line Item." + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-sessions": { + "post": { + "operationId": "PostCartsCartPaymentSessions", + "summary": "Initialize Payment Sessions", + "description": "Creates Payment Sessions for each of the available Payment Providers in the Cart's Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/discounts/{code}": { + "delete": { + "operationId": "DeleteCartsCartDiscountsDiscount", + "description": "Removes a Discount from a Cart.", + "summary": "Remove Discount from Cart", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Discount code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/line-items/{line_id}": { + "delete": { + "operationId": "DeleteCartsCartLineItemsItem", + "summary": "Delete a Line Item", + "description": "Removes a Line Item from a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "line_id", + "required": true, + "description": "The id of the Line Item.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCartsCartLineItemsItem", + "summary": "Update a Line Item", + "description": "Updates a Line Item if the desired quantity can be fulfilled.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "line_id", + "required": true, + "description": "The id of the Line Item.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "quantity" + ], + "properties": { + "quantity": { + "type": "integer", + "description": "The quantity to set the Line Item to." + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-sessions/{provider_id}": { + "delete": { + "operationId": "DeleteCartsCartPaymentSessionsSession", + "summary": "Delete a Payment Session", + "description": "Deletes a Payment Session on a Cart. May be useful if a payment has failed.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "provider_id", + "required": true, + "description": "The id of the Payment Provider used to create the Payment Session to be deleted.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCartsCartPaymentSessionsSession", + "summary": "Refresh a Payment Session", + "description": "Refreshes a Payment Session to ensure that it is in sync with the Cart - this is usually not necessary.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "provider_id", + "required": true, + "description": "The id of the Payment Provider that created the Payment Session to be refreshed.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}": { + "get": { + "operationId": "GetCartsCart", + "summary": "Retrieve a Cart", + "description": "Retrieves a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-session": { + "post": { + "operationId": "PostCartsCartPaymentSession", + "summary": "Select a Payment Session", + "description": "Selects a Payment Session as the session intended to be used towards the completion of the Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "provider_id" + ], + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider." + } + } + } + } + } + } + } + }, + "/store/carts/{id}": { + "post": { + "operationId": "PostCartsCart", + "summary": "Update a Cart\"", + "description": "Updates a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "region_id": { + "type": "string", + "description": "The id of the Region to create the Cart in." + }, + "country_code": { + "type": "string", + "description": "The 2 character ISO country code to create the Cart in." + }, + "email": { + "type": "string", + "description": "An email to be used on the Cart." + }, + "billing_address": { + "description": "The Address to be used for billing purposes.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "shipping_address": { + "description": "The Address to be used for shipping.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "gift_cards": { + "description": "An array of Gift Card codes to add to the Cart.", + "type": "array", + "items": { + "properties": { + "code": { + "description": "The code that a Gift Card is identified by.", + "type": "string" + } + } + } + }, + "discounts": { + "description": "An array of Discount codes to add to the Cart.", + "type": "array", + "items": { + "properties": { + "code": { + "description": "The code that a Discount is identifed by.", + "type": "string" + } + } + } + }, + "customer_id": { + "description": "The id of the Customer to associate the Cart with.", + "type": "string" + }, + "context": { + "description": "An optional object to provide context to the Cart.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-session/update": { + "post": { + "operationId": "PostCartsCartPaymentSessionUpdate", + "summary": "Update a Payment Session", + "description": "Updates a Payment Session with additional data.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "provider_id", + "data" + ], + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider responsible for the Payment Session to update." + }, + "data": { + "type": "object", + "description": "The data to update the payment session with." + } + } + } + } + } + } + } + }, + "/orders/cart/{cart_id}": { + "get": { + "operationId": "GetOrdersOrderCartId", + "summary": "Retrieves Order by Cart id", + "description": "Retrieves an Order by the id of the Cart that was used to create the Order.", + "parameters": [ + { + "in": "path", + "name": "cart_id", + "required": true, + "description": "The id of Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + }, + "/orders/{id}": { + "get": { + "operationId": "GetOrdersOrder", + "summary": "Retrieves an Order", + "description": "Retrieves an Order", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Order.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/orders": { + "get": { + "operationId": "GetOrders", + "summary": "Look Up an Order", + "description": "Looks for an Order with a given `display_id`, `email` pair. The `display_id`, `email` pair must match in order for the Order to be returned.", + "parameters": [ + { + "in": "query", + "name": "display_id", + "required": true, + "description": "The display id given to the Order.", + "schema": { + "type": "number" + } + }, + { + "in": "query", + "name": "email", + "required": true, + "description": "The email of the Order with the given display_id.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + }, + "/products/{id}": { + "get": { + "operationId": "GetProductsProduct", + "summary": "Retrieves a Product", + "description": "Retrieves a Product.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Product.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "product": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + }, + "/products": { + "get": { + "operationId": "GetProducts", + "summary": "List Products", + "description": "Retrieves a list of Products.", + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of Products.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of Products to return,", + "type": "integer" + }, + "products": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, + "/return-reasons": { + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/regions/{id}": { + "get": { + "operationId": "GetRegionsRegion", + "summary": "Retrieves a Region", + "description": "Retrieves a Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Region.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/regions": { + "get": { + "operationId": "GetRegions", + "summary": "List Regions", + "description": "Retrieves a list of Regions.", + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of regions.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of regions to return,", + "type": "integer" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + } + }, + "/returns": { + "post": { + "operationId": "PostReturns", + "summary": "Create Return", + "description": "Creates a Return for an Order.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "order_id": { + "type": "string", + "description": "The id of the Order to create the Return from." + }, + "items": { + "description": "The items to include in the Return.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item from the Order.", + "type": "string" + }, + "quantity": { + "description": "The quantity to return.", + "type": "integer" + } + } + } + }, + "return_shipping": { + "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", + "type": "object", + "properties": { + "option_id": { + "type": "string", + "description": "The id of the Shipping Option to create the Shipping Method from." + } + } + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, + "/shipping-options": { + "get": { + "operationId": "GetShippingOptions", + "summary": "Retrieve Shipping Options", + "description": "Retrieves a list of Shipping Options.", + "parameters": [ + { + "in": "query", + "name": "is_return", + "description": "Whether return Shipping Options should be included. By default all Shipping Options are returned.", + "schema": { + "type": "boolean" + } + }, + { + "in": "query", + "name": "product_ids", + "description": "A comma separated list of Product ids to filter Shipping Options by.", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "region_id", + "description": "the Region to retrieve Shipping Options from.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Option" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_options": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_option" + } + } + } + } + } + } + } + } + } + }, + "/shipping-options/{cart_id}": { + "get": { + "operationId": "GetShippingOptionsCartId", + "summary": "Retrieve Shipping Options for Cart", + "description": "Retrieves a list of Shipping Options available to a cart.", + "parameters": [ + { + "in": "path", + "name": "cart_id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Option" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_options": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_option" + } + } + } + } + } + } + } + } + } + }, + "/swaps/{cart_id}": { + "get": { + "operationId": "GetSwapsSwapCartId", + "summary": "Retrieve Swap by Cart id", + "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", + "parameters": [ + { + "in": "path", + "name": "cart_id", + "required": true, + "description": "The id of the Cart", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Swap" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "swap": { + "$ref": "#/components/schemas/swap" + } + } + } + } + } + } + } + } + }, + "/variants/{variant_id}": { + "get": { + "operationId": "GetVariantsVariant", + "summary": "Retrieve a Product Variant", + "description": "Retrieves a Product Variant by id", + "parameters": [ + { + "in": "path", + "name": "variant_id", + "required": true, + "description": "The id of the Product Variant.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product Variant" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "variant": { + "$ref": "#/components/schemas/product_variant" + } + } + } + } + } + } + } + } + }, + "/variants": { + "get": { + "operationId": "GetVariants", + "summary": "Retrieve Product Variants", + "description": "Retrieves a list of Product Variants", + "parameters": [ + { + "in": "query", + "name": "ids", + "description": "A comma separated list of Product Variant ids to filter by.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product Variant" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "variants": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product_variant" + } + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "address": { + "title": "Address", + "description": "An address.", + "x-resourceId": "address", + "properties": { + "id": { + "type": "string" + }, + "customer_id": { + "type": "string" + }, + "company": { + "type": "string" + }, + "first_name": { + "type": "string" + }, + "last_name": { + "type": "string" + }, + "address_1": { + "type": "string" + }, + "address_2": { + "type": "string" + }, + "city": { + "type": "string" + }, + "country_code": { + "type": "string" + }, + "country": { + "$ref": "#/components/schemas/country" + } + } + }, + "cart": { + "title": "Cart", + "description": "Represents a user cart", + "x-resourceId": "cart", + "properties": { + "id": { + "type": "string" + }, + "email": { + "type": "string" + }, + "billing_address_id": { + "type": "string" + }, + "billing_address": { + "$ref": "#/components/schemas/address" + }, + "shipping_address_id": { + "type": "string" + }, + "shipping_address": { + "$ref": "#/components/schemas/address" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/line_item" + } + }, + "region_id": { + "type": "string" + }, + "region": { + "$ref": "#/components/schemas/region" + }, + "discounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + }, + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } + }, + "customer_id": { + "type": "string" + }, + "customer": { + "$ref": "#/components/schemas/customer" + }, + "payment_session": { + "$ref": "#/components/schemas/payment_session" + }, + "payment_sessions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/payment_session" + } + }, + "payment": { + "$ref": "#/components/schemas/payment" + }, + "shipping_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_method" + } + }, + "type": { + "type": "string", + "enum": [ + "default", + "swap", + "payment_link" + ] + }, + "completed_at": { + "type": "string", + "format": "date-time" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + }, + "shipping_total": { + "type": "integer" + }, + "discount_total": { + "type": "integer" + }, + "tax_total": { + "type": "integer" + }, + "subtotal": { + "type": "integer" + }, + "refundable_amount": { + "type": "integer" + }, + "gift_card_total": { + "type": "integer" + } + } + }, + "claim_image": { + "title": "Claim Image", + "description": "Represents photo documentation of a claim.", + "x-resourceId": "claim_image", + "properties": { + "id": { + "type": "string" + }, + "claim_item_id": { + "type": "string" + }, + "url": { + "type": "string" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + } + } + }, + "claim_item": { + "title": "Claim Item", + "description": "Represents a claimed item along with information about the reasons for the claim.", + "x-resourceId": "claim_item", + "properties": { + "id": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "$ref": "#/components/schemas/claim_image" + } + }, + "claim_order_id": { + "type": "string" + }, + "item_id": { + "type": "string" + }, + "item": { + "description": "The Line Item that the claim refers to", + "$ref": "#/components/schemas/line_item" + }, + "variant_id": { + "type": "string" + }, + "variant": { + "description": "The Product Variant that is claimed.", + "$ref": "#/components/schemas/product_variant" + }, + "reason": { + "description": "The reason for the claim", + "type": "string", + "enum": [ + "missing_item", + "wrong_item", + "production_failure", + "other" + ] + }, + "note": { + "description": "An optional note about the claim, for additional information", + "type": "string" + }, + "quantity": { + "description": "The quantity of the item that is being claimed; must be less than or equal to the amount purchased in the original order.", + "type": "integer" + }, + "tags": { + "description": "User defined tags for easy filtering and grouping.", + "type": "array", + "items": { + "$ref": "#/components/schemas/claim_tag" + } + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + } + } + }, + "claim_order": { + "title": "Claim Order", + "description": "Claim Orders represent a group of faulty or missing items. Each claim order consists of a subset of items associated with an original order, and can contain additional information about fulfillments and returns.", + "x-resourceId": "claim_order", + "properties": { + "id": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "refund", + "replace" + ] + }, + "payment_status": { + "type": "string", + "enum": [ + "na", + "not_refunded", + "refunded" + ] + }, + "fulfillment_status": { + "type": "string", + "enum": [ + "not_fulfilled", + "partially_fulfilled", + "fulfilled", + "partially_shipped", + "shipped", + "partially_returned", + "returned", + "canceled", + "requires_action" + ] + }, + "claim_items": { + "description": "The items that have been claimed", + "type": "array", + "items": { + "$ref": "#/components/schemas/claim_item" + } + }, + "additional_items": { + "description": "Refers to the new items to be shipped when the claim order has the type `replace`", + "type": "array", + "items": { + "$ref": "#/components/schemas/line_item" + } + }, + "order_id": { + "description": "The id of the order that the claim comes from.", + "type": "string" + }, + "return_order": { + "description": "Holds information about the return if the claim is to be returned", + "$ref": "#/components/schemas/return" + }, + "shipping_address_id": { + "description": "The id of the address that the new items should be shipped to", + "type": "string" + }, + "shipping_address": { + "description": "The address that the new items should be shipped to", + "$ref": "#/components/schemas/address" + }, + "shipping_methods": { + "description": "The shipping methods that the claim order will be shipped with.", + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_method" + } + }, + "fulfillments": { + "description": "The fulfillments of the new items to be shipped", + "type": "array", + "items": { + "$ref": "#/components/schemas/fulfillment" + } + }, + "refund_amount": { + "description": "The amount that will be refunded in conjunction with the claim", + "type": "integer" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "no_notification": { + "type": "boolean" + }, + "metadata": { + "type": "object" + } + } + }, + "claim_tag": { + "title": "Claim Tag", + "description": "Claim Tags are user defined tags that can be assigned to claim items for easy filtering and grouping.", + "x-resourceId": "claim_tag", + "properties": { + "id": { + "description": "The id of the claim tag. Will be prefixed by `ctag_`.", + "type": "string" + }, + "value": { + "description": "The value that the claim tag holds", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "update_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "country": { + "title": "Country", + "description": "Country details", + "x-resourceId": "country", + "properties": { + "id": { + "description": "The database id of the country", + "type": "integer" + }, + "iso_2": { + "description": "The 2 character ISO code for the country.", + "type": "string" + }, + "iso_3": { + "description": "The 3 character ISO code for the country.", + "type": "string" + }, + "num_code": { + "description": "The numerical ISO code for the country.", + "type": "string" + }, + "name": { + "description": "The normalized country name; in upper case.", + "type": "string" + }, + "display_name": { + "description": "The country name appropriate for display.", + "type": "string" + } + } + }, + "currency": { + "title": "Currency", + "description": "Currency", + "x-resourceId": "currency", + "properties": { + "code": { + "description": "The 3 character ISO code for the currency.", + "type": "string" + }, + "symbol": { + "description": "The symbol used to indicate the currency.", + "type": "string" + }, + "symbol_native": { + "description": "The native symbol used to indicate the currency.", + "type": "string" + }, + "name": { + "description": "The written name of the currency", + "type": "string" + } + } + }, + "customer": { + "title": "Customer", + "description": "Represents a customer", + "x-resourceId": "customer", + "properties": { + "id": { + "type": "string" + }, + "email": { + "type": "string" + }, + "billing_address_id": { + "type": "string" + }, + "billing_address": { + "description": "The Customer's billing address.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "shipping_addresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/address" + } + }, + "first_name": { + "type": "string" + }, + "last_name": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "has_account": { + "type": "boolean" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + } + } + }, + "discount_rule": { + "title": "Discount Rule", + "description": "Holds the rules that governs how a Discount is calculated when applied to a Cart.", + "x-resourceId": "discount_rule", + "properties": { + "id": { + "description": "The id of the Discount Rule. Will be prefixed by `dru_`.", + "type": "string" + }, + "type": { + "description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers.", + "type": "string", + "enum": [ + "fixed", + "percentage", + "free_shipping" + ] + }, + "description": { + "description": "A short description of the discount", + "type": "string" + }, + "value": { + "description": "The value that the discount represents; this will depend on the type of the discount", + "type": "integer" + }, + "allocation": { + "description": "The scope that the discount should apply to.", + "type": "string", + "enum": [ + "total", + "item" + ] + }, + "valid_for": { + "description": "A set of Products that the discount can be used for.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "update_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "discount": { + "title": "Discount", + "description": "Represents a discount that can be applied to a cart for promotional purposes.", + "x-resourceId": "discount", + "properties": { + "id": { + "description": "The id of the Discount. Will be prefixed by `disc_`.", + "type": "string" + }, + "code": { + "description": "A unique code for the discount - this will be used by the customer to apply the discount", + "type": "string" + }, + "is_dynamic": { + "description": "A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts", + "type": "boolean" + }, + "rule": { + "description": "The Discount Rule that governs the behaviour of the Discount", + "anyOf": [ + { + "$ref": "#/components/schemas/discount_rule" + } + ] + }, + "is_disabled": { + "description": "Whether the Discount has been disabled. Disabled discounts cannot be applied to carts", + "type": "boolean" + }, + "parent_discount_id": { + "description": "The Discount that the discount was created from. This will always be a dynamic discount", + "type": "string" + }, + "starts_at": { + "description": "The time at which the discount can be used.", + "type": "string", + "format": "date-time" + }, + "ends_at": { + "description": "The time at which the discount can no longer be used.", + "type": "string", + "format": "date-time" + }, + "regions": { + "description": "The Regions in which the Discount can be used", + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "draft-order": { + "title": "DraftOrder", + "description": "Represents a draft order", + "x-resourceId": "draft-order", + "properties": { + "id": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "open", + "completed" + ] + }, + "display_id": { + "type": "string" + }, + "cart_id": { + "type": "string" + }, + "cart": { + "anyOf": [ + { + "$ref": "#/components/schemas/cart" + } + ] + }, + "order_id": { + "type": "string" + }, + "order": { + "anyOf": [ + { + "$ref": "#/components/schemas/order" + } + ] + }, + "canceled_at": { + "type": "string", + "format": "date-time" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "update_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "completed_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + }, + "idempotency_key": { + "type": "string" + } + } + }, + "fulfillment_item": { + "title": "Fulfillment Item", + "description": "Correlates a Line Item with a Fulfillment, keeping track of the quantity of the Line Item.", + "x-resourceId": "fulfillment_item", + "properties": { + "fulfillment_id": { + "description": "The id of the Fulfillment that the Fulfillment Item belongs to.", + "type": "string" + }, + "item_id": { + "description": "The id of the Line Item that the Fulfillment Item references.", + "type": "string" + }, + "item": { + "description": "The Line Item that the Fulfillment Item references.", + "anyOf": [ + { + "$ref": "#/components/schemas/line_item" + } + ] + }, + "quantity": { + "description": "The quantity of the Line Item that is included in the Fulfillment.", + "type": "integer" + } + } + }, + "fulfillment_provider": { + "title": "Fulfillment Provider", + "description": "Represents a fulfillment provider plugin and holds its installation status.", + "x-resourceId": "fulfillment_provider", + "properties": { + "id": { + "description": "The id of the fulfillment provider as given by the plugin.", + "type": "string" + }, + "is_installed": { + "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", + "type": "boolean" + } + } + }, + "fulfillment": { + "title": "Fulfillment", + "description": "Fulfillments are created once store operators can prepare the purchased goods. Fulfillments will eventually be shipped and hold information about how to track shipments. Fulfillments are created through a provider, which is typically an external shipping aggregator, shipping partner og 3PL, most plugins will have asynchronous communications with these providers through webhooks in order to automatically update and synchronize the state of Fulfillments.", + "x-resourceId": "fulfillment", + "properties": { + "id": { + "description": "The id of the Fulfillment. This value will be prefixed by `ful_`.", + "type": "string" + }, + "claim_order_id": { + "description": "The id of the Claim that the Fulfillment belongs to.", + "type": "string" + }, + "swap_id": { + "description": "The id of the Swap that the Fulfillment belongs to.", + "type": "string" + }, + "order_id": { + "description": "The id of the Order that the Fulfillment belongs to.", + "type": "string" + }, + "provider_id": { + "description": "The id of the Fulfillment Provider responsible for handling the fulfillment", + "type": "string" + }, + "items": { + "description": "The Fulfillment Items in the Fulfillment - these hold information about how many of each Line Item has been fulfilled.", + "type": "array", + "items": { + "$ref": "#/components/schemas/fulfillment_item" + } + }, + "tracking_links": { + "description": "The Tracking Links that can be used to track the status of the Fulfillment, these will usually be provided by the Fulfillment Provider.", + "type": "array", + "items": { + "$ref": "#/components/schemas/tracking_link" + } + }, + "tracking_numbers": { + "deprecated": true, + "description": "The tracking numbers that can be used to track the status of the fulfillment.", + "type": "array", + "items": { + "type": "string" + } + }, + "shipped_at": { + "description": "The date with timezone at which the Fulfillment was shipped.", + "type": "string", + "format": "date-time" + }, + "canceled_at": { + "description": "The date with timezone at which the Fulfillment was canceled.", + "type": "string", + "format": "date-time" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "gift_card_transaction": { + "title": "Gift Card Transaction", + "description": "Gift Card Transactions are created once a Customer uses a Gift Card to pay for their Order", + "x-resourceId": "gift_card_transaction", + "properties": { + "id": { + "description": "The id of the Gift Card Transaction. This value will be prefixed by `gct_`.", + "type": "string" + }, + "gift_card_id": { + "description": "The id of the Gift Card that was used in the transaction.", + "type": "string" + }, + "gift_card": { + "description": "The Gift Card that was used in the transaction.", + "anyOf": [ + { + "$ref": "#/components/schemas/gift_card" + } + ] + }, + "order_id": { + "description": "The id of the Order that the Gift Card was used to pay for.", + "type": "string" + }, + "amount": { + "description": "The amount that was used from the Gift Card.", + "type": "integer" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + } + } + }, + "gift_card": { + "title": "Gift Card", + "description": "Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.", + "x-resourceId": "gift_card", + "properties": { + "id": { + "description": "The id of the Gift Card. This value will be prefixed by `gift_`.", + "type": "string" + }, + "code": { + "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", + "type": "string" + }, + "value": { + "description": "The value that the Gift Card represents.", + "type": "integer" + }, + "balance": { + "description": "The remaining value on the Gift Card.", + "type": "integer" + }, + "region_id": { + "description": "The id of the Region in which the Gift Card is available.", + "type": "string" + }, + "region": { + "description": "The Region in which the Gift Card is available.", + "anyOf": [ + { + "$ref": "#/components/schemas/region" + } + ] + }, + "order_id": { + "description": "The id of the Order that the Gift Card was purchased in.", + "type": "string" + }, + "is_disabled": { + "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", + "type": "boolean" + }, + "ends_at": { + "description": "The time at which the Gift Card can no longer be used.", + "type": "string", + "format": "date-time" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "image": { + "title": "Image", + "description": "Images holds a reference to a URL at which the image file can be found.", + "x-resourceId": "image", + "properties": { + "id": { + "description": "The id of the Image. This value will be prefixed by `img_`.", + "type": "string" + }, + "url": { + "description": "The URL at which the image file can be found.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "update_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "line_item": { + "title": "Line Item", + "description": "Line Items represent purchasable units that can be added to a Cart for checkout. When Line Items are purchased they will get copied to the resulting order and can eventually be referenced in Fulfillments and Returns. Line Items may also be created when processing Swaps and Claims.", + "x-resourceId": "line_item", + "properties": { + "id": { + "description": "The id of the Line Item. This value will be prefixed by `item_`.", + "type": "string" + }, + "cart_id": { + "description": "The id of the Cart that the Line Item belongs to.", + "type": "string" + }, + "order_id": { + "description": "The id of the Order that the Line Item belongs to.", + "type": "string" + }, + "swap_id": { + "description": "The id of the Swap that the Line Item belongs to.", + "type": "string" + }, + "claim_order_id": { + "description": "The id of the Claim that the Line Item belongs to.", + "type": "string" + }, + "title": { + "description": "The title of the Line Item, this should be easily identifiable by the Customer.", + "type": "string" + }, + "description": { + "description": "A more detailed description of the contents of the Line Item.", + "type": "string" + }, + "thumbnail": { + "description": "A URL string to a small image of the contents of the Line Item.", + "type": "string" + }, + "is_giftcard": { + "description": "Flag to indicate if the Line Item is a Gift Card.", + "type": "boolean" + }, + "should_merge": { + "description": "Flag to indicate if new Line Items with the same variant should be merged or added as an additional Line Item.", + "type": "boolean" + }, + "allow_discounts": { + "description": "Flag to indicate if the Line Item should be included when doing discount calculations.", + "type": "boolean" + }, + "unit_price": { + "description": "The price of one unit of the content in the Line Item. This should be in the currency defined by the Cart/Order/Swap/Claim that the Line Item belongs to.", + "type": "boolean" + }, + "variant_id": { + "description": "The id of the Product Variant contained in the Line Item.", + "type": "string" + }, + "variant": { + "description": "The Product Variant contained in the Line Item.", + "anyOf": [ + { + "$ref": "#/components/schemas/product_variant" + } + ] + }, + "quantity": { + "description": "The quantity of the content in the Line Item.", + "type": "integer" + }, + "fulfilled_quantity": { + "description": "The quantity of the Line Item that has been fulfilled.", + "type": "integer" + }, + "returned_quantity": { + "description": "The quantity of the Line Item that has been returned.", + "type": "integer" + }, + "shipped_quantity": { + "description": "The quantity of the Line Item that has been shipped.", + "type": "integer" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + }, + "refundable": { + "description": "The amount that can be refunded from the given Line Item. Takes taxes and discounts into consideration.", + "type": "integer" + } + } + }, + "money_amount": { + "title": "Money Amount", + "description": "Money Amounts represents an amount that a given Product Variant can be purcased for. Each Money Amount either has a Currency or Region associated with it to indicate the pricing in a given Currency or, for fully region-based pricing, the given price in a specific Region. If region-based pricing is used the amount will be in the currency defined for the Reigon.", + "x-resourceId": "money_amount", + "properties": { + "id": { + "description": "The id of the Money Amount. This value will be prefixed by `ma_`.", + "type": "string" + }, + "currency_code": { + "description": "The 3 character currency code that the Money Amount is given in.", + "type": "string" + }, + "amount": { + "description": "The amount in the smallest currecny unit (e.g. cents 100 cents to charge $1) that the Product Variant will cost.", + "type": "integer" + }, + "sale_amount": { + "description": "An optional sale amount that the Product Variant will be available for when defined.", + "type": "integer" + }, + "variant_id": { + "description": "The id of the Product Variant that the Money Amount belongs to.", + "type": "string" + }, + "region_id": { + "description": "The id of the Region that the Money Amount is defined for.", + "type": "string" + }, + "region": { + "description": "The Region that the Money Amount is defined for.", + "anyOf": [ + { + "$ref": "#/components/schemas/region" + } + ] + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + } + } + }, + "notification_provider": { + "title": "Notification Provider", + "description": "Represents a notification provider plugin and holds its installation status.", + "x-resourceId": "notification_provider", + "properties": { + "id": { + "description": "The id of the notification provider as given by the plugin.", + "type": "string" + }, + "is_installed": { + "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", + "type": "boolean" + } + } + }, + "notification": { + "title": "Notification", + "description": "Notifications a communications sent via Notification Providers as a reaction to internal events such as `order.placed`. Notifications can be used to show a chronological timeline for communications sent to a Customer regarding an Order, and enables resends.", + "x-resourceId": "notification", + "properties": { + "id": { + "description": "The id of the Notification. This value will be prefixed by `noti_`.", + "type": "string" + }, + "event_name": { + "description": "The name of the event that the notification was sent for.", + "type": "string" + }, + "resource_type": { + "description": "The type of resource that the Notification refers to.", + "type": "string" + }, + "resource_id": { + "description": "The id of the resource that the Notification refers to.", + "type": "string" + }, + "customer_id": { + "description": "The id of the Customer that the Notification was sent to.", + "type": "string" + }, + "customer": { + "description": "The Customer that the Notification was sent to.", + "anyOf": [ + { + "$ref": "#/components/schemas/customer" + } + ] + }, + "to": { + "description": "The address that the Notification was sent to. This will usually be an email address, but represent other addresses such as a chat bot user id", + "type": "string" + }, + "data": { + "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.", + "type": "object" + }, + "parent_id": { + "description": "The id of the Notification that was originally sent.", + "type": "string" + }, + "resends": { + "description": "The resends that have been completed after the original Notification.", + "type": "array", + "items": { + "$ref": "#/components/schemas/notification_resend" + } + }, + "provider_id": { + "description": "The id of the Notification Provider that handles the Notification.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + } + } + }, + "notification_resend": { + "title": "Notification Resend", + "description": "A resend of a Notification.", + "x-resourceId": "notification_resend", + "properties": { + "id": { + "description": "The id of the Notification. This value will be prefixed by `noti_`.", + "type": "string" + }, + "event_name": { + "description": "The name of the event that the notification was sent for.", + "type": "string" + }, + "resource_type": { + "description": "The type of resource that the Notification refers to.", + "type": "string" + }, + "resource_id": { + "description": "The id of the resource that the Notification refers to.", + "type": "string" + }, + "to": { + "description": "The address that the Notification was sent to. This will usually be an email address, but represent other addresses such as a chat bot user id", + "type": "string" + }, + "data": { + "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.", + "type": "object" + }, + "parent_id": { + "description": "The id of the Notification that was originally sent.", + "type": "string" + }, + "provider_id": { + "description": "The id of the Notification Provider that handles the Notification.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + } + } + }, + "order": { + "title": "Order", + "description": "Represents an order", + "x-resourceId": "order", + "properties": { + "id": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "pending", + "completed", + "archived", + "canceled", + "requires_action" + ] + }, + "fulfillment_status": { + "type": "string", + "enum": [ + "not_fulfilled", + "partially_fulfilled", + "fulfilled", + "partially_shipped", + "shipped", + "partially_returned", + "returned", + "canceled", + "requires_action" + ] + }, + "payment_status": { + "type": "string", + "enum": [ + "not_paid", + "awaiting", + "captured", + "partially_refunded", + "refuneded", + "canceled", + "requires_action" + ] + }, + "display_id": { + "type": "integer" + }, + "cart_id": { + "type": "string" + }, + "currency_code": { + "type": "string" + }, + "tax_rate": { + "type": "integer" + }, + "discounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/discount" + } + }, + "email": { + "type": "string" + }, + "billing_address_id": { + "type": "string" + }, + "billing_address": { + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "shipping_address_id": { + "type": "string" + }, + "shipping_address": { + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/line_item" + } + }, + "region_id": { + "type": "string" + }, + "region": { + "anyOf": [ + { + "$ref": "#/components/schemas/region" + } + ] + }, + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } + }, + "customer_id": { + "type": "string" + }, + "customer": { + "anyOf": [ + { + "$ref": "#/components/schemas/customer" + } + ] + }, + "payment_session": { + "anyOf": [ + { + "$ref": "#/components/schemas/payment_session" + } + ] + }, + "payment_sessions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/payment_session" + } + }, + "payments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/payment" + } + }, + "shipping_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_method" + } + }, + "fulfillments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/fulfillment" + } + }, + "returns": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return" + } + }, + "claims": { + "type": "array", + "items": { + "$ref": "#/components/schemas/claim_order" + } + }, + "refunds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/refund" + } + }, + "swaps": { + "type": "array", + "items": { + "$ref": "#/components/schemas/refund" + } + }, + "gift_card_transactions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card_transaction" + } + }, + "canceled_at": { + "type": "string", + "format": "date-time" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "update_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + }, + "shipping_total": { + "type": "integer" + }, + "discount_total": { + "type": "integer" + }, + "tax_total": { + "type": "integer" + }, + "subtotal": { + "type": "integer" + }, + "refundable_amount": { + "type": "integer" + }, + "gift_card_total": { + "type": "integer" + }, + "paid_total": { + "type": "integer" + }, + "no_notification": { + "type": "boolean" + } + } + }, + "payment_provider": { + "title": "Payment Provider", + "description": "Represents a Payment Provider plugin and holds its installation status.", + "x-resourceId": "payment_provider", + "properties": { + "id": { + "description": "The id of the payment provider as given by the plugin.", + "type": "string" + }, + "is_installed": { + "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", + "type": "boolean" + } + } + }, + "payment_session": { + "title": "Payment Session", + "description": "Payment Sessions are created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, who is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for capture/refunds/etc.", + "x-resourceId": "payment_session", + "properties": { + "id": { + "description": "The id of the Payment Session. This value will be prefixed with `ps_`.", + "type": "string" + }, + "cart_id": { + "description": "The id of the Cart that the Payment Session is created for.", + "type": "string" + }, + "provider_id": { + "description": "The id of the Payment Provider that is responsible for the Payment Session", + "type": "string" + }, + "is_selected": { + "description": "A flag to indicate if the Payment Session has been selected as the method that will be used to complete the purchase.", + "type": "boolean" + }, + "status": { + "description": "Indicates the status of the Payment Session. Will default to `pending`, and will eventually become `authorized`. Payment Sessions may have the status of `requires_more` to indicate that further actions are to be completed by the Customer.", + "type": "string", + "enum": [ + "authorized", + "pending", + "requires_more", + "error", + "canceled" + ] + }, + "data": { + "description": "The data required for the Payment Provider to identify, modify and process the Payment Session. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.", + "type": "object" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + } + } + }, + "payment": { + "title": "Payment", + "description": "Payments represent an amount authorized with a given payment method, Payments can be captured, canceled or refunded.", + "x-resourceId": "payment", + "properties": { + "id": { + "description": "The id of the Payment. This value will be prefixed with `pay_`.", + "type": "string" + }, + "swap_id": { + "description": "The id of the Swap that the Payment is used for.", + "type": "string" + }, + "order_id": { + "description": "The id of the Order that the Payment is used for.", + "type": "string" + }, + "cart_id": { + "description": "The id of the Cart that the Payment Session is created for.", + "type": "string" + }, + "amount": { + "description": "The amount that the Payment has been authorized for.", + "type": "integer" + }, + "currency_code": { + "description": "The 3 character ISO currency code that the Payment is completed in.", + "type": "string" + }, + "amount_refunded": { + "description": "The amount of the original Payment amount that has been refunded back to the Customer.", + "type": "integer" + }, + "provider_id": { + "description": "The id of the Payment Provider that is responsible for the Payment", + "type": "string" + }, + "data": { + "description": "The data required for the Payment Provider to identify, modify and process the Payment. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.", + "type": "object" + }, + "captured_at": { + "description": "The date with timezone at which the Payment was captured.", + "type": "string", + "format": "date-time" + }, + "canceled_at": { + "description": "The date with timezone at which the Payment was canceled.", + "type": "string", + "format": "date-time" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_collection": { + "title": "Product Collection", + "description": "Product Collections represents a group of Products that are related.", + "x-resourceId": "product_collection", + "properties": { + "id": { + "description": "The id of the Product Collection. This value will be prefixed with `pcol_`.", + "type": "string" + }, + "title": { + "description": "The title that the Product Collection is identified by.", + "type": "string" + }, + "handle": { + "description": "A unique string that identifies the Product Collection - can for example be used in slug structures.", + "type": "string" + }, + "products": { + "description": "The Products contained in the Product Collection.", + "type": "array", + "items": { + "type": "object" + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_option_value": { + "title": "Product Option Value", + "description": "A value given to a Product Variant's option set. Product Variant have a Product Option Value for each of the Product Options defined on the Product.", + "x-resourceId": "product_option_value", + "properties": { + "id": { + "description": "The id of the Product Option Value. This value will be prefixed with `optval_`.", + "type": "string" + }, + "value": { + "description": "The value that the Product Variant has defined for the specific Product Option (e.g. if the Product Option is \"Size\" this value could be \"Small\", \"Medium\" or \"Large\").", + "type": "string" + }, + "option_id": { + "description": "The id of the Product Option that the Product Option Value is defined for.", + "type": "string" + }, + "variant_id": { + "description": "The id of the Product Variant that the Product Option Value is defined for.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_option": { + "title": "Product Option", + "description": "Product Options define properties that may vary between different variants of a Product. Common Product Options are \"Size\" and \"Color\", but Medusa doesn't limit what Product Options that can be defined.", + "x-resourceId": "product_option", + "properties": { + "id": { + "description": "The id of the Product Option. This value will be prefixed with `opt_`.", + "type": "string" + }, + "title": { + "description": "The title that the Product Option is defined by (e.g. \"Size\").", + "type": "string" + }, + "values": { + "description": "The Product Option Values that are defined for the Product Option.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product_option_value" + } + }, + "product_id": { + "description": "The id of the Product that the Product Option is defined for.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_tag": { + "title": "Product Tag", + "description": "Product Tags can be added to Products for easy filtering and grouping.", + "x-resourceId": "product_tag", + "properties": { + "id": { + "description": "The id of the Product Tag. This value will be prefixed with `ptag_`.", + "type": "string" + }, + "value": { + "description": "The value that the Product Tag represents (e.g. \"Pants\").", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_type": { + "title": "Product Type", + "description": "Product Type can be added to Products for filtering and reporting purposes.", + "x-resourceId": "product_type", + "properties": { + "id": { + "description": "The id of the Product Type. This value will be prefixed with `ptyp_`.", + "type": "string" + }, + "value": { + "description": "The value that the Product Type represents (e.g. \"Clothing\").", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product_variant": { + "title": "Product Variant", + "description": "Product Variants represent a Product with a specific set of Product Option configurations. The maximum number of Product Variants that a Product can have is given by the number of available Product Option combinations.", + "x-resourceId": "product_variant", + "properties": { + "id": { + "description": "The id of the Product Variant. This value will be prefixed with `variant_`.", + "type": "string" + }, + "title": { + "description": "A title that can be displayed for easy identification of the Product Variant.", + "type": "string" + }, + "product_id": { + "description": "The id of the Product that the Product Variant belongs to.", + "type": "string" + }, + "prices": { + "description": "The Money Amounts defined for the Product Variant. Each Money Amount represents a price in a given currency or a price in a specific Region.", + "type": "array", + "items": { + "$ref": "#/components/schemas/money_amount" + } + }, + "sku": { + "description": "The unique stock keeping unit used to identify the Product Variant. This will usually be a unqiue identifer for the item that is to be shipped, and can be referenced across multiple systems.", + "type": "string" + }, + "barcode": { + "description": "A generic field for a GTIN number that can be used to identify the Product Variant.", + "type": "string" + }, + "ean": { + "description": "An EAN barcode number that can be used to identify the Product Variant.", + "type": "string" + }, + "upc": { + "description": "A UPC barcode number that can be used to identify the Product Variant.", + "type": "string" + }, + "inventory_quantity": { + "description": "The current quantity of the item that is stocked.", + "type": "integer" + }, + "allow_backorder": { + "description": "Whether the Product Variant should be purchasable when `inventory_quantity` is 0.", + "type": "boolean" + }, + "manage_inventory": { + "description": "Whether Medusa should manage inventory for the Product Variant.", + "type": "boolean" + }, + "hs_code": { + "description": "The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "origin_country": { + "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "mid_code": { + "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "material": { + "description": "The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "weight": { + "description": "The weight of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "height": { + "description": "The height of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "width": { + "description": "The width of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "length": { + "description": "The length of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "options": { + "description": "The Product Option Values specified for the Product Variant.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product_option_value" + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "product": { + "title": "Product", + "description": "Products are a grouping of Product Variants that have common properties such as images and descriptions. Products can have multiple options which define the properties that Product Variants differ by.", + "x-resourceId": "product", + "properties": { + "id": { + "description": "The id of the Product. This value will be prefixed with `prod_`.", + "type": "string" + }, + "title": { + "description": "A title that can be displayed for easy identification of the Product.", + "type": "string" + }, + "subtitle": { + "description": "An optional subtitle that can be used to further specify the Product.", + "type": "string" + }, + "description": { + "description": "A short description of the Product.", + "type": "string" + }, + "handle": { + "description": "A unique identifier for the Product (e.g. for slug structure).", + "type": "string" + }, + "is_giftcard": { + "description": "Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.", + "type": "boolean" + }, + "images": { + "description": "Images of the Product", + "type": "array", + "items": { + "$ref": "#/components/schemas/image" + } + }, + "thumbnail": { + "description": "A URL to an image file that can be used to identify the Product.", + "type": "string" + }, + "options": { + "description": "The Product Options that are defined for the Product. Product Variants of the Product will have a unique combination of Product Option Values.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product_option" + } + }, + "variants": { + "description": "The Product Variants that belong to the Product. Each will have a unique combination of Product Option Values.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product_variant" + } + }, + "profile_id": { + "description": "The id of the Shipping Profile that the Product belongs to. Shipping Profiles have a set of defined Shipping Options that can be used to Fulfill a given set of Products.", + "type": "string" + }, + "hs_code": { + "description": "The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "origin_country": { + "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "mid_code": { + "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "material": { + "description": "The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.", + "type": "string" + }, + "weight": { + "description": "The weight of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "height": { + "description": "The height of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "width": { + "description": "The width of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "length": { + "description": "The length of the Product Variant. May be used in shipping rate calculations.", + "type": "string" + }, + "type": { + "description": "The Product Type of the Product (e.g. \"Clothing\")", + "anyOf": [ + { + "$ref": "#/components/schemas/product_type" + } + ] + }, + "collection": { + "description": "The Product Collection that the Product belongs to (e.g. \"SS20\")", + "anyOf": [ + { + "$ref": "#/components/schemas/product_collection" + } + ] + }, + "tags": { + "description": "The Product Tags assigned to the Product.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product_tag" + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "refund": { + "title": "Refund", + "description": "Refund represent an amount of money transfered back to the Customer for a given reason. Refunds may occur in relation to Returns, Swaps and Claims, but can also be initiated by a store operator.", + "x-resourceId": "refund", + "properties": { + "id": { + "description": "The id of the Refund. This value will be prefixed with `ref_`.", + "type": "string" + }, + "order_id": { + "description": "The id of the Order that the Refund is related to.", + "type": "string" + }, + "amount": { + "description": "The amount that has be refunded to the Customer.", + "type": "integer" + }, + "note": { + "description": "An optional note explaining why the amount was refunded.", + "type": "string" + }, + "reason": { + "description": "The reason given for the Refund, will automatically be set when processed as part of a Swap, Claim or Return.", + "type": "string", + "enum": [ + "discount", + "return", + "swap", + "claim", + "other" + ] + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "region": { + "title": "Region", + "description": "Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.", + "x-resourceId": "region", + "properties": { + "id": { + "description": "The id of the Region. This value will be prefixed with `reg_`.", + "type": "string" + }, + "name": { + "description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.", + "type": "string" + }, + "currency_code": { + "description": "The 3 character ISO currency code that Customers will shop in in the Region.", + "type": "string" + }, + "tax_rate": { + "description": "The tax rate that should be charged on purchases in the Region.", + "type": "number" + }, + "tax_code": { + "description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.", + "type": "string" + }, + "countries": { + "description": "The countries that are included in the Region.", + "type": "array", + "items": { + "$ref": "#/components/schemas/country" + } + }, + "payment_providers": { + "description": "The Payment Providers that can be used to process Payments in the Region.", + "type": "array", + "items": { + "$ref": "#/components/schemas/payment_provider" + } + }, + "fulfillment_providers": { + "description": "The Fulfillment Providers that can be used to fulfill orders in the Region.", + "type": "array", + "items": { + "$ref": "#/components/schemas/fulfillment_provider" + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "return_item": { + "title": "Return Item", + "description": "Correlates a Line Item with a Return, keeping track of the quantity of the Line Item that will be returned.", + "x-resourceId": "return_item", + "properties": { + "return_id": { + "description": "The id of the Return that the Return Item belongs to.", + "type": "string" + }, + "item_id": { + "description": "The id of the Line Item that the Return Item references.", + "type": "string" + }, + "item": { + "description": "The Line Item that the Return Item references.", + "anyOf": [ + { + "$ref": "#/components/schemas/line_item" + } + ] + }, + "quantity": { + "description": "The quantity of the Line Item that is included in the Return.", + "type": "integer" + }, + "is_requested": { + "description": "Whether the Return Item was requested initially or received unexpectedly in the warehouse.", + "type": "boolean" + }, + "requested_quantity": { + "description": "The quantity that was originally requested to be returned.", + "type": "integer" + }, + "recieved_quantity": { + "description": "The quantity that was received in the warehouse.", + "type": "integer" + }, + "reason": { + "description": "The reason for returning the item.", + "anyOf": [ + { + "$ref": "#/components/schemas/return_reason" + } + ] + }, + "note": { + "description": "An optional note with additional details about the Return.", + "type": "string" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "return_reason": { + "title": "Return Reason", + "description": "A Reason for why a given product is returned. A Return Reason can be used on Return Items in order to indicate why a Line Item was returned.", + "x-resourceId": "return_reason", + "properties": { + "id": { + "description": "The id of the Return Reason will start with `rr_`.", + "type": "string" + }, + "description": { + "description": "A description of the Reason.", + "type": "string" + }, + "label": { + "description": "A text that can be displayed to the Customer as a reason.", + "type": "string" + }, + "value": { + "description": "The value to identify the reason by.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "return": { + "title": "Return", + "description": "Return orders hold information about Line Items that a Customer wishes to send back, along with how the items will be returned. Returns can be used as part of a Swap.", + "x-resourceId": "return", + "properties": { + "id": { + "description": "The id of the Return. This value will be prefixed with `ret_`.", + "type": "string" + }, + "status": { + "description": "Status of the Return.", + "type": "string", + "enum": [ + "requested", + "received", + "requires_action" + ] + }, + "items": { + "description": "The Return Items that will be shipped back to the warehouse. type: array items: $ref: " + }, + "swap_id": { + "description": "The id of the Swap that the Return is a part of.", + "type": "string" + }, + "order_id": { + "description": "The id of the Order that the Return is made from.", + "type": "string" + }, + "claim_order_id": { + "description": "The id of the Claim that the Return is a part of.", + "type": "string" + }, + "shipping_method": { + "description": "The Shipping Method that will be used to send the Return back. Can be null if the Customer facilitates the return shipment themselves.", + "anyOf": [ + { + "$ref": "#/components/schemas/shipping_method" + } + ] + }, + "shipping_data": { + "description": "Data about the return shipment as provided by the Fulfilment Provider that handles the return shipment.", + "type": "object" + }, + "refund_amount": { + "description": "The amount that should be refunded as a result of the return.", + "type": "integer" + }, + "received_at": { + "description": "The date with timezone at which the return was received.", + "type": "string", + "format": "date-time" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "no_notification": { + "description": "When set to true, no notification will be sent related to this return.", + "type": "boolean" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "shipping_method": { + "title": "Shipping Method", + "description": "Shipping Methods represent a way in which an Order or Return can be shipped. Shipping Methods are built from a Shipping Option, but may contain additional details, that can be necessary for the Fulfillment Provider to handle the shipment.", + "x-resourceId": "shipping_method", + "properties": { + "id": { + "description": "The id of the Shipping Method. This value will be prefixed with `sm_`.", + "type": "string" + }, + "shipping_option_id": { + "description": "The id of the Shipping Option that the Shipping Method is built from.", + "type": "string" + }, + "shipping_option": { + "description": "The Shipping Option that the Shipping Method is built from.", + "anyOf": [ + { + "$ref": "#/components/schemas/shipping_option" + } + ] + }, + "order_id": { + "description": "The id of the Order that the Shipping Method is used on.", + "type": "string" + }, + "return_id": { + "description": "The id of the Return that the Shipping Method is used on.", + "type": "string" + }, + "swap_id": { + "description": "The id of the Swap that the Shipping Method is used on.", + "type": "string" + }, + "cart_id": { + "description": "The id of the Cart that the Shipping Method is used on.", + "type": "string" + }, + "claim_order_id": { + "description": "The id of the Claim that the Shipping Method is used on.", + "type": "string" + }, + "price": { + "description": "The amount to charge for the Shipping Method. The currency of the price is defined by the Region that the Order that the Shipping Method belongs to is a part of.", + "type": "integer" + }, + "data": { + "description": "Additional data that the Fulfillment Provider needs to fulfill the shipment. This is used in combination with the Shipping Options data, and may contain information such as a drop point id.", + "type": "object" + } + } + }, + "shipping_option_requirement": { + "title": "Shipping Option Requirement", + "description": "A requirement that a Cart must satisfy for the Shipping Option to be available to the Cart.", + "x-resourceId": "shipping_option_requirement", + "properties": { + "id": { + "description": "The id of the Shipping Option Requirement. This value will be prefixed with `sor_`.", + "type": "string" + }, + "shipping_option_id": { + "description": "The id of the Shipping Option that the Shipping Option Requirement belongs to.", + "type": "string" + }, + "type": { + "description": "The type of the requirement, this defines how the value will be compared to the Cart's total. `min_subtotal` requirements define the minimum subtotal that is needed for the Shipping Option to be available, while the `max_subtotal` defines the maximum subtotal that the Cart can have for the Shipping Option to be available.", + "type": "string", + "enum": [ + "min_subtotal", + "max_subtotal" + ] + }, + "amount": { + "description": "The amount to compare the Cart subtotal to.", + "type": "integer" + } + } + }, + "shipping_option": { + "title": "Shipping Option", + "description": "Shipping Options represent a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.", + "x-resourceId": "shipping_option", + "properties": { + "id": { + "description": "The id of the Shipping Option. This value will be prefixed with `so_`.", + "type": "string" + }, + "name": { + "description": "The name given to the Shipping Option - this may be displayed to the Customer.", + "type": "string" + }, + "region_id": { + "description": "The id of the Region that the Shipping Option belongs to.", + "type": "string" + }, + "region": { + "description": "The id of the Region that the Shipping Option belongs to.", + "anyOf": [ + { + "$ref": "#/components/schemas/region" + } + ] + }, + "profile_id": { + "description": "The id of the Shipping Profile that the Shipping Option belongs to. Shipping Profiles have a set of defined Shipping Options that can be used to Fulfill a given set of Products.", + "type": "string" + }, + "provider_id": { + "description": "The id of the Fulfillment Provider, that will be used to process Fulfillments from the Shipping Option.", + "type": "string" + }, + "price_type": { + "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", + "type": "string", + "enum": [ + "flat_rate", + "calculated" + ] + }, + "amount": { + "description": "The amount to charge for shipping when the Shipping Option price type is `flat_rate`.", + "type": "integer" + }, + "is_return": { + "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", + "type": "boolean" + }, + "requirements": { + "description": "The requirements that must be satisfied for the Shipping Option to be available for a Cart.", + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_option_requirement" + } + }, + "data": { + "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", + "type": "object" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "shipping_profile": { + "title": "Shipping Profile", + "description": "Shipping Profiles have a set of defined Shipping Options that can be used to fulfill a given set of Products.", + "x-resourceId": "shipping_profile", + "properties": { + "id": { + "description": "The id of the Shipping Profile. This value will be prefixed with `sp_`.", + "type": "string" + }, + "name": { + "description": "The name given to the Shipping profile - this may be displayed to the Customer.", + "type": "string" + }, + "type": { + "description": "The type of the Shipping Profile, may be `default`, `gift_card` or `custom`.", + "type": "string", + "enum": [ + "default", + "gift_card", + "custom" + ] + }, + "products": { + "description": "The Products that the Shipping Profile defines Shipping Options for.", + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + }, + "shipping_options": { + "description": "The Shipping Options that can be used to fulfill the Products in the Shipping Profile.", + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/components/schemas/shipping_option" + } + ] + } + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "store": { + "title": "Store", + "description": "Holds settings for the Store, such as name, currencies, etc.", + "x-resourceId": "store", + "properties": { + "id": { + "description": "The id of the Store. This value will be prefixed with `store_`.", + "type": "string" + }, + "name": { + "description": "The name of the Store - this may be displayed to the Customer.", + "type": "string" + }, + "default_currency_code": { + "description": "The default currency code used when no other currency code is specified.", + "type": "string" + }, + "currencies": { + "description": "The currencies that are enabled for the Store.", + "type": "array", + "items": { + "$ref": "#/components/schemas/currency" + } + }, + "swap_link_template": { + "description": "A template to generate Swap links from use {{cart_id}} to include the Swap's `cart_id` in the link.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "swap": { + "title": "Swap", + "description": "Swaps can be created when a Customer wishes to exchange Products that they have purchased to different Products. Swaps consist of a Return of previously purchased Products and a Fulfillment of new Products, the amount paid for the Products being returned will be used towards payment for the new Products. In the case where the amount paid for the the Products being returned exceed the amount to be paid for the new Products, a Refund will be issued for the difference.", + "x-resourceId": "swap", + "properties": { + "id": { + "description": "The id of the Swap. This value will be prefixed with `swap_`.", + "type": "string" + }, + "fulfillment_status": { + "description": "The status of the Fulfillment of the Swap.", + "type": "string", + "enum": [ + "not_fulfilled", + "partially_fulfilled", + "fulfilled", + "partially_shipped", + "shipped", + "partially_returned", + "returned", + "canceled", + "requires_action" + ] + }, + "payment_status": { + "description": "The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.", + "type": "string", + "enum": [ + "not_paid", + "awaiting", + "captured", + "canceled", + "difference_refunded", + "requires_action" + ] + }, + "order_id": { + "description": "The id of the Order where the Line Items to be returned where purchased.", + "type": "string" + }, + "additional_items": { + "description": "The new Line Items to ship to the Customer.", + "type": "array", + "items": { + "$ref": "#/components/schemas/line_item" + } + }, + "return_order": { + "description": "The Return that is issued for the return part of the Swap.", + "anyOf": [ + { + "$ref": "#/components/schemas/return" + } + ] + }, + "fulfillments": { + "description": "The Fulfillments used to send the new Line Items.", + "type": "array", + "items": { + "$ref": "#/components/schemas/fulfillment" + } + }, + "payment": { + "description": "The Payment authorized when the Swap requires an additional amount to be charged from the Customer.", + "anyOf": [ + { + "$ref": "#/components/schemas/payment" + } + ] + }, + "difference_due": { + "description": "The difference that is paid or refunded as a result of the Swap. May be negative when the amount paid for the returned items exceed the total of the new Products.", + "type": "integer" + }, + "shipping_address": { + "description": "The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "shipping_methods": { + "description": "The Shipping Methods used to fulfill the addtional items purchased.", + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_method" + } + }, + "cart_id": { + "description": "The id of the Cart that the Customer will use to confirm the Swap.", + "type": "string" + }, + "confirmed_at": { + "description": "The date with timezone at which the Swap was confirmed by the Customer.", + "type": "string", + "format": "date-time" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "no_notification": { + "description": "If set to true, no notification will be sent related to this swap", + "type": "boolean" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "tracking_link": { + "title": "Tracking Link", + "description": "Tracking Link holds information about tracking numbers for a Fulfillment. Tracking Links can optionally contain a URL that can be visited to see the status of the shipment.", + "x-resourceId": "tracking_link", + "properties": { + "id": { + "description": "The id of the Tracking Link. This value will be prefixed with `tlink_`.", + "type": "string" + }, + "url": { + "description": "The URL at which the status of the shipment can be tracked.", + "type": "string" + }, + "tracking_number": { + "description": "The tracking number given by the shipping carrier.", + "type": "string" + }, + "fulfillment_id": { + "description": "The id of the Fulfillment that the Tracking Link references.", + "type": "string" + }, + "created_at": { + "description": "The date with timezone at which the resource was created.", + "type": "string", + "format": "date-time" + }, + "updated_at": { + "description": "The date with timezone at which the resource was last updated.", + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "description": "The date with timezone at which the resource was deleted.", + "type": "string", + "format": "date-time" + }, + "metadata": { + "description": "An optional key-value map with additional information.", + "type": "object" + } + } + }, + "user": { + "title": "User", + "description": "Represents a User who can manage store settings.", + "x-resourceId": "user", + "properties": { + "id": { + "description": "The unique id of the User. This will be prefixed with `usr_`", + "type": "string" + }, + "email": { + "description": "The email of the User", + "type": "string" + }, + "first_name": { + "type": "string" + }, + "last_name": { + "description": "The Customer's billing address.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "updated_at": { + "type": "string", + "format": "date-time" + }, + "deleted_at": { + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object" + } + } + } + } + } +} \ No newline at end of file diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml new file mode 100644 index 0000000000..b36b9dd521 --- /dev/null +++ b/docs/api/store-spec3.yaml @@ -0,0 +1,3822 @@ +openapi: 3.0.0 +info: + version: 1.0.0 + title: Medusa Storefront API + license: + name: MIT +tags: + - name: Auth + description: >- + Auth endpoints allows authorization of admin Users and manages their + sessions. + - name: Cart + x-resourceId: cart + - name: Collection + x-resourceId: product_collection + - name: Customer + x-resourceId: customer + - name: Discount + x-resourceId: discount + - name: Gift Card + x-resourceId: gift_card + - name: Notification + x-resourceId: notification + - name: Order + x-resourceId: order + - name: Product + x-resourceId: product + - name: Region + x-resourceId: region + - name: Return + x-resourceId: return + - name: Shipping Option + x-resourceId: shipping_option + - name: Shipping Profile + x-resourceId: shipping_profile + - name: Swap + x-resourceId: swap + - name: Product Variant + x-resourceId: product_variant +servers: + - url: 'https://api.medusa-commerce.com/store' +paths: + /auth: + post: + operationId: PostAuth + summary: Authenticate Customer + description: >- + Logs a Customer in and authorizes them to view their details. Successful + authentication will set a session cookie in the Customer's browser. + parameters: [] + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - password + properties: + email: + type: string + description: The Customer's email. + password: + type: string + description: The Customer's password. + delete: + operationId: DeleteAuth + summary: Log out + description: Destroys a Customer's authenticated session. + tags: + - Auth + responses: + '200': + description: OK + get: + operationId: GetAuth + summary: Get Session + description: Gets the currently logged in Customer. + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/auth/{email}': + get: + operationId: GetAuthEmail + summary: Check if email has account + description: Checks if a Customer with the given email has signed up. + parameters: + - in: path + name: email + required: true + description: The Customer's email. + schema: + type: string + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + exists: + type: boolean + '/carts/{id}/shipping-methods': + post: + operationId: PostCartsCartShippingMethod + description: Adds a Shipping Method to the Cart. + summary: Add a Shipping Method + tags: + - Cart + parameters: + - in: path + name: id + required: true + description: The cart id. + schema: + type: string + responses: + '200': + description: A successful response + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - option_id + properties: + option_id: + type: string + description: id of the shipping option to create the method from + data: + type: object + description: >- + Used to hold any data that the shipping method may need to + process the fulfillment of the order. Look at the + documentation for your installed fulfillment providers to + find out what to send. + '/carts/{id}/complete-cart': + post: + summary: Complete a Cart + operationId: PostCartsCartComplete + description: >- + Completes a cart. The following steps will be performed. Payment + authorization is attempted and if more work is required, we simply + return the cart for further updates. If payment is authorized and order + is not yet created, we make sure to do so. The completion of a cart can + be performed idempotently with a provided header `Idempotency-Key`. If + not provided, we will generate one for the request. + parameters: + - in: path + name: id + required: true + description: The Cart id. + schema: + type: string + tags: + - Cart + responses: + '200': + description: >- + If a cart was successfully authorized, but requires further action + from the user the response body will contain the cart with an + updated payment session. If the Cart was successfully completed the + response body will contain the newly created Order. + content: + application/json: + schema: + oneOf: + - type: object + properties: + order: + $ref: '#/components/schemas/order' + - type: object + properties: + cart: + $ref: '#/components/schemas/cart' + /carts: + post: + summary: Create a Cart + operationId: PostCart + description: >- + Creates a Cart within the given region and with the initial items. If no + `region_id` is provided the cart will be associated with the first + Region available. If no items are provided the cart will be empty after + creation. If a user is logged in the cart's customer id and email will + be set. + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + items: + description: >- + An optional array of `variant_id`, `quantity` pairs to + generate Line Items from. + type: array + items: + properties: + variant_id: + description: >- + The id of the Product Variant to generate a Line Item + from. + type: string + quantity: + description: The quantity of the Product Variant to add + type: integer + context: + description: >- + An optional object to provide context to the Cart. The + `context` field is automatically populated with `ip` and + `user_agent` + type: object + tags: + - Cart + responses: + '200': + description: Successfully created a new Cart + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items': + post: + operationId: PostCartsCartLineItems + summary: Add a Line Item + description: >- + Generates a Line Item with a given Product Variant and adds it to the + Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart to add the Line Item to. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - variant_id + - quantity + properties: + variant_id: + type: string + description: >- + The id of the Product Variant to generate the Line Item + from. + quantity: + type: integer + description: The quantity of the Product Variant to add to the Line Item. + metadata: + type: object + description: >- + An optional key-value map with additional details about the + Line Item. + '/carts/{id}/payment-sessions': + post: + operationId: PostCartsCartPaymentSessions + summary: Initialize Payment Sessions + description: >- + Creates Payment Sessions for each of the available Payment Providers in + the Cart's Region. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/discounts/{code}': + delete: + operationId: DeleteCartsCartDiscountsDiscount + description: Removes a Discount from a Cart. + summary: Remove Discount from Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: code + required: true + description: The unique Discount code. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items/{line_id}': + delete: + operationId: DeleteCartsCartLineItemsItem + summary: Delete a Line Item + description: Removes a Line Item from a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartLineItemsItem + summary: Update a Line Item + description: Updates a Line Item if the desired quantity can be fulfilled. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - quantity + properties: + quantity: + type: integer + description: The quantity to set the Line Item to. + '/carts/{id}/payment-sessions/{provider_id}': + delete: + operationId: DeleteCartsCartPaymentSessionsSession + summary: Delete a Payment Session + description: >- + Deletes a Payment Session on a Cart. May be useful if a payment has + failed. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: >- + The id of the Payment Provider used to create the Payment Session to + be deleted. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartPaymentSessionsSession + summary: Refresh a Payment Session + description: >- + Refreshes a Payment Session to ensure that it is in sync with the Cart - + this is usually not necessary. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: >- + The id of the Payment Provider that created the Payment Session to + be refreshed. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}': + get: + operationId: GetCartsCart + summary: Retrieve a Cart + description: Retrieves a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/payment-session': + post: + operationId: PostCartsCartPaymentSession + summary: Select a Payment Session + description: >- + Selects a Payment Session as the session intended to be used towards the + completion of the Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + properties: + provider_id: + type: string + description: The id of the Payment Provider. + '/store/carts/{id}': + post: + operationId: PostCartsCart + summary: Update a Cart" + description: Updates a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + email: + type: string + description: An email to be used on the Cart. + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + shipping_address: + description: The Address to be used for shipping. + anyOf: + - $ref: '#/components/schemas/address' + gift_cards: + description: An array of Gift Card codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Gift Card is identified by. + type: string + discounts: + description: An array of Discount codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Discount is identifed by. + type: string + customer_id: + description: The id of the Customer to associate the Cart with. + type: string + context: + description: An optional object to provide context to the Cart. + type: object + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/payment-session/update': + post: + operationId: PostCartsCartPaymentSessionUpdate + summary: Update a Payment Session + description: Updates a Payment Session with additional data. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + - data + properties: + provider_id: + type: string + description: >- + The id of the Payment Provider responsible for the Payment + Session to update. + data: + type: object + description: The data to update the payment session with. + '/gift-cards/{code}': + get: + operationId: GetGiftCardsCode + summary: Retrieve Gift Card by Code + description: Retrieves a Gift Card by its associated unqiue code. + parameters: + - in: path + name: code + required: true + description: The unique Gift Card code. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + description: The id of the Gift Card + code: + description: The code of the Gift Card + value: + description: The original value of the Gift Card. + balance: + description: The current balanace of the Gift Card + region: + $ref: '#/components/schemas/region' + '/customers/{id}/addresses': + post: + operationId: PostCustomersCustomerAddresses + summary: Add a Shipping Address + description: Adds a Shipping Address to a Customer's saved addresses. + parameters: + - in: path + name: id + required: true + description: The Customer id. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + address: + description: The Address to add to the Customer. + anyOf: + - $ref: '#/components/schemas/address' + tags: + - Customer + responses: + '200': + description: A successful response + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer account. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + - password + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + password: + type: string + description: The Customer's password for login. + phone: + type: string + description: The Customer's phone number. + '/customers/{id}/addresses/{address_id}': + delete: + operationId: DeleteCustomersCustomerAddressesAddress + summary: Delete an Address + description: Removes an Address from the Customer's saved addresse. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + - in: path + name: address_id + required: true + description: The id of the Address to remove. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomerAddressesAddress + summary: Update a Shipping Address + description: Updates a Customer's saved Shipping Address. + parameters: + - in: path + name: id + required: true + description: The Customer id. + schema: + type: string + - in: path + name: address_id + required: true + description: The id of the Address to update. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + address: + description: The updated Address. + anyOf: + - $ref: '#/components/schemas/address' + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieves a Customer + description: >- + Retrieves a Customer - the Customer must be logged in to retrieve their + details. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update Customer details + description: Updates a Customer's saved details. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + description: The Customer's first name. + type: string + last_name: + description: The Customer's last name. + type: string + password: + description: The Customer's password. + type: string + phone: + description: The Customer's phone number. + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}/payment-methods': + get: + operationId: GetCustomersCustomerPaymentMethods + summary: Retrieve saved payment methods + description: >- + Retrieves a list of a Customer's saved payment methods. Payment methods + are saved with Payment Providers and it is their responsibility to fetch + saved methods. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + payment_methods: + type: array + items: + properties: + provider_id: + type: string + description: >- + The id of the Payment Provider where the payment + method is saved. + data: + type: object + description: >- + The data needed for the Payment Provider to use the + saved payment method. + '/customers/{id}/orders': + get: + operationId: GetCustomersCustomerOrders + summary: Retrieve Customer Orders + description: Retrieves a list of a Customer's Orders. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + payment_methods: + type: array + items: + $ref: '#/components/schemas/order' + '/customers/{id}/password-token': + post: + operationId: PostCustomersCustomerPasswordToken + summary: Creates a reset password token + description: >- + Creates a reset password token to be used in a subsequent + /reset-password request. The password token should be sent out of band + e.g. via email and will not be returned. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '204': + description: OK + '/customers/{id}/reset-password': + post: + operationId: PostCustomersCustomerResetPassword + summary: Resets Customer password + description: >- + Resets a Customer's password using a password token created by a + previous /password-token request. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - token + - password + properties: + email: + type: string + description: The Customer's email. + token: + type: string + description: The password token created by a /password-token request. + password: + type: string + description: The new password to set for the Customer. + '/orders/cart/{cart_id}': + get: + operationId: GetOrdersOrderCartId + summary: Retrieves Order by Cart id + description: >- + Retrieves an Order by the id of the Cart that was used to create the + Order. + parameters: + - in: path + name: cart_id + required: true + description: The id of Cart. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieves an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + /orders: + get: + operationId: GetOrders + summary: Look Up an Order + description: >- + Looks for an Order with a given `display_id`, `email` pair. The + `display_id`, `email` pair must match in order for the Order to be + returned. + parameters: + - in: query + name: display_id + required: true + description: The display id given to the Order. + schema: + type: number + - in: query + name: email + required: true + description: The email of the Order with the given display_id. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/products/{id}': + get: + operationId: GetProductsProduct + summary: Retrieves a Product + description: Retrieves a Product. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + /products: + get: + operationId: GetProducts + summary: List Products + description: Retrieves a list of Products. + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + count: + description: The total number of Products. + type: integer + offset: + description: The offset for pagination. + type: integer + limit: + description: 'The maxmimum number of Products to return,' + type: integer + products: + type: array + items: + $ref: '#/components/schemas/product' + '/regions/{id}': + get: + operationId: GetRegionsRegion + summary: Retrieves a Region + description: Retrieves a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + /regions: + get: + operationId: GetRegions + summary: List Regions + description: Retrieves a list of Regions. + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + count: + description: The total number of regions. + type: integer + offset: + description: The offset for pagination. + type: integer + limit: + description: 'The maxmimum number of regions to return,' + type: integer + regions: + type: array + items: + $ref: '#/components/schemas/region' + /returns: + post: + operationId: PostReturns + summary: Create Return + description: Creates a Return for an Order. + requestBody: + content: + application/json: + schema: + properties: + order_id: + type: string + description: The id of the Order to create the Return from. + items: + description: The items to include in the Return. + type: array + items: + properties: + item_id: + description: The id of the Line Item from the Order. + type: string + quantity: + description: The quantity to return. + type: integer + return_shipping: + description: >- + If the Return is to be handled by the store operator the + Customer can choose a Return Shipping Method. Alternatvely + the Customer can handle the Return themselves. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + /shipping-options: + get: + operationId: GetShippingOptions + summary: Retrieve Shipping Options + description: Retrieves a list of Shipping Options. + parameters: + - in: query + name: is_return + description: >- + Whether return Shipping Options should be included. By default all + Shipping Options are returned. + schema: + type: boolean + - in: query + name: product_ids + description: A comma separated list of Product ids to filter Shipping Options by. + schema: + type: string + - in: query + name: region_id + description: the Region to retrieve Shipping Options from. + schema: + type: string + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_options: + type: array + items: + $ref: '#/components/schemas/shipping_option' + '/shipping-options/{cart_id}': + get: + operationId: GetShippingOptionsCartId + summary: Retrieve Shipping Options for Cart + description: Retrieves a list of Shipping Options available to a cart. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Shipping Option + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + shipping_options: + type: array + items: + $ref: '#/components/schemas/shipping_option' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' + '/variants/{variant_id}': + get: + operationId: GetVariantsVariant + summary: Retrieve a Product Variant + description: Retrieves a Product Variant by id + parameters: + - in: path + name: variant_id + required: true + description: The id of the Product Variant. + schema: + type: string + tags: + - Product Variant + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + variant: + $ref: '#/components/schemas/product_variant' + /variants: + get: + operationId: GetVariants + summary: Retrieve Product Variants + description: Retrieves a list of Product Variants + parameters: + - in: query + name: ids + description: A comma separated list of Product Variant ids to filter by. + schema: + type: string + tags: + - Product Variant + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + variants: + type: array + items: + $ref: '#/components/schemas/product_variant' +components: + schemas: + address: + title: Address + description: An address. + x-resourceId: address + properties: + id: + type: string + customer_id: + type: string + company: + type: string + first_name: + type: string + last_name: + type: string + address_1: + type: string + address_2: + type: string + city: + type: string + country_code: + type: string + country: + $ref: '#/components/schemas/country' + cart: + title: Cart + description: Represents a user cart + x-resourceId: cart + properties: + id: + type: string + email: + type: string + billing_address_id: + type: string + billing_address: + $ref: '#/components/schemas/address' + shipping_address_id: + type: string + shipping_address: + $ref: '#/components/schemas/address' + items: + type: array + items: + $ref: '#/components/schemas/line_item' + region_id: + type: string + region: + $ref: '#/components/schemas/region' + discounts: + type: array + items: + $ref: '#/components/schemas/region' + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + customer_id: + type: string + customer: + $ref: '#/components/schemas/customer' + payment_session: + $ref: '#/components/schemas/payment_session' + payment_sessions: + type: array + items: + $ref: '#/components/schemas/payment_session' + payment: + $ref: '#/components/schemas/payment' + shipping_methods: + type: array + items: + $ref: '#/components/schemas/shipping_method' + type: + type: string + enum: + - default + - swap + - payment_link + completed_at: + type: string + format: date-time + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + shipping_total: + type: integer + discount_total: + type: integer + tax_total: + type: integer + subtotal: + type: integer + refundable_amount: + type: integer + gift_card_total: + type: integer + claim_image: + title: Claim Image + description: Represents photo documentation of a claim. + x-resourceId: claim_image + properties: + id: + type: string + claim_item_id: + type: string + url: + type: string + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + claim_item: + title: Claim Item + description: >- + Represents a claimed item along with information about the reasons for + the claim. + x-resourceId: claim_item + properties: + id: + type: string + images: + type: array + items: + $ref: '#/components/schemas/claim_image' + claim_order_id: + type: string + item_id: + type: string + item: + description: The Line Item that the claim refers to + $ref: '#/components/schemas/line_item' + variant_id: + type: string + variant: + description: The Product Variant that is claimed. + $ref: '#/components/schemas/product_variant' + reason: + description: The reason for the claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + note: + description: 'An optional note about the claim, for additional information' + type: string + quantity: + description: >- + The quantity of the item that is being claimed; must be less than or + equal to the amount purchased in the original order. + type: integer + tags: + description: User defined tags for easy filtering and grouping. + type: array + items: + $ref: '#/components/schemas/claim_tag' + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + claim_order: + title: Claim Order + description: >- + Claim Orders represent a group of faulty or missing items. Each claim + order consists of a subset of items associated with an original order, + and can contain additional information about fulfillments and returns. + x-resourceId: claim_order + properties: + id: + type: string + type: + type: string + enum: + - refund + - replace + payment_status: + type: string + enum: + - na + - not_refunded + - refunded + fulfillment_status: + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + claim_items: + description: The items that have been claimed + type: array + items: + $ref: '#/components/schemas/claim_item' + additional_items: + description: >- + Refers to the new items to be shipped when the claim order has the + type `replace` + type: array + items: + $ref: '#/components/schemas/line_item' + order_id: + description: The id of the order that the claim comes from. + type: string + return_order: + description: Holds information about the return if the claim is to be returned + $ref: '#/components/schemas/return' + shipping_address_id: + description: The id of the address that the new items should be shipped to + type: string + shipping_address: + description: The address that the new items should be shipped to + $ref: '#/components/schemas/address' + shipping_methods: + description: The shipping methods that the claim order will be shipped with. + type: array + items: + $ref: '#/components/schemas/shipping_method' + fulfillments: + description: The fulfillments of the new items to be shipped + type: array + items: + $ref: '#/components/schemas/fulfillment' + refund_amount: + description: The amount that will be refunded in conjunction with the claim + type: integer + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + no_notification: + type: boolean + metadata: + type: object + claim_tag: + title: Claim Tag + description: >- + Claim Tags are user defined tags that can be assigned to claim items for + easy filtering and grouping. + x-resourceId: claim_tag + properties: + id: + description: The id of the claim tag. Will be prefixed by `ctag_`. + type: string + value: + description: The value that the claim tag holds + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + country: + title: Country + description: Country details + x-resourceId: country + properties: + id: + description: The database id of the country + type: integer + iso_2: + description: The 2 character ISO code for the country. + type: string + iso_3: + description: The 3 character ISO code for the country. + type: string + num_code: + description: The numerical ISO code for the country. + type: string + name: + description: The normalized country name; in upper case. + type: string + display_name: + description: The country name appropriate for display. + type: string + currency: + title: Currency + description: Currency + x-resourceId: currency + properties: + code: + description: The 3 character ISO code for the currency. + type: string + symbol: + description: The symbol used to indicate the currency. + type: string + symbol_native: + description: The native symbol used to indicate the currency. + type: string + name: + description: The written name of the currency + type: string + customer: + title: Customer + description: Represents a customer + x-resourceId: customer + properties: + id: + type: string + email: + type: string + billing_address_id: + type: string + billing_address: + description: The Customer's billing address. + anyOf: + - $ref: '#/components/schemas/address' + shipping_addresses: + type: array + items: + $ref: '#/components/schemas/address' + first_name: + type: string + last_name: + type: string + phone: + type: string + has_account: + type: boolean + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + discount_rule: + title: Discount Rule + description: >- + Holds the rules that governs how a Discount is calculated when applied + to a Cart. + x-resourceId: discount_rule + properties: + id: + description: The id of the Discount Rule. Will be prefixed by `dru_`. + type: string + type: + description: >- + The type of the Discount, can be `fixed` for discounts that reduce + the price by a fixed amount, `percentage` for percentage reductions + or `free_shipping` for shipping vouchers. + type: string + enum: + - fixed + - percentage + - free_shipping + description: + description: A short description of the discount + type: string + value: + description: >- + The value that the discount represents; this will depend on the type + of the discount + type: integer + allocation: + description: The scope that the discount should apply to. + type: string + enum: + - total + - item + valid_for: + description: A set of Products that the discount can be used for. + type: array + items: + $ref: '#/components/schemas/product' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + discount: + title: Discount + description: >- + Represents a discount that can be applied to a cart for promotional + purposes. + x-resourceId: discount + properties: + id: + description: The id of the Discount. Will be prefixed by `disc_`. + type: string + code: + description: >- + A unique code for the discount - this will be used by the customer + to apply the discount + type: string + is_dynamic: + description: >- + A flag to indicate if multiple instances of the discount can be + generated. I.e. for newsletter discounts + type: boolean + rule: + description: The Discount Rule that governs the behaviour of the Discount + anyOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + description: >- + Whether the Discount has been disabled. Disabled discounts cannot be + applied to carts + type: boolean + parent_discount_id: + description: >- + The Discount that the discount was created from. This will always be + a dynamic discount + type: string + starts_at: + description: The time at which the discount can be used. + type: string + format: date-time + ends_at: + description: The time at which the discount can no longer be used. + type: string + format: date-time + regions: + description: The Regions in which the Discount can be used + type: array + items: + $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + draft-order: + title: DraftOrder + description: Represents a draft order + x-resourceId: draft-order + properties: + id: + type: string + status: + type: string + enum: + - open + - completed + display_id: + type: string + cart_id: + type: string + cart: + anyOf: + - $ref: '#/components/schemas/cart' + order_id: + type: string + order: + anyOf: + - $ref: '#/components/schemas/order' + canceled_at: + type: string + format: date-time + created_at: + type: string + format: date-time + update_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + completed_at: + type: string + format: date-time + metadata: + type: object + idempotency_key: + type: string + fulfillment_item: + title: Fulfillment Item + description: >- + Correlates a Line Item with a Fulfillment, keeping track of the quantity + of the Line Item. + x-resourceId: fulfillment_item + properties: + fulfillment_id: + description: The id of the Fulfillment that the Fulfillment Item belongs to. + type: string + item_id: + description: The id of the Line Item that the Fulfillment Item references. + type: string + item: + description: The Line Item that the Fulfillment Item references. + anyOf: + - $ref: '#/components/schemas/line_item' + quantity: + description: The quantity of the Line Item that is included in the Fulfillment. + type: integer + fulfillment_provider: + title: Fulfillment Provider + description: >- + Represents a fulfillment provider plugin and holds its installation + status. + x-resourceId: fulfillment_provider + properties: + id: + description: The id of the fulfillment provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + fulfillment: + title: Fulfillment + description: >- + Fulfillments are created once store operators can prepare the purchased + goods. Fulfillments will eventually be shipped and hold information + about how to track shipments. Fulfillments are created through a + provider, which is typically an external shipping aggregator, shipping + partner og 3PL, most plugins will have asynchronous communications with + these providers through webhooks in order to automatically update and + synchronize the state of Fulfillments. + x-resourceId: fulfillment + properties: + id: + description: The id of the Fulfillment. This value will be prefixed by `ful_`. + type: string + claim_order_id: + description: The id of the Claim that the Fulfillment belongs to. + type: string + swap_id: + description: The id of the Swap that the Fulfillment belongs to. + type: string + order_id: + description: The id of the Order that the Fulfillment belongs to. + type: string + provider_id: + description: >- + The id of the Fulfillment Provider responsible for handling the + fulfillment + type: string + items: + description: >- + The Fulfillment Items in the Fulfillment - these hold information + about how many of each Line Item has been fulfilled. + type: array + items: + $ref: '#/components/schemas/fulfillment_item' + tracking_links: + description: >- + The Tracking Links that can be used to track the status of the + Fulfillment, these will usually be provided by the Fulfillment + Provider. + type: array + items: + $ref: '#/components/schemas/tracking_link' + tracking_numbers: + deprecated: true + description: >- + The tracking numbers that can be used to track the status of the + fulfillment. + type: array + items: + type: string + shipped_at: + description: The date with timezone at which the Fulfillment was shipped. + type: string + format: date-time + canceled_at: + description: The date with timezone at which the Fulfillment was canceled. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + gift_card_transaction: + title: Gift Card Transaction + description: >- + Gift Card Transactions are created once a Customer uses a Gift Card to + pay for their Order + x-resourceId: gift_card_transaction + properties: + id: + description: >- + The id of the Gift Card Transaction. This value will be prefixed by + `gct_`. + type: string + gift_card_id: + description: The id of the Gift Card that was used in the transaction. + type: string + gift_card: + description: The Gift Card that was used in the transaction. + anyOf: + - $ref: '#/components/schemas/gift_card' + order_id: + description: The id of the Order that the Gift Card was used to pay for. + type: string + amount: + description: The amount that was used from the Gift Card. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + gift_card: + title: Gift Card + description: >- + Gift Cards are redeemable and represent a value that can be used towards + the payment of an Order. + x-resourceId: gift_card + properties: + id: + description: The id of the Gift Card. This value will be prefixed by `gift_`. + type: string + code: + description: >- + The unique code that identifies the Gift Card. This is used by the + Customer to redeem the value of the Gift Card. + type: string + value: + description: The value that the Gift Card represents. + type: integer + balance: + description: The remaining value on the Gift Card. + type: integer + region_id: + description: The id of the Region in which the Gift Card is available. + type: string + region: + description: The Region in which the Gift Card is available. + anyOf: + - $ref: '#/components/schemas/region' + order_id: + description: The id of the Order that the Gift Card was purchased in. + type: string + is_disabled: + description: >- + Whether the Gift Card has been disabled. Disabled Gift Cards cannot + be applied to carts. + type: boolean + ends_at: + description: The time at which the Gift Card can no longer be used. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + image: + title: Image + description: Images holds a reference to a URL at which the image file can be found. + x-resourceId: image + properties: + id: + description: The id of the Image. This value will be prefixed by `img_`. + type: string + url: + description: The URL at which the image file can be found. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + update_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + line_item: + title: Line Item + description: >- + Line Items represent purchasable units that can be added to a Cart for + checkout. When Line Items are purchased they will get copied to the + resulting order and can eventually be referenced in Fulfillments and + Returns. Line Items may also be created when processing Swaps and + Claims. + x-resourceId: line_item + properties: + id: + description: The id of the Line Item. This value will be prefixed by `item_`. + type: string + cart_id: + description: The id of the Cart that the Line Item belongs to. + type: string + order_id: + description: The id of the Order that the Line Item belongs to. + type: string + swap_id: + description: The id of the Swap that the Line Item belongs to. + type: string + claim_order_id: + description: The id of the Claim that the Line Item belongs to. + type: string + title: + description: >- + The title of the Line Item, this should be easily identifiable by + the Customer. + type: string + description: + description: A more detailed description of the contents of the Line Item. + type: string + thumbnail: + description: A URL string to a small image of the contents of the Line Item. + type: string + is_giftcard: + description: Flag to indicate if the Line Item is a Gift Card. + type: boolean + should_merge: + description: >- + Flag to indicate if new Line Items with the same variant should be + merged or added as an additional Line Item. + type: boolean + allow_discounts: + description: >- + Flag to indicate if the Line Item should be included when doing + discount calculations. + type: boolean + unit_price: + description: >- + The price of one unit of the content in the Line Item. This should + be in the currency defined by the Cart/Order/Swap/Claim that the + Line Item belongs to. + type: boolean + variant_id: + description: The id of the Product Variant contained in the Line Item. + type: string + variant: + description: The Product Variant contained in the Line Item. + anyOf: + - $ref: '#/components/schemas/product_variant' + quantity: + description: The quantity of the content in the Line Item. + type: integer + fulfilled_quantity: + description: The quantity of the Line Item that has been fulfilled. + type: integer + returned_quantity: + description: The quantity of the Line Item that has been returned. + type: integer + shipped_quantity: + description: The quantity of the Line Item that has been shipped. + type: integer + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + refundable: + description: >- + The amount that can be refunded from the given Line Item. Takes + taxes and discounts into consideration. + type: integer + money_amount: + title: Money Amount + description: >- + Money Amounts represents an amount that a given Product Variant can be + purcased for. Each Money Amount either has a Currency or Region + associated with it to indicate the pricing in a given Currency or, for + fully region-based pricing, the given price in a specific Region. If + region-based pricing is used the amount will be in the currency defined + for the Reigon. + x-resourceId: money_amount + properties: + id: + description: The id of the Money Amount. This value will be prefixed by `ma_`. + type: string + currency_code: + description: The 3 character currency code that the Money Amount is given in. + type: string + amount: + description: >- + The amount in the smallest currecny unit (e.g. cents 100 cents to + charge $1) that the Product Variant will cost. + type: integer + sale_amount: + description: >- + An optional sale amount that the Product Variant will be available + for when defined. + type: integer + variant_id: + description: The id of the Product Variant that the Money Amount belongs to. + type: string + region_id: + description: The id of the Region that the Money Amount is defined for. + type: string + region: + description: The Region that the Money Amount is defined for. + anyOf: + - $ref: '#/components/schemas/region' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + notification_provider: + title: Notification Provider + description: >- + Represents a notification provider plugin and holds its installation + status. + x-resourceId: notification_provider + properties: + id: + description: The id of the notification provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + notification: + title: Notification + description: >- + Notifications a communications sent via Notification Providers as a + reaction to internal events such as `order.placed`. Notifications can be + used to show a chronological timeline for communications sent to a + Customer regarding an Order, and enables resends. + x-resourceId: notification + properties: + id: + description: The id of the Notification. This value will be prefixed by `noti_`. + type: string + event_name: + description: The name of the event that the notification was sent for. + type: string + resource_type: + description: The type of resource that the Notification refers to. + type: string + resource_id: + description: The id of the resource that the Notification refers to. + type: string + customer_id: + description: The id of the Customer that the Notification was sent to. + type: string + customer: + description: The Customer that the Notification was sent to. + anyOf: + - $ref: '#/components/schemas/customer' + to: + description: >- + The address that the Notification was sent to. This will usually be + an email address, but represent other addresses such as a chat bot + user id + type: string + data: + description: >- + The data that the Notification was sent with. This contains all the + data necessary for the Notification Provider to initiate a resend. + type: object + parent_id: + description: The id of the Notification that was originally sent. + type: string + resends: + description: >- + The resends that have been completed after the original + Notification. + type: array + items: + $ref: '#/components/schemas/notification_resend' + provider_id: + description: The id of the Notification Provider that handles the Notification. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + notification_resend: + title: Notification Resend + description: A resend of a Notification. + x-resourceId: notification_resend + properties: + id: + description: The id of the Notification. This value will be prefixed by `noti_`. + type: string + event_name: + description: The name of the event that the notification was sent for. + type: string + resource_type: + description: The type of resource that the Notification refers to. + type: string + resource_id: + description: The id of the resource that the Notification refers to. + type: string + to: + description: >- + The address that the Notification was sent to. This will usually be + an email address, but represent other addresses such as a chat bot + user id + type: string + data: + description: >- + The data that the Notification was sent with. This contains all the + data necessary for the Notification Provider to initiate a resend. + type: object + parent_id: + description: The id of the Notification that was originally sent. + type: string + provider_id: + description: The id of the Notification Provider that handles the Notification. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + order: + title: Order + description: Represents an order + x-resourceId: order + properties: + id: + type: string + status: + type: string + enum: + - pending + - completed + - archived + - canceled + - requires_action + fulfillment_status: + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + payment_status: + type: string + enum: + - not_paid + - awaiting + - captured + - partially_refunded + - refuneded + - canceled + - requires_action + display_id: + type: integer + cart_id: + type: string + currency_code: + type: string + tax_rate: + type: integer + discounts: + type: array + items: + $ref: '#/components/schemas/discount' + email: + type: string + billing_address_id: + type: string + billing_address: + anyOf: + - $ref: '#/components/schemas/address' + shipping_address_id: + type: string + shipping_address: + anyOf: + - $ref: '#/components/schemas/address' + items: + type: array + items: + $ref: '#/components/schemas/line_item' + region_id: + type: string + region: + anyOf: + - $ref: '#/components/schemas/region' + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + customer_id: + type: string + customer: + anyOf: + - $ref: '#/components/schemas/customer' + payment_session: + anyOf: + - $ref: '#/components/schemas/payment_session' + payment_sessions: + type: array + items: + $ref: '#/components/schemas/payment_session' + payments: + type: array + items: + $ref: '#/components/schemas/payment' + shipping_methods: + type: array + items: + $ref: '#/components/schemas/shipping_method' + fulfillments: + type: array + items: + $ref: '#/components/schemas/fulfillment' + returns: + type: array + items: + $ref: '#/components/schemas/return' + claims: + type: array + items: + $ref: '#/components/schemas/claim_order' + refunds: + type: array + items: + $ref: '#/components/schemas/refund' + swaps: + type: array + items: + $ref: '#/components/schemas/refund' + gift_card_transactions: + type: array + items: + $ref: '#/components/schemas/gift_card_transaction' + canceled_at: + type: string + format: date-time + created_at: + type: string + format: date-time + update_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object + shipping_total: + type: integer + discount_total: + type: integer + tax_total: + type: integer + subtotal: + type: integer + refundable_amount: + type: integer + gift_card_total: + type: integer + paid_total: + type: integer + no_notification: + type: boolean + payment_provider: + title: Payment Provider + description: Represents a Payment Provider plugin and holds its installation status. + x-resourceId: payment_provider + properties: + id: + description: The id of the payment provider as given by the plugin. + type: string + is_installed: + description: >- + Whether the plugin is installed in the current version. Plugins that + are no longer installed are not deleted by will have this field set + to `false`. + type: boolean + payment_session: + title: Payment Session + description: >- + Payment Sessions are created when a Customer initilizes the checkout + flow, and can be used to hold the state of a payment flow. Each Payment + Session is controlled by a Payment Provider, who is responsible for the + communication with external payment services. Authorized Payment + Sessions will eventually get promoted to Payments to indicate that they + are authorized for capture/refunds/etc. + x-resourceId: payment_session + properties: + id: + description: >- + The id of the Payment Session. This value will be prefixed with + `ps_`. + type: string + cart_id: + description: The id of the Cart that the Payment Session is created for. + type: string + provider_id: + description: >- + The id of the Payment Provider that is responsible for the Payment + Session + type: string + is_selected: + description: >- + A flag to indicate if the Payment Session has been selected as the + method that will be used to complete the purchase. + type: boolean + status: + description: >- + Indicates the status of the Payment Session. Will default to + `pending`, and will eventually become `authorized`. Payment Sessions + may have the status of `requires_more` to indicate that further + actions are to be completed by the Customer. + type: string + enum: + - authorized + - pending + - requires_more + - error + - canceled + data: + description: >- + The data required for the Payment Provider to identify, modify and + process the Payment Session. Typically this will be an object that + holds an id to the external payment session, but can be an empty + object if the Payment Provider doesn't hold any state. + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + payment: + title: Payment + description: >- + Payments represent an amount authorized with a given payment method, + Payments can be captured, canceled or refunded. + x-resourceId: payment + properties: + id: + description: The id of the Payment. This value will be prefixed with `pay_`. + type: string + swap_id: + description: The id of the Swap that the Payment is used for. + type: string + order_id: + description: The id of the Order that the Payment is used for. + type: string + cart_id: + description: The id of the Cart that the Payment Session is created for. + type: string + amount: + description: The amount that the Payment has been authorized for. + type: integer + currency_code: + description: The 3 character ISO currency code that the Payment is completed in. + type: string + amount_refunded: + description: >- + The amount of the original Payment amount that has been refunded + back to the Customer. + type: integer + provider_id: + description: The id of the Payment Provider that is responsible for the Payment + type: string + data: + description: >- + The data required for the Payment Provider to identify, modify and + process the Payment. Typically this will be an object that holds an + id to the external payment session, but can be an empty object if + the Payment Provider doesn't hold any state. + type: object + captured_at: + description: The date with timezone at which the Payment was captured. + type: string + format: date-time + canceled_at: + description: The date with timezone at which the Payment was canceled. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_collection: + title: Product Collection + description: Product Collections represents a group of Products that are related. + x-resourceId: product_collection + properties: + id: + description: >- + The id of the Product Collection. This value will be prefixed with + `pcol_`. + type: string + title: + description: The title that the Product Collection is identified by. + type: string + handle: + description: >- + A unique string that identifies the Product Collection - can for + example be used in slug structures. + type: string + products: + description: The Products contained in the Product Collection. + type: array + items: + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_option_value: + title: Product Option Value + description: >- + A value given to a Product Variant's option set. Product Variant have a + Product Option Value for each of the Product Options defined on the + Product. + x-resourceId: product_option_value + properties: + id: + description: >- + The id of the Product Option Value. This value will be prefixed with + `optval_`. + type: string + value: + description: >- + The value that the Product Variant has defined for the specific + Product Option (e.g. if the Product Option is "Size" this value + could be "Small", "Medium" or "Large"). + type: string + option_id: + description: >- + The id of the Product Option that the Product Option Value is + defined for. + type: string + variant_id: + description: >- + The id of the Product Variant that the Product Option Value is + defined for. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_option: + title: Product Option + description: >- + Product Options define properties that may vary between different + variants of a Product. Common Product Options are "Size" and "Color", + but Medusa doesn't limit what Product Options that can be defined. + x-resourceId: product_option + properties: + id: + description: >- + The id of the Product Option. This value will be prefixed with + `opt_`. + type: string + title: + description: The title that the Product Option is defined by (e.g. "Size"). + type: string + values: + description: The Product Option Values that are defined for the Product Option. + type: array + items: + $ref: '#/components/schemas/product_option_value' + product_id: + description: The id of the Product that the Product Option is defined for. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_tag: + title: Product Tag + description: Product Tags can be added to Products for easy filtering and grouping. + x-resourceId: product_tag + properties: + id: + description: The id of the Product Tag. This value will be prefixed with `ptag_`. + type: string + value: + description: The value that the Product Tag represents (e.g. "Pants"). + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_type: + title: Product Type + description: >- + Product Type can be added to Products for filtering and reporting + purposes. + x-resourceId: product_type + properties: + id: + description: >- + The id of the Product Type. This value will be prefixed with + `ptyp_`. + type: string + value: + description: The value that the Product Type represents (e.g. "Clothing"). + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product_variant: + title: Product Variant + description: >- + Product Variants represent a Product with a specific set of Product + Option configurations. The maximum number of Product Variants that a + Product can have is given by the number of available Product Option + combinations. + x-resourceId: product_variant + properties: + id: + description: >- + The id of the Product Variant. This value will be prefixed with + `variant_`. + type: string + title: + description: >- + A title that can be displayed for easy identification of the Product + Variant. + type: string + product_id: + description: The id of the Product that the Product Variant belongs to. + type: string + prices: + description: >- + The Money Amounts defined for the Product Variant. Each Money Amount + represents a price in a given currency or a price in a specific + Region. + type: array + items: + $ref: '#/components/schemas/money_amount' + sku: + description: >- + The unique stock keeping unit used to identify the Product Variant. + This will usually be a unqiue identifer for the item that is to be + shipped, and can be referenced across multiple systems. + type: string + barcode: + description: >- + A generic field for a GTIN number that can be used to identify the + Product Variant. + type: string + ean: + description: >- + An EAN barcode number that can be used to identify the Product + Variant. + type: string + upc: + description: >- + A UPC barcode number that can be used to identify the Product + Variant. + type: string + inventory_quantity: + description: The current quantity of the item that is stocked. + type: integer + allow_backorder: + description: >- + Whether the Product Variant should be purchasable when + `inventory_quantity` is 0. + type: boolean + manage_inventory: + description: Whether Medusa should manage inventory for the Product Variant. + type: boolean + hs_code: + description: >- + The Harmonized System code of the Product Variant. May be used by + Fulfillment Providers to pass customs information to shipping + carriers. + type: string + origin_country: + description: >- + The country in which the Product Variant was produced. May be used + by Fulfillment Providers to pass customs information to shipping + carriers. + type: string + mid_code: + description: >- + The Manufacturers Identification code that identifies the + manufacturer of the Product Variant. May be used by Fulfillment + Providers to pass customs information to shipping carriers. + type: string + material: + description: >- + The material and composition that the Product Variant is made of, + May be used by Fulfillment Providers to pass customs information to + shipping carriers. + type: string + weight: + description: >- + The weight of the Product Variant. May be used in shipping rate + calculations. + type: string + height: + description: >- + The height of the Product Variant. May be used in shipping rate + calculations. + type: string + width: + description: >- + The width of the Product Variant. May be used in shipping rate + calculations. + type: string + length: + description: >- + The length of the Product Variant. May be used in shipping rate + calculations. + type: string + options: + description: The Product Option Values specified for the Product Variant. + type: array + items: + $ref: '#/components/schemas/product_option_value' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + product: + title: Product + description: >- + Products are a grouping of Product Variants that have common properties + such as images and descriptions. Products can have multiple options + which define the properties that Product Variants differ by. + x-resourceId: product + properties: + id: + description: The id of the Product. This value will be prefixed with `prod_`. + type: string + title: + description: >- + A title that can be displayed for easy identification of the + Product. + type: string + subtitle: + description: >- + An optional subtitle that can be used to further specify the + Product. + type: string + description: + description: A short description of the Product. + type: string + handle: + description: A unique identifier for the Product (e.g. for slug structure). + type: string + is_giftcard: + description: >- + Whether the Product represents a Gift Card. Products that represent + Gift Cards will automatically generate a redeemable Gift Card code + once they are purchased. + type: boolean + images: + description: Images of the Product + type: array + items: + $ref: '#/components/schemas/image' + thumbnail: + description: A URL to an image file that can be used to identify the Product. + type: string + options: + description: >- + The Product Options that are defined for the Product. Product + Variants of the Product will have a unique combination of Product + Option Values. + type: array + items: + $ref: '#/components/schemas/product_option' + variants: + description: >- + The Product Variants that belong to the Product. Each will have a + unique combination of Product Option Values. + type: array + items: + $ref: '#/components/schemas/product_variant' + profile_id: + description: >- + The id of the Shipping Profile that the Product belongs to. Shipping + Profiles have a set of defined Shipping Options that can be used to + Fulfill a given set of Products. + type: string + hs_code: + description: >- + The Harmonized System code of the Product Variant. May be used by + Fulfillment Providers to pass customs information to shipping + carriers. + type: string + origin_country: + description: >- + The country in which the Product Variant was produced. May be used + by Fulfillment Providers to pass customs information to shipping + carriers. + type: string + mid_code: + description: >- + The Manufacturers Identification code that identifies the + manufacturer of the Product Variant. May be used by Fulfillment + Providers to pass customs information to shipping carriers. + type: string + material: + description: >- + The material and composition that the Product Variant is made of, + May be used by Fulfillment Providers to pass customs information to + shipping carriers. + type: string + weight: + description: >- + The weight of the Product Variant. May be used in shipping rate + calculations. + type: string + height: + description: >- + The height of the Product Variant. May be used in shipping rate + calculations. + type: string + width: + description: >- + The width of the Product Variant. May be used in shipping rate + calculations. + type: string + length: + description: >- + The length of the Product Variant. May be used in shipping rate + calculations. + type: string + type: + description: The Product Type of the Product (e.g. "Clothing") + anyOf: + - $ref: '#/components/schemas/product_type' + collection: + description: The Product Collection that the Product belongs to (e.g. "SS20") + anyOf: + - $ref: '#/components/schemas/product_collection' + tags: + description: The Product Tags assigned to the Product. + type: array + items: + $ref: '#/components/schemas/product_tag' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + refund: + title: Refund + description: >- + Refund represent an amount of money transfered back to the Customer for + a given reason. Refunds may occur in relation to Returns, Swaps and + Claims, but can also be initiated by a store operator. + x-resourceId: refund + properties: + id: + description: The id of the Refund. This value will be prefixed with `ref_`. + type: string + order_id: + description: The id of the Order that the Refund is related to. + type: string + amount: + description: The amount that has be refunded to the Customer. + type: integer + note: + description: An optional note explaining why the amount was refunded. + type: string + reason: + description: >- + The reason given for the Refund, will automatically be set when + processed as part of a Swap, Claim or Return. + type: string + enum: + - discount + - return + - swap + - claim + - other + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + region: + title: Region + description: >- + Regions hold settings for how Customers in a given geographical location + shop. The is, for example, where currencies and tax rates are defined. A + Region can consist of multiple countries to accomodate common shopping + settings across countries. + x-resourceId: region + properties: + id: + description: The id of the Region. This value will be prefixed with `reg_`. + type: string + name: + description: >- + The name of the region as displayed to the customer. If the Region + only has one country it is recommended to write the country name. + type: string + currency_code: + description: >- + The 3 character ISO currency code that Customers will shop in in the + Region. + type: string + tax_rate: + description: The tax rate that should be charged on purchases in the Region. + type: number + tax_code: + description: >- + The tax code used on purchases in the Region. This may be used by + other systems for accounting purposes. + type: string + countries: + description: The countries that are included in the Region. + type: array + items: + $ref: '#/components/schemas/country' + payment_providers: + description: >- + The Payment Providers that can be used to process Payments in the + Region. + type: array + items: + $ref: '#/components/schemas/payment_provider' + fulfillment_providers: + description: >- + The Fulfillment Providers that can be used to fulfill orders in the + Region. + type: array + items: + $ref: '#/components/schemas/fulfillment_provider' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + return_item: + title: Return Item + description: >- + Correlates a Line Item with a Return, keeping track of the quantity of + the Line Item that will be returned. + x-resourceId: return_item + properties: + return_id: + description: The id of the Return that the Return Item belongs to. + type: string + item_id: + description: The id of the Line Item that the Return Item references. + type: string + item: + description: The Line Item that the Return Item references. + anyOf: + - $ref: '#/components/schemas/line_item' + quantity: + description: The quantity of the Line Item that is included in the Return. + type: integer + is_requested: + description: >- + Whether the Return Item was requested initially or received + unexpectedly in the warehouse. + type: boolean + requested_quantity: + description: The quantity that was originally requested to be returned. + type: integer + recieved_quantity: + description: The quantity that was received in the warehouse. + type: integer + reason: + description: The reason for returning the item. + anyOf: + - $ref: '#/components/schemas/return_reason' + note: + description: An optional note with additional details about the Return. + type: string + metadata: + description: An optional key-value map with additional information. + type: object + return_reason: + title: Return Reason + description: >- + A Reason for why a given product is returned. A Return Reason can be + used on Return Items in order to indicate why a Line Item was returned. + x-resourceId: return_reason + properties: + id: + description: The id of the Return Reason will start with `rr_`. + type: string + description: + description: A description of the Reason. + type: string + label: + description: A text that can be displayed to the Customer as a reason. + type: string + value: + description: The value to identify the reason by. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + return: + title: Return + description: >- + Return orders hold information about Line Items that a Customer wishes + to send back, along with how the items will be returned. Returns can be + used as part of a Swap. + x-resourceId: return + properties: + id: + description: The id of the Return. This value will be prefixed with `ret_`. + type: string + status: + description: Status of the Return. + type: string + enum: + - requested + - received + - requires_action + items: + description: >- + The Return Items that will be shipped back to the warehouse. type: + array items: $ref: + swap_id: + description: The id of the Swap that the Return is a part of. + type: string + order_id: + description: The id of the Order that the Return is made from. + type: string + claim_order_id: + description: The id of the Claim that the Return is a part of. + type: string + shipping_method: + description: >- + The Shipping Method that will be used to send the Return back. Can + be null if the Customer facilitates the return shipment themselves. + anyOf: + - $ref: '#/components/schemas/shipping_method' + shipping_data: + description: >- + Data about the return shipment as provided by the Fulfilment + Provider that handles the return shipment. + type: object + refund_amount: + description: The amount that should be refunded as a result of the return. + type: integer + received_at: + description: The date with timezone at which the return was received. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + no_notification: + description: >- + When set to true, no notification will be sent related to this + return. + type: boolean + metadata: + description: An optional key-value map with additional information. + type: object + shipping_method: + title: Shipping Method + description: >- + Shipping Methods represent a way in which an Order or Return can be + shipped. Shipping Methods are built from a Shipping Option, but may + contain additional details, that can be necessary for the Fulfillment + Provider to handle the shipment. + x-resourceId: shipping_method + properties: + id: + description: >- + The id of the Shipping Method. This value will be prefixed with + `sm_`. + type: string + shipping_option_id: + description: >- + The id of the Shipping Option that the Shipping Method is built + from. + type: string + shipping_option: + description: The Shipping Option that the Shipping Method is built from. + anyOf: + - $ref: '#/components/schemas/shipping_option' + order_id: + description: The id of the Order that the Shipping Method is used on. + type: string + return_id: + description: The id of the Return that the Shipping Method is used on. + type: string + swap_id: + description: The id of the Swap that the Shipping Method is used on. + type: string + cart_id: + description: The id of the Cart that the Shipping Method is used on. + type: string + claim_order_id: + description: The id of the Claim that the Shipping Method is used on. + type: string + price: + description: >- + The amount to charge for the Shipping Method. The currency of the + price is defined by the Region that the Order that the Shipping + Method belongs to is a part of. + type: integer + data: + description: >- + Additional data that the Fulfillment Provider needs to fulfill the + shipment. This is used in combination with the Shipping Options + data, and may contain information such as a drop point id. + type: object + shipping_option_requirement: + title: Shipping Option Requirement + description: >- + A requirement that a Cart must satisfy for the Shipping Option to be + available to the Cart. + x-resourceId: shipping_option_requirement + properties: + id: + description: >- + The id of the Shipping Option Requirement. This value will be + prefixed with `sor_`. + type: string + shipping_option_id: + description: >- + The id of the Shipping Option that the Shipping Option Requirement + belongs to. + type: string + type: + description: >- + The type of the requirement, this defines how the value will be + compared to the Cart's total. `min_subtotal` requirements define the + minimum subtotal that is needed for the Shipping Option to be + available, while the `max_subtotal` defines the maximum subtotal + that the Cart can have for the Shipping Option to be available. + type: string + enum: + - min_subtotal + - max_subtotal + amount: + description: The amount to compare the Cart subtotal to. + type: integer + shipping_option: + title: Shipping Option + description: >- + Shipping Options represent a way in which an Order or Return can be + shipped. Shipping Options have an associated Fulfillment Provider that + will be used when the fulfillment of an Order is initiated. Shipping + Options themselves cannot be added to Carts, but serve as a template for + Shipping Methods. This distinction makes it possible to customize + individual Shipping Methods with additional information. + x-resourceId: shipping_option + properties: + id: + description: >- + The id of the Shipping Option. This value will be prefixed with + `so_`. + type: string + name: + description: >- + The name given to the Shipping Option - this may be displayed to the + Customer. + type: string + region_id: + description: The id of the Region that the Shipping Option belongs to. + type: string + region: + description: The id of the Region that the Shipping Option belongs to. + anyOf: + - $ref: '#/components/schemas/region' + profile_id: + description: >- + The id of the Shipping Profile that the Shipping Option belongs to. + Shipping Profiles have a set of defined Shipping Options that can be + used to Fulfill a given set of Products. + type: string + provider_id: + description: >- + The id of the Fulfillment Provider, that will be used to process + Fulfillments from the Shipping Option. + type: string + price_type: + description: >- + The type of pricing calculation that is used when creatin Shipping + Methods from the Shipping Option. Can be `flat_rate` for fixed + prices or `calculated` if the Fulfillment Provider can provide price + calulations. + type: string + enum: + - flat_rate + - calculated + amount: + description: >- + The amount to charge for shipping when the Shipping Option price + type is `flat_rate`. + type: integer + is_return: + description: >- + Flag to indicate if the Shipping Option can be used for Return + shipments. + type: boolean + requirements: + description: >- + The requirements that must be satisfied for the Shipping Option to + be available for a Cart. + type: array + items: + $ref: '#/components/schemas/shipping_option_requirement' + data: + description: >- + The data needed for the Fulfillment Provider to identify the + Shipping Option. + type: object + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + shipping_profile: + title: Shipping Profile + description: >- + Shipping Profiles have a set of defined Shipping Options that can be + used to fulfill a given set of Products. + x-resourceId: shipping_profile + properties: + id: + description: >- + The id of the Shipping Profile. This value will be prefixed with + `sp_`. + type: string + name: + description: >- + The name given to the Shipping profile - this may be displayed to + the Customer. + type: string + type: + description: >- + The type of the Shipping Profile, may be `default`, `gift_card` or + `custom`. + type: string + enum: + - default + - gift_card + - custom + products: + description: The Products that the Shipping Profile defines Shipping Options for. + type: array + items: + $ref: '#/components/schemas/product' + shipping_options: + description: >- + The Shipping Options that can be used to fulfill the Products in the + Shipping Profile. + type: array + items: + anyOf: + - $ref: '#/components/schemas/shipping_option' + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + store: + title: Store + description: 'Holds settings for the Store, such as name, currencies, etc.' + x-resourceId: store + properties: + id: + description: The id of the Store. This value will be prefixed with `store_`. + type: string + name: + description: The name of the Store - this may be displayed to the Customer. + type: string + default_currency_code: + description: >- + The default currency code used when no other currency code is + specified. + type: string + currencies: + description: The currencies that are enabled for the Store. + type: array + items: + $ref: '#/components/schemas/currency' + swap_link_template: + description: >- + A template to generate Swap links from use {{cart_id}} to include + the Swap's `cart_id` in the link. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + swap: + title: Swap + description: >- + Swaps can be created when a Customer wishes to exchange Products that + they have purchased to different Products. Swaps consist of a Return of + previously purchased Products and a Fulfillment of new Products, the + amount paid for the Products being returned will be used towards payment + for the new Products. In the case where the amount paid for the the + Products being returned exceed the amount to be paid for the new + Products, a Refund will be issued for the difference. + x-resourceId: swap + properties: + id: + description: The id of the Swap. This value will be prefixed with `swap_`. + type: string + fulfillment_status: + description: The status of the Fulfillment of the Swap. + type: string + enum: + - not_fulfilled + - partially_fulfilled + - fulfilled + - partially_shipped + - shipped + - partially_returned + - returned + - canceled + - requires_action + payment_status: + description: >- + The status of the Payment of the Swap. The payment may either refer + to the refund of an amount or the authorization of a new amount. + type: string + enum: + - not_paid + - awaiting + - captured + - canceled + - difference_refunded + - requires_action + order_id: + description: >- + The id of the Order where the Line Items to be returned where + purchased. + type: string + additional_items: + description: The new Line Items to ship to the Customer. + type: array + items: + $ref: '#/components/schemas/line_item' + return_order: + description: The Return that is issued for the return part of the Swap. + anyOf: + - $ref: '#/components/schemas/return' + fulfillments: + description: The Fulfillments used to send the new Line Items. + type: array + items: + $ref: '#/components/schemas/fulfillment' + payment: + description: >- + The Payment authorized when the Swap requires an additional amount + to be charged from the Customer. + anyOf: + - $ref: '#/components/schemas/payment' + difference_due: + description: >- + The difference that is paid or refunded as a result of the Swap. May + be negative when the amount paid for the returned items exceed the + total of the new Products. + type: integer + shipping_address: + description: >- + The Address to send the new Line Items to - in most cases this will + be the same as the shipping address on the Order. + anyOf: + - $ref: '#/components/schemas/address' + shipping_methods: + description: The Shipping Methods used to fulfill the addtional items purchased. + type: array + items: + $ref: '#/components/schemas/shipping_method' + cart_id: + description: The id of the Cart that the Customer will use to confirm the Swap. + type: string + confirmed_at: + description: >- + The date with timezone at which the Swap was confirmed by the + Customer. + type: string + format: date-time + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + no_notification: + description: 'If set to true, no notification will be sent related to this swap' + type: boolean + metadata: + description: An optional key-value map with additional information. + type: object + tracking_link: + title: Tracking Link + description: >- + Tracking Link holds information about tracking numbers for a + Fulfillment. Tracking Links can optionally contain a URL that can be + visited to see the status of the shipment. + x-resourceId: tracking_link + properties: + id: + description: >- + The id of the Tracking Link. This value will be prefixed with + `tlink_`. + type: string + url: + description: The URL at which the status of the shipment can be tracked. + type: string + tracking_number: + description: The tracking number given by the shipping carrier. + type: string + fulfillment_id: + description: The id of the Fulfillment that the Tracking Link references. + type: string + created_at: + description: The date with timezone at which the resource was created. + type: string + format: date-time + updated_at: + description: The date with timezone at which the resource was last updated. + type: string + format: date-time + deleted_at: + description: The date with timezone at which the resource was deleted. + type: string + format: date-time + metadata: + description: An optional key-value map with additional information. + type: object + user: + title: User + description: Represents a User who can manage store settings. + x-resourceId: user + properties: + id: + description: The unique id of the User. This will be prefixed with `usr_` + type: string + email: + description: The email of the User + type: string + first_name: + type: string + last_name: + description: The Customer's billing address. + anyOf: + - $ref: '#/components/schemas/address' + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + deleted_at: + type: string + format: date-time + metadata: + type: object diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts deleted file mode 100644 index 0e0ac4ef00..0000000000 --- a/packages/medusa/src/migrations/1622713782458-no_notification.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotification1622713782458 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} diff --git a/packages/medusa/src/migrations/1623231564533-no_notification.ts b/packages/medusa/src/migrations/1623231564533-no_notification.ts new file mode 100644 index 0000000000..2b3cac3d30 --- /dev/null +++ b/packages/medusa/src/migrations/1623231564533-no_notification.ts @@ -0,0 +1,20 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1623231564533 implements MigrationInterface { + name = 'noNotification1623231564533' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + } + +} From 5507f35acf9484901bf5dc5ac1e14a5fed8dfa61 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 16:34:03 +0200 Subject: [PATCH 14/55] began testing no_notification in different layers --- .../admin/orders/__tests__/get-order.js | 1 + .../admin/orders/__tests__/return-order.js | 82 +++++++++++++++++++ .../api/routes/admin/orders/request-return.js | 14 +++- .../medusa/src/services/__mocks__/order.js | 2 + .../medusa/src/services/__tests__/order.js | 16 ++++ .../medusa/src/services/__tests__/swap.js | 26 +++++- packages/medusa/src/services/claim.js | 10 +-- packages/medusa/src/services/order.js | 7 +- packages/medusa/src/services/return.js | 1 + packages/medusa/src/services/swap.js | 2 +- 10 files changed, 148 insertions(+), 13 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js index 5001ed0def..57cb1db7ea 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js @@ -62,6 +62,7 @@ const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] describe("GET /admin/orders", () => { diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js index 5a36010d3e..f84e0bc65a 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js @@ -2,6 +2,8 @@ import { IdMap } from "medusa-test-utils" import { request } from "../../../../../helpers/test-request" import { orders } from "../../../../../services/__mocks__/order" import { ReturnService } from "../../../../../services/__mocks__/return" +import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus" +import { OrderServiceMock } from "../../../../../services/__mocks__/order" describe("POST /admin/orders/:id/return", () => { describe("successfully returns full order", () => { @@ -21,6 +23,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: 10, + no_notification: true, }, adminSession: { jwt: { @@ -47,6 +50,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 10, + no_notification: true, shipping_method: undefined, }) }) @@ -69,6 +73,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: -1, + no_notification: true, }, adminSession: { jwt: { @@ -95,6 +100,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 0, + no_notification: true, shipping_method: undefined, }) }) @@ -118,6 +124,7 @@ describe("POST /admin/orders/:id/return", () => { ], refund: -1, }, + no_notification: true, adminSession: { jwt: { userId: IdMap.getId("admin_user"), @@ -143,6 +150,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 0, + no_notification: true, shipping_method: undefined, }) }) @@ -165,6 +173,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: 100, + no_notification: true, return_shipping: { option_id: "opt_1234", price: 12, @@ -195,6 +204,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 100, + no_notification: true, shipping_method: { option_id: "opt_1234", price: 12, @@ -205,4 +215,76 @@ describe("POST /admin/orders/:id/return", () => { expect(ReturnService.fulfill).toHaveBeenCalledWith("return") }) }) + + describe("the api call overrides notification settings of order", () => { + it("eventBus is called with the proper no notification feature", async () => { + jest.clearAllMocks() + const subject = await request( + "POST", + `/admin/orders/${IdMap.getId("test-order")}/return`, + { + payload: { + items: [ + { + item_id: IdMap.getId("existingLine"), + quantity: 10, + }, + ], + refund: 100, + return_shipping: { + option_id: "opt_1234", + price: 12, + }, + no_notification: false, + }, + adminSession: { + jwt: { + userId: IdMap.getId("admin_user"), + }, + }, + } + ) + expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: false, + return_id: expect.any(String) + }) + }) + }) + + describe("the api call inherits notification settings of order", () => { + it("eventBus is called with the proper no notification feature", async () => { + jest.clearAllMocks() + await request( + "POST", + `/admin/orders/${IdMap.getId("test-order")}/return`, + { + payload: { + items: [ + { + item_id: IdMap.getId("existingLine"), + quantity: 10, + }, + ], + refund: 100, + return_shipping: { + option_id: "opt_1234", + price: 12, + }, + }, + adminSession: { + jwt: { + userId: IdMap.getId("admin_user"), + }, + }, + } + ) + + expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: true, + return_id: expect.any(String) + }) + }) + }) }) diff --git a/packages/medusa/src/api/routes/admin/orders/request-return.js b/packages/medusa/src/api/routes/admin/orders/request-return.js index 3c0b49ed9f..1d3e0c0da0 100644 --- a/packages/medusa/src/api/routes/admin/orders/request-return.js +++ b/packages/medusa/src/api/routes/admin/orders/request-return.js @@ -43,6 +43,9 @@ import { defaultRelations, defaultFields } from "./" * receive_now: * description: A flag to indicate if the Return should be registerd as received immediately. * type: boolean + * no_notification: + * description: A flag to indicate if no notifications should be emitted related to the requested Return. + * type: boolean * refund: * description: The amount to refund. * type: integer @@ -79,6 +82,7 @@ export default async (req, res) => { }) .optional(), receive_now: Validator.boolean().default(false), + no_notification: Validator.boolean().optional(), refund: Validator.number() .integer() .optional(), @@ -141,6 +145,13 @@ export default async (req, res) => { } } + let order = await orderService + .withTransaction(manager) + .retrieve(id) + + const evaluatedNoNotification = value.no_notification !== undefined ? value.no_notification : order.no_notification + returnObj.no_notification = evaluatedNoNotification + const createdReturn = await returnService .withTransaction(manager) .create(returnObj) @@ -150,12 +161,13 @@ export default async (req, res) => { .withTransaction(manager) .fulfill(createdReturn.id) } - + await eventBus .withTransaction(manager) .emit("order.return_requested", { id, return_id: createdReturn.id, + no_notification: evaluatedNoNotification }) return { diff --git a/packages/medusa/src/services/__mocks__/order.js b/packages/medusa/src/services/__mocks__/order.js index bd8d0d6c05..5779f64e3b 100644 --- a/packages/medusa/src/services/__mocks__/order.js +++ b/packages/medusa/src/services/__mocks__/order.js @@ -47,6 +47,7 @@ export const orders = { providerid: "default_provider", data: {}, }, + no_notification: true, shipping_method: [ { providerid: "default_provider", @@ -99,6 +100,7 @@ export const orders = { payment_method: { providerid: "default_provider", }, + no_notification: false, shipping_methods: [ { id: IdMap.getId("expensiveShipping"), diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 6e9755094a..2536f014e7 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1129,5 +1129,21 @@ describe("OrderService", () => { ) ).rejects.toThrow("Cannot refund more than the original order amount") }) + + it("emits correct no_notification option", async () => { + await orderService.createRefund( + IdMap.getId("order_123"), + 100, + "discount", + "note", + false + ) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: false, + refund_id: expect.any(String) + } ) + }) }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 695583da6a..99d50f750d 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -57,6 +57,7 @@ const testOrder = generateOrder( currency_code: "dkk", region_id: IdMap.getId("region"), tax_rate: 0, + no_notification: true, shipping_address: { first_name: "test", last_name: "testson", @@ -327,6 +328,7 @@ describe("SwapService", () => { order_id: IdMap.getId("test"), fulfillment_status: "not_fulfilled", payment_status: "not_paid", + no_notification: true, additional_items: [ { unit_price: 100, @@ -342,8 +344,7 @@ describe("SwapService", () => { it.each([ [true, true], [false, false], - [undefined, undefined] - ])( "passes correct notification to eventBus with %s", async (input, expected) => { + ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { await swapService.create( testOrder, @@ -357,11 +358,28 @@ describe("SwapService", () => { ) expect(eventBusService.emit).toHaveBeenCalledWith( - expect.anything(), + expect.any(String), {"id": undefined, "no_notification": expected}) }) + + it("passes inherited value of order when no no_notification value is given ", async () => { + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + } + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": true}) + }) + + }) }) - }) describe("receiveReturn", () => { beforeEach(() => { diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 18ed345134..80b5858331 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -235,7 +235,7 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = noNotification ? noNotification : order.no_notification + const evaluatedNoNotification = no_notification ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, @@ -293,7 +293,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -437,7 +437,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -482,7 +482,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -533,7 +533,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index cb9af46a5e..86caba4c51 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1113,7 +1113,7 @@ class OrderService extends BaseService { /** * Refunds a given amount back to the customer. */ - async createRefund(orderId, refundAmount, reason, note) { + async createRefund(orderId, refundAmount, reason, note, noNotification) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { select: ["refundable_amount", "total", "refunded_total", "no_notification"], @@ -1132,10 +1132,13 @@ class OrderService extends BaseService { .refundPayment(order.payments, refundAmount, reason, note) const result = await this.retrieve(orderId) + + const evaluatedNoNotification = noNotification != undefined ? noNotification : order.no_notification + this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, - no_notification: order.no_notification + no_notification: evaluatedNoNotification }) return result }) diff --git a/packages/medusa/src/services/return.js b/packages/medusa/src/services/return.js index c3399d8718..c7ae661064 100644 --- a/packages/medusa/src/services/return.js +++ b/packages/medusa/src/services/return.js @@ -330,6 +330,7 @@ class ReturnService extends BaseService { reason_id: i.reason_id, note: i.note, metadata: i.metadata, + no_notification: data.no_notification, }) ) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 07d017ee06..5eb222ec82 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -238,7 +238,7 @@ class SwapService extends BaseService { }) ) - const evaluatedNoNotification = noNotification ? noNotification : order.noNotification + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ From 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 10 Jun 2021 11:33:31 +0200 Subject: [PATCH 15/55] added tests to remaining components --- .../api/routes/admin/orders/create-order.js | 1 + .../api/routes/admin/orders/refund-payment.js | 6 +++++- .../api/routes/admin/orders/update-order.js | 3 ++- .../medusa/src/services/__tests__/claim.js | 21 +++++++++++++++++++ .../medusa/src/services/__tests__/order.js | 10 ++++++--- .../medusa/src/services/__tests__/swap.js | 18 +--------------- packages/medusa/src/services/claim.js | 2 +- packages/medusa/src/services/order.js | 2 +- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/create-order.js b/packages/medusa/src/api/routes/admin/orders/create-order.js index e6ff1b36df..5adce02ad8 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-order.js +++ b/packages/medusa/src/api/routes/admin/orders/create-order.js @@ -27,6 +27,7 @@ export default async (req, res) => { items: Validator.array().optional(), }) .required(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index c4629e0987..0bb0ccc616 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -25,6 +25,9 @@ import { defaultRelations, defaultFields } from "./" * note: * description: A not with additional details about the Refund. * type: string + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * tags: * - Order * responses: @@ -47,6 +50,7 @@ export default async (req, res) => { note: Validator.string() .allow("") .optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -57,7 +61,7 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createRefund(id, value.amount, value.reason, value.note) + await orderService.createRefund(id, value.amount, value.reason, value.note, value.no_notification) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.js b/packages/medusa/src/api/routes/admin/orders/update-order.js index ba1ed0bf8c..582b1b9a81 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.js +++ b/packages/medusa/src/api/routes/admin/orders/update-order.js @@ -22,7 +22,8 @@ export default async (req, res) => { price: Validator.number(), data: Validator.object(), items: Validator.array(), - }) + }), + no_notification: Validator.boolean(), }) const { value, error } = schema.validate(req.body) diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index cedc534746..ceebac20ed 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -22,6 +22,7 @@ describe("ClaimService", () => { order: { id: "1234", region_id: "order_region", + no_notification: true, items: [ { id: "itm_1", @@ -138,6 +139,7 @@ describe("ClaimService", () => { expect(claimRepo.create).toHaveBeenCalledTimes(1) expect(claimRepo.create).toHaveBeenCalledWith({ payment_status: "not_refunded", + no_notification: true, refund_amount: 1000, type: "refund", order_id: "1234", @@ -156,6 +158,7 @@ describe("ClaimService", () => { expect(eventBusService.emit).toHaveBeenCalledTimes(1) expect(eventBusService.emit).toHaveBeenCalledWith("claim.created", { id: "claim_134", + no_notification: true, }) }) @@ -208,6 +211,24 @@ describe("ClaimService", () => { }) ).rejects.toThrow(`Claims must have at least one claim item.`) }) + + it.each( + [ + [false, false], + [undefined, true] + ], + "passes correct no_notification status to event bus", async (input, expected) => { + await claimService.create({ + ...testClaim, + no_notification: input, + }) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: expected + }) + + }) }) describe("retrieve", () => { diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 2536f014e7..a9526a8245 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1081,6 +1081,7 @@ describe("OrderService", () => { paid_total: 100, refundable_amount: 100, refunded_total: 0, + no_notification: true, }) }, }) @@ -1130,18 +1131,21 @@ describe("OrderService", () => { ).rejects.toThrow("Cannot refund more than the original order amount") }) - it("emits correct no_notification option", async () => { + it.each([ + [false, false], + [undefined, true], + ],"emits correct no_notification option", async (input, expected) => { await orderService.createRefund( IdMap.getId("order_123"), 100, "discount", "note", - false + input ) expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ id: expect.any(String), - no_notification: false, + no_notification: expected, refund_id: expect.any(String) } ) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 99d50f750d..4adb462748 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -344,6 +344,7 @@ describe("SwapService", () => { it.each([ [true, true], [false, false], + [undefined, true], ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { await swapService.create( @@ -361,23 +362,6 @@ describe("SwapService", () => { expect.any(String), {"id": undefined, "no_notification": expected}) }) - - it("passes inherited value of order when no no_notification value is given ", async () => { - await swapService.create( - testOrder, - [{ item_id: IdMap.getId("line"), quantity: 1 }], - [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], - { - id: IdMap.getId("return-shipping"), - price: 20, - } - ) - - expect(eventBusService.emit).toHaveBeenCalledWith( - expect.anything(), - {"id": undefined, "no_notification": true}) - }) - }) }) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 80b5858331..7b13d6c561 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -235,7 +235,7 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = no_notification ? no_notification : order.no_notification + const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 86caba4c51..fb08796e2b 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1133,7 +1133,7 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) - const evaluatedNoNotification = noNotification != undefined ? noNotification : order.no_notification + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, From ea53b798318fd851d003dddd0e229af8ffb9a121 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 11:03:27 +0200 Subject: [PATCH 16/55] added changes to swap and notification service --- docs/api/admin-spec3.json | 1524 +++++------ docs/api/admin-spec3.yaml | 2235 +++++++++-------- docs/api/store-spec3.json | 561 +++-- docs/api/store-spec3.yaml | 142 +- .../api/routes/admin/orders/create-swap.js | 7 +- .../api/routes/store/returns/create-return.js | 6 + .../src/services/__tests__/notification.js | 65 +- .../medusa/src/services/__tests__/swap.js | 24 + packages/medusa/src/services/notification.js | 3 + packages/medusa/src/services/swap.js | 3 + 10 files changed, 2335 insertions(+), 2235 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index 5da7fcc4b6..de03c84c1d 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -145,6 +145,183 @@ } } }, + "/customers": { + "post": { + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer.", + "parameters": [], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } + } + }, + "get": { + "operationId": "GetCustomers", + "summary": "List Customers", + "description": "Retrieves a list of Customers.", + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/customers/{id}": { + "get": { + "operationId": "GetCustomersCustomer", + "summary": "Retrieve a Customer", + "description": "Retrieves a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCustomersCustomer", + "summary": "Update a Customer", + "description": "Updates a Customer.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Customer.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "description": "The Customer's phone number.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Customer" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, "/collections": { "post": { "operationId": "PostCollections", @@ -357,14 +534,47 @@ } } }, - "/customers": { + "/gift-cards": { "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer.", - "parameters": [], + "operationId": "PostGiftCards", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "value": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -373,54 +583,22 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } } } } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } } }, "get": { - "operationId": "GetCustomers", - "summary": "List Customers", - "description": "Retrieves a list of Customers.", + "operationId": "GetGiftCards", + "summary": "List Gift Cards", + "description": "Retrieves a list of Gift Cards.", "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -429,8 +607,11 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } } } } @@ -440,24 +621,24 @@ } } }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieve a Customer", - "description": "Retrieves a Customer.", + "/gift-cards/{id}": { + "delete": { + "operationId": "DeleteGiftCardsGiftCard", + "summary": "Delete a Gift Card", + "description": "Deletes a Gift Card", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card to delete.", "schema": { "type": "string" } } ], "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -466,8 +647,51 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "id": { + "type": "string", + "description": "The id of the deleted Gift Card" + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCardsGiftCard", + "summary": "Retrieve a Gift Card", + "description": "Retrieves a Gift Card.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -477,15 +701,15 @@ } }, "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update a Customer", - "description": "Updates a Customer.", + "operationId": "PostGiftCardsGiftCard", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Customer.", + "description": "The id of the Gift Card.", "schema": { "type": "string" } @@ -496,16 +720,28 @@ "application/json": { "schema": { "properties": { - "first_name": { - "type": "string", - "description": "The Customer's first name." + "balance": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." }, - "last_name": { - "type": "string", - "description": "The Customer's last name." + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." }, - "phone": { - "description": "The Customer's phone number.", + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", "type": "object" } } @@ -514,7 +750,7 @@ } }, "tags": [ - "Customer" + "Gift Card" ], "responses": { "200": { @@ -523,8 +759,8 @@ "application/json": { "schema": { "properties": { - "customer": { - "$ref": "#/components/schemas/customer" + "gift_card": { + "$ref": "#/components/schemas/gift_card" } } } @@ -717,6 +953,10 @@ "type": "string" } }, + "usage_limit": { + "type": "number", + "description": "Maximum times the discount can be used" + }, "metadata": { "description": "An optional set of key-value pairs to hold additional information.", "type": "object" @@ -1038,242 +1278,6 @@ } } }, - "/gift-cards": { - "post": { - "operationId": "PostGiftCards", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "value": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCards", - "summary": "List Gift Cards", - "description": "Retrieves a list of Gift Cards.", - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - } - }, - "/gift-cards/{id}": { - "delete": { - "operationId": "DeleteGiftCardsGiftCard", - "summary": "Delete a Gift Card", - "description": "Deletes a Gift Card", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card to delete.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Gift Card" - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetGiftCardsGiftCard", - "summary": "Retrieve a Gift Card", - "description": "Retrieves a Gift Card.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostGiftCardsGiftCard", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "balance": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" - } - } - } - } - } - } - } - } - }, "/notifications": { "get": { "operationId": "GetNotifications", @@ -1960,6 +1964,10 @@ } } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -2265,82 +2273,6 @@ } } }, - "/orders/{id}/returns/{return_id}/receive": { - "post": { - "operationId": "PostOrdersOrderReturnsReturnReceive", - "summary": "Receive a Return", - "description": "Registers a Return as received.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "return_id", - "required": true, - "description": "The id of the Return.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "items": { - "description": "The Line Items that have been received.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Line Item.", - "type": "integer" - } - } - } - }, - "refund": { - "description": "The amount to refund.", - "type": "integer" - } - } - } - } - } - }, - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, "/orders/{id}/swaps/{swap_id}/receive": { "post": { "operationId": "PostOrdersOrderSwapsSwapReceive", @@ -3926,6 +3858,183 @@ } } }, + "/return-reasons": { + "post": { + "operationId": "PostReturnReasons", + "summary": "Create a Return Reason", + "description": "Creates a Return Reason", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostReturnReasonsReason", + "summary": "Update a Return Reason", + "description": "Updates a Return Reason", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, "/regions/{id}/countries": { "post": { "operationId": "PostRegionsRegionCountries", @@ -4565,183 +4674,6 @@ } } }, - "/return-reasons": { - "post": { - "operationId": "PostReturnReasons", - "summary": "Create a Return Reason", - "description": "Creates a Return Reason", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostReturnReasonsReason", - "summary": "Update a Return Reason", - "description": "Updates a Return Reason", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, "/returns": { "get": { "operationId": "GetReturns", @@ -4771,6 +4703,269 @@ } } }, + "/returns/{id}receive": { + "post": { + "operationId": "PostReturnsReturnReceive", + "summary": "Receive a Return", + "description": "Registers a Return as received. Updates statuses on Orders and Swaps accordingly.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "items": { + "description": "The Line Items that have been received.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Line Item.", + "type": "integer" + } + } + } + }, + "refund": { + "description": "The amount to refund.", + "type": "integer" + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, + "/shipping-profiles": { + "post": { + "operationId": "PostShippingProfiles", + "summary": "Create a Shipping Profile", + "description": "Creates a Shipping Profile", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfiles", + "summary": "List Shipping Profiles", + "description": "Retrieves a list of Shipping Profile.", + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + } + }, + "/shipping-profiles/{id}": { + "delete": { + "operationId": "DeleteShippingProfilesProfile", + "summary": "Delete a Shipping Profile", + "description": "Deletes a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Shipping Profile." + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfilesProfile", + "summary": "Retrieve a Shipping Profile", + "description": "Retrieves a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostShippingProfilesProfile", + "summary": "Update a Shipping Profiles", + "description": "Updates a Shipping Profile", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + }, "/shipping-options": { "post": { "operationId": "PostShippingOptions", @@ -5043,202 +5238,6 @@ } } }, - "/shipping-profiles": { - "post": { - "operationId": "PostShippingProfiles", - "summary": "Create a Shipping Profile", - "description": "Creates a Shipping Profile", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfiles", - "summary": "List Shipping Profiles", - "description": "Retrieves a list of Shipping Profile.", - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - } - }, - "/shipping-profiles/{id}": { - "delete": { - "operationId": "DeleteShippingProfilesProfile", - "summary": "Delete a Shipping Profile", - "description": "Deletes a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Shipping Profile." - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfilesProfile", - "summary": "Retrieve a Shipping Profile", - "description": "Retrieves a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostShippingProfilesProfile", - "summary": "Update a Shipping Profiles", - "description": "Updates a Shipping Profile", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - }, "/store/currencies/{code}": { "post": { "operationId": "PostStoreCurrenciesCode", @@ -6020,10 +6019,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6095,6 +6090,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6869,6 +6872,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 048de24094..01407368f2 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,6 +85,119 @@ paths: properties: user: $ref: '#/components/schemas/user' + /customers: + post: + operationId: PostCustomers + summary: Create a Customer + description: Creates a Customer. + parameters: [] + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + requestBody: + content: + application/json: + schema: + type: object + required: + - email + - first_name + - last_name + properties: + email: + type: string + description: The Customer's email address. + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + type: string + description: The Customer's phone number. + get: + operationId: GetCustomers + summary: List Customers + description: Retrieves a list of Customers. + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + '/customers/{id}': + get: + operationId: GetCustomersCustomer + summary: Retrieve a Customer + description: Retrieves a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + post: + operationId: PostCustomersCustomer + summary: Update a Customer + description: Updates a Customer. + parameters: + - in: path + name: id + required: true + description: The id of the Customer. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + first_name: + type: string + description: The Customer's first name. + last_name: + type: string + description: The Customer's last name. + phone: + description: The Customer's phone number. + type: object + tags: + - Customer + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' /collections: post: operationId: PostCollections @@ -227,119 +340,6 @@ paths: properties: collection: $ref: '#/components/schemas/product_collection' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieve a Customer - description: Retrieves a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - description: The Customer's phone number. - type: object - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -478,6 +478,9 @@ paths: type: array items: type: string + usage_limit: + type: number + description: Maximum times the discount can be used metadata: description: >- An optional set of key-value pairs to hold additional @@ -910,266 +913,34 @@ paths: properties: notification: $ref: '#/components/schemas/notification' - '/orders/{id}/shipping-methods': + /return-reasons: post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason requestBody: content: application/json: schema: properties: - fulfillment_id: - description: The id of the Fulfillment. + label: + description: The label to display to the Customer. type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: + value: description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1177,317 +948,14 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': + return_reason: + $ref: '#/components/schemas/return_reason' get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. tags: - - Order + - Return Reason responses: '200': description: OK @@ -1495,49 +963,24 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: + return_reasons: type: array items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string tags: - - Order + - Return Reason responses: '200': description: OK @@ -1545,24 +988,17 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns/{return_id}/receive': + return_reason: + $ref: '#/components/schemas/return_reason' post: - operationId: PostOrdersOrderReturnsReturnReceive - summary: Receive a Return - description: Registers a Return as received. + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: return_id - required: true - description: The id of the Return. + description: The id of the Return Reason. schema: type: string requestBody: @@ -1570,269 +1006,24 @@ paths: application/json: schema: properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. + label: + description: The label to display to the Customer. type: string - note: - description: A not with additional details about the Refund. + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -1840,8 +1031,8 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + return_reason: + $ref: '#/components/schemas/return_reason' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -3159,126 +2350,6 @@ paths: properties: region: $ref: '#/components/schemas/region' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' /returns: get: operationId: GetReturns @@ -3297,6 +2368,937 @@ paths: type: array items: $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: If set to true no notification will be send + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' /shipping-options: post: operationId: PostShippingOptions @@ -3608,6 +3610,24 @@ paths: properties: shipping_profiles: $ref: '#/components/schemas/shipping_profile' + /swaps: + get: + operationId: GetSwaps + summary: List Swaps + description: Retrieves a list of Swaps. + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swaps: + type: array + items: + $ref: '#/components/schemas/swap' '/store/currencies/{code}': post: operationId: PostStoreCurrenciesCode @@ -3718,24 +3738,6 @@ paths: type: array items: $ref: '#/components/schemas/store' - /swaps: - get: - operationId: GetSwaps - summary: List Swaps - description: Retrieves a list of Swaps. - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swaps: - type: array - items: - $ref: '#/components/schemas/swap' /variants: get: operationId: GetVariants @@ -4167,9 +4169,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4232,6 +4231,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4865,6 +4870,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 5727ac1234..545a298abd 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -976,6 +976,55 @@ } } }, + "/gift-cards/{code}": { + "get": { + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", + "parameters": [ + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Gift Card code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, "/customers/{id}/addresses": { "post": { "operationId": "PostCustomersCustomerAddresses", @@ -1481,277 +1530,6 @@ } } }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", - "parameters": [ - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Gift Card code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/products/{id}": { - "get": { - "operationId": "GetProductsProduct", - "summary": "Retrieves a Product", - "description": "Retrieves a Product.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Product.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "product": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - }, - "/products": { - "get": { - "operationId": "GetProducts", - "summary": "List Products", - "description": "Retrieves a list of Products.", - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of Products.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of Products to return,", - "type": "integer" - }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, - "/return-reasons": { - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/regions/{id}": { - "get": { - "operationId": "GetRegionsRegion", - "summary": "Retrieves a Region", - "description": "Retrieves a Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Region.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/regions": { - "get": { - "operationId": "GetRegions", - "summary": "List Regions", - "description": "Retrieves a list of Regions.", - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of regions.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of regions to return,", - "type": "integer" - }, - "regions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - } - }, "/orders/cart/{cart_id}": { "get": { "operationId": "GetOrdersOrderCartId", @@ -1872,6 +1650,162 @@ } } }, + "/products/{id}": { + "get": { + "operationId": "GetProductsProduct", + "summary": "Retrieves a Product", + "description": "Retrieves a Product.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Product.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "product": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + }, + "/products": { + "get": { + "operationId": "GetProducts", + "summary": "List Products", + "description": "Retrieves a list of Products.", + "tags": [ + "Product" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of Products.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of Products to return,", + "type": "integer" + }, + "products": { + "type": "array", + "items": { + "$ref": "#/components/schemas/product" + } + } + } + } + } + } + } + } + } + }, + "/regions/{id}": { + "get": { + "operationId": "GetRegionsRegion", + "summary": "Retrieves a Region", + "description": "Retrieves a Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Region.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "region": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + }, + "/regions": { + "get": { + "operationId": "GetRegions", + "summary": "List Regions", + "description": "Retrieves a list of Regions.", + "tags": [ + "Region" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total number of regions.", + "type": "integer" + }, + "offset": { + "description": "The offset for pagination.", + "type": "integer" + }, + "limit": { + "description": "The maxmimum number of regions to return,", + "type": "integer" + }, + "regions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/region" + } + } + } + } + } + } + } + } + } + }, "/returns": { "post": { "operationId": "PostReturns", @@ -1911,6 +1845,10 @@ "description": "The id of the Shipping Option to create the Shipping Method from." } } + }, + "no_notification": { + "description": "If set to true no notification will be send", + "type": "boolean" } } } @@ -1938,6 +1876,72 @@ } } }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, + "/return-reasons": { + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, "/shipping-options": { "get": { "operationId": "GetShippingOptions", @@ -2696,10 +2700,6 @@ "$ref": "#/components/schemas/product" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2771,6 +2771,14 @@ "$ref": "#/components/schemas/region" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, + "usage_count": { + "description": "The number of times a discount has been used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -3545,6 +3553,9 @@ }, "gift_card_total": { "type": "integer" + }, + "paid_total": { + "type": "integer" } } }, diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 43e7a49d17..5f6fd465cf 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -1147,47 +1147,6 @@ paths: type: array items: $ref: '#/components/schemas/product' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' '/regions/{id}': get: operationId: GetRegionsRegion @@ -1238,6 +1197,47 @@ paths: type: array items: $ref: '#/components/schemas/region' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' /returns: post: operationId: PostReturns @@ -1274,6 +1274,9 @@ paths: description: >- The id of the Shipping Option to create the Shipping Method from. + no_notification: + description: If set to true no notification will be send + type: boolean tags: - Return responses: @@ -1285,6 +1288,29 @@ paths: properties: return: $ref: '#/components/schemas/return' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' /shipping-options: get: operationId: GetShippingOptions @@ -1346,29 +1372,6 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1829,9 +1832,6 @@ components: type: array items: $ref: '#/components/schemas/product' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1894,6 +1894,12 @@ components: type: array items: $ref: '#/components/schemas/region' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer + usage_count: + description: The number of times a discount has been used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -2527,6 +2533,8 @@ components: type: integer gift_card_total: type: integer + paid_total: + type: integer payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 7782400eaa..f81c02b35f 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -45,6 +45,9 @@ import { defaultFields, defaultRelations } from "./" * quantity: * description: The quantity of the Product Variant to ship. * type: integer + * no_notification: + * description: If set to true no notification will be send. + * type: boolean * tags: * - Order * responses: @@ -65,7 +68,7 @@ export default async (req, res) => { .items({ item_id: Validator.string().required(), quantity: Validator.number().required(), - }) + }) .required(), return_shipping: Validator.object() .keys({ @@ -79,6 +82,7 @@ export default async (req, res) => { variant_id: Validator.string().required(), quantity: Validator.number().required(), }), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -134,6 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, + no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index e04bf44037..c61727c4c5 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,6 +31,10 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. + * no_notification: + * description: If set to true no notification will be send + * type: boolean + * * tags: * - Return * responses: @@ -59,6 +63,7 @@ export default async (req, res) => { option_id: Validator.string().optional(), }) .optional(), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -132,6 +137,7 @@ export default async (req, res) => { .emit("order.return_requested", { id: value.order_id, return_id: createdReturn.id, + no_notification: no_notification }) return { diff --git a/packages/medusa/src/services/__tests__/notification.js b/packages/medusa/src/services/__tests__/notification.js index f26ab26d15..64b6361b65 100644 --- a/packages/medusa/src/services/__tests__/notification.js +++ b/packages/medusa/src/services/__tests__/notification.js @@ -1,30 +1,31 @@ import NotificationService from "../notification" -import { IdMap, MockManager, MockRepository } from "medusa-test-utils" +import { MockManager, MockRepository } from "medusa-test-utils" describe("NotificationService", () => { - describe("send", () => { - const notificationRepository = MockRepository({ create: c => c }) + const notificationRepository = MockRepository({ create: c => c }) - const container = { - manager: MockManager, - notificationRepository, - noti_test: { - sendNotification: jest.fn(() => - Promise.resolve({ - to: "test@mail.com", - data: { id: "something" }, - }) - ), - }, - } + const container = { + manager: MockManager, + notificationRepository, + noti_test: { + sendNotification: jest.fn(() => + Promise.resolve({ + to: "test@mail.com", + data: { id: "something" }, + }) + ), + }, + } - const notificationService = new NotificationService(container) + beforeEach(() => { + jest.clearAllMocks() + }) - beforeEach(() => { - jest.clearAllMocks() - }) + describe("send", () =>{ it("successfully calls provider and saves noti", async () => { + const notificationService = new NotificationService(container) + await notificationService.send("event.test", { id: "test" }, "test") expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) @@ -51,4 +52,30 @@ describe("NotificationService", () => { expect(notificationRepository.save).toHaveBeenCalledWith(constructed) }) }) + + describe("handleEvent", () => { + + it("cancels notification if no_notification is set", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", + return_id: "id", + no_notification: true}) + + expect(container.noti_test.sendNotification).not.toHaveBeenCalled() + }) + + it("if no_notification is not set notification is send", async () => { + const notificationService = new NotificationService(container) + const event = "event.test" + notificationService.subscribe(event, "test") + + await notificationService.handleEvent(event, {id: "id", return_id: "id"}) + + expect(container.noti_test.sendNotification).toHaveBeenCalledTimes(1) + }) + + }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index cbbc61fc85..695583da6a 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -338,6 +338,28 @@ describe("SwapService", () => { expect(returnService.create).toHaveBeenCalledTimes(1) }) + + it.each([ + [true, true], + [false, false], + [undefined, undefined] + ])( "passes correct notification to eventBus with %s", async (input, expected) => { + + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + }, + input + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": expected}) + }) }) }) @@ -918,4 +940,6 @@ describe("SwapService", () => { }) }) }) + + }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index df75b7fdc0..e0165ef952 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -164,6 +164,9 @@ class NotificationService extends BaseService { if (!subs) { return } + if(data['no_notification'] === true) { + return + } return Promise.all( subs.map(async providerId => { diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index fef1599ceb..6c7ca61ec2 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,6 +204,7 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. + * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap * @returns {Promise} the newly created swap. */ async create( @@ -211,6 +212,7 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, + noNotification, custom = {} ) { return this.atomicPhase_(async manager => { @@ -256,6 +258,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, + no_notification: noNotification, }) return result From bc3fc2188cf62010c39d3771d0e1fc207c9ebf3a Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 12:07:03 +0200 Subject: [PATCH 17/55] began impl. of no_notification --- .../src/api/routes/store/returns/create-return.js | 9 ++------- .../src/migrations/1622713782458-no_notification.ts | 11 +++++++++++ packages/medusa/src/models/claim-order.ts | 3 +++ packages/medusa/src/models/order.ts | 3 +++ packages/medusa/src/models/return.ts | 3 +++ packages/medusa/src/models/swap.ts | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index c61727c4c5..1101dbd08e 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,9 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * no_notification: - * description: If set to true no notification will be send - * type: boolean * * tags: * - Return @@ -62,8 +59,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional(), - no_notification: Validator.boolean().optional() + .optional() }) const { value, error } = schema.validate(req.body) @@ -136,8 +132,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id, - no_notification: no_notification + return_id: createdReturn.id }) return { diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts new file mode 100644 index 0000000000..0e0ac4ef00 --- /dev/null +++ b/packages/medusa/src/migrations/1622713782458-no_notification.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1622713782458 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 547245544f..dea06419f1 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,6 +134,9 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index a6d7be6ff0..95aad02d1d 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,6 +245,9 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ nullable: true }) idempotency_key: string diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index 77cd1d2837..b3bdc6b8bf 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,6 +99,9 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 606bdfade7..37708b6b94 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,6 +130,9 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date + @Column({ type: "boolean"}) + no_notification: Boolean + @Column({ type: "jsonb", nullable: true }) metadata: any From 4d560a5045225ce6965fde34611e2001f8fef541 Mon Sep 17 00:00:00 2001 From: --list Date: Tue, 8 Jun 2021 16:00:58 +0200 Subject: [PATCH 18/55] removed not working migration --- .../src/migrations/1622713782458-no_notification.ts | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts deleted file mode 100644 index 0e0ac4ef00..0000000000 --- a/packages/medusa/src/migrations/1622713782458-no_notification.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotification1622713782458 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} From 5fd199313964a89a1c8fc66d8c0ec98d2d1cabd0 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:20:38 +0200 Subject: [PATCH 19/55] added no_notification to services and api endpoints --- .../api/routes/admin/orders/create-claim.js | 5 + .../api/routes/admin/orders/create-swap.js | 4 +- .../src/api/routes/admin/orders/index.js | 2 + .../api/routes/admin/orders/update-claim.js | 4 + .../api/routes/admin/orders/update-order.js | 2 +- .../1623164855464-no_notifications.ts | 134 ++++++++++++++++++ packages/medusa/src/models/claim-order.ts | 2 +- packages/medusa/src/models/order.ts | 2 +- packages/medusa/src/models/return.ts | 2 +- packages/medusa/src/models/swap.ts | 2 +- packages/medusa/src/services/claim.js | 10 ++ packages/medusa/src/services/order.js | 19 ++- packages/medusa/src/services/swap.js | 12 +- 13 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.js b/packages/medusa/src/api/routes/admin/orders/create-claim.js index ce77c090a4..5e0e207f58 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.js @@ -91,6 +91,9 @@ import { defaultRelations, defaultFields } from "./" * refund_amount: * description: The amount to refund the Customer when the Claim type is `refund`. * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -155,6 +158,7 @@ export default async (req, res) => { .integer() .optional(), shipping_address: Validator.object().optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) @@ -212,6 +216,7 @@ export default async (req, res) => { return_shipping: value.return_shipping, additional_items: value.additional_items, shipping_methods: value.shipping_methods, + no_notification: value.no_notification, metadata: value.metadata, }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index f81c02b35f..648aed1aab 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -46,7 +46,7 @@ import { defaultFields, defaultRelations } from "./" * description: The quantity of the Product Variant to ship. * type: integer * no_notification: - * description: If set to true no notification will be send. + * description: If set to true no notification will be send related to this Swap. * type: boolean * tags: * - Order @@ -138,7 +138,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, - no_notification, + value.no_notification, { idempotency_key: idempotencyKey.idempotency_key } ) diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 98e72e599c..29ce86e109 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -237,6 +237,7 @@ export const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedFields = [ @@ -265,6 +266,7 @@ export const allowedFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedRelations = [ diff --git a/packages/medusa/src/api/routes/admin/orders/update-claim.js b/packages/medusa/src/api/routes/admin/orders/update-claim.js index ffbd4eae46..90346be45c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/update-claim.js @@ -62,6 +62,9 @@ import { defaultRelations, defaultFields } from "./" * price: * description: The price to charge for the Shipping Method * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -106,6 +109,7 @@ export default async (req, res) => { .optional(), }) .optional(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.js b/packages/medusa/src/api/routes/admin/orders/update-order.js index 37e321024b..ba1ed0bf8c 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.js +++ b/packages/medusa/src/api/routes/admin/orders/update-order.js @@ -22,7 +22,7 @@ export default async (req, res) => { price: Validator.number(), data: Validator.object(), items: Validator.array(), - }), + }) }) const { value, error } = schema.validate(req.body) diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts new file mode 100644 index 0000000000..e24bbbff9a --- /dev/null +++ b/packages/medusa/src/migrations/1623164855464-no_notifications.ts @@ -0,0 +1,134 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotifications1623164855464 implements MigrationInterface { + name = 'noNotifications1623164855464' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index dea06419f1..91ab66b450 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -134,7 +134,7 @@ export class ClaimOrder { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index 95aad02d1d..10258270d9 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -245,7 +245,7 @@ export class Order { @Column({ type: "jsonb", nullable: true }) metadata: any - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ nullable: true }) diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index b3bdc6b8bf..98a52122b9 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -99,7 +99,7 @@ export class Return { @UpdateDateColumn({ type: "timestamptz" }) updated_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index 37708b6b94..e0c173c1ba 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -130,7 +130,7 @@ export class Swap { @DeleteDateColumn({ type: "timestamptz" }) deleted_at: Date - @Column({ type: "boolean"}) + @Column({ type: "boolean", nullable: true}) no_notification: Boolean @Column({ type: "jsonb", nullable: true }) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 758586815b..18ed345134 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -149,6 +149,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.UPDATED, { id: claim.id, + no_notification: claim.no_notification }) return claim @@ -174,6 +175,7 @@ class ClaimService extends BaseService { refund_amount, shipping_address, shipping_address_id, + no_notification, ...rest } = data @@ -233,6 +235,8 @@ class ClaimService extends BaseService { ) ) + const evaluatedNoNotification = noNotification ? noNotification : order.no_notification + const created = claimRepo.create({ shipping_address_id: addressId, payment_status: type === "refund" ? "not_refunded" : "na", @@ -241,6 +245,7 @@ class ClaimService extends BaseService { type, additional_items: newItems, order_id: order.id, + no_notification: evaluatedNoNotification }) const result = await claimRepo.save(created) @@ -288,6 +293,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, + no_notification: claim.no_notification }) return result @@ -395,6 +401,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.FULFILLMENT_CREATED, { id: id, fulfillment_id: fulfillment.id, + no_notification: claim.no_notification }) } @@ -430,6 +437,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, + no_notification: claim.no_notification }) return result @@ -474,6 +482,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, + no_notification: claim.no_notification }) return result @@ -524,6 +533,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, + no_notification: claim.no_notification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 6444a444ff..5fe6fea0ac 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -405,6 +405,7 @@ class OrderService extends BaseService { OrderService.Events.COMPLETED, { id: orderId, + no_notification: order.no_notification } ) @@ -549,7 +550,7 @@ class OrderService extends BaseService { await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.PLACED, { - id: result.id, + id: result.id }) return result @@ -611,6 +612,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.SHIPMENT_CREATED, { id: orderId, fulfillment_id: shipmentRes.id, + no_notification: order.no_notification }) return result @@ -631,6 +633,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PLACED, { id: result.id, + no_notification: order.no_notification }) return result }) @@ -818,6 +821,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.UPDATED, { id: orderId, + no_notification: order.no_notification }) return result }) @@ -868,6 +872,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.CANCELED, { id: order.id, + no_notification: order.no_notification }) return result }) @@ -895,7 +900,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.PAYMENT_CAPTURE_FAILED, { id: orderId, payment_id: p.id, - error: err, + error: err }) }) @@ -921,6 +926,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PAYMENT_CAPTURED, { id: result.id, + no_notification: order.no_notification }) } @@ -977,6 +983,7 @@ class OrderService extends BaseService { "tax_total", "gift_card_total", "total", + "no_notification" ], relations: [ "discounts", @@ -1049,6 +1056,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.FULFILLMENT_CREATED, { id: orderId, fulfillment_id: fulfillment.id, + no_notification: order.no_notification }) } @@ -1107,7 +1115,7 @@ class OrderService extends BaseService { async createRefund(orderId, refundAmount, reason, note) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["refundable_amount", "total", "refunded_total"], + select: ["refundable_amount", "total", "refunded_total", "no_notification"], relations: ["payments"], }) @@ -1126,6 +1134,7 @@ class OrderService extends BaseService { this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, + no_notification: order.no_notification }) return result }) @@ -1206,7 +1215,7 @@ class OrderService extends BaseService { async registerReturnReceived(orderId, receivedReturn, customRefundAmount) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["total", "refunded_total", "refundable_amount"], + select: ["total", "refunded_total", "refundable_amount", "no_notification"], relations: ["items", "returns", "payments"], }) @@ -1229,6 +1238,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.RETURN_ACTION_REQUIRED, { id: result.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result } @@ -1260,6 +1270,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.ITEMS_RETURNED, { id: order.id, return_id: receivedReturn.id, + no_notification: order.no_notification }) return result }) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 6c7ca61ec2..07d017ee06 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -204,7 +204,9 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. - * @param {boolean?} noNotification - an optional flag to disable sending notification when creating swap + * @param {boolean?} noNotification - an optional flag to disable sending + * notification when creating swap. If set, it overrules the attribute inherited + * from the order. * @returns {Promise} the newly created swap. */ async create( @@ -236,6 +238,8 @@ class SwapService extends BaseService { }) ) + const evaluatedNoNotification = noNotification ? noNotification : order.noNotification + const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ ...custom, @@ -243,6 +247,7 @@ class SwapService extends BaseService { payment_status: "not_paid", order_id: order.id, additional_items: newItems, + no_notification: evaluatedNoNotification }) const result = await swapRepo.save(created) @@ -258,7 +263,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.CREATED, { id: result.id, - no_notification: noNotification, + no_notification: evaluatedNoNotification, }) return result @@ -559,6 +564,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.PAYMENT_COMPLETED, { id: swap.id, + no_notification: swap.no_notification }) return result @@ -750,6 +756,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.SHIPMENT_CREATED, { id: swapId, fulfillment_id: shipment.id, + no_notification: swap.no_notification }) return result }) @@ -806,6 +813,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.RECEIVED, { id: id, order_id: result.order_id, + no_notification: swap.no_notification }) return result From 32c212c19392994845a6c381ea8cd188a58f9a17 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:54:42 +0200 Subject: [PATCH 20/55] removed wrong migration --- .../1623164855464-no_notifications.ts | 134 ------------------ 1 file changed, 134 deletions(-) delete mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts deleted file mode 100644 index e24bbbff9a..0000000000 --- a/packages/medusa/src/migrations/1623164855464-no_notifications.ts +++ /dev/null @@ -1,134 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotifications1623164855464 implements MigrationInterface { - name = 'noNotifications1623164855464' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} From f34474957e1fcce4f4b1f2a274315e7c88a2da39 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:20:38 +0200 Subject: [PATCH 21/55] added no_notification to services and api endpoints --- .../1623164855464-no_notifications.ts | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts new file mode 100644 index 0000000000..e24bbbff9a --- /dev/null +++ b/packages/medusa/src/migrations/1623164855464-no_notifications.ts @@ -0,0 +1,134 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotifications1623164855464 implements MigrationInterface { + name = 'noNotifications1623164855464' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); + await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); + await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); + await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); + await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); + await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); + await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); + await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); + await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); + await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); + await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +} From 86d91da31f1eddc93ed2c6feaf2366272869bdf9 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 11:03:27 +0200 Subject: [PATCH 22/55] added changes to swap and notification service --- .../medusa/src/api/routes/store/returns/create-return.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index 1101dbd08e..c61727c4c5 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,6 +31,9 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. + * no_notification: + * description: If set to true no notification will be send + * type: boolean * * tags: * - Return @@ -59,7 +62,8 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional() + .optional(), + no_notification: Validator.boolean().optional() }) const { value, error } = schema.validate(req.body) @@ -132,7 +136,8 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id + return_id: createdReturn.id, + no_notification: no_notification }) return { From b8833055b2c51815a5ee1aa99bd2f1a23e161628 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 3 Jun 2021 12:07:03 +0200 Subject: [PATCH 23/55] began impl. of no_notification --- .../src/api/routes/store/returns/create-return.js | 9 ++------- .../src/migrations/1622713782458-no_notification.ts | 11 +++++++++++ packages/medusa/src/models/claim-order.ts | 3 +++ packages/medusa/src/models/order.ts | 3 +++ packages/medusa/src/models/return.ts | 3 +++ packages/medusa/src/models/swap.ts | 3 +++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index c61727c4c5..1101dbd08e 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,9 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * no_notification: - * description: If set to true no notification will be send - * type: boolean * * tags: * - Return @@ -62,8 +59,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional(), - no_notification: Validator.boolean().optional() + .optional() }) const { value, error } = schema.validate(req.body) @@ -136,8 +132,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id, - no_notification: no_notification + return_id: createdReturn.id }) return { diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts new file mode 100644 index 0000000000..0e0ac4ef00 --- /dev/null +++ b/packages/medusa/src/migrations/1622713782458-no_notification.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1622713782458 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/medusa/src/models/claim-order.ts b/packages/medusa/src/models/claim-order.ts index 91ab66b450..c5c8ec430b 100644 --- a/packages/medusa/src/models/claim-order.ts +++ b/packages/medusa/src/models/claim-order.ts @@ -226,6 +226,9 @@ export class ClaimOrder { * deleted_at: * type: string * format: date-time + * no_notification: + * description: "Flag for describing whether or not notifications related to this should be send." + * type: boolean * metadata: * type: object */ diff --git a/packages/medusa/src/models/order.ts b/packages/medusa/src/models/order.ts index 10258270d9..6aab13bc40 100644 --- a/packages/medusa/src/models/order.ts +++ b/packages/medusa/src/models/order.ts @@ -417,4 +417,7 @@ export class Order { * type: integer * paid_total: * type: integer + * no_notification: + * description: "Flag for describing whether or not notifications related to this should be send." + * type: boolean */ diff --git a/packages/medusa/src/models/return.ts b/packages/medusa/src/models/return.ts index 98a52122b9..c79d012646 100644 --- a/packages/medusa/src/models/return.ts +++ b/packages/medusa/src/models/return.ts @@ -168,6 +168,9 @@ export class Return { * description: "The date with timezone at which the resource was last updated." * type: string * format: date-time + * no_notification: + * description: "Flag for describing whether or not notifications related to this should be send." + * type: boolean * metadata: * description: "An optional key-value map with additional information." * type: object diff --git a/packages/medusa/src/models/swap.ts b/packages/medusa/src/models/swap.ts index e0c173c1ba..f8c8bc8aee 100644 --- a/packages/medusa/src/models/swap.ts +++ b/packages/medusa/src/models/swap.ts @@ -227,6 +227,9 @@ export class Swap { * description: "The date with timezone at which the resource was last updated." * type: string * format: date-time + * no_notification: + * description: "Flag for describing whether or not notifications related to this should be send." + * type: boolean * metadata: * description: "An optional key-value map with additional information." * type: object From 1df4bb5086e7da17875a6def90ef076b4c863653 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 10:54:42 +0200 Subject: [PATCH 24/55] removed wrong migration --- .../1623164855464-no_notifications.ts | 134 ------------------ 1 file changed, 134 deletions(-) delete mode 100644 packages/medusa/src/migrations/1623164855464-no_notifications.ts diff --git a/packages/medusa/src/migrations/1623164855464-no_notifications.ts b/packages/medusa/src/migrations/1623164855464-no_notifications.ts deleted file mode 100644 index e24bbbff9a..0000000000 --- a/packages/medusa/src/migrations/1623164855464-no_notifications.ts +++ /dev/null @@ -1,134 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotifications1623164855464 implements MigrationInterface { - name = 'noNotifications1623164855464' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE CASCADE`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60"`); - await queryRunner.query(`ALTER TABLE "store_currencies" DROP CONSTRAINT "FK_b4f4b63d1736689b7008980394c"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3"`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" DROP CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16"`); - await queryRunner.query(`ALTER TABLE "order_discounts" DROP CONSTRAINT "FK_e7b488cebe333f449398769b2cc"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_0fb38b6d167793192bc126d835e"`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" DROP CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_8df75ef4f35f217768dc1135458"`); - await queryRunner.query(`ALTER TABLE "cart_discounts" DROP CONSTRAINT "FK_6680319ebe1f46d18f106191d59"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec"`); - await queryRunner.query(`ALTER TABLE "discount_regions" DROP CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_be66106a673b88a81c603abe7eb"`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" DROP CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b"`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" DROP CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4"`); - await queryRunner.query(`ALTER TABLE "product_tags" DROP CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_2212515ba306c79f42c46a99db7"`); - await queryRunner.query(`ALTER TABLE "product_images" DROP CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf"`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" DROP CONSTRAINT "FK_c556e14eff4d6f03db593df955e"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0"`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" DROP CONSTRAINT "FK_8aaa78ba90d3802edac317df869"`); - await queryRunner.query(`ALTER TABLE "draft_order" DROP CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" DROP CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44"`); - await queryRunner.query(`ALTER TABLE "product_option" DROP CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6"`); - await queryRunner.query(`ALTER TABLE "fulfillment" ALTER COLUMN "provider_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "fulfillment" ADD CONSTRAINT "FK_beb35a6de60a6c4f91d5ae57e44" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount" ALTER COLUMN "starts_at" SET DEFAULT CURRENT_TIMESTAMP`); - await queryRunner.query(`ALTER TABLE "product_option" ALTER COLUMN "product_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "product_option" ADD CONSTRAINT "FK_e634fca34f6b594b87fdbee95f6" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_b4f4b63d1736689b7008980394c" FOREIGN KEY ("store_id") REFERENCES "store"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "store_currencies" ADD CONSTRAINT "FK_82a6bbb0b527c20a0002ddcbd60" FOREIGN KEY ("currency_code") REFERENCES "currency"("code") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_e62ff11e4730bb3adfead979ee2" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_gift_cards" ADD CONSTRAINT "FK_f2bb9f71e95b315eb24b2b84cb3" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_e7b488cebe333f449398769b2cc" FOREIGN KEY ("order_id") REFERENCES "order"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "order_discounts" ADD CONSTRAINT "FK_0fc1ec4e3db9001ad60c19daf16" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_d38047a90f3d42f0be7909e8aea" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_gift_cards" ADD CONSTRAINT "FK_0fb38b6d167793192bc126d835e" FOREIGN KEY ("gift_card_id") REFERENCES "gift_card"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_6680319ebe1f46d18f106191d59" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cart_discounts" ADD CONSTRAINT "FK_8df75ef4f35f217768dc1135458" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_f4194aa81073f3fab8aa86906ff" FOREIGN KEY ("discount_id") REFERENCES "discount"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_regions" ADD CONSTRAINT "FK_a21a7ffbe420d492eb46c305fec" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_4e0739e5f0244c08d41174ca08a" FOREIGN KEY ("discount_rule_id") REFERENCES "discount_rule"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "discount_rule_products" ADD CONSTRAINT "FK_be66106a673b88a81c603abe7eb" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_c2c0f3edf39515bd15432afe6e5" FOREIGN KEY ("item_id") REFERENCES "claim_item"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "claim_item_tags" ADD CONSTRAINT "FK_dc9bbf9fcb9ba458d25d512811b" FOREIGN KEY ("tag_id") REFERENCES "claim_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_5b0c6fc53c574299ecc7f9ee22e" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_tags" ADD CONSTRAINT "FK_21683a063fe82dafdf681ecc9c4" FOREIGN KEY ("product_tag_id") REFERENCES "product_tag"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_4f166bb8c2bfcef2498d97b4068" FOREIGN KEY ("product_id") REFERENCES "product"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "product_images" ADD CONSTRAINT "FK_2212515ba306c79f42c46a99db7" FOREIGN KEY ("image_id") REFERENCES "image"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_c556e14eff4d6f03db593df955e" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_fulfillment_providers" ADD CONSTRAINT "FK_37f361c38a18d12a3fa3158d0cf" FOREIGN KEY ("provider_id") REFERENCES "fulfillment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_8aaa78ba90d3802edac317df869" FOREIGN KEY ("region_id") REFERENCES "region"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "region_payment_providers" ADD CONSTRAINT "FK_3a6947180aeec283cd92c59ebb0" FOREIGN KEY ("provider_id") REFERENCES "payment_provider"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "draft_order" ADD CONSTRAINT "FK_5bd11d0e2a9628128e2c26fd0a6" FOREIGN KEY ("cart_id") REFERENCES "cart"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} From 2934acab6729c99ab582264d4f1cf9b05ba4dc84 Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 11:54:12 +0200 Subject: [PATCH 25/55] trimmed migration --- docs/api/admin-spec3.yaml | 6107 ----------------- docs/api/store-spec3.json | 4883 ------------- docs/api/store-spec3.yaml | 3770 ---------- .../1622713782458-no_notification.ts | 11 - .../1623231564533-no_notification.ts | 20 + 5 files changed, 20 insertions(+), 14771 deletions(-) delete mode 100644 docs/api/admin-spec3.yaml delete mode 100644 docs/api/store-spec3.json delete mode 100644 docs/api/store-spec3.yaml delete mode 100644 packages/medusa/src/migrations/1622713782458-no_notification.ts create mode 100644 packages/medusa/src/migrations/1623231564533-no_notification.ts diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml deleted file mode 100644 index 01407368f2..0000000000 --- a/docs/api/admin-spec3.yaml +++ /dev/null @@ -1,6107 +0,0 @@ -openapi: 3.0.0 -info: - version: 1.0.0 - title: Medusa Admin API - license: - name: MIT -tags: - - name: Auth - description: >- - Auth endpoints allows authorization of admin Users and manages their - sessions. - - name: Collection - x-resourceId: product_collection - - name: Customer - x-resourceId: customer - - name: Discount - x-resourceId: discount - - name: Gift Card - x-resourceId: gift_card - - name: Notification - x-resourceId: notification - - name: Order - x-resourceId: order - - name: Product - x-resourceId: product - - name: Region - x-resourceId: region - - name: Return - x-resourceId: return - - name: Shipping Option - x-resourceId: shipping_option - - name: Shipping Profile - x-resourceId: shipping_profile - - name: Swap - x-resourceId: swap - - name: Product Variant - x-resourceId: product_variant -servers: - - url: 'https://api.medusa-commerce.com/admin' -paths: - /auth: - post: - operationId: PostAuth - summary: Authenticate a User - description: Logs a User in and authorizes them to manage Store settings. - parameters: [] - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - user: - $ref: '#/components/schemas/user' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - password - properties: - email: - type: string - description: The User's email. - password: - type: string - description: The User's password. - get: - operationId: GetAuth - summary: Get Session - description: Gets the currently logged in User. - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - user: - $ref: '#/components/schemas/user' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - type: string - description: The Customer's phone number. - get: - operationId: GetCustomers - summary: List Customers - description: Retrieves a list of Customers. - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieve a Customer - description: Retrieves a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update a Customer - description: Updates a Customer. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - phone: - description: The Customer's phone number. - type: object - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - /collections: - post: - operationId: PostCollections - summary: Create a Product Collection - description: Creates a Product Collection. - requestBody: - content: - application/json: - schema: - required: - - title - properties: - title: - type: string - description: The title to identify the Collection by. - handle: - type: string - description: >- - An optional handle to be used in slugs, if none is provided - we will kebab-case the title. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - get: - operationId: GetCollections - summary: List Product Collections - description: Retrieve a list of Product Collection. - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - '/collections/{id}': - delete: - operationId: DeleteCollectionsCollection - summary: Delete a Product Collection - description: Deletes a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Collection. - schema: - type: string - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Collection - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetCollectionsCollection - summary: Retrieve a Product Collection - description: Retrieves a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Product Collection - schema: - type: string - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - post: - operationId: PostCollectionsCollection - summary: Update a Product Collection - description: Updates a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Collection. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - type: string - description: The title to identify the Collection by. - handle: - type: string - description: >- - An optional handle to be used in slugs, if none is provided - we will kebab-case the title. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - '/discounts/{id}/regions/{region_id}': - post: - operationId: PostDiscountsDiscountRegionsRegion - summary: Adds Region availability - description: Adds a Region to the list of Regions that a Discount can be used in. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: region_id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - delete: - operationId: DeleteDiscountsDiscountRegionsRegion - summary: Remove Region availability - description: >- - Removes a Region from the list of Regions that a Discount can be used - in. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: region_id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/products/{product_id}': - post: - operationId: DeleteDiscountsDiscountProductsProduct - summary: Remove Product availability - description: >- - Removes a Product from the list of Products that a Discount can be used - for. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: product_id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - /discounts: - post: - operationId: PostDiscounts - summary: Creates a Discount - description: >- - Creates a Discount with a given set of rules that define how the - Discount behaves. - requestBody: - content: - application/json: - schema: - properties: - code: - type: string - description: A unique code that will be used to redeem the Discount - is_dynamic: - type: string - description: >- - Whether the Discount should have multiple instances of - itself, each with a different code. This can be useful for - automatically generated codes that all have to follow a - common set of rules. - rule: - description: The Discount Rule that defines how Discounts are calculated - oneOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - type: boolean - description: >- - Whether the Discount code is disabled on creation. You will - have to enable it later to make it available to Customers. - starts_at: - type: string - format: date-time - description: The time at which the Discount should be available. - ends_at: - type: string - format: date-time - description: >- - The time at which the Discount should no longer be - available. - regions: - description: >- - A list of Region ids representing the Regions in which the - Discount can be used. - type: array - items: - type: string - usage_limit: - type: number - description: Maximum times the discount can be used - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - get: - operationId: GetDiscounts - summary: List Discounts - description: Retrieves a list of Discounts - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/dynamic-codes': - post: - operationId: PostDiscountsDiscountDynamicCodes - summary: Create a dynamic Discount code - description: >- - Creates a unique code that can map to a parent Discount. This is useful - if you want to automatically generate codes with the same behaviour. - parameters: - - in: path - name: id - required: true - description: The id of the Discount to create the dynamic code from." - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - requestBody: - content: - application/json: - schema: - type: object - required: - - code - properties: - code: - type: string - description: The unique code that will be used to redeem the Discount. - metadata: - type: object - description: >- - An optional set of key-value paris to hold additional - information. - '/discounts/{id}': - delete: - operationId: DeleteDiscountsDiscount - summary: Delete a Discount - description: Deletes a Discount. - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Discount - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetDiscountsDiscount - summary: Retrieve a Discount - description: Retrieves a Discount - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - post: - operationId: PostDiscountsDiscount - summary: Update a Discount - description: >- - Updates a Discount with a given set of rules that define how the - Discount behaves. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - code: - type: string - description: A unique code that will be used to redeem the Discount - is_dynamic: - type: string - description: >- - Whether the Discount should have multiple instances of - itself, each with a different code. This can be useful for - automatically generated codes that all have to follow a - common set of rules. - rule: - description: The Discount Rule that defines how Discounts are calculated - oneOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - type: boolean - description: >- - Whether the Discount code is disabled on creation. You will - have to enable it later to make it available to Customers. - starts_at: - type: string - format: date-time - description: The time at which the Discount should be available. - ends_at: - type: string - format: date-time - description: >- - The time at which the Discount should no longer be - available. - regions: - description: >- - A list of Region ids representing the Regions in which the - Discount can be used. - type: array - items: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/dynamic-codes/{code}': - delete: - operationId: DeleteDiscountsDiscountDynamicCodesCode - summary: Delete a dynamic code - description: Deletes a dynamic code from a Discount. - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - - in: path - name: code - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - /gift-cards: - post: - operationId: PostGiftCards - summary: Create a Gift Card - description: >- - Creates a Gift Card that can redeemed by its unique code. The Gift Card - is only valid within 1 region. - requestBody: - content: - application/json: - schema: - properties: - value: - type: integer - description: >- - The value (excluding VAT) that the Gift Card should - represent. - is_disabled: - type: boolean - description: >- - Whether the Gift Card is disabled on creation. You will have - to enable it later to make it available to Customers. - ends_at: - type: string - format: date-time - description: >- - The time at which the Gift Card should no longer be - available. - region_id: - description: The id of the Region in which the Gift Card can be used. - type: array - items: - type: string - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - gift_card: - $ref: '#/components/schemas/gift_card' - get: - operationId: GetGiftCards - summary: List Gift Cards - description: Retrieves a list of Gift Cards. - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - '/gift-cards/{id}': - delete: - operationId: DeleteGiftCardsGiftCard - summary: Delete a Gift Card - description: Deletes a Gift Card - parameters: - - in: path - name: id - required: true - description: The id of the Gift Card to delete. - schema: - type: string - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Gift Card - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetGiftCardsGiftCard - summary: Retrieve a Gift Card - description: Retrieves a Gift Card. - parameters: - - in: path - name: id - required: true - description: The id of the Gift Card. - schema: - type: string - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - gift_card: - $ref: '#/components/schemas/gift_card' - post: - operationId: PostGiftCardsGiftCard - summary: Create a Gift Card - description: >- - Creates a Gift Card that can redeemed by its unique code. The Gift Card - is only valid within 1 region. - parameters: - - in: path - name: id - required: true - description: The id of the Gift Card. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - balance: - type: integer - description: >- - The value (excluding VAT) that the Gift Card should - represent. - is_disabled: - type: boolean - description: >- - Whether the Gift Card is disabled on creation. You will have - to enable it later to make it available to Customers. - ends_at: - type: string - format: date-time - description: >- - The time at which the Gift Card should no longer be - available. - region_id: - description: The id of the Region in which the Gift Card can be used. - type: array - items: - type: string - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - gift_card: - $ref: '#/components/schemas/gift_card' - /notifications: - get: - operationId: GetNotifications - summary: List Notifications - description: Retrieves a list of Notifications. - tags: - - Notification - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - notifications: - type: array - items: - $ref: '#/components/schemas/notification' - '/notifications/{id}/resend': - post: - operationId: PostNotificationsNotificationResend - summary: Resend Notification - description: >- - Resends a previously sent notifications, with the same data but - optionally to a different address - parameters: - - in: path - name: id - required: true - description: The id of the Notification - schema: - type: string - tags: - - Notification - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - notification: - $ref: '#/components/schemas/notification' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - '/products/{id}/options': - post: - operationId: PostProductsProductOptions - summary: Add an Option - description: Adds a Product Option to a Product - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - description: >- - The title the Product Option will be identified by i.e. - "Size" - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - /products: - post: - operationId: PostProducts - summary: Create a Product - description: Creates a Product - requestBody: - content: - application/json: - schema: - properties: - title: - description: The title of the Product - type: string - subtitle: - description: The subtitle of the Product - type: string - description: - description: A description of the Product. - type: string - is_giftcard: - description: >- - A flag to indicate if the Product represents a Gift Card. - Purchasing Products with this flag set to `true` will result - in a Gift Card being created. - type: boolean - images: - description: Images of the Product. - type: array - items: - type: string - thumbnail: - description: The thumbnail to use for the Product. - type: string - handle: - description: A unique handle to identify the Product by. - type: string - type: - description: The Product Type to associate the Product with. - type: object - properties: - value: - description: The value of the Product Type. - type: string - collection_id: - description: The id of the Collection the Product should belong to. - type: string - tags: - description: Tags to associate the Product with. - type: array - items: - properties: - id: - description: The id of an existing Tag. - type: string - value: - description: 'The value of the Tag, these will be upserted.' - type: string - options: - description: >- - The Options that the Product should have. These define on - which properties the Product's Product Variants will differ. - type: array - items: - properties: - title: - description: The title to identify the Product Option by. - type: string - variants: - description: A list of Product Variants to create with the Product. - type: array - items: - properties: - title: - description: The title to identify the Product Variant by. - type: string - sku: - description: The unique SKU for the Product Variant. - type: string - ean: - description: The EAN number of the item. - type: string - upc: - description: The UPC number of the item. - type: string - barcode: - description: A generic GTIN field for the Product Variant. - type: string - hs_code: - description: The Harmonized System code for the Product Variant. - type: string - inventory_quantity: - description: The amount of stock kept for the Product Variant. - type: integer - allow_backorder: - description: >- - Whether the Product Variant can be purchased when out - of stock. - type: boolean - manage_inventory: - description: >- - Whether Medusa should keep track of the inventory for - this Product Variant. - type: boolean - weight: - description: The wieght of the Product Variant. - type: string - length: - description: The length of the Product Variant. - type: string - height: - description: The height of the Product Variant. - type: string - width: - description: The width of the Product Variant. - type: string - origin_country: - description: The country of origin of the Product Variant. - type: string - mid_code: - description: >- - The Manufacturer Identification code for the Product - Variant. - type: string - material: - description: The material composition of the Product Variant. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - prices: - type: array - items: - properties: - region_id: - description: >- - The id of the Region for which the price is - used. - type: string - currency_code: - description: >- - The 3 character ISO currency code for which the - price will be used. - type: string - amount: - description: The amount to charge for the Product Variant. - type: integer - sale_amount: - description: >- - The sale amount to charge for the Product - Variant. - type: integer - options: - type: array - items: - properties: - value: - description: >- - The value to give for the Product Option at the - same index in the Product's `options` field. - type: string - weight: - description: The wieght of the Product. - type: string - length: - description: The length of the Product. - type: string - height: - description: The height of the Product. - type: string - width: - description: The width of the Product. - type: string - origin_country: - description: The country of origin of the Product. - type: string - mid_code: - description: The Manufacturer Identification code for the Product. - type: string - material: - description: The material composition of the Product. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - get: - operationId: GetProducts - summary: List Product - description: Retrieves a list of Product - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - count: - description: The number of Products. - type: integer - offset: - description: The offset of the Product query. - type: integer - limit: - description: The limit of the Product query. - type: integer - products: - type: array - items: - $ref: '#/components/schemas/product' - '/products/{id}/variants': - post: - operationId: PostProductsProductVariants - summary: Create a Product Variant - description: >- - Creates a Product Variant. Each Product Variant must have a unique - combination of Product Option Values. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - description: The title to identify the Product Variant by. - type: string - sku: - description: The unique SKU for the Product Variant. - type: string - ean: - description: The EAN number of the item. - type: string - upc: - description: The UPC number of the item. - type: string - barcode: - description: A generic GTIN field for the Product Variant. - type: string - hs_code: - description: The Harmonized System code for the Product Variant. - type: string - inventory_quantity: - description: The amount of stock kept for the Product Variant. - type: integer - allow_backorder: - description: >- - Whether the Product Variant can be purchased when out of - stock. - type: boolean - manage_inventory: - description: >- - Whether Medusa should keep track of the inventory for this - Product Variant. - type: boolean - weight: - description: The wieght of the Product Variant. - type: string - length: - description: The length of the Product Variant. - type: string - height: - description: The height of the Product Variant. - type: string - width: - description: The width of the Product Variant. - type: string - origin_country: - description: The country of origin of the Product Variant. - type: string - mid_code: - description: >- - The Manufacturer Identification code for the Product - Variant. - type: string - material: - description: The material composition of the Product Variant. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - prices: - type: array - items: - properties: - region_id: - description: The id of the Region for which the price is used. - type: string - currency_code: - description: >- - The 3 character ISO currency code for which the price - will be used. - type: string - amount: - description: The amount to charge for the Product Variant. - type: integer - sale_amount: - description: The sale amount to charge for the Product Variant. - type: integer - options: - type: array - items: - properties: - option_id: - description: The id of the Product Option to set the value for. - type: string - value: - description: The value to give for the Product Option. - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - get: - operationId: GetProductsProductVariants - summary: List a Product's Product Variants - description: Retrieves a list of the Product Variants associated with a Product. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - variants: - type: array - items: - $ref: '#/components/schemas/product_variant' - '/products/{id}/options/{option_id}': - delete: - operationId: DeleteProductsProductOptionsOption - summary: Delete a Product Option - description: >- - Deletes a Product Option. Before a Product Option can be deleted all - Option Values for the Product Option must be the same. You may, for - example, have to delete some of your variants prior to deleting the - Product Option - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - - in: path - name: option_id - required: true - description: The id of the Product Option. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Product Option - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - product: - $ref: '#/components/schemas/product' - post: - operationId: PostProductsProductOptionsOption - summary: Update a Product Option. - description: Updates a Product Option - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - - in: path - name: option_id - required: true - description: The id of the Product Option. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - description: The title of the Product Option - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - '/products/{id}': - delete: - operationId: DeleteProductsProduct - summary: Delete a Product - description: Deletes a Product and it's associated Product Variants. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Product. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetProductsProduct - summary: Retrieve a Product - description: Retrieves a Product. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - post: - operationId: PostProductsProduct - summary: Update a Product - description: Updates a Product - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - description: The title of the Product - type: string - subtitle: - description: The subtitle of the Product - type: string - description: - description: A description of the Product. - type: string - is_giftcard: - description: >- - A flag to indicate if the Product represents a Gift Card. - Purchasing Products with this flag set to `true` will result - in a Gift Card being created. - type: boolean - images: - description: Images of the Product. - type: array - items: - type: string - thumbnail: - description: The thumbnail to use for the Product. - type: string - handle: - description: A unique handle to identify the Product by. - type: string - type: - description: The Product Type to associate the Product with. - type: object - properties: - value: - description: The value of the Product Type. - type: string - collection_id: - description: The id of the Collection the Product should belong to. - type: string - tags: - description: Tags to associate the Product with. - type: array - items: - properties: - id: - description: The id of an existing Tag. - type: string - value: - description: 'The value of the Tag, these will be upserted.' - type: string - options: - description: >- - The Options that the Product should have. These define on - which properties the Product's Product Variants will differ. - type: array - items: - properties: - title: - description: The title to identify the Product Option by. - type: string - variants: - description: A list of Product Variants to create with the Product. - type: array - items: - properties: - title: - description: The title to identify the Product Variant by. - type: string - sku: - description: The unique SKU for the Product Variant. - type: string - ean: - description: The EAN number of the item. - type: string - upc: - description: The UPC number of the item. - type: string - barcode: - description: A generic GTIN field for the Product Variant. - type: string - hs_code: - description: The Harmonized System code for the Product Variant. - type: string - inventory_quantity: - description: The amount of stock kept for the Product Variant. - type: integer - allow_backorder: - description: >- - Whether the Product Variant can be purchased when out - of stock. - type: boolean - manage_inventory: - description: >- - Whether Medusa should keep track of the inventory for - this Product Variant. - type: boolean - weight: - description: The wieght of the Product Variant. - type: string - length: - description: The length of the Product Variant. - type: string - height: - description: The height of the Product Variant. - type: string - width: - description: The width of the Product Variant. - type: string - origin_country: - description: The country of origin of the Product Variant. - type: string - mid_code: - description: >- - The Manufacturer Identification code for the Product - Variant. - type: string - material: - description: The material composition of the Product Variant. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - prices: - type: array - items: - properties: - region_id: - description: >- - The id of the Region for which the price is - used. - type: string - currency_code: - description: >- - The 3 character ISO currency code for which the - price will be used. - type: string - amount: - description: The amount to charge for the Product Variant. - type: integer - sale_amount: - description: >- - The sale amount to charge for the Product - Variant. - type: integer - options: - type: array - items: - properties: - value: - description: >- - The value to give for the Product Option at the - same index in the Product's `options` field. - type: string - weight: - description: The wieght of the Product. - type: string - length: - description: The length of the Product. - type: string - height: - description: The height of the Product. - type: string - width: - description: The width of the Product. - type: string - origin_country: - description: The country of origin of the Product. - type: string - mid_code: - description: The Manufacturer Identification code for the Product. - type: string - material: - description: The material composition of the Product. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - '/products/{id}/variants/{variant_id}': - delete: - operationId: DeleteProductsProductVariantsVariant - summary: Delete a Product Variant - description: Deletes a Product Variant. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - - in: path - name: variant_id - required: true - description: The id of the Product Variant. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Product Variant. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - post: - operationId: PostProductsProductVariantsVariant - summary: Update a Product Variant - description: Update a Product Variant. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - - in: path - name: variant_id - required: true - description: The id of the Product Variant. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - description: The title to identify the Product Variant by. - type: string - sku: - description: The unique SKU for the Product Variant. - type: string - ean: - description: The EAN number of the item. - type: string - upc: - description: The UPC number of the item. - type: string - barcode: - description: A generic GTIN field for the Product Variant. - type: string - hs_code: - description: The Harmonized System code for the Product Variant. - type: string - inventory_quantity: - description: The amount of stock kept for the Product Variant. - type: integer - allow_backorder: - description: >- - Whether the Product Variant can be purchased when out of - stock. - type: boolean - manage_inventory: - description: >- - Whether Medusa should keep track of the inventory for this - Product Variant. - type: boolean - weight: - description: The wieght of the Product Variant. - type: string - length: - description: The length of the Product Variant. - type: string - height: - description: The height of the Product Variant. - type: string - width: - description: The width of the Product Variant. - type: string - origin_country: - description: The country of origin of the Product Variant. - type: string - mid_code: - description: >- - The Manufacturer Identification code for the Product - Variant. - type: string - material: - description: The material composition of the Product Variant. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - prices: - type: array - items: - properties: - region_id: - description: The id of the Region for which the price is used. - type: string - currency_code: - description: >- - The 3 character ISO currency code for which the price - will be used. - type: string - amount: - description: The amount to charge for the Product Variant. - type: integer - sale_amount: - description: The sale amount to charge for the Product Variant. - type: integer - options: - type: array - items: - properties: - option_id: - description: The id of the Product Option to set the value for. - type: string - value: - description: The value to give for the Product Option. - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - /products/types: - get: - operationId: GetProductsTypes - summary: List Product Types - description: Retrieves a list of Product Types. - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - types: - type: array - items: - $ref: '#/components/schemas/product_type' - '/regions/{id}/countries': - post: - operationId: PostRegionsRegionCountries - summary: Add Country - description: Adds a Country to the list of Countries in a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - country_code: - description: The 2 character ISO code for the Country. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-providers': - post: - operationId: PostRegionsRegionFulfillmentProviders - summary: Add Fulfillment Provider - description: Adds a Fulfillment Provider to a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - provider_id: - description: The id of the Fulfillment Provider to add. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/payment-providers': - post: - operationId: PostRegionsRegionPaymentProviders - summary: Add Payment Provider - description: Adds a Payment Provider to a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - provider_id: - description: The id of the Payment Provider to add. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - /regions: - post: - operationId: PostRegions - summary: Create a Region - description: Creates a Region - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Region - type: string - currency_code: - description: The 3 character ISO currency code to use for the Region. - type: string - tax_code: - description: An optional tax code the Region. - type: string - tax_rate: - description: The tax rate to use on Orders in the Region. - type: number - payment_providers: - description: >- - A list of Payment Providers that should be enabled for the - Region - type: array - items: - type: string - fulfillment_providers: - description: >- - A list of Fulfillment Providers that should be enabled for - the Region - type: array - items: - type: string - countries: - description: A list of countries that should be included in the Region. - type: array - items: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - get: - operationId: GetRegions - summary: List Regions - description: Retrieves a list of Regions. - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - regions: - type: array - items: - $ref: '#/components/schemas/region' - '/regions/{id}/metadata/{key}': - delete: - operationId: DeleteRegionsRegionMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}': - delete: - operationId: DeleteRegionsRegion - summary: Delete a Region - description: Deletes a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Region. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetRegionsRegion - summary: Retrieve a Region - description: Retrieves a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - post: - operationId: PostRegionsRegion - summary: Update a Region - description: Updates a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Region - type: string - currency_code: - description: The 3 character ISO currency code to use for the Region. - type: string - tax_code: - description: An optional tax code the Region. - type: string - tax_rate: - description: The tax rate to use on Orders in the Region. - type: number - payment_providers: - description: >- - A list of Payment Providers that should be enabled for the - Region - type: array - items: - type: string - fulfillment_providers: - description: >- - A list of Fulfillment Providers that should be enabled for - the Region - type: array - items: - type: string - countries: - description: A list of countries that should be included in the Region. - type: array - items: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-options': - get: - operationId: GetRegionsRegionFulfillmentOptions - summary: List Fulfillment Options available in the Region - description: Gathers all the fulfillment options available to in the Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - fulfillment_options: - type: array - items: - type: object - '/regions/{id}/countries/{country_code}': - delete: - operationId: PostRegionsRegionCountriesCountry - summary: Remove Country - description: Removes a Country from the list of Countries in a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: country_code - required: true - description: The 2 character ISO code for the Country. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-providers/{provider_id}': - delete: - operationId: PostRegionsRegionFulfillmentProvidersProvider - summary: Remove Fulfillment Provider - description: Removes a Fulfillment Provider. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: provider_id - required: true - description: The id of the Fulfillment Provider. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/payment-providers/{provider_id}': - delete: - operationId: PostRegionsRegionPaymentProvidersProvider - summary: Remove Payment Provider - description: Removes a Payment Provider. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: provider_id - required: true - description: The id of the Payment Provider. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - /returns: - get: - operationId: GetReturns - summary: List Returns - description: Retrieves a list of Returns - tags: - - Return - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - returns: - type: array - items: - $ref: '#/components/schemas/return' - '/returns/{id}receive': - post: - operationId: PostReturnsReturnReceive - summary: Receive a Return - description: >- - Registers a Return as received. Updates statuses on Orders and Swaps - accordingly. - parameters: - - in: path - name: id - required: true - description: The id of the Return. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Return - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return: - $ref: '#/components/schemas/return' - '/orders/{id}/shipping-methods': - post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: - description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. - type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - no_notification: - description: If set to true no notification will be send - type: boolean - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': - get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: - type: array - items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. - type: string - note: - description: A not with additional details about the Refund. - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - /shipping-options: - post: - operationId: PostShippingOptions - summary: Create Shipping Option - description: Creates a Shipping Option - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Shipping Option - type: string - region_id: - description: >- - The id of the Region in which the Shipping Option will be - available. - type: string - provider_id: - description: >- - The id of the Fulfillment Provider that handles the Shipping - Option. - type: string - profile_id: - description: >- - The id of the Shipping Profile to add the Shipping Option - to. - type: number - data: - description: >- - The data needed for the Fulfillment Provider to handle - shipping with this Shipping Option. - type: object - price_type: - description: The type of the Shipping Option price. - type: string - enum: - - flat_rate - - calculated - amount: - description: The amount to charge for the Shipping Option. - type: integer - requirements: - description: >- - The requirements that must be satisfied for the Shipping - Option to be available. - type: array - items: - properties: - type: - description: The type of the requirement - type: string - enum: - - max_subtotal - - min_subtotal - amount: - description: The amount to compare with. - type: integer - is_return: - description: Whether the Shipping Option defines a return shipment. - type: boolean - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_option: - $ref: '#/components/schemas/shipping_option' - get: - operationId: GetShippingOptions - summary: List Shipping Options - description: Retrieves a list of Shipping Options. - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_options: - type: array - items: - $ref: '#/components/schemas/shipping_option' - '/shipping-options/{id}': - delete: - operationId: DeleteShippingOptionsOption - summary: Delete a Shipping Option - description: Deletes a Shipping Option. - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Option. - schema: - type: string - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Shipping Option. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetShippingOptionsOption - summary: Retrieve a Shipping Option - description: Retrieves a Shipping Option. - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Option. - schema: - type: string - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_option: - $ref: '#/components/schemas/shipping_option' - post: - operationId: PostShippingOptionsOption - summary: Update Shipping Option - description: Updates a Shipping Option - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Option. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Shipping Option - type: string - amount: - description: The amount to charge for the Shipping Option. - type: integer - requirements: - description: >- - The requirements that must be satisfied for the Shipping - Option to be available. - type: array - items: - properties: - type: - description: The type of the requirement - type: string - enum: - - max_subtotal - - min_subtotal - amount: - description: The amount to compare with. - type: integer - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_option: - $ref: '#/components/schemas/shipping_option' - /shipping-profiles: - post: - operationId: PostShippingProfiles - summary: Create a Shipping Profile - description: Creates a Shipping Profile - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Shipping Profile - type: string - tags: - - Shipping Profile - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_profile: - $ref: '#/components/schemas/shipping_profile' - get: - operationId: GetShippingProfiles - summary: List Shipping Profiles - description: Retrieves a list of Shipping Profile. - tags: - - Shipping Profile - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_profiles: - type: array - items: - $ref: '#/components/schemas/shipping_profile' - '/shipping-profiles/{id}': - delete: - operationId: DeleteShippingProfilesProfile - summary: Delete a Shipping Profile - description: Deletes a Shipping Profile. - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Profile. - schema: - type: string - tags: - - Shipping Profile - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Shipping Profile. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetShippingProfilesProfile - summary: Retrieve a Shipping Profile - description: Retrieves a Shipping Profile. - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Profile. - schema: - type: string - tags: - - Shipping Profile - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_profile: - $ref: '#/components/schemas/shipping_profile' - post: - operationId: PostShippingProfilesProfile - summary: Update a Shipping Profiles - description: Updates a Shipping Profile - parameters: - - in: path - name: id - required: true - description: The id of the Shipping Profile. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Shipping Profile - type: string - tags: - - Shipping Profile - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_profiles: - $ref: '#/components/schemas/shipping_profile' - /swaps: - get: - operationId: GetSwaps - summary: List Swaps - description: Retrieves a list of Swaps. - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swaps: - type: array - items: - $ref: '#/components/schemas/swap' - '/store/currencies/{code}': - post: - operationId: PostStoreCurrenciesCode - summary: Add a Currency Code - description: Adds a Currency Code to the available currencies. - parameters: - - in: path - name: code - required: true - description: The 3 character ISO currency code. - schema: - type: string - tags: - - Store - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - store: - $ref: '#/components/schemas/store' - delete: - operationId: DeleteStoreCurrenciesCode - summary: Remvoe a Currency Code - description: Removes a Currency Code from the available currencies. - parameters: - - in: path - name: code - required: true - description: The 3 character ISO currency code. - schema: - type: string - tags: - - Store - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - store: - $ref: '#/components/schemas/store' - /store: - get: - operationId: GetStore - summary: Retrieve Store details. - description: Retrieves the Store details - tags: - - Store - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - store: - $ref: '#/components/schemas/store' - post: - operationId: PostStore - summary: Update Store details. - description: Updates the Store details - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Store - type: string - swap_link_template: - description: >- - A template for Swap links - use `{{cart_id}}` to insert the - Swap Cart id - type: string - default_currency_code: - description: The default currency code for the Store. - type: string - tags: - - Store - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - store: - $ref: '#/components/schemas/store' - /store/payment-providers: - get: - operationId: GetStorePaymentProviders - summary: Retrieve configured Payment Providers - description: Retrieves the configured Payment Providers - tags: - - Store - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - payment_providers: - type: array - items: - $ref: '#/components/schemas/store' - /variants: - get: - operationId: GetVariants - summary: List Product Variants. - description: Retrieves a list of Product Variants - tags: - - Product Variant - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - variants: - type: array - items: - $ref: '#/components/schemas/product_variant' -components: - schemas: - address: - title: Address - description: An address. - x-resourceId: address - properties: - id: - type: string - customer_id: - type: string - company: - type: string - first_name: - type: string - last_name: - type: string - address_1: - type: string - address_2: - type: string - city: - type: string - country_code: - type: string - country: - $ref: '#/components/schemas/country' - cart: - title: Cart - description: Represents a user cart - x-resourceId: cart - properties: - id: - type: string - email: - type: string - billing_address_id: - type: string - billing_address: - $ref: '#/components/schemas/address' - shipping_address_id: - type: string - shipping_address: - $ref: '#/components/schemas/address' - items: - type: array - items: - $ref: '#/components/schemas/line_item' - region_id: - type: string - region: - $ref: '#/components/schemas/region' - discounts: - type: array - items: - $ref: '#/components/schemas/region' - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - customer_id: - type: string - customer: - $ref: '#/components/schemas/customer' - payment_session: - $ref: '#/components/schemas/payment_session' - payment_sessions: - type: array - items: - $ref: '#/components/schemas/payment_session' - payment: - $ref: '#/components/schemas/payment' - shipping_methods: - type: array - items: - $ref: '#/components/schemas/shipping_method' - type: - type: string - enum: - - default - - swap - - payment_link - completed_at: - type: string - format: date-time - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - shipping_total: - type: integer - discount_total: - type: integer - tax_total: - type: integer - subtotal: - type: integer - refundable_amount: - type: integer - gift_card_total: - type: integer - claim_image: - title: Claim Image - description: Represents photo documentation of a claim. - x-resourceId: claim_image - properties: - id: - type: string - claim_item_id: - type: string - url: - type: string - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_item: - title: Claim Item - description: >- - Represents a claimed item along with information about the reasons for - the claim. - x-resourceId: claim_item - properties: - id: - type: string - images: - type: array - items: - $ref: '#/components/schemas/claim_image' - claim_order_id: - type: string - item_id: - type: string - item: - description: The Line Item that the claim refers to - $ref: '#/components/schemas/line_item' - variant_id: - type: string - variant: - description: The Product Variant that is claimed. - $ref: '#/components/schemas/product_variant' - reason: - description: The reason for the claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - note: - description: 'An optional note about the claim, for additional information' - type: string - quantity: - description: >- - The quantity of the item that is being claimed; must be less than or - equal to the amount purchased in the original order. - type: integer - tags: - description: User defined tags for easy filtering and grouping. - type: array - items: - $ref: '#/components/schemas/claim_tag' - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_order: - title: Claim Order - description: >- - Claim Orders represent a group of faulty or missing items. Each claim - order consists of a subset of items associated with an original order, - and can contain additional information about fulfillments and returns. - x-resourceId: claim_order - properties: - id: - type: string - type: - type: string - enum: - - refund - - replace - payment_status: - type: string - enum: - - na - - not_refunded - - refunded - fulfillment_status: - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - claim_items: - description: The items that have been claimed - type: array - items: - $ref: '#/components/schemas/claim_item' - additional_items: - description: >- - Refers to the new items to be shipped when the claim order has the - type `replace` - type: array - items: - $ref: '#/components/schemas/line_item' - order_id: - description: The id of the order that the claim comes from. - type: string - return_order: - description: Holds information about the return if the claim is to be returned - $ref: '#/components/schemas/return' - shipping_address_id: - description: The id of the address that the new items should be shipped to - type: string - shipping_address: - description: The address that the new items should be shipped to - $ref: '#/components/schemas/address' - shipping_methods: - description: The shipping methods that the claim order will be shipped with. - type: array - items: - $ref: '#/components/schemas/shipping_method' - fulfillments: - description: The fulfillments of the new items to be shipped - type: array - items: - $ref: '#/components/schemas/fulfillment' - refund_amount: - description: The amount that will be refunded in conjunction with the claim - type: integer - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_tag: - title: Claim Tag - description: >- - Claim Tags are user defined tags that can be assigned to claim items for - easy filtering and grouping. - x-resourceId: claim_tag - properties: - id: - description: The id of the claim tag. Will be prefixed by `ctag_`. - type: string - value: - description: The value that the claim tag holds - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - country: - title: Country - description: Country details - x-resourceId: country - properties: - id: - description: The database id of the country - type: integer - iso_2: - description: The 2 character ISO code for the country. - type: string - iso_3: - description: The 3 character ISO code for the country. - type: string - num_code: - description: The numerical ISO code for the country. - type: string - name: - description: The normalized country name; in upper case. - type: string - display_name: - description: The country name appropriate for display. - type: string - currency: - title: Currency - description: Currency - x-resourceId: currency - properties: - code: - description: The 3 character ISO code for the currency. - type: string - symbol: - description: The symbol used to indicate the currency. - type: string - symbol_native: - description: The native symbol used to indicate the currency. - type: string - name: - description: The written name of the currency - type: string - customer: - title: Customer - description: Represents a customer - x-resourceId: customer - properties: - id: - type: string - email: - type: string - billing_address_id: - type: string - billing_address: - description: The Customer's billing address. - anyOf: - - $ref: '#/components/schemas/address' - shipping_addresses: - type: array - items: - $ref: '#/components/schemas/address' - first_name: - type: string - last_name: - type: string - phone: - type: string - has_account: - type: boolean - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - discount_rule: - title: Discount Rule - description: >- - Holds the rules that governs how a Discount is calculated when applied - to a Cart. - x-resourceId: discount_rule - properties: - id: - description: The id of the Discount Rule. Will be prefixed by `dru_`. - type: string - type: - description: >- - The type of the Discount, can be `fixed` for discounts that reduce - the price by a fixed amount, `percentage` for percentage reductions - or `free_shipping` for shipping vouchers. - type: string - enum: - - fixed - - percentage - - free_shipping - description: - description: A short description of the discount - type: string - value: - description: >- - The value that the discount represents; this will depend on the type - of the discount - type: integer - allocation: - description: The scope that the discount should apply to. - type: string - enum: - - total - - item - valid_for: - description: A set of Products that the discount can be used for. - type: array - items: - $ref: '#/components/schemas/product' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - discount: - title: Discount - description: >- - Represents a discount that can be applied to a cart for promotional - purposes. - x-resourceId: discount - properties: - id: - description: The id of the Discount. Will be prefixed by `disc_`. - type: string - code: - description: >- - A unique code for the discount - this will be used by the customer - to apply the discount - type: string - is_dynamic: - description: >- - A flag to indicate if multiple instances of the discount can be - generated. I.e. for newsletter discounts - type: boolean - rule: - description: The Discount Rule that governs the behaviour of the Discount - anyOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - description: >- - Whether the Discount has been disabled. Disabled discounts cannot be - applied to carts - type: boolean - parent_discount_id: - description: >- - The Discount that the discount was created from. This will always be - a dynamic discount - type: string - starts_at: - description: The time at which the discount can be used. - type: string - format: date-time - ends_at: - description: The time at which the discount can no longer be used. - type: string - format: date-time - regions: - description: The Regions in which the Discount can be used - type: array - items: - $ref: '#/components/schemas/region' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer - usage_count: - description: The number of times a discount has been used. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - fulfillment_item: - title: Fulfillment Item - description: >- - Correlates a Line Item with a Fulfillment, keeping track of the quantity - of the Line Item. - x-resourceId: fulfillment_item - properties: - fulfillment_id: - description: The id of the Fulfillment that the Fulfillment Item belongs to. - type: string - item_id: - description: The id of the Line Item that the Fulfillment Item references. - type: string - item: - description: The Line Item that the Fulfillment Item references. - anyOf: - - $ref: '#/components/schemas/line_item' - quantity: - description: The quantity of the Line Item that is included in the Fulfillment. - type: integer - fulfillment_provider: - title: Fulfillment Provider - description: >- - Represents a fulfillment provider plugin and holds its installation - status. - x-resourceId: fulfillment_provider - properties: - id: - description: The id of the fulfillment provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - fulfillment: - title: Fulfillment - description: >- - Fulfillments are created once store operators can prepare the purchased - goods. Fulfillments will eventually be shipped and hold information - about how to track shipments. Fulfillments are created through a - provider, which is typically an external shipping aggregator, shipping - partner og 3PL, most plugins will have asynchronous communications with - these providers through webhooks in order to automatically update and - synchronize the state of Fulfillments. - x-resourceId: fulfillment - properties: - id: - description: The id of the Fulfillment. This value will be prefixed by `ful_`. - type: string - claim_order_id: - description: The id of the Claim that the Fulfillment belongs to. - type: string - swap_id: - description: The id of the Swap that the Fulfillment belongs to. - type: string - order_id: - description: The id of the Order that the Fulfillment belongs to. - type: string - provider_id: - description: >- - The id of the Fulfillment Provider responsible for handling the - fulfillment - type: string - items: - description: >- - The Fulfillment Items in the Fulfillment - these hold information - about how many of each Line Item has been fulfilled. - type: array - items: - $ref: '#/components/schemas/fulfillment_item' - tracking_links: - description: >- - The Tracking Links that can be used to track the status of the - Fulfillment, these will usually be provided by the Fulfillment - Provider. - type: array - items: - $ref: '#/components/schemas/tracking_link' - tracking_numbers: - deprecated: true - description: >- - The tracking numbers that can be used to track the status of the - fulfillment. - type: array - items: - type: string - shipped_at: - description: The date with timezone at which the Fulfillment was shipped. - type: string - format: date-time - canceled_at: - description: The date with timezone at which the Fulfillment was canceled. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - gift_card_transaction: - title: Gift Card Transaction - description: >- - Gift Card Transactions are created once a Customer uses a Gift Card to - pay for their Order - x-resourceId: gift_card_transaction - properties: - id: - description: >- - The id of the Gift Card Transaction. This value will be prefixed by - `gct_`. - type: string - gift_card_id: - description: The id of the Gift Card that was used in the transaction. - type: string - gift_card: - description: The Gift Card that was used in the transaction. - anyOf: - - $ref: '#/components/schemas/gift_card' - order_id: - description: The id of the Order that the Gift Card was used to pay for. - type: string - amount: - description: The amount that was used from the Gift Card. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - gift_card: - title: Gift Card - description: >- - Gift Cards are redeemable and represent a value that can be used towards - the payment of an Order. - x-resourceId: gift_card - properties: - id: - description: The id of the Gift Card. This value will be prefixed by `gift_`. - type: string - code: - description: >- - The unique code that identifies the Gift Card. This is used by the - Customer to redeem the value of the Gift Card. - type: string - value: - description: The value that the Gift Card represents. - type: integer - balance: - description: The remaining value on the Gift Card. - type: integer - region_id: - description: The id of the Region in which the Gift Card is available. - type: string - region: - description: The Region in which the Gift Card is available. - anyOf: - - $ref: '#/components/schemas/region' - order_id: - description: The id of the Order that the Gift Card was purchased in. - type: string - is_disabled: - description: >- - Whether the Gift Card has been disabled. Disabled Gift Cards cannot - be applied to carts. - type: boolean - ends_at: - description: The time at which the Gift Card can no longer be used. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - image: - title: Image - description: Images holds a reference to a URL at which the image file can be found. - x-resourceId: image - properties: - id: - description: The id of the Image. This value will be prefixed by `img_`. - type: string - url: - description: The URL at which the image file can be found. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - line_item: - title: Line Item - description: >- - Line Items represent purchasable units that can be added to a Cart for - checkout. When Line Items are purchased they will get copied to the - resulting order and can eventually be referenced in Fulfillments and - Returns. Line Items may also be created when processing Swaps and - Claims. - x-resourceId: line_item - properties: - id: - description: The id of the Line Item. This value will be prefixed by `item_`. - type: string - cart_id: - description: The id of the Cart that the Line Item belongs to. - type: string - order_id: - description: The id of the Order that the Line Item belongs to. - type: string - swap_id: - description: The id of the Swap that the Line Item belongs to. - type: string - claim_order_id: - description: The id of the Claim that the Line Item belongs to. - type: string - title: - description: >- - The title of the Line Item, this should be easily identifiable by - the Customer. - type: string - description: - description: A more detailed description of the contents of the Line Item. - type: string - thumbnail: - description: A URL string to a small image of the contents of the Line Item. - type: string - is_giftcard: - description: Flag to indicate if the Line Item is a Gift Card. - type: boolean - should_merge: - description: >- - Flag to indicate if new Line Items with the same variant should be - merged or added as an additional Line Item. - type: boolean - allow_discounts: - description: >- - Flag to indicate if the Line Item should be included when doing - discount calculations. - type: boolean - unit_price: - description: >- - The price of one unit of the content in the Line Item. This should - be in the currency defined by the Cart/Order/Swap/Claim that the - Line Item belongs to. - type: boolean - variant_id: - description: The id of the Product Variant contained in the Line Item. - type: string - variant: - description: The Product Variant contained in the Line Item. - anyOf: - - $ref: '#/components/schemas/product_variant' - quantity: - description: The quantity of the content in the Line Item. - type: integer - fulfilled_quantity: - description: The quantity of the Line Item that has been fulfilled. - type: integer - returned_quantity: - description: The quantity of the Line Item that has been returned. - type: integer - shipped_quantity: - description: The quantity of the Line Item that has been shipped. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - refundable: - description: >- - The amount that can be refunded from the given Line Item. Takes - taxes and discounts into consideration. - type: integer - money_amount: - title: Money Amount - description: >- - Money Amounts represents an amount that a given Product Variant can be - purcased for. Each Money Amount either has a Currency or Region - associated with it to indicate the pricing in a given Currency or, for - fully region-based pricing, the given price in a specific Region. If - region-based pricing is used the amount will be in the currency defined - for the Reigon. - x-resourceId: money_amount - properties: - id: - description: The id of the Money Amount. This value will be prefixed by `ma_`. - type: string - currency_code: - description: The 3 character currency code that the Money Amount is given in. - type: string - amount: - description: >- - The amount in the smallest currecny unit (e.g. cents 100 cents to - charge $1) that the Product Variant will cost. - type: integer - sale_amount: - description: >- - An optional sale amount that the Product Variant will be available - for when defined. - type: integer - variant_id: - description: The id of the Product Variant that the Money Amount belongs to. - type: string - region_id: - description: The id of the Region that the Money Amount is defined for. - type: string - region: - description: The Region that the Money Amount is defined for. - anyOf: - - $ref: '#/components/schemas/region' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - notification_provider: - title: Notification Provider - description: >- - Represents a notification provider plugin and holds its installation - status. - x-resourceId: notification_provider - properties: - id: - description: The id of the notification provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - notification: - title: Notification - description: >- - Notifications a communications sent via Notification Providers as a - reaction to internal events such as `order.placed`. Notifications can be - used to show a chronological timeline for communications sent to a - Customer regarding an Order, and enables resends. - x-resourceId: notification - properties: - id: - description: The id of the Notification. This value will be prefixed by `noti_`. - type: string - event_name: - description: The name of the event that the notification was sent for. - type: string - resource_type: - description: The type of resource that the Notification refers to. - type: string - resource_id: - description: The id of the resource that the Notification refers to. - type: string - customer_id: - description: The id of the Customer that the Notification was sent to. - type: string - customer: - description: The Customer that the Notification was sent to. - anyOf: - - $ref: '#/components/schemas/customer' - to: - description: >- - The address that the Notification was sent to. This will usually be - an email address, but represent other addresses such as a chat bot - user id - type: string - data: - description: >- - The data that the Notification was sent with. This contains all the - data necessary for the Notification Provider to initiate a resend. - type: object - parent_id: - description: The id of the Notification that was originally sent. - type: string - resends: - description: >- - The resends that have been completed after the original - Notification. - type: array - items: - $ref: '#/components/schemas/notification_resend' - provider_id: - description: The id of the Notification Provider that handles the Notification. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - notification_resend: - title: Notification Resend - description: A resend of a Notification. - x-resourceId: notification_resend - properties: - id: - description: The id of the Notification. This value will be prefixed by `noti_`. - type: string - event_name: - description: The name of the event that the notification was sent for. - type: string - resource_type: - description: The type of resource that the Notification refers to. - type: string - resource_id: - description: The id of the resource that the Notification refers to. - type: string - to: - description: >- - The address that the Notification was sent to. This will usually be - an email address, but represent other addresses such as a chat bot - user id - type: string - data: - description: >- - The data that the Notification was sent with. This contains all the - data necessary for the Notification Provider to initiate a resend. - type: object - parent_id: - description: The id of the Notification that was originally sent. - type: string - provider_id: - description: The id of the Notification Provider that handles the Notification. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - order: - title: Order - description: Represents an order - x-resourceId: order - properties: - id: - type: string - status: - type: string - enum: - - pending - - completed - - archived - - canceled - - requires_action - fulfillment_status: - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - payment_status: - type: string - enum: - - not_paid - - awaiting - - captured - - partially_refunded - - refuneded - - canceled - - requires_action - display_id: - type: integer - cart_id: - type: string - currency_code: - type: string - tax_rate: - type: integer - discounts: - type: array - items: - $ref: '#/components/schemas/discount' - email: - type: string - billing_address_id: - type: string - billing_address: - anyOf: - - $ref: '#/components/schemas/address' - shipping_address_id: - type: string - shipping_address: - anyOf: - - $ref: '#/components/schemas/address' - items: - type: array - items: - $ref: '#/components/schemas/line_item' - region_id: - type: string - region: - anyOf: - - $ref: '#/components/schemas/region' - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - customer_id: - type: string - customer: - anyOf: - - $ref: '#/components/schemas/customer' - payment_session: - anyOf: - - $ref: '#/components/schemas/payment_session' - payment_sessions: - type: array - items: - $ref: '#/components/schemas/payment_session' - payments: - type: array - items: - $ref: '#/components/schemas/payment' - shipping_methods: - type: array - items: - $ref: '#/components/schemas/shipping_method' - fulfillments: - type: array - items: - $ref: '#/components/schemas/fulfillment' - returns: - type: array - items: - $ref: '#/components/schemas/return' - claims: - type: array - items: - $ref: '#/components/schemas/claim_order' - refunds: - type: array - items: - $ref: '#/components/schemas/refund' - swaps: - type: array - items: - $ref: '#/components/schemas/refund' - gift_card_transactions: - type: array - items: - $ref: '#/components/schemas/gift_card_transaction' - canceled_at: - type: string - format: date-time - created_at: - type: string - format: date-time - update_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - shipping_total: - type: integer - discount_total: - type: integer - tax_total: - type: integer - subtotal: - type: integer - refundable_amount: - type: integer - gift_card_total: - type: integer - paid_total: - type: integer - payment_provider: - title: Payment Provider - description: Represents a Payment Provider plugin and holds its installation status. - x-resourceId: payment_provider - properties: - id: - description: The id of the payment provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - payment_session: - title: Payment Session - description: >- - Payment Sessions are created when a Customer initilizes the checkout - flow, and can be used to hold the state of a payment flow. Each Payment - Session is controlled by a Payment Provider, who is responsible for the - communication with external payment services. Authorized Payment - Sessions will eventually get promoted to Payments to indicate that they - are authorized for capture/refunds/etc. - x-resourceId: payment_session - properties: - id: - description: >- - The id of the Payment Session. This value will be prefixed with - `ps_`. - type: string - cart_id: - description: The id of the Cart that the Payment Session is created for. - type: string - provider_id: - description: >- - The id of the Payment Provider that is responsible for the Payment - Session - type: string - is_selected: - description: >- - A flag to indicate if the Payment Session has been selected as the - method that will be used to complete the purchase. - type: boolean - status: - description: >- - Indicates the status of the Payment Session. Will default to - `pending`, and will eventually become `authorized`. Payment Sessions - may have the status of `requires_more` to indicate that further - actions are to be completed by the Customer. - type: string - enum: - - authorized - - pending - - requires_more - - error - - canceled - data: - description: >- - The data required for the Payment Provider to identify, modify and - process the Payment Session. Typically this will be an object that - holds an id to the external payment session, but can be an empty - object if the Payment Provider doesn't hold any state. - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - payment: - title: Payment - description: >- - Payments represent an amount authorized with a given payment method, - Payments can be captured, canceled or refunded. - x-resourceId: payment - properties: - id: - description: The id of the Payment. This value will be prefixed with `pay_`. - type: string - swap_id: - description: The id of the Swap that the Payment is used for. - type: string - order_id: - description: The id of the Order that the Payment is used for. - type: string - cart_id: - description: The id of the Cart that the Payment Session is created for. - type: string - amount: - description: The amount that the Payment has been authorized for. - type: integer - currency_code: - description: The 3 character ISO currency code that the Payment is completed in. - type: string - amount_refunded: - description: >- - The amount of the original Payment amount that has been refunded - back to the Customer. - type: integer - provider_id: - description: The id of the Payment Provider that is responsible for the Payment - type: string - data: - description: >- - The data required for the Payment Provider to identify, modify and - process the Payment. Typically this will be an object that holds an - id to the external payment session, but can be an empty object if - the Payment Provider doesn't hold any state. - type: object - captured_at: - description: The date with timezone at which the Payment was captured. - type: string - format: date-time - canceled_at: - description: The date with timezone at which the Payment was canceled. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_collection: - title: Product Collection - description: Product Collections represents a group of Products that are related. - x-resourceId: product_collection - properties: - id: - description: >- - The id of the Product Collection. This value will be prefixed with - `pcol_`. - type: string - title: - description: The title that the Product Collection is identified by. - type: string - handle: - description: >- - A unique string that identifies the Product Collection - can for - example be used in slug structures. - type: string - products: - description: The Products contained in the Product Collection. - type: array - items: - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_option_value: - title: Product Option Value - description: >- - A value given to a Product Variant's option set. Product Variant have a - Product Option Value for each of the Product Options defined on the - Product. - x-resourceId: product_option_value - properties: - id: - description: >- - The id of the Product Option Value. This value will be prefixed with - `optval_`. - type: string - value: - description: >- - The value that the Product Variant has defined for the specific - Product Option (e.g. if the Product Option is "Size" this value - could be "Small", "Medium" or "Large"). - type: string - option_id: - description: >- - The id of the Product Option that the Product Option Value is - defined for. - type: string - variant_id: - description: >- - The id of the Product Variant that the Product Option Value is - defined for. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_option: - title: Product Option - description: >- - Product Options define properties that may vary between different - variants of a Product. Common Product Options are "Size" and "Color", - but Medusa doesn't limit what Product Options that can be defined. - x-resourceId: product_option - properties: - id: - description: >- - The id of the Product Option. This value will be prefixed with - `opt_`. - type: string - title: - description: The title that the Product Option is defined by (e.g. "Size"). - type: string - values: - description: The Product Option Values that are defined for the Product Option. - type: array - items: - $ref: '#/components/schemas/product_option_value' - product_id: - description: The id of the Product that the Product Option is defined for. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_tag: - title: Product Tag - description: Product Tags can be added to Products for easy filtering and grouping. - x-resourceId: product_tag - properties: - id: - description: The id of the Product Tag. This value will be prefixed with `ptag_`. - type: string - value: - description: The value that the Product Tag represents (e.g. "Pants"). - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_type: - title: Product Type - description: >- - Product Type can be added to Products for filtering and reporting - purposes. - x-resourceId: product_type - properties: - id: - description: >- - The id of the Product Type. This value will be prefixed with - `ptyp_`. - type: string - value: - description: The value that the Product Type represents (e.g. "Clothing"). - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_variant: - title: Product Variant - description: >- - Product Variants represent a Product with a specific set of Product - Option configurations. The maximum number of Product Variants that a - Product can have is given by the number of available Product Option - combinations. - x-resourceId: product_variant - properties: - id: - description: >- - The id of the Product Variant. This value will be prefixed with - `variant_`. - type: string - title: - description: >- - A title that can be displayed for easy identification of the Product - Variant. - type: string - product_id: - description: The id of the Product that the Product Variant belongs to. - type: string - prices: - description: >- - The Money Amounts defined for the Product Variant. Each Money Amount - represents a price in a given currency or a price in a specific - Region. - type: array - items: - $ref: '#/components/schemas/money_amount' - sku: - description: >- - The unique stock keeping unit used to identify the Product Variant. - This will usually be a unqiue identifer for the item that is to be - shipped, and can be referenced across multiple systems. - type: string - barcode: - description: >- - A generic field for a GTIN number that can be used to identify the - Product Variant. - type: string - ean: - description: >- - An EAN barcode number that can be used to identify the Product - Variant. - type: string - upc: - description: >- - A UPC barcode number that can be used to identify the Product - Variant. - type: string - inventory_quantity: - description: The current quantity of the item that is stocked. - type: integer - allow_backorder: - description: >- - Whether the Product Variant should be purchasable when - `inventory_quantity` is 0. - type: boolean - manage_inventory: - description: Whether Medusa should manage inventory for the Product Variant. - type: boolean - hs_code: - description: >- - The Harmonized System code of the Product Variant. May be used by - Fulfillment Providers to pass customs information to shipping - carriers. - type: string - origin_country: - description: >- - The country in which the Product Variant was produced. May be used - by Fulfillment Providers to pass customs information to shipping - carriers. - type: string - mid_code: - description: >- - The Manufacturers Identification code that identifies the - manufacturer of the Product Variant. May be used by Fulfillment - Providers to pass customs information to shipping carriers. - type: string - material: - description: >- - The material and composition that the Product Variant is made of, - May be used by Fulfillment Providers to pass customs information to - shipping carriers. - type: string - weight: - description: >- - The weight of the Product Variant. May be used in shipping rate - calculations. - type: string - height: - description: >- - The height of the Product Variant. May be used in shipping rate - calculations. - type: string - width: - description: >- - The width of the Product Variant. May be used in shipping rate - calculations. - type: string - length: - description: >- - The length of the Product Variant. May be used in shipping rate - calculations. - type: string - options: - description: The Product Option Values specified for the Product Variant. - type: array - items: - $ref: '#/components/schemas/product_option_value' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product: - title: Product - description: >- - Products are a grouping of Product Variants that have common properties - such as images and descriptions. Products can have multiple options - which define the properties that Product Variants differ by. - x-resourceId: product - properties: - id: - description: The id of the Product. This value will be prefixed with `prod_`. - type: string - title: - description: >- - A title that can be displayed for easy identification of the - Product. - type: string - subtitle: - description: >- - An optional subtitle that can be used to further specify the - Product. - type: string - description: - description: A short description of the Product. - type: string - handle: - description: A unique identifier for the Product (e.g. for slug structure). - type: string - is_giftcard: - description: >- - Whether the Product represents a Gift Card. Products that represent - Gift Cards will automatically generate a redeemable Gift Card code - once they are purchased. - type: boolean - images: - description: Images of the Product - type: array - items: - $ref: '#/components/schemas/image' - thumbnail: - description: A URL to an image file that can be used to identify the Product. - type: string - options: - description: >- - The Product Options that are defined for the Product. Product - Variants of the Product will have a unique combination of Product - Option Values. - type: array - items: - $ref: '#/components/schemas/product_option' - variants: - description: >- - The Product Variants that belong to the Product. Each will have a - unique combination of Product Option Values. - type: array - items: - $ref: '#/components/schemas/product_variant' - profile_id: - description: >- - The id of the Shipping Profile that the Product belongs to. Shipping - Profiles have a set of defined Shipping Options that can be used to - Fulfill a given set of Products. - type: string - hs_code: - description: >- - The Harmonized System code of the Product Variant. May be used by - Fulfillment Providers to pass customs information to shipping - carriers. - type: string - origin_country: - description: >- - The country in which the Product Variant was produced. May be used - by Fulfillment Providers to pass customs information to shipping - carriers. - type: string - mid_code: - description: >- - The Manufacturers Identification code that identifies the - manufacturer of the Product Variant. May be used by Fulfillment - Providers to pass customs information to shipping carriers. - type: string - material: - description: >- - The material and composition that the Product Variant is made of, - May be used by Fulfillment Providers to pass customs information to - shipping carriers. - type: string - weight: - description: >- - The weight of the Product Variant. May be used in shipping rate - calculations. - type: string - height: - description: >- - The height of the Product Variant. May be used in shipping rate - calculations. - type: string - width: - description: >- - The width of the Product Variant. May be used in shipping rate - calculations. - type: string - length: - description: >- - The length of the Product Variant. May be used in shipping rate - calculations. - type: string - type: - description: The Product Type of the Product (e.g. "Clothing") - anyOf: - - $ref: '#/components/schemas/product_type' - collection: - description: The Product Collection that the Product belongs to (e.g. "SS20") - anyOf: - - $ref: '#/components/schemas/product_collection' - tags: - description: The Product Tags assigned to the Product. - type: array - items: - $ref: '#/components/schemas/product_tag' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - refund: - title: Refund - description: >- - Refund represent an amount of money transfered back to the Customer for - a given reason. Refunds may occur in relation to Returns, Swaps and - Claims, but can also be initiated by a store operator. - x-resourceId: refund - properties: - id: - description: The id of the Refund. This value will be prefixed with `ref_`. - type: string - order_id: - description: The id of the Order that the Refund is related to. - type: string - amount: - description: The amount that has be refunded to the Customer. - type: integer - note: - description: An optional note explaining why the amount was refunded. - type: string - reason: - description: >- - The reason given for the Refund, will automatically be set when - processed as part of a Swap, Claim or Return. - type: string - enum: - - discount - - return - - swap - - claim - - other - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - region: - title: Region - description: >- - Regions hold settings for how Customers in a given geographical location - shop. The is, for example, where currencies and tax rates are defined. A - Region can consist of multiple countries to accomodate common shopping - settings across countries. - x-resourceId: region - properties: - id: - description: The id of the Region. This value will be prefixed with `reg_`. - type: string - name: - description: >- - The name of the region as displayed to the customer. If the Region - only has one country it is recommended to write the country name. - type: string - currency_code: - description: >- - The 3 character ISO currency code that Customers will shop in in the - Region. - type: string - tax_rate: - description: The tax rate that should be charged on purchases in the Region. - type: number - tax_code: - description: >- - The tax code used on purchases in the Region. This may be used by - other systems for accounting purposes. - type: string - countries: - description: The countries that are included in the Region. - type: array - items: - $ref: '#/components/schemas/country' - payment_providers: - description: >- - The Payment Providers that can be used to process Payments in the - Region. - type: array - items: - $ref: '#/components/schemas/payment_provider' - fulfillment_providers: - description: >- - The Fulfillment Providers that can be used to fulfill orders in the - Region. - type: array - items: - $ref: '#/components/schemas/fulfillment_provider' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - return_item: - title: Return Item - description: >- - Correlates a Line Item with a Return, keeping track of the quantity of - the Line Item that will be returned. - x-resourceId: return_item - properties: - return_id: - description: The id of the Return that the Return Item belongs to. - type: string - item_id: - description: The id of the Line Item that the Return Item references. - type: string - item: - description: The Line Item that the Return Item references. - anyOf: - - $ref: '#/components/schemas/line_item' - quantity: - description: The quantity of the Line Item that is included in the Return. - type: integer - is_requested: - description: >- - Whether the Return Item was requested initially or received - unexpectedly in the warehouse. - type: boolean - requested_quantity: - description: The quantity that was originally requested to be returned. - type: integer - recieved_quantity: - description: The quantity that was received in the warehouse. - type: integer - reason: - description: The reason for returning the item. - anyOf: - - $ref: '#/components/schemas/return_reason' - note: - description: An optional note with additional details about the Return. - type: string - metadata: - description: An optional key-value map with additional information. - type: object - return_reason: - title: Return Reason - description: >- - A Reason for why a given product is returned. A Return Reason can be - used on Return Items in order to indicate why a Line Item was returned. - x-resourceId: return_reason - properties: - id: - description: The id of the Return Reason will start with `rr_`. - type: string - description: - description: A description of the Reason. - type: string - label: - description: A text that can be displayed to the Customer as a reason. - type: string - value: - description: The value to identify the reason by. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - return: - title: Return - description: >- - Return orders hold information about Line Items that a Customer wishes - to send back, along with how the items will be returned. Returns can be - used as part of a Swap. - x-resourceId: return - properties: - id: - description: The id of the Return. This value will be prefixed with `ret_`. - type: string - status: - description: Status of the Return. - type: string - enum: - - requested - - received - - requires_action - items: - description: >- - The Return Items that will be shipped back to the warehouse. type: - array items: $ref: - swap_id: - description: The id of the Swap that the Return is a part of. - type: string - order_id: - description: The id of the Order that the Return is made from. - type: string - claim_order_id: - description: The id of the Claim that the Return is a part of. - type: string - shipping_method: - description: >- - The Shipping Method that will be used to send the Return back. Can - be null if the Customer facilitates the return shipment themselves. - anyOf: - - $ref: '#/components/schemas/shipping_method' - shipping_data: - description: >- - Data about the return shipment as provided by the Fulfilment - Provider that handles the return shipment. - type: object - refund_amount: - description: The amount that should be refunded as a result of the return. - type: integer - received_at: - description: The date with timezone at which the return was received. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - shipping_method: - title: Shipping Method - description: >- - Shipping Methods represent a way in which an Order or Return can be - shipped. Shipping Methods are built from a Shipping Option, but may - contain additional details, that can be necessary for the Fulfillment - Provider to handle the shipment. - x-resourceId: shipping_method - properties: - id: - description: >- - The id of the Shipping Method. This value will be prefixed with - `sm_`. - type: string - shipping_option_id: - description: >- - The id of the Shipping Option that the Shipping Method is built - from. - type: string - shipping_option: - description: The Shipping Option that the Shipping Method is built from. - anyOf: - - $ref: '#/components/schemas/shipping_option' - order_id: - description: The id of the Order that the Shipping Method is used on. - type: string - return_id: - description: The id of the Return that the Shipping Method is used on. - type: string - swap_id: - description: The id of the Swap that the Shipping Method is used on. - type: string - cart_id: - description: The id of the Cart that the Shipping Method is used on. - type: string - claim_order_id: - description: The id of the Claim that the Shipping Method is used on. - type: string - price: - description: >- - The amount to charge for the Shipping Method. The currency of the - price is defined by the Region that the Order that the Shipping - Method belongs to is a part of. - type: integer - data: - description: >- - Additional data that the Fulfillment Provider needs to fulfill the - shipment. This is used in combination with the Shipping Options - data, and may contain information such as a drop point id. - type: object - shipping_option_requirement: - title: Shipping Option Requirement - description: >- - A requirement that a Cart must satisfy for the Shipping Option to be - available to the Cart. - x-resourceId: shipping_option_requirement - properties: - id: - description: >- - The id of the Shipping Option Requirement. This value will be - prefixed with `sor_`. - type: string - shipping_option_id: - description: >- - The id of the Shipping Option that the Shipping Option Requirement - belongs to. - type: string - type: - description: >- - The type of the requirement, this defines how the value will be - compared to the Cart's total. `min_subtotal` requirements define the - minimum subtotal that is needed for the Shipping Option to be - available, while the `max_subtotal` defines the maximum subtotal - that the Cart can have for the Shipping Option to be available. - type: string - enum: - - min_subtotal - - max_subtotal - amount: - description: The amount to compare the Cart subtotal to. - type: integer - shipping_option: - title: Shipping Option - description: >- - Shipping Options represent a way in which an Order or Return can be - shipped. Shipping Options have an associated Fulfillment Provider that - will be used when the fulfillment of an Order is initiated. Shipping - Options themselves cannot be added to Carts, but serve as a template for - Shipping Methods. This distinction makes it possible to customize - individual Shipping Methods with additional information. - x-resourceId: shipping_option - properties: - id: - description: >- - The id of the Shipping Option. This value will be prefixed with - `so_`. - type: string - name: - description: >- - The name given to the Shipping Option - this may be displayed to the - Customer. - type: string - region_id: - description: The id of the Region that the Shipping Option belongs to. - type: string - region: - description: The id of the Region that the Shipping Option belongs to. - anyOf: - - $ref: '#/components/schemas/region' - profile_id: - description: >- - The id of the Shipping Profile that the Shipping Option belongs to. - Shipping Profiles have a set of defined Shipping Options that can be - used to Fulfill a given set of Products. - type: string - provider_id: - description: >- - The id of the Fulfillment Provider, that will be used to process - Fulfillments from the Shipping Option. - type: string - price_type: - description: >- - The type of pricing calculation that is used when creatin Shipping - Methods from the Shipping Option. Can be `flat_rate` for fixed - prices or `calculated` if the Fulfillment Provider can provide price - calulations. - type: string - enum: - - flat_rate - - calculated - amount: - description: >- - The amount to charge for shipping when the Shipping Option price - type is `flat_rate`. - type: integer - is_return: - description: >- - Flag to indicate if the Shipping Option can be used for Return - shipments. - type: boolean - requirements: - description: >- - The requirements that must be satisfied for the Shipping Option to - be available for a Cart. - type: array - items: - $ref: '#/components/schemas/shipping_option_requirement' - data: - description: >- - The data needed for the Fulfillment Provider to identify the - Shipping Option. - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - shipping_profile: - title: Shipping Profile - description: >- - Shipping Profiles have a set of defined Shipping Options that can be - used to fulfill a given set of Products. - x-resourceId: shipping_profile - properties: - id: - description: >- - The id of the Shipping Profile. This value will be prefixed with - `sp_`. - type: string - name: - description: >- - The name given to the Shipping profile - this may be displayed to - the Customer. - type: string - type: - description: >- - The type of the Shipping Profile, may be `default`, `gift_card` or - `custom`. - type: string - enum: - - default - - gift_card - - custom - products: - description: The Products that the Shipping Profile defines Shipping Options for. - type: array - items: - $ref: '#/components/schemas/product' - shipping_options: - description: >- - The Shipping Options that can be used to fulfill the Products in the - Shipping Profile. - type: array - items: - anyOf: - - $ref: '#/components/schemas/shipping_option' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - store: - title: Store - description: 'Holds settings for the Store, such as name, currencies, etc.' - x-resourceId: store - properties: - id: - description: The id of the Store. This value will be prefixed with `store_`. - type: string - name: - description: The name of the Store - this may be displayed to the Customer. - type: string - default_currency_code: - description: >- - The default currency code used when no other currency code is - specified. - type: string - currencies: - description: The currencies that are enabled for the Store. - type: array - items: - $ref: '#/components/schemas/currency' - swap_link_template: - description: >- - A template to generate Swap links from use {{cart_id}} to include - the Swap's `cart_id` in the link. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - swap: - title: Swap - description: >- - Swaps can be created when a Customer wishes to exchange Products that - they have purchased to different Products. Swaps consist of a Return of - previously purchased Products and a Fulfillment of new Products, the - amount paid for the Products being returned will be used towards payment - for the new Products. In the case where the amount paid for the the - Products being returned exceed the amount to be paid for the new - Products, a Refund will be issued for the difference. - x-resourceId: swap - properties: - id: - description: The id of the Swap. This value will be prefixed with `swap_`. - type: string - fulfillment_status: - description: The status of the Fulfillment of the Swap. - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - payment_status: - description: >- - The status of the Payment of the Swap. The payment may either refer - to the refund of an amount or the authorization of a new amount. - type: string - enum: - - not_paid - - awaiting - - captured - - canceled - - difference_refunded - - requires_action - order_id: - description: >- - The id of the Order where the Line Items to be returned where - purchased. - type: string - additional_items: - description: The new Line Items to ship to the Customer. - type: array - items: - $ref: '#/components/schemas/line_item' - return_order: - description: The Return that is issued for the return part of the Swap. - anyOf: - - $ref: '#/components/schemas/return' - fulfillments: - description: The Fulfillments used to send the new Line Items. - type: array - items: - $ref: '#/components/schemas/fulfillment' - payment: - description: >- - The Payment authorized when the Swap requires an additional amount - to be charged from the Customer. - anyOf: - - $ref: '#/components/schemas/payment' - difference_due: - description: >- - The difference that is paid or refunded as a result of the Swap. May - be negative when the amount paid for the returned items exceed the - total of the new Products. - type: integer - shipping_address: - description: >- - The Address to send the new Line Items to - in most cases this will - be the same as the shipping address on the Order. - anyOf: - - $ref: '#/components/schemas/address' - shipping_methods: - description: The Shipping Methods used to fulfill the addtional items purchased. - type: array - items: - $ref: '#/components/schemas/shipping_method' - cart_id: - description: The id of the Cart that the Customer will use to confirm the Swap. - type: string - confirmed_at: - description: >- - The date with timezone at which the Swap was confirmed by the - Customer. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - tracking_link: - title: Tracking Link - description: >- - Tracking Link holds information about tracking numbers for a - Fulfillment. Tracking Links can optionally contain a URL that can be - visited to see the status of the shipment. - x-resourceId: tracking_link - properties: - id: - description: >- - The id of the Tracking Link. This value will be prefixed with - `tlink_`. - type: string - url: - description: The URL at which the status of the shipment can be tracked. - type: string - tracking_number: - description: The tracking number given by the shipping carrier. - type: string - fulfillment_id: - description: The id of the Fulfillment that the Tracking Link references. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - user: - title: User - description: Represents a User who can manage store settings. - x-resourceId: user - properties: - id: - description: The unique id of the User. This will be prefixed with `usr_` - type: string - email: - description: The email of the User - type: string - first_name: - type: string - last_name: - description: The Customer's billing address. - anyOf: - - $ref: '#/components/schemas/address' - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json deleted file mode 100644 index 545a298abd..0000000000 --- a/docs/api/store-spec3.json +++ /dev/null @@ -1,4883 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "version": "1.0.0", - "title": "Medusa Storefront API", - "license": { - "name": "MIT" - } - }, - "tags": [ - { - "name": "Auth", - "description": "Auth endpoints allows authorization of admin Users and manages their sessions." - }, - { - "name": "Cart", - "x-resourceId": "cart" - }, - { - "name": "Collection", - "x-resourceId": "product_collection" - }, - { - "name": "Customer", - "x-resourceId": "customer" - }, - { - "name": "Discount", - "x-resourceId": "discount" - }, - { - "name": "Gift Card", - "x-resourceId": "gift_card" - }, - { - "name": "Notification", - "x-resourceId": "notification" - }, - { - "name": "Order", - "x-resourceId": "order" - }, - { - "name": "Product", - "x-resourceId": "product" - }, - { - "name": "Region", - "x-resourceId": "region" - }, - { - "name": "Return", - "x-resourceId": "return" - }, - { - "name": "Shipping Option", - "x-resourceId": "shipping_option" - }, - { - "name": "Shipping Profile", - "x-resourceId": "shipping_profile" - }, - { - "name": "Swap", - "x-resourceId": "swap" - }, - { - "name": "Product Variant", - "x-resourceId": "product_variant" - } - ], - "servers": [ - { - "url": "https://api.medusa-commerce.com/store" - } - ], - "paths": { - "/auth": { - "post": { - "operationId": "PostAuth", - "summary": "Authenticate Customer", - "description": "Logs a Customer in and authorizes them to view their details. Successful authentication will set a session cookie in the Customer's browser.", - "parameters": [], - "tags": [ - "Auth" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "password" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email." - }, - "password": { - "type": "string", - "description": "The Customer's password." - } - } - } - } - } - } - }, - "delete": { - "operationId": "DeleteAuth", - "summary": "Log out", - "description": "Destroys a Customer's authenticated session.", - "tags": [ - "Auth" - ], - "responses": { - "200": { - "description": "OK" - } - } - }, - "get": { - "operationId": "GetAuth", - "summary": "Get Session", - "description": "Gets the currently logged in Customer.", - "tags": [ - "Auth" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/auth/{email}": { - "get": { - "operationId": "GetAuthEmail", - "summary": "Check if email has account", - "description": "Checks if a Customer with the given email has signed up.", - "parameters": [ - { - "in": "path", - "name": "email", - "required": true, - "description": "The Customer's email.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Auth" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "exists": { - "type": "boolean" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/shipping-methods": { - "post": { - "operationId": "PostCartsCartShippingMethod", - "description": "Adds a Shipping Method to the Cart.", - "summary": "Add a Shipping Method", - "tags": [ - "Cart" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The cart id.", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "A successful response", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "option_id" - ], - "properties": { - "option_id": { - "type": "string", - "description": "id of the shipping option to create the method from" - }, - "data": { - "type": "object", - "description": "Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send." - } - } - } - } - } - } - } - }, - "/carts/{id}/complete-cart": { - "post": { - "summary": "Complete a Cart", - "operationId": "PostCartsCartComplete", - "description": "Completes a cart. The following steps will be performed. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header `Idempotency-Key`. If not provided, we will generate one for the request.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The Cart id.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "If a cart was successfully authorized, but requires further action from the user the response body will contain the cart with an updated payment session. If the Cart was successfully completed the response body will contain the newly created Order.", - "content": { - "application/json": { - "schema": { - "oneOf": [ - { - "type": "object", - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - }, - { - "type": "object", - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - ] - } - } - } - } - } - } - }, - "/carts": { - "post": { - "summary": "Create a Cart", - "operationId": "PostCart", - "description": "Creates a Cart within the given region and with the initial items. If no `region_id` is provided the cart will be associated with the first Region available. If no items are provided the cart will be empty after creation. If a user is logged in the cart's customer id and email will be set.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "region_id": { - "type": "string", - "description": "The id of the Region to create the Cart in." - }, - "country_code": { - "type": "string", - "description": "The 2 character ISO country code to create the Cart in." - }, - "items": { - "description": "An optional array of `variant_id`, `quantity` pairs to generate Line Items from.", - "type": "array", - "items": { - "properties": { - "variant_id": { - "description": "The id of the Product Variant to generate a Line Item from.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Product Variant to add", - "type": "integer" - } - } - } - }, - "context": { - "description": "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "Successfully created a new Cart", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/line-items": { - "post": { - "operationId": "PostCartsCartLineItems", - "summary": "Add a Line Item", - "description": "Generates a Line Item with a given Product Variant and adds it to the Cart", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart to add the Line Item to.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "variant_id", - "quantity" - ], - "properties": { - "variant_id": { - "type": "string", - "description": "The id of the Product Variant to generate the Line Item from." - }, - "quantity": { - "type": "integer", - "description": "The quantity of the Product Variant to add to the Line Item." - }, - "metadata": { - "type": "object", - "description": "An optional key-value map with additional details about the Line Item." - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-sessions": { - "post": { - "operationId": "PostCartsCartPaymentSessions", - "summary": "Initialize Payment Sessions", - "description": "Creates Payment Sessions for each of the available Payment Providers in the Cart's Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/discounts/{code}": { - "delete": { - "operationId": "DeleteCartsCartDiscountsDiscount", - "description": "Removes a Discount from a Cart.", - "summary": "Remove Discount from Cart", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Discount code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/line-items/{line_id}": { - "delete": { - "operationId": "DeleteCartsCartLineItemsItem", - "summary": "Delete a Line Item", - "description": "Removes a Line Item from a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "line_id", - "required": true, - "description": "The id of the Line Item.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCartsCartLineItemsItem", - "summary": "Update a Line Item", - "description": "Updates a Line Item if the desired quantity can be fulfilled.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "line_id", - "required": true, - "description": "The id of the Line Item.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "quantity" - ], - "properties": { - "quantity": { - "type": "integer", - "description": "The quantity to set the Line Item to." - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-sessions/{provider_id}": { - "delete": { - "operationId": "DeleteCartsCartPaymentSessionsSession", - "summary": "Delete a Payment Session", - "description": "Deletes a Payment Session on a Cart. May be useful if a payment has failed.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "provider_id", - "required": true, - "description": "The id of the Payment Provider used to create the Payment Session to be deleted.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCartsCartPaymentSessionsSession", - "summary": "Refresh a Payment Session", - "description": "Refreshes a Payment Session to ensure that it is in sync with the Cart - this is usually not necessary.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "provider_id", - "required": true, - "description": "The id of the Payment Provider that created the Payment Session to be refreshed.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}": { - "get": { - "operationId": "GetCartsCart", - "summary": "Retrieve a Cart", - "description": "Retrieves a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-session": { - "post": { - "operationId": "PostCartsCartPaymentSession", - "summary": "Select a Payment Session", - "description": "Selects a Payment Session as the session intended to be used towards the completion of the Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "provider_id" - ], - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider." - } - } - } - } - } - } - } - }, - "/store/carts/{id}": { - "post": { - "operationId": "PostCartsCart", - "summary": "Update a Cart\"", - "description": "Updates a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "region_id": { - "type": "string", - "description": "The id of the Region to create the Cart in." - }, - "country_code": { - "type": "string", - "description": "The 2 character ISO country code to create the Cart in." - }, - "email": { - "type": "string", - "description": "An email to be used on the Cart." - }, - "billing_address": { - "description": "The Address to be used for billing purposes.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "shipping_address": { - "description": "The Address to be used for shipping.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "gift_cards": { - "description": "An array of Gift Card codes to add to the Cart.", - "type": "array", - "items": { - "properties": { - "code": { - "description": "The code that a Gift Card is identified by.", - "type": "string" - } - } - } - }, - "discounts": { - "description": "An array of Discount codes to add to the Cart.", - "type": "array", - "items": { - "properties": { - "code": { - "description": "The code that a Discount is identifed by.", - "type": "string" - } - } - } - }, - "customer_id": { - "description": "The id of the Customer to associate the Cart with.", - "type": "string" - }, - "context": { - "description": "An optional object to provide context to the Cart.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-session/update": { - "post": { - "operationId": "PostCartsCartPaymentSessionUpdate", - "summary": "Update a Payment Session", - "description": "Updates a Payment Session with additional data.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "provider_id", - "data" - ], - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider responsible for the Payment Session to update." - }, - "data": { - "type": "object", - "description": "The data to update the payment session with." - } - } - } - } - } - } - } - }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", - "parameters": [ - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Gift Card code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/customers/{id}/addresses": { - "post": { - "operationId": "PostCustomersCustomerAddresses", - "summary": "Add a Shipping Address", - "description": "Adds a Shipping Address to a Customer's saved addresses.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The Customer id.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "address": { - "description": "The Address to add to the Customer.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - } - } - } - } - } - }, - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "A successful response", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/customers": { - "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer account.", - "parameters": [], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name", - "password" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "password": { - "type": "string", - "description": "The Customer's password for login." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } - } - } - }, - "/customers/{id}/addresses/{address_id}": { - "delete": { - "operationId": "DeleteCustomersCustomerAddressesAddress", - "summary": "Delete an Address", - "description": "Removes an Address from the Customer's saved addresse.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "address_id", - "required": true, - "description": "The id of the Address to remove.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCustomersCustomerAddressesAddress", - "summary": "Update a Shipping Address", - "description": "Updates a Customer's saved Shipping Address.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The Customer id.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "address_id", - "required": true, - "description": "The id of the Address to update.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "address": { - "description": "The updated Address.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - } - } - } - } - } - }, - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieves a Customer", - "description": "Retrieves a Customer - the Customer must be logged in to retrieve their details.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update Customer details", - "description": "Updates a Customer's saved details.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "first_name": { - "description": "The Customer's first name.", - "type": "string" - }, - "last_name": { - "description": "The Customer's last name.", - "type": "string" - }, - "password": { - "description": "The Customer's password.", - "type": "string" - }, - "phone": { - "description": "The Customer's phone number.", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/customers/{id}/payment-methods": { - "get": { - "operationId": "GetCustomersCustomerPaymentMethods", - "summary": "Retrieve saved payment methods", - "description": "Retrieves a list of a Customer's saved payment methods. Payment methods are saved with Payment Providers and it is their responsibility to fetch saved methods.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "payment_methods": { - "type": "array", - "items": { - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider where the payment method is saved." - }, - "data": { - "type": "object", - "description": "The data needed for the Payment Provider to use the saved payment method." - } - } - } - } - } - } - } - } - } - } - } - }, - "/customers/{id}/orders": { - "get": { - "operationId": "GetCustomersCustomerOrders", - "summary": "Retrieve Customer Orders", - "description": "Retrieves a list of a Customer's Orders.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "payment_methods": { - "type": "array", - "items": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - } - }, - "/customers/{id}/password-token": { - "post": { - "operationId": "PostCustomersCustomerPasswordToken", - "summary": "Creates a reset password token", - "description": "Creates a reset password token to be used in a subsequent /reset-password request. The password token should be sent out of band e.g. via email and will not be returned.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "204": { - "description": "OK" - } - } - } - }, - "/customers/{id}/reset-password": { - "post": { - "operationId": "PostCustomersCustomerResetPassword", - "summary": "Resets Customer password", - "description": "Resets a Customer's password using a password token created by a previous /password-token request.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "token", - "password" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email." - }, - "token": { - "type": "string", - "description": "The password token created by a /password-token request." - }, - "password": { - "type": "string", - "description": "The new password to set for the Customer." - } - } - } - } - } - } - } - }, - "/orders/cart/{cart_id}": { - "get": { - "operationId": "GetOrdersOrderCartId", - "summary": "Retrieves Order by Cart id", - "description": "Retrieves an Order by the id of the Cart that was used to create the Order.", - "parameters": [ - { - "in": "path", - "name": "cart_id", - "required": true, - "description": "The id of Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, - "/orders/{id}": { - "get": { - "operationId": "GetOrdersOrder", - "summary": "Retrieves an Order", - "description": "Retrieves an Order", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/orders": { - "get": { - "operationId": "GetOrders", - "summary": "Look Up an Order", - "description": "Looks for an Order with a given `display_id`, `email` pair. The `display_id`, `email` pair must match in order for the Order to be returned.", - "parameters": [ - { - "in": "query", - "name": "display_id", - "required": true, - "description": "The display id given to the Order.", - "schema": { - "type": "number" - } - }, - { - "in": "query", - "name": "email", - "required": true, - "description": "The email of the Order with the given display_id.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, - "/products/{id}": { - "get": { - "operationId": "GetProductsProduct", - "summary": "Retrieves a Product", - "description": "Retrieves a Product.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Product.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "product": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - }, - "/products": { - "get": { - "operationId": "GetProducts", - "summary": "List Products", - "description": "Retrieves a list of Products.", - "tags": [ - "Product" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of Products.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of Products to return,", - "type": "integer" - }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - } - } - } - } - } - } - } - } - }, - "/regions/{id}": { - "get": { - "operationId": "GetRegionsRegion", - "summary": "Retrieves a Region", - "description": "Retrieves a Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Region.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "region": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - }, - "/regions": { - "get": { - "operationId": "GetRegions", - "summary": "List Regions", - "description": "Retrieves a list of Regions.", - "tags": [ - "Region" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "count": { - "description": "The total number of regions.", - "type": "integer" - }, - "offset": { - "description": "The offset for pagination.", - "type": "integer" - }, - "limit": { - "description": "The maxmimum number of regions to return,", - "type": "integer" - }, - "regions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - } - } - } - } - } - } - } - } - }, - "/returns": { - "post": { - "operationId": "PostReturns", - "summary": "Create Return", - "description": "Creates a Return for an Order.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "order_id": { - "type": "string", - "description": "The id of the Order to create the Return from." - }, - "items": { - "description": "The items to include in the Return.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item from the Order.", - "type": "string" - }, - "quantity": { - "description": "The quantity to return.", - "type": "integer" - } - } - } - }, - "return_shipping": { - "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", - "type": "object", - "properties": { - "option_id": { - "type": "string", - "description": "The id of the Shipping Option to create the Shipping Method from." - } - } - }, - "no_notification": { - "description": "If set to true no notification will be send", - "type": "boolean" - } - } - } - } - } - }, - "tags": [ - "Return" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return": { - "$ref": "#/components/schemas/return" - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, - "/return-reasons": { - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/shipping-options": { - "get": { - "operationId": "GetShippingOptions", - "summary": "Retrieve Shipping Options", - "description": "Retrieves a list of Shipping Options.", - "parameters": [ - { - "in": "query", - "name": "is_return", - "description": "Whether return Shipping Options should be included. By default all Shipping Options are returned.", - "schema": { - "type": "boolean" - } - }, - { - "in": "query", - "name": "product_ids", - "description": "A comma separated list of Product ids to filter Shipping Options by.", - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "region_id", - "description": "the Region to retrieve Shipping Options from.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Option" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_options": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_option" - } - } - } - } - } - } - } - } - } - }, - "/shipping-options/{cart_id}": { - "get": { - "operationId": "GetShippingOptionsCartId", - "summary": "Retrieve Shipping Options for Cart", - "description": "Retrieves a list of Shipping Options available to a cart.", - "parameters": [ - { - "in": "path", - "name": "cart_id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Option" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_options": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_option" - } - } - } - } - } - } - } - } - } - }, - "/swaps/{cart_id}": { - "get": { - "operationId": "GetSwapsSwapCartId", - "summary": "Retrieve Swap by Cart id", - "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", - "parameters": [ - { - "in": "path", - "name": "cart_id", - "required": true, - "description": "The id of the Cart", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Swap" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "swap": { - "$ref": "#/components/schemas/swap" - } - } - } - } - } - } - } - } - }, - "/variants/{variant_id}": { - "get": { - "operationId": "GetVariantsVariant", - "summary": "Retrieve a Product Variant", - "description": "Retrieves a Product Variant by id", - "parameters": [ - { - "in": "path", - "name": "variant_id", - "required": true, - "description": "The id of the Product Variant.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product Variant" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "variant": { - "$ref": "#/components/schemas/product_variant" - } - } - } - } - } - } - } - } - }, - "/variants": { - "get": { - "operationId": "GetVariants", - "summary": "Retrieve Product Variants", - "description": "Retrieves a list of Product Variants", - "parameters": [ - { - "in": "query", - "name": "ids", - "description": "A comma separated list of Product Variant ids to filter by.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Product Variant" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "variants": { - "type": "array", - "items": { - "$ref": "#/components/schemas/product_variant" - } - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "address": { - "title": "Address", - "description": "An address.", - "x-resourceId": "address", - "properties": { - "id": { - "type": "string" - }, - "customer_id": { - "type": "string" - }, - "company": { - "type": "string" - }, - "first_name": { - "type": "string" - }, - "last_name": { - "type": "string" - }, - "address_1": { - "type": "string" - }, - "address_2": { - "type": "string" - }, - "city": { - "type": "string" - }, - "country_code": { - "type": "string" - }, - "country": { - "$ref": "#/components/schemas/country" - } - } - }, - "cart": { - "title": "Cart", - "description": "Represents a user cart", - "x-resourceId": "cart", - "properties": { - "id": { - "type": "string" - }, - "email": { - "type": "string" - }, - "billing_address_id": { - "type": "string" - }, - "billing_address": { - "$ref": "#/components/schemas/address" - }, - "shipping_address_id": { - "type": "string" - }, - "shipping_address": { - "$ref": "#/components/schemas/address" - }, - "items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/line_item" - } - }, - "region_id": { - "type": "string" - }, - "region": { - "$ref": "#/components/schemas/region" - }, - "discounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - }, - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - }, - "customer_id": { - "type": "string" - }, - "customer": { - "$ref": "#/components/schemas/customer" - }, - "payment_session": { - "$ref": "#/components/schemas/payment_session" - }, - "payment_sessions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/payment_session" - } - }, - "payment": { - "$ref": "#/components/schemas/payment" - }, - "shipping_methods": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_method" - } - }, - "type": { - "type": "string", - "enum": [ - "default", - "swap", - "payment_link" - ] - }, - "completed_at": { - "type": "string", - "format": "date-time" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - }, - "shipping_total": { - "type": "integer" - }, - "discount_total": { - "type": "integer" - }, - "tax_total": { - "type": "integer" - }, - "subtotal": { - "type": "integer" - }, - "refundable_amount": { - "type": "integer" - }, - "gift_card_total": { - "type": "integer" - } - } - }, - "claim_image": { - "title": "Claim Image", - "description": "Represents photo documentation of a claim.", - "x-resourceId": "claim_image", - "properties": { - "id": { - "type": "string" - }, - "claim_item_id": { - "type": "string" - }, - "url": { - "type": "string" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - } - } - }, - "claim_item": { - "title": "Claim Item", - "description": "Represents a claimed item along with information about the reasons for the claim.", - "x-resourceId": "claim_item", - "properties": { - "id": { - "type": "string" - }, - "images": { - "type": "array", - "items": { - "$ref": "#/components/schemas/claim_image" - } - }, - "claim_order_id": { - "type": "string" - }, - "item_id": { - "type": "string" - }, - "item": { - "description": "The Line Item that the claim refers to", - "$ref": "#/components/schemas/line_item" - }, - "variant_id": { - "type": "string" - }, - "variant": { - "description": "The Product Variant that is claimed.", - "$ref": "#/components/schemas/product_variant" - }, - "reason": { - "description": "The reason for the claim", - "type": "string", - "enum": [ - "missing_item", - "wrong_item", - "production_failure", - "other" - ] - }, - "note": { - "description": "An optional note about the claim, for additional information", - "type": "string" - }, - "quantity": { - "description": "The quantity of the item that is being claimed; must be less than or equal to the amount purchased in the original order.", - "type": "integer" - }, - "tags": { - "description": "User defined tags for easy filtering and grouping.", - "type": "array", - "items": { - "$ref": "#/components/schemas/claim_tag" - } - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - } - } - }, - "claim_order": { - "title": "Claim Order", - "description": "Claim Orders represent a group of faulty or missing items. Each claim order consists of a subset of items associated with an original order, and can contain additional information about fulfillments and returns.", - "x-resourceId": "claim_order", - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "refund", - "replace" - ] - }, - "payment_status": { - "type": "string", - "enum": [ - "na", - "not_refunded", - "refunded" - ] - }, - "fulfillment_status": { - "type": "string", - "enum": [ - "not_fulfilled", - "partially_fulfilled", - "fulfilled", - "partially_shipped", - "shipped", - "partially_returned", - "returned", - "canceled", - "requires_action" - ] - }, - "claim_items": { - "description": "The items that have been claimed", - "type": "array", - "items": { - "$ref": "#/components/schemas/claim_item" - } - }, - "additional_items": { - "description": "Refers to the new items to be shipped when the claim order has the type `replace`", - "type": "array", - "items": { - "$ref": "#/components/schemas/line_item" - } - }, - "order_id": { - "description": "The id of the order that the claim comes from.", - "type": "string" - }, - "return_order": { - "description": "Holds information about the return if the claim is to be returned", - "$ref": "#/components/schemas/return" - }, - "shipping_address_id": { - "description": "The id of the address that the new items should be shipped to", - "type": "string" - }, - "shipping_address": { - "description": "The address that the new items should be shipped to", - "$ref": "#/components/schemas/address" - }, - "shipping_methods": { - "description": "The shipping methods that the claim order will be shipped with.", - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_method" - } - }, - "fulfillments": { - "description": "The fulfillments of the new items to be shipped", - "type": "array", - "items": { - "$ref": "#/components/schemas/fulfillment" - } - }, - "refund_amount": { - "description": "The amount that will be refunded in conjunction with the claim", - "type": "integer" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - } - } - }, - "claim_tag": { - "title": "Claim Tag", - "description": "Claim Tags are user defined tags that can be assigned to claim items for easy filtering and grouping.", - "x-resourceId": "claim_tag", - "properties": { - "id": { - "description": "The id of the claim tag. Will be prefixed by `ctag_`.", - "type": "string" - }, - "value": { - "description": "The value that the claim tag holds", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "update_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "country": { - "title": "Country", - "description": "Country details", - "x-resourceId": "country", - "properties": { - "id": { - "description": "The database id of the country", - "type": "integer" - }, - "iso_2": { - "description": "The 2 character ISO code for the country.", - "type": "string" - }, - "iso_3": { - "description": "The 3 character ISO code for the country.", - "type": "string" - }, - "num_code": { - "description": "The numerical ISO code for the country.", - "type": "string" - }, - "name": { - "description": "The normalized country name; in upper case.", - "type": "string" - }, - "display_name": { - "description": "The country name appropriate for display.", - "type": "string" - } - } - }, - "currency": { - "title": "Currency", - "description": "Currency", - "x-resourceId": "currency", - "properties": { - "code": { - "description": "The 3 character ISO code for the currency.", - "type": "string" - }, - "symbol": { - "description": "The symbol used to indicate the currency.", - "type": "string" - }, - "symbol_native": { - "description": "The native symbol used to indicate the currency.", - "type": "string" - }, - "name": { - "description": "The written name of the currency", - "type": "string" - } - } - }, - "customer": { - "title": "Customer", - "description": "Represents a customer", - "x-resourceId": "customer", - "properties": { - "id": { - "type": "string" - }, - "email": { - "type": "string" - }, - "billing_address_id": { - "type": "string" - }, - "billing_address": { - "description": "The Customer's billing address.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "shipping_addresses": { - "type": "array", - "items": { - "$ref": "#/components/schemas/address" - } - }, - "first_name": { - "type": "string" - }, - "last_name": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "has_account": { - "type": "boolean" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - } - } - }, - "discount_rule": { - "title": "Discount Rule", - "description": "Holds the rules that governs how a Discount is calculated when applied to a Cart.", - "x-resourceId": "discount_rule", - "properties": { - "id": { - "description": "The id of the Discount Rule. Will be prefixed by `dru_`.", - "type": "string" - }, - "type": { - "description": "The type of the Discount, can be `fixed` for discounts that reduce the price by a fixed amount, `percentage` for percentage reductions or `free_shipping` for shipping vouchers.", - "type": "string", - "enum": [ - "fixed", - "percentage", - "free_shipping" - ] - }, - "description": { - "description": "A short description of the discount", - "type": "string" - }, - "value": { - "description": "The value that the discount represents; this will depend on the type of the discount", - "type": "integer" - }, - "allocation": { - "description": "The scope that the discount should apply to.", - "type": "string", - "enum": [ - "total", - "item" - ] - }, - "valid_for": { - "description": "A set of Products that the discount can be used for.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "update_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "discount": { - "title": "Discount", - "description": "Represents a discount that can be applied to a cart for promotional purposes.", - "x-resourceId": "discount", - "properties": { - "id": { - "description": "The id of the Discount. Will be prefixed by `disc_`.", - "type": "string" - }, - "code": { - "description": "A unique code for the discount - this will be used by the customer to apply the discount", - "type": "string" - }, - "is_dynamic": { - "description": "A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts", - "type": "boolean" - }, - "rule": { - "description": "The Discount Rule that governs the behaviour of the Discount", - "anyOf": [ - { - "$ref": "#/components/schemas/discount_rule" - } - ] - }, - "is_disabled": { - "description": "Whether the Discount has been disabled. Disabled discounts cannot be applied to carts", - "type": "boolean" - }, - "parent_discount_id": { - "description": "The Discount that the discount was created from. This will always be a dynamic discount", - "type": "string" - }, - "starts_at": { - "description": "The time at which the discount can be used.", - "type": "string", - "format": "date-time" - }, - "ends_at": { - "description": "The time at which the discount can no longer be used.", - "type": "string", - "format": "date-time" - }, - "regions": { - "description": "The Regions in which the Discount can be used", - "type": "array", - "items": { - "$ref": "#/components/schemas/region" - } - }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, - "usage_count": { - "description": "The number of times a discount has been used.", - "type": "integer" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "fulfillment_item": { - "title": "Fulfillment Item", - "description": "Correlates a Line Item with a Fulfillment, keeping track of the quantity of the Line Item.", - "x-resourceId": "fulfillment_item", - "properties": { - "fulfillment_id": { - "description": "The id of the Fulfillment that the Fulfillment Item belongs to.", - "type": "string" - }, - "item_id": { - "description": "The id of the Line Item that the Fulfillment Item references.", - "type": "string" - }, - "item": { - "description": "The Line Item that the Fulfillment Item references.", - "anyOf": [ - { - "$ref": "#/components/schemas/line_item" - } - ] - }, - "quantity": { - "description": "The quantity of the Line Item that is included in the Fulfillment.", - "type": "integer" - } - } - }, - "fulfillment_provider": { - "title": "Fulfillment Provider", - "description": "Represents a fulfillment provider plugin and holds its installation status.", - "x-resourceId": "fulfillment_provider", - "properties": { - "id": { - "description": "The id of the fulfillment provider as given by the plugin.", - "type": "string" - }, - "is_installed": { - "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", - "type": "boolean" - } - } - }, - "fulfillment": { - "title": "Fulfillment", - "description": "Fulfillments are created once store operators can prepare the purchased goods. Fulfillments will eventually be shipped and hold information about how to track shipments. Fulfillments are created through a provider, which is typically an external shipping aggregator, shipping partner og 3PL, most plugins will have asynchronous communications with these providers through webhooks in order to automatically update and synchronize the state of Fulfillments.", - "x-resourceId": "fulfillment", - "properties": { - "id": { - "description": "The id of the Fulfillment. This value will be prefixed by `ful_`.", - "type": "string" - }, - "claim_order_id": { - "description": "The id of the Claim that the Fulfillment belongs to.", - "type": "string" - }, - "swap_id": { - "description": "The id of the Swap that the Fulfillment belongs to.", - "type": "string" - }, - "order_id": { - "description": "The id of the Order that the Fulfillment belongs to.", - "type": "string" - }, - "provider_id": { - "description": "The id of the Fulfillment Provider responsible for handling the fulfillment", - "type": "string" - }, - "items": { - "description": "The Fulfillment Items in the Fulfillment - these hold information about how many of each Line Item has been fulfilled.", - "type": "array", - "items": { - "$ref": "#/components/schemas/fulfillment_item" - } - }, - "tracking_links": { - "description": "The Tracking Links that can be used to track the status of the Fulfillment, these will usually be provided by the Fulfillment Provider.", - "type": "array", - "items": { - "$ref": "#/components/schemas/tracking_link" - } - }, - "tracking_numbers": { - "deprecated": true, - "description": "The tracking numbers that can be used to track the status of the fulfillment.", - "type": "array", - "items": { - "type": "string" - } - }, - "shipped_at": { - "description": "The date with timezone at which the Fulfillment was shipped.", - "type": "string", - "format": "date-time" - }, - "canceled_at": { - "description": "The date with timezone at which the Fulfillment was canceled.", - "type": "string", - "format": "date-time" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "gift_card_transaction": { - "title": "Gift Card Transaction", - "description": "Gift Card Transactions are created once a Customer uses a Gift Card to pay for their Order", - "x-resourceId": "gift_card_transaction", - "properties": { - "id": { - "description": "The id of the Gift Card Transaction. This value will be prefixed by `gct_`.", - "type": "string" - }, - "gift_card_id": { - "description": "The id of the Gift Card that was used in the transaction.", - "type": "string" - }, - "gift_card": { - "description": "The Gift Card that was used in the transaction.", - "anyOf": [ - { - "$ref": "#/components/schemas/gift_card" - } - ] - }, - "order_id": { - "description": "The id of the Order that the Gift Card was used to pay for.", - "type": "string" - }, - "amount": { - "description": "The amount that was used from the Gift Card.", - "type": "integer" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - } - } - }, - "gift_card": { - "title": "Gift Card", - "description": "Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.", - "x-resourceId": "gift_card", - "properties": { - "id": { - "description": "The id of the Gift Card. This value will be prefixed by `gift_`.", - "type": "string" - }, - "code": { - "description": "The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.", - "type": "string" - }, - "value": { - "description": "The value that the Gift Card represents.", - "type": "integer" - }, - "balance": { - "description": "The remaining value on the Gift Card.", - "type": "integer" - }, - "region_id": { - "description": "The id of the Region in which the Gift Card is available.", - "type": "string" - }, - "region": { - "description": "The Region in which the Gift Card is available.", - "anyOf": [ - { - "$ref": "#/components/schemas/region" - } - ] - }, - "order_id": { - "description": "The id of the Order that the Gift Card was purchased in.", - "type": "string" - }, - "is_disabled": { - "description": "Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.", - "type": "boolean" - }, - "ends_at": { - "description": "The time at which the Gift Card can no longer be used.", - "type": "string", - "format": "date-time" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "image": { - "title": "Image", - "description": "Images holds a reference to a URL at which the image file can be found.", - "x-resourceId": "image", - "properties": { - "id": { - "description": "The id of the Image. This value will be prefixed by `img_`.", - "type": "string" - }, - "url": { - "description": "The URL at which the image file can be found.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "update_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "line_item": { - "title": "Line Item", - "description": "Line Items represent purchasable units that can be added to a Cart for checkout. When Line Items are purchased they will get copied to the resulting order and can eventually be referenced in Fulfillments and Returns. Line Items may also be created when processing Swaps and Claims.", - "x-resourceId": "line_item", - "properties": { - "id": { - "description": "The id of the Line Item. This value will be prefixed by `item_`.", - "type": "string" - }, - "cart_id": { - "description": "The id of the Cart that the Line Item belongs to.", - "type": "string" - }, - "order_id": { - "description": "The id of the Order that the Line Item belongs to.", - "type": "string" - }, - "swap_id": { - "description": "The id of the Swap that the Line Item belongs to.", - "type": "string" - }, - "claim_order_id": { - "description": "The id of the Claim that the Line Item belongs to.", - "type": "string" - }, - "title": { - "description": "The title of the Line Item, this should be easily identifiable by the Customer.", - "type": "string" - }, - "description": { - "description": "A more detailed description of the contents of the Line Item.", - "type": "string" - }, - "thumbnail": { - "description": "A URL string to a small image of the contents of the Line Item.", - "type": "string" - }, - "is_giftcard": { - "description": "Flag to indicate if the Line Item is a Gift Card.", - "type": "boolean" - }, - "should_merge": { - "description": "Flag to indicate if new Line Items with the same variant should be merged or added as an additional Line Item.", - "type": "boolean" - }, - "allow_discounts": { - "description": "Flag to indicate if the Line Item should be included when doing discount calculations.", - "type": "boolean" - }, - "unit_price": { - "description": "The price of one unit of the content in the Line Item. This should be in the currency defined by the Cart/Order/Swap/Claim that the Line Item belongs to.", - "type": "boolean" - }, - "variant_id": { - "description": "The id of the Product Variant contained in the Line Item.", - "type": "string" - }, - "variant": { - "description": "The Product Variant contained in the Line Item.", - "anyOf": [ - { - "$ref": "#/components/schemas/product_variant" - } - ] - }, - "quantity": { - "description": "The quantity of the content in the Line Item.", - "type": "integer" - }, - "fulfilled_quantity": { - "description": "The quantity of the Line Item that has been fulfilled.", - "type": "integer" - }, - "returned_quantity": { - "description": "The quantity of the Line Item that has been returned.", - "type": "integer" - }, - "shipped_quantity": { - "description": "The quantity of the Line Item that has been shipped.", - "type": "integer" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - }, - "refundable": { - "description": "The amount that can be refunded from the given Line Item. Takes taxes and discounts into consideration.", - "type": "integer" - } - } - }, - "money_amount": { - "title": "Money Amount", - "description": "Money Amounts represents an amount that a given Product Variant can be purcased for. Each Money Amount either has a Currency or Region associated with it to indicate the pricing in a given Currency or, for fully region-based pricing, the given price in a specific Region. If region-based pricing is used the amount will be in the currency defined for the Reigon.", - "x-resourceId": "money_amount", - "properties": { - "id": { - "description": "The id of the Money Amount. This value will be prefixed by `ma_`.", - "type": "string" - }, - "currency_code": { - "description": "The 3 character currency code that the Money Amount is given in.", - "type": "string" - }, - "amount": { - "description": "The amount in the smallest currecny unit (e.g. cents 100 cents to charge $1) that the Product Variant will cost.", - "type": "integer" - }, - "sale_amount": { - "description": "An optional sale amount that the Product Variant will be available for when defined.", - "type": "integer" - }, - "variant_id": { - "description": "The id of the Product Variant that the Money Amount belongs to.", - "type": "string" - }, - "region_id": { - "description": "The id of the Region that the Money Amount is defined for.", - "type": "string" - }, - "region": { - "description": "The Region that the Money Amount is defined for.", - "anyOf": [ - { - "$ref": "#/components/schemas/region" - } - ] - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - } - } - }, - "notification_provider": { - "title": "Notification Provider", - "description": "Represents a notification provider plugin and holds its installation status.", - "x-resourceId": "notification_provider", - "properties": { - "id": { - "description": "The id of the notification provider as given by the plugin.", - "type": "string" - }, - "is_installed": { - "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", - "type": "boolean" - } - } - }, - "notification": { - "title": "Notification", - "description": "Notifications a communications sent via Notification Providers as a reaction to internal events such as `order.placed`. Notifications can be used to show a chronological timeline for communications sent to a Customer regarding an Order, and enables resends.", - "x-resourceId": "notification", - "properties": { - "id": { - "description": "The id of the Notification. This value will be prefixed by `noti_`.", - "type": "string" - }, - "event_name": { - "description": "The name of the event that the notification was sent for.", - "type": "string" - }, - "resource_type": { - "description": "The type of resource that the Notification refers to.", - "type": "string" - }, - "resource_id": { - "description": "The id of the resource that the Notification refers to.", - "type": "string" - }, - "customer_id": { - "description": "The id of the Customer that the Notification was sent to.", - "type": "string" - }, - "customer": { - "description": "The Customer that the Notification was sent to.", - "anyOf": [ - { - "$ref": "#/components/schemas/customer" - } - ] - }, - "to": { - "description": "The address that the Notification was sent to. This will usually be an email address, but represent other addresses such as a chat bot user id", - "type": "string" - }, - "data": { - "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.", - "type": "object" - }, - "parent_id": { - "description": "The id of the Notification that was originally sent.", - "type": "string" - }, - "resends": { - "description": "The resends that have been completed after the original Notification.", - "type": "array", - "items": { - "$ref": "#/components/schemas/notification_resend" - } - }, - "provider_id": { - "description": "The id of the Notification Provider that handles the Notification.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - } - } - }, - "notification_resend": { - "title": "Notification Resend", - "description": "A resend of a Notification.", - "x-resourceId": "notification_resend", - "properties": { - "id": { - "description": "The id of the Notification. This value will be prefixed by `noti_`.", - "type": "string" - }, - "event_name": { - "description": "The name of the event that the notification was sent for.", - "type": "string" - }, - "resource_type": { - "description": "The type of resource that the Notification refers to.", - "type": "string" - }, - "resource_id": { - "description": "The id of the resource that the Notification refers to.", - "type": "string" - }, - "to": { - "description": "The address that the Notification was sent to. This will usually be an email address, but represent other addresses such as a chat bot user id", - "type": "string" - }, - "data": { - "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.", - "type": "object" - }, - "parent_id": { - "description": "The id of the Notification that was originally sent.", - "type": "string" - }, - "provider_id": { - "description": "The id of the Notification Provider that handles the Notification.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - } - } - }, - "order": { - "title": "Order", - "description": "Represents an order", - "x-resourceId": "order", - "properties": { - "id": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "pending", - "completed", - "archived", - "canceled", - "requires_action" - ] - }, - "fulfillment_status": { - "type": "string", - "enum": [ - "not_fulfilled", - "partially_fulfilled", - "fulfilled", - "partially_shipped", - "shipped", - "partially_returned", - "returned", - "canceled", - "requires_action" - ] - }, - "payment_status": { - "type": "string", - "enum": [ - "not_paid", - "awaiting", - "captured", - "partially_refunded", - "refuneded", - "canceled", - "requires_action" - ] - }, - "display_id": { - "type": "integer" - }, - "cart_id": { - "type": "string" - }, - "currency_code": { - "type": "string" - }, - "tax_rate": { - "type": "integer" - }, - "discounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/discount" - } - }, - "email": { - "type": "string" - }, - "billing_address_id": { - "type": "string" - }, - "billing_address": { - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "shipping_address_id": { - "type": "string" - }, - "shipping_address": { - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/line_item" - } - }, - "region_id": { - "type": "string" - }, - "region": { - "anyOf": [ - { - "$ref": "#/components/schemas/region" - } - ] - }, - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } - }, - "customer_id": { - "type": "string" - }, - "customer": { - "anyOf": [ - { - "$ref": "#/components/schemas/customer" - } - ] - }, - "payment_session": { - "anyOf": [ - { - "$ref": "#/components/schemas/payment_session" - } - ] - }, - "payment_sessions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/payment_session" - } - }, - "payments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/payment" - } - }, - "shipping_methods": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_method" - } - }, - "fulfillments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/fulfillment" - } - }, - "returns": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return" - } - }, - "claims": { - "type": "array", - "items": { - "$ref": "#/components/schemas/claim_order" - } - }, - "refunds": { - "type": "array", - "items": { - "$ref": "#/components/schemas/refund" - } - }, - "swaps": { - "type": "array", - "items": { - "$ref": "#/components/schemas/refund" - } - }, - "gift_card_transactions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card_transaction" - } - }, - "canceled_at": { - "type": "string", - "format": "date-time" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "update_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - }, - "shipping_total": { - "type": "integer" - }, - "discount_total": { - "type": "integer" - }, - "tax_total": { - "type": "integer" - }, - "subtotal": { - "type": "integer" - }, - "refundable_amount": { - "type": "integer" - }, - "gift_card_total": { - "type": "integer" - }, - "paid_total": { - "type": "integer" - } - } - }, - "payment_provider": { - "title": "Payment Provider", - "description": "Represents a Payment Provider plugin and holds its installation status.", - "x-resourceId": "payment_provider", - "properties": { - "id": { - "description": "The id of the payment provider as given by the plugin.", - "type": "string" - }, - "is_installed": { - "description": "Whether the plugin is installed in the current version. Plugins that are no longer installed are not deleted by will have this field set to `false`.", - "type": "boolean" - } - } - }, - "payment_session": { - "title": "Payment Session", - "description": "Payment Sessions are created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, who is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for capture/refunds/etc.", - "x-resourceId": "payment_session", - "properties": { - "id": { - "description": "The id of the Payment Session. This value will be prefixed with `ps_`.", - "type": "string" - }, - "cart_id": { - "description": "The id of the Cart that the Payment Session is created for.", - "type": "string" - }, - "provider_id": { - "description": "The id of the Payment Provider that is responsible for the Payment Session", - "type": "string" - }, - "is_selected": { - "description": "A flag to indicate if the Payment Session has been selected as the method that will be used to complete the purchase.", - "type": "boolean" - }, - "status": { - "description": "Indicates the status of the Payment Session. Will default to `pending`, and will eventually become `authorized`. Payment Sessions may have the status of `requires_more` to indicate that further actions are to be completed by the Customer.", - "type": "string", - "enum": [ - "authorized", - "pending", - "requires_more", - "error", - "canceled" - ] - }, - "data": { - "description": "The data required for the Payment Provider to identify, modify and process the Payment Session. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.", - "type": "object" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - } - } - }, - "payment": { - "title": "Payment", - "description": "Payments represent an amount authorized with a given payment method, Payments can be captured, canceled or refunded.", - "x-resourceId": "payment", - "properties": { - "id": { - "description": "The id of the Payment. This value will be prefixed with `pay_`.", - "type": "string" - }, - "swap_id": { - "description": "The id of the Swap that the Payment is used for.", - "type": "string" - }, - "order_id": { - "description": "The id of the Order that the Payment is used for.", - "type": "string" - }, - "cart_id": { - "description": "The id of the Cart that the Payment Session is created for.", - "type": "string" - }, - "amount": { - "description": "The amount that the Payment has been authorized for.", - "type": "integer" - }, - "currency_code": { - "description": "The 3 character ISO currency code that the Payment is completed in.", - "type": "string" - }, - "amount_refunded": { - "description": "The amount of the original Payment amount that has been refunded back to the Customer.", - "type": "integer" - }, - "provider_id": { - "description": "The id of the Payment Provider that is responsible for the Payment", - "type": "string" - }, - "data": { - "description": "The data required for the Payment Provider to identify, modify and process the Payment. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.", - "type": "object" - }, - "captured_at": { - "description": "The date with timezone at which the Payment was captured.", - "type": "string", - "format": "date-time" - }, - "canceled_at": { - "description": "The date with timezone at which the Payment was canceled.", - "type": "string", - "format": "date-time" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_collection": { - "title": "Product Collection", - "description": "Product Collections represents a group of Products that are related.", - "x-resourceId": "product_collection", - "properties": { - "id": { - "description": "The id of the Product Collection. This value will be prefixed with `pcol_`.", - "type": "string" - }, - "title": { - "description": "The title that the Product Collection is identified by.", - "type": "string" - }, - "handle": { - "description": "A unique string that identifies the Product Collection - can for example be used in slug structures.", - "type": "string" - }, - "products": { - "description": "The Products contained in the Product Collection.", - "type": "array", - "items": { - "type": "object" - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_option_value": { - "title": "Product Option Value", - "description": "A value given to a Product Variant's option set. Product Variant have a Product Option Value for each of the Product Options defined on the Product.", - "x-resourceId": "product_option_value", - "properties": { - "id": { - "description": "The id of the Product Option Value. This value will be prefixed with `optval_`.", - "type": "string" - }, - "value": { - "description": "The value that the Product Variant has defined for the specific Product Option (e.g. if the Product Option is \"Size\" this value could be \"Small\", \"Medium\" or \"Large\").", - "type": "string" - }, - "option_id": { - "description": "The id of the Product Option that the Product Option Value is defined for.", - "type": "string" - }, - "variant_id": { - "description": "The id of the Product Variant that the Product Option Value is defined for.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_option": { - "title": "Product Option", - "description": "Product Options define properties that may vary between different variants of a Product. Common Product Options are \"Size\" and \"Color\", but Medusa doesn't limit what Product Options that can be defined.", - "x-resourceId": "product_option", - "properties": { - "id": { - "description": "The id of the Product Option. This value will be prefixed with `opt_`.", - "type": "string" - }, - "title": { - "description": "The title that the Product Option is defined by (e.g. \"Size\").", - "type": "string" - }, - "values": { - "description": "The Product Option Values that are defined for the Product Option.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product_option_value" - } - }, - "product_id": { - "description": "The id of the Product that the Product Option is defined for.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_tag": { - "title": "Product Tag", - "description": "Product Tags can be added to Products for easy filtering and grouping.", - "x-resourceId": "product_tag", - "properties": { - "id": { - "description": "The id of the Product Tag. This value will be prefixed with `ptag_`.", - "type": "string" - }, - "value": { - "description": "The value that the Product Tag represents (e.g. \"Pants\").", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_type": { - "title": "Product Type", - "description": "Product Type can be added to Products for filtering and reporting purposes.", - "x-resourceId": "product_type", - "properties": { - "id": { - "description": "The id of the Product Type. This value will be prefixed with `ptyp_`.", - "type": "string" - }, - "value": { - "description": "The value that the Product Type represents (e.g. \"Clothing\").", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product_variant": { - "title": "Product Variant", - "description": "Product Variants represent a Product with a specific set of Product Option configurations. The maximum number of Product Variants that a Product can have is given by the number of available Product Option combinations.", - "x-resourceId": "product_variant", - "properties": { - "id": { - "description": "The id of the Product Variant. This value will be prefixed with `variant_`.", - "type": "string" - }, - "title": { - "description": "A title that can be displayed for easy identification of the Product Variant.", - "type": "string" - }, - "product_id": { - "description": "The id of the Product that the Product Variant belongs to.", - "type": "string" - }, - "prices": { - "description": "The Money Amounts defined for the Product Variant. Each Money Amount represents a price in a given currency or a price in a specific Region.", - "type": "array", - "items": { - "$ref": "#/components/schemas/money_amount" - } - }, - "sku": { - "description": "The unique stock keeping unit used to identify the Product Variant. This will usually be a unqiue identifer for the item that is to be shipped, and can be referenced across multiple systems.", - "type": "string" - }, - "barcode": { - "description": "A generic field for a GTIN number that can be used to identify the Product Variant.", - "type": "string" - }, - "ean": { - "description": "An EAN barcode number that can be used to identify the Product Variant.", - "type": "string" - }, - "upc": { - "description": "A UPC barcode number that can be used to identify the Product Variant.", - "type": "string" - }, - "inventory_quantity": { - "description": "The current quantity of the item that is stocked.", - "type": "integer" - }, - "allow_backorder": { - "description": "Whether the Product Variant should be purchasable when `inventory_quantity` is 0.", - "type": "boolean" - }, - "manage_inventory": { - "description": "Whether Medusa should manage inventory for the Product Variant.", - "type": "boolean" - }, - "hs_code": { - "description": "The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "origin_country": { - "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "mid_code": { - "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "material": { - "description": "The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "weight": { - "description": "The weight of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "height": { - "description": "The height of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "width": { - "description": "The width of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "length": { - "description": "The length of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "options": { - "description": "The Product Option Values specified for the Product Variant.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product_option_value" - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "product": { - "title": "Product", - "description": "Products are a grouping of Product Variants that have common properties such as images and descriptions. Products can have multiple options which define the properties that Product Variants differ by.", - "x-resourceId": "product", - "properties": { - "id": { - "description": "The id of the Product. This value will be prefixed with `prod_`.", - "type": "string" - }, - "title": { - "description": "A title that can be displayed for easy identification of the Product.", - "type": "string" - }, - "subtitle": { - "description": "An optional subtitle that can be used to further specify the Product.", - "type": "string" - }, - "description": { - "description": "A short description of the Product.", - "type": "string" - }, - "handle": { - "description": "A unique identifier for the Product (e.g. for slug structure).", - "type": "string" - }, - "is_giftcard": { - "description": "Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.", - "type": "boolean" - }, - "images": { - "description": "Images of the Product", - "type": "array", - "items": { - "$ref": "#/components/schemas/image" - } - }, - "thumbnail": { - "description": "A URL to an image file that can be used to identify the Product.", - "type": "string" - }, - "options": { - "description": "The Product Options that are defined for the Product. Product Variants of the Product will have a unique combination of Product Option Values.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product_option" - } - }, - "variants": { - "description": "The Product Variants that belong to the Product. Each will have a unique combination of Product Option Values.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product_variant" - } - }, - "profile_id": { - "description": "The id of the Shipping Profile that the Product belongs to. Shipping Profiles have a set of defined Shipping Options that can be used to Fulfill a given set of Products.", - "type": "string" - }, - "hs_code": { - "description": "The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "origin_country": { - "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "mid_code": { - "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "material": { - "description": "The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.", - "type": "string" - }, - "weight": { - "description": "The weight of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "height": { - "description": "The height of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "width": { - "description": "The width of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "length": { - "description": "The length of the Product Variant. May be used in shipping rate calculations.", - "type": "string" - }, - "type": { - "description": "The Product Type of the Product (e.g. \"Clothing\")", - "anyOf": [ - { - "$ref": "#/components/schemas/product_type" - } - ] - }, - "collection": { - "description": "The Product Collection that the Product belongs to (e.g. \"SS20\")", - "anyOf": [ - { - "$ref": "#/components/schemas/product_collection" - } - ] - }, - "tags": { - "description": "The Product Tags assigned to the Product.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product_tag" - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "refund": { - "title": "Refund", - "description": "Refund represent an amount of money transfered back to the Customer for a given reason. Refunds may occur in relation to Returns, Swaps and Claims, but can also be initiated by a store operator.", - "x-resourceId": "refund", - "properties": { - "id": { - "description": "The id of the Refund. This value will be prefixed with `ref_`.", - "type": "string" - }, - "order_id": { - "description": "The id of the Order that the Refund is related to.", - "type": "string" - }, - "amount": { - "description": "The amount that has be refunded to the Customer.", - "type": "integer" - }, - "note": { - "description": "An optional note explaining why the amount was refunded.", - "type": "string" - }, - "reason": { - "description": "The reason given for the Refund, will automatically be set when processed as part of a Swap, Claim or Return.", - "type": "string", - "enum": [ - "discount", - "return", - "swap", - "claim", - "other" - ] - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "region": { - "title": "Region", - "description": "Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.", - "x-resourceId": "region", - "properties": { - "id": { - "description": "The id of the Region. This value will be prefixed with `reg_`.", - "type": "string" - }, - "name": { - "description": "The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.", - "type": "string" - }, - "currency_code": { - "description": "The 3 character ISO currency code that Customers will shop in in the Region.", - "type": "string" - }, - "tax_rate": { - "description": "The tax rate that should be charged on purchases in the Region.", - "type": "number" - }, - "tax_code": { - "description": "The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.", - "type": "string" - }, - "countries": { - "description": "The countries that are included in the Region.", - "type": "array", - "items": { - "$ref": "#/components/schemas/country" - } - }, - "payment_providers": { - "description": "The Payment Providers that can be used to process Payments in the Region.", - "type": "array", - "items": { - "$ref": "#/components/schemas/payment_provider" - } - }, - "fulfillment_providers": { - "description": "The Fulfillment Providers that can be used to fulfill orders in the Region.", - "type": "array", - "items": { - "$ref": "#/components/schemas/fulfillment_provider" - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "return_item": { - "title": "Return Item", - "description": "Correlates a Line Item with a Return, keeping track of the quantity of the Line Item that will be returned.", - "x-resourceId": "return_item", - "properties": { - "return_id": { - "description": "The id of the Return that the Return Item belongs to.", - "type": "string" - }, - "item_id": { - "description": "The id of the Line Item that the Return Item references.", - "type": "string" - }, - "item": { - "description": "The Line Item that the Return Item references.", - "anyOf": [ - { - "$ref": "#/components/schemas/line_item" - } - ] - }, - "quantity": { - "description": "The quantity of the Line Item that is included in the Return.", - "type": "integer" - }, - "is_requested": { - "description": "Whether the Return Item was requested initially or received unexpectedly in the warehouse.", - "type": "boolean" - }, - "requested_quantity": { - "description": "The quantity that was originally requested to be returned.", - "type": "integer" - }, - "recieved_quantity": { - "description": "The quantity that was received in the warehouse.", - "type": "integer" - }, - "reason": { - "description": "The reason for returning the item.", - "anyOf": [ - { - "$ref": "#/components/schemas/return_reason" - } - ] - }, - "note": { - "description": "An optional note with additional details about the Return.", - "type": "string" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "return_reason": { - "title": "Return Reason", - "description": "A Reason for why a given product is returned. A Return Reason can be used on Return Items in order to indicate why a Line Item was returned.", - "x-resourceId": "return_reason", - "properties": { - "id": { - "description": "The id of the Return Reason will start with `rr_`.", - "type": "string" - }, - "description": { - "description": "A description of the Reason.", - "type": "string" - }, - "label": { - "description": "A text that can be displayed to the Customer as a reason.", - "type": "string" - }, - "value": { - "description": "The value to identify the reason by.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "return": { - "title": "Return", - "description": "Return orders hold information about Line Items that a Customer wishes to send back, along with how the items will be returned. Returns can be used as part of a Swap.", - "x-resourceId": "return", - "properties": { - "id": { - "description": "The id of the Return. This value will be prefixed with `ret_`.", - "type": "string" - }, - "status": { - "description": "Status of the Return.", - "type": "string", - "enum": [ - "requested", - "received", - "requires_action" - ] - }, - "items": { - "description": "The Return Items that will be shipped back to the warehouse. type: array items: $ref: " - }, - "swap_id": { - "description": "The id of the Swap that the Return is a part of.", - "type": "string" - }, - "order_id": { - "description": "The id of the Order that the Return is made from.", - "type": "string" - }, - "claim_order_id": { - "description": "The id of the Claim that the Return is a part of.", - "type": "string" - }, - "shipping_method": { - "description": "The Shipping Method that will be used to send the Return back. Can be null if the Customer facilitates the return shipment themselves.", - "anyOf": [ - { - "$ref": "#/components/schemas/shipping_method" - } - ] - }, - "shipping_data": { - "description": "Data about the return shipment as provided by the Fulfilment Provider that handles the return shipment.", - "type": "object" - }, - "refund_amount": { - "description": "The amount that should be refunded as a result of the return.", - "type": "integer" - }, - "received_at": { - "description": "The date with timezone at which the return was received.", - "type": "string", - "format": "date-time" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "shipping_method": { - "title": "Shipping Method", - "description": "Shipping Methods represent a way in which an Order or Return can be shipped. Shipping Methods are built from a Shipping Option, but may contain additional details, that can be necessary for the Fulfillment Provider to handle the shipment.", - "x-resourceId": "shipping_method", - "properties": { - "id": { - "description": "The id of the Shipping Method. This value will be prefixed with `sm_`.", - "type": "string" - }, - "shipping_option_id": { - "description": "The id of the Shipping Option that the Shipping Method is built from.", - "type": "string" - }, - "shipping_option": { - "description": "The Shipping Option that the Shipping Method is built from.", - "anyOf": [ - { - "$ref": "#/components/schemas/shipping_option" - } - ] - }, - "order_id": { - "description": "The id of the Order that the Shipping Method is used on.", - "type": "string" - }, - "return_id": { - "description": "The id of the Return that the Shipping Method is used on.", - "type": "string" - }, - "swap_id": { - "description": "The id of the Swap that the Shipping Method is used on.", - "type": "string" - }, - "cart_id": { - "description": "The id of the Cart that the Shipping Method is used on.", - "type": "string" - }, - "claim_order_id": { - "description": "The id of the Claim that the Shipping Method is used on.", - "type": "string" - }, - "price": { - "description": "The amount to charge for the Shipping Method. The currency of the price is defined by the Region that the Order that the Shipping Method belongs to is a part of.", - "type": "integer" - }, - "data": { - "description": "Additional data that the Fulfillment Provider needs to fulfill the shipment. This is used in combination with the Shipping Options data, and may contain information such as a drop point id.", - "type": "object" - } - } - }, - "shipping_option_requirement": { - "title": "Shipping Option Requirement", - "description": "A requirement that a Cart must satisfy for the Shipping Option to be available to the Cart.", - "x-resourceId": "shipping_option_requirement", - "properties": { - "id": { - "description": "The id of the Shipping Option Requirement. This value will be prefixed with `sor_`.", - "type": "string" - }, - "shipping_option_id": { - "description": "The id of the Shipping Option that the Shipping Option Requirement belongs to.", - "type": "string" - }, - "type": { - "description": "The type of the requirement, this defines how the value will be compared to the Cart's total. `min_subtotal` requirements define the minimum subtotal that is needed for the Shipping Option to be available, while the `max_subtotal` defines the maximum subtotal that the Cart can have for the Shipping Option to be available.", - "type": "string", - "enum": [ - "min_subtotal", - "max_subtotal" - ] - }, - "amount": { - "description": "The amount to compare the Cart subtotal to.", - "type": "integer" - } - } - }, - "shipping_option": { - "title": "Shipping Option", - "description": "Shipping Options represent a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.", - "x-resourceId": "shipping_option", - "properties": { - "id": { - "description": "The id of the Shipping Option. This value will be prefixed with `so_`.", - "type": "string" - }, - "name": { - "description": "The name given to the Shipping Option - this may be displayed to the Customer.", - "type": "string" - }, - "region_id": { - "description": "The id of the Region that the Shipping Option belongs to.", - "type": "string" - }, - "region": { - "description": "The id of the Region that the Shipping Option belongs to.", - "anyOf": [ - { - "$ref": "#/components/schemas/region" - } - ] - }, - "profile_id": { - "description": "The id of the Shipping Profile that the Shipping Option belongs to. Shipping Profiles have a set of defined Shipping Options that can be used to Fulfill a given set of Products.", - "type": "string" - }, - "provider_id": { - "description": "The id of the Fulfillment Provider, that will be used to process Fulfillments from the Shipping Option.", - "type": "string" - }, - "price_type": { - "description": "The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be `flat_rate` for fixed prices or `calculated` if the Fulfillment Provider can provide price calulations.", - "type": "string", - "enum": [ - "flat_rate", - "calculated" - ] - }, - "amount": { - "description": "The amount to charge for shipping when the Shipping Option price type is `flat_rate`.", - "type": "integer" - }, - "is_return": { - "description": "Flag to indicate if the Shipping Option can be used for Return shipments.", - "type": "boolean" - }, - "requirements": { - "description": "The requirements that must be satisfied for the Shipping Option to be available for a Cart.", - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_option_requirement" - } - }, - "data": { - "description": "The data needed for the Fulfillment Provider to identify the Shipping Option.", - "type": "object" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "shipping_profile": { - "title": "Shipping Profile", - "description": "Shipping Profiles have a set of defined Shipping Options that can be used to fulfill a given set of Products.", - "x-resourceId": "shipping_profile", - "properties": { - "id": { - "description": "The id of the Shipping Profile. This value will be prefixed with `sp_`.", - "type": "string" - }, - "name": { - "description": "The name given to the Shipping profile - this may be displayed to the Customer.", - "type": "string" - }, - "type": { - "description": "The type of the Shipping Profile, may be `default`, `gift_card` or `custom`.", - "type": "string", - "enum": [ - "default", - "gift_card", - "custom" - ] - }, - "products": { - "description": "The Products that the Shipping Profile defines Shipping Options for.", - "type": "array", - "items": { - "$ref": "#/components/schemas/product" - } - }, - "shipping_options": { - "description": "The Shipping Options that can be used to fulfill the Products in the Shipping Profile.", - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/shipping_option" - } - ] - } - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "store": { - "title": "Store", - "description": "Holds settings for the Store, such as name, currencies, etc.", - "x-resourceId": "store", - "properties": { - "id": { - "description": "The id of the Store. This value will be prefixed with `store_`.", - "type": "string" - }, - "name": { - "description": "The name of the Store - this may be displayed to the Customer.", - "type": "string" - }, - "default_currency_code": { - "description": "The default currency code used when no other currency code is specified.", - "type": "string" - }, - "currencies": { - "description": "The currencies that are enabled for the Store.", - "type": "array", - "items": { - "$ref": "#/components/schemas/currency" - } - }, - "swap_link_template": { - "description": "A template to generate Swap links from use {{cart_id}} to include the Swap's `cart_id` in the link.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "swap": { - "title": "Swap", - "description": "Swaps can be created when a Customer wishes to exchange Products that they have purchased to different Products. Swaps consist of a Return of previously purchased Products and a Fulfillment of new Products, the amount paid for the Products being returned will be used towards payment for the new Products. In the case where the amount paid for the the Products being returned exceed the amount to be paid for the new Products, a Refund will be issued for the difference.", - "x-resourceId": "swap", - "properties": { - "id": { - "description": "The id of the Swap. This value will be prefixed with `swap_`.", - "type": "string" - }, - "fulfillment_status": { - "description": "The status of the Fulfillment of the Swap.", - "type": "string", - "enum": [ - "not_fulfilled", - "partially_fulfilled", - "fulfilled", - "partially_shipped", - "shipped", - "partially_returned", - "returned", - "canceled", - "requires_action" - ] - }, - "payment_status": { - "description": "The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.", - "type": "string", - "enum": [ - "not_paid", - "awaiting", - "captured", - "canceled", - "difference_refunded", - "requires_action" - ] - }, - "order_id": { - "description": "The id of the Order where the Line Items to be returned where purchased.", - "type": "string" - }, - "additional_items": { - "description": "The new Line Items to ship to the Customer.", - "type": "array", - "items": { - "$ref": "#/components/schemas/line_item" - } - }, - "return_order": { - "description": "The Return that is issued for the return part of the Swap.", - "anyOf": [ - { - "$ref": "#/components/schemas/return" - } - ] - }, - "fulfillments": { - "description": "The Fulfillments used to send the new Line Items.", - "type": "array", - "items": { - "$ref": "#/components/schemas/fulfillment" - } - }, - "payment": { - "description": "The Payment authorized when the Swap requires an additional amount to be charged from the Customer.", - "anyOf": [ - { - "$ref": "#/components/schemas/payment" - } - ] - }, - "difference_due": { - "description": "The difference that is paid or refunded as a result of the Swap. May be negative when the amount paid for the returned items exceed the total of the new Products.", - "type": "integer" - }, - "shipping_address": { - "description": "The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "shipping_methods": { - "description": "The Shipping Methods used to fulfill the addtional items purchased.", - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_method" - } - }, - "cart_id": { - "description": "The id of the Cart that the Customer will use to confirm the Swap.", - "type": "string" - }, - "confirmed_at": { - "description": "The date with timezone at which the Swap was confirmed by the Customer.", - "type": "string", - "format": "date-time" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "tracking_link": { - "title": "Tracking Link", - "description": "Tracking Link holds information about tracking numbers for a Fulfillment. Tracking Links can optionally contain a URL that can be visited to see the status of the shipment.", - "x-resourceId": "tracking_link", - "properties": { - "id": { - "description": "The id of the Tracking Link. This value will be prefixed with `tlink_`.", - "type": "string" - }, - "url": { - "description": "The URL at which the status of the shipment can be tracked.", - "type": "string" - }, - "tracking_number": { - "description": "The tracking number given by the shipping carrier.", - "type": "string" - }, - "fulfillment_id": { - "description": "The id of the Fulfillment that the Tracking Link references.", - "type": "string" - }, - "created_at": { - "description": "The date with timezone at which the resource was created.", - "type": "string", - "format": "date-time" - }, - "updated_at": { - "description": "The date with timezone at which the resource was last updated.", - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "description": "The date with timezone at which the resource was deleted.", - "type": "string", - "format": "date-time" - }, - "metadata": { - "description": "An optional key-value map with additional information.", - "type": "object" - } - } - }, - "user": { - "title": "User", - "description": "Represents a User who can manage store settings.", - "x-resourceId": "user", - "properties": { - "id": { - "description": "The unique id of the User. This will be prefixed with `usr_`", - "type": "string" - }, - "email": { - "description": "The email of the User", - "type": "string" - }, - "first_name": { - "type": "string" - }, - "last_name": { - "description": "The Customer's billing address.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "updated_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "metadata": { - "type": "object" - } - } - } - } - } -} \ No newline at end of file diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml deleted file mode 100644 index 5f6fd465cf..0000000000 --- a/docs/api/store-spec3.yaml +++ /dev/null @@ -1,3770 +0,0 @@ -openapi: 3.0.0 -info: - version: 1.0.0 - title: Medusa Storefront API - license: - name: MIT -tags: - - name: Auth - description: >- - Auth endpoints allows authorization of admin Users and manages their - sessions. - - name: Cart - x-resourceId: cart - - name: Collection - x-resourceId: product_collection - - name: Customer - x-resourceId: customer - - name: Discount - x-resourceId: discount - - name: Gift Card - x-resourceId: gift_card - - name: Notification - x-resourceId: notification - - name: Order - x-resourceId: order - - name: Product - x-resourceId: product - - name: Region - x-resourceId: region - - name: Return - x-resourceId: return - - name: Shipping Option - x-resourceId: shipping_option - - name: Shipping Profile - x-resourceId: shipping_profile - - name: Swap - x-resourceId: swap - - name: Product Variant - x-resourceId: product_variant -servers: - - url: 'https://api.medusa-commerce.com/store' -paths: - /auth: - post: - operationId: PostAuth - summary: Authenticate Customer - description: >- - Logs a Customer in and authorizes them to view their details. Successful - authentication will set a session cookie in the Customer's browser. - parameters: [] - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - password - properties: - email: - type: string - description: The Customer's email. - password: - type: string - description: The Customer's password. - delete: - operationId: DeleteAuth - summary: Log out - description: Destroys a Customer's authenticated session. - tags: - - Auth - responses: - '200': - description: OK - get: - operationId: GetAuth - summary: Get Session - description: Gets the currently logged in Customer. - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/auth/{email}': - get: - operationId: GetAuthEmail - summary: Check if email has account - description: Checks if a Customer with the given email has signed up. - parameters: - - in: path - name: email - required: true - description: The Customer's email. - schema: - type: string - tags: - - Auth - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - exists: - type: boolean - '/carts/{id}/shipping-methods': - post: - operationId: PostCartsCartShippingMethod - description: Adds a Shipping Method to the Cart. - summary: Add a Shipping Method - tags: - - Cart - parameters: - - in: path - name: id - required: true - description: The cart id. - schema: - type: string - responses: - '200': - description: A successful response - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - option_id - properties: - option_id: - type: string - description: id of the shipping option to create the method from - data: - type: object - description: >- - Used to hold any data that the shipping method may need to - process the fulfillment of the order. Look at the - documentation for your installed fulfillment providers to - find out what to send. - '/carts/{id}/complete-cart': - post: - summary: Complete a Cart - operationId: PostCartsCartComplete - description: >- - Completes a cart. The following steps will be performed. Payment - authorization is attempted and if more work is required, we simply - return the cart for further updates. If payment is authorized and order - is not yet created, we make sure to do so. The completion of a cart can - be performed idempotently with a provided header `Idempotency-Key`. If - not provided, we will generate one for the request. - parameters: - - in: path - name: id - required: true - description: The Cart id. - schema: - type: string - tags: - - Cart - responses: - '200': - description: >- - If a cart was successfully authorized, but requires further action - from the user the response body will contain the cart with an - updated payment session. If the Cart was successfully completed the - response body will contain the newly created Order. - content: - application/json: - schema: - oneOf: - - type: object - properties: - order: - $ref: '#/components/schemas/order' - - type: object - properties: - cart: - $ref: '#/components/schemas/cart' - /carts: - post: - summary: Create a Cart - operationId: PostCart - description: >- - Creates a Cart within the given region and with the initial items. If no - `region_id` is provided the cart will be associated with the first - Region available. If no items are provided the cart will be empty after - creation. If a user is logged in the cart's customer id and email will - be set. - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - items: - description: >- - An optional array of `variant_id`, `quantity` pairs to - generate Line Items from. - type: array - items: - properties: - variant_id: - description: >- - The id of the Product Variant to generate a Line Item - from. - type: string - quantity: - description: The quantity of the Product Variant to add - type: integer - context: - description: >- - An optional object to provide context to the Cart. The - `context` field is automatically populated with `ip` and - `user_agent` - type: object - tags: - - Cart - responses: - '200': - description: Successfully created a new Cart - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items': - post: - operationId: PostCartsCartLineItems - summary: Add a Line Item - description: >- - Generates a Line Item with a given Product Variant and adds it to the - Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart to add the Line Item to. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - variant_id - - quantity - properties: - variant_id: - type: string - description: >- - The id of the Product Variant to generate the Line Item - from. - quantity: - type: integer - description: The quantity of the Product Variant to add to the Line Item. - metadata: - type: object - description: >- - An optional key-value map with additional details about the - Line Item. - '/carts/{id}/payment-sessions': - post: - operationId: PostCartsCartPaymentSessions - summary: Initialize Payment Sessions - description: >- - Creates Payment Sessions for each of the available Payment Providers in - the Cart's Region. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/discounts/{code}': - delete: - operationId: DeleteCartsCartDiscountsDiscount - description: Removes a Discount from a Cart. - summary: Remove Discount from Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: code - required: true - description: The unique Discount code. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items/{line_id}': - delete: - operationId: DeleteCartsCartLineItemsItem - summary: Delete a Line Item - description: Removes a Line Item from a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartLineItemsItem - summary: Update a Line Item - description: Updates a Line Item if the desired quantity can be fulfilled. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - quantity - properties: - quantity: - type: integer - description: The quantity to set the Line Item to. - '/carts/{id}/payment-sessions/{provider_id}': - delete: - operationId: DeleteCartsCartPaymentSessionsSession - summary: Delete a Payment Session - description: >- - Deletes a Payment Session on a Cart. May be useful if a payment has - failed. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: >- - The id of the Payment Provider used to create the Payment Session to - be deleted. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartPaymentSessionsSession - summary: Refresh a Payment Session - description: >- - Refreshes a Payment Session to ensure that it is in sync with the Cart - - this is usually not necessary. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: >- - The id of the Payment Provider that created the Payment Session to - be refreshed. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}': - get: - operationId: GetCartsCart - summary: Retrieve a Cart - description: Retrieves a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session': - post: - operationId: PostCartsCartPaymentSession - summary: Select a Payment Session - description: >- - Selects a Payment Session as the session intended to be used towards the - completion of the Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - properties: - provider_id: - type: string - description: The id of the Payment Provider. - '/store/carts/{id}': - post: - operationId: PostCartsCart - summary: Update a Cart" - description: Updates a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - email: - type: string - description: An email to be used on the Cart. - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - shipping_address: - description: The Address to be used for shipping. - anyOf: - - $ref: '#/components/schemas/address' - gift_cards: - description: An array of Gift Card codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Gift Card is identified by. - type: string - discounts: - description: An array of Discount codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Discount is identifed by. - type: string - customer_id: - description: The id of the Customer to associate the Cart with. - type: string - context: - description: An optional object to provide context to the Cart. - type: object - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session/update': - post: - operationId: PostCartsCartPaymentSessionUpdate - summary: Update a Payment Session - description: Updates a Payment Session with additional data. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - - data - properties: - provider_id: - type: string - description: >- - The id of the Payment Provider responsible for the Payment - Session to update. - data: - type: object - description: The data to update the payment session with. - '/customers/{id}/addresses': - post: - operationId: PostCustomersCustomerAddresses - summary: Add a Shipping Address - description: Adds a Shipping Address to a Customer's saved addresses. - parameters: - - in: path - name: id - required: true - description: The Customer id. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - address: - description: The Address to add to the Customer. - anyOf: - - $ref: '#/components/schemas/address' - tags: - - Customer - responses: - '200': - description: A successful response - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - /customers: - post: - operationId: PostCustomers - summary: Create a Customer - description: Creates a Customer account. - parameters: [] - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - first_name - - last_name - - password - properties: - email: - type: string - description: The Customer's email address. - first_name: - type: string - description: The Customer's first name. - last_name: - type: string - description: The Customer's last name. - password: - type: string - description: The Customer's password for login. - phone: - type: string - description: The Customer's phone number. - '/customers/{id}/addresses/{address_id}': - delete: - operationId: DeleteCustomersCustomerAddressesAddress - summary: Delete an Address - description: Removes an Address from the Customer's saved addresse. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - - in: path - name: address_id - required: true - description: The id of the Address to remove. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomerAddressesAddress - summary: Update a Shipping Address - description: Updates a Customer's saved Shipping Address. - parameters: - - in: path - name: id - required: true - description: The Customer id. - schema: - type: string - - in: path - name: address_id - required: true - description: The id of the Address to update. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - address: - description: The updated Address. - anyOf: - - $ref: '#/components/schemas/address' - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}': - get: - operationId: GetCustomersCustomer - summary: Retrieves a Customer - description: >- - Retrieves a Customer - the Customer must be logged in to retrieve their - details. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - post: - operationId: PostCustomersCustomer - summary: Update Customer details - description: Updates a Customer's saved details. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - first_name: - description: The Customer's first name. - type: string - last_name: - description: The Customer's last name. - type: string - password: - description: The Customer's password. - type: string - phone: - description: The Customer's phone number. - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - '/customers/{id}/payment-methods': - get: - operationId: GetCustomersCustomerPaymentMethods - summary: Retrieve saved payment methods - description: >- - Retrieves a list of a Customer's saved payment methods. Payment methods - are saved with Payment Providers and it is their responsibility to fetch - saved methods. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - payment_methods: - type: array - items: - properties: - provider_id: - type: string - description: >- - The id of the Payment Provider where the payment - method is saved. - data: - type: object - description: >- - The data needed for the Payment Provider to use the - saved payment method. - '/customers/{id}/orders': - get: - operationId: GetCustomersCustomerOrders - summary: Retrieve Customer Orders - description: Retrieves a list of a Customer's Orders. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - payment_methods: - type: array - items: - $ref: '#/components/schemas/order' - '/customers/{id}/password-token': - post: - operationId: PostCustomersCustomerPasswordToken - summary: Creates a reset password token - description: >- - Creates a reset password token to be used in a subsequent - /reset-password request. The password token should be sent out of band - e.g. via email and will not be returned. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '204': - description: OK - '/customers/{id}/reset-password': - post: - operationId: PostCustomersCustomerResetPassword - summary: Resets Customer password - description: >- - Resets a Customer's password using a password token created by a - previous /password-token request. - parameters: - - in: path - name: id - required: true - description: The id of the Customer. - schema: - type: string - tags: - - Customer - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - requestBody: - content: - application/json: - schema: - type: object - required: - - email - - token - - password - properties: - email: - type: string - description: The Customer's email. - token: - type: string - description: The password token created by a /password-token request. - password: - type: string - description: The new password to set for the Customer. - '/gift-cards/{code}': - get: - operationId: GetGiftCardsCode - summary: Retrieve Gift Card by Code - description: Retrieves a Gift Card by its associated unqiue code. - parameters: - - in: path - name: code - required: true - description: The unique Gift Card code. - schema: - type: string - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - description: The id of the Gift Card - code: - description: The code of the Gift Card - value: - description: The original value of the Gift Card. - balance: - description: The current balanace of the Gift Card - region: - $ref: '#/components/schemas/region' - '/orders/cart/{cart_id}': - get: - operationId: GetOrdersOrderCartId - summary: Retrieves Order by Cart id - description: >- - Retrieves an Order by the id of the Cart that was used to create the - Order. - parameters: - - in: path - name: cart_id - required: true - description: The id of Cart. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': - get: - operationId: GetOrdersOrder - summary: Retrieves an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - customer: - $ref: '#/components/schemas/customer' - /orders: - get: - operationId: GetOrders - summary: Look Up an Order - description: >- - Looks for an Order with a given `display_id`, `email` pair. The - `display_id`, `email` pair must match in order for the Order to be - returned. - parameters: - - in: query - name: display_id - required: true - description: The display id given to the Order. - schema: - type: number - - in: query - name: email - required: true - description: The email of the Order with the given display_id. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/products/{id}': - get: - operationId: GetProductsProduct - summary: Retrieves a Product - description: Retrieves a Product. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - /products: - get: - operationId: GetProducts - summary: List Products - description: Retrieves a list of Products. - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - count: - description: The total number of Products. - type: integer - offset: - description: The offset for pagination. - type: integer - limit: - description: 'The maxmimum number of Products to return,' - type: integer - products: - type: array - items: - $ref: '#/components/schemas/product' - '/regions/{id}': - get: - operationId: GetRegionsRegion - summary: Retrieves a Region - description: Retrieves a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - /regions: - get: - operationId: GetRegions - summary: List Regions - description: Retrieves a list of Regions. - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - count: - description: The total number of regions. - type: integer - offset: - description: The offset for pagination. - type: integer - limit: - description: 'The maxmimum number of regions to return,' - type: integer - regions: - type: array - items: - $ref: '#/components/schemas/region' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - /returns: - post: - operationId: PostReturns - summary: Create Return - description: Creates a Return for an Order. - requestBody: - content: - application/json: - schema: - properties: - order_id: - type: string - description: The id of the Order to create the Return from. - items: - description: The items to include in the Return. - type: array - items: - properties: - item_id: - description: The id of the Line Item from the Order. - type: string - quantity: - description: The quantity to return. - type: integer - return_shipping: - description: >- - If the Return is to be handled by the store operator the - Customer can choose a Return Shipping Method. Alternatvely - the Customer can handle the Return themselves. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - no_notification: - description: If set to true no notification will be send - type: boolean - tags: - - Return - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return: - $ref: '#/components/schemas/return' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' - /shipping-options: - get: - operationId: GetShippingOptions - summary: Retrieve Shipping Options - description: Retrieves a list of Shipping Options. - parameters: - - in: query - name: is_return - description: >- - Whether return Shipping Options should be included. By default all - Shipping Options are returned. - schema: - type: boolean - - in: query - name: product_ids - description: A comma separated list of Product ids to filter Shipping Options by. - schema: - type: string - - in: query - name: region_id - description: the Region to retrieve Shipping Options from. - schema: - type: string - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_options: - type: array - items: - $ref: '#/components/schemas/shipping_option' - '/shipping-options/{cart_id}': - get: - operationId: GetShippingOptionsCartId - summary: Retrieve Shipping Options for Cart - description: Retrieves a list of Shipping Options available to a cart. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Shipping Option - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - shipping_options: - type: array - items: - $ref: '#/components/schemas/shipping_option' - '/variants/{variant_id}': - get: - operationId: GetVariantsVariant - summary: Retrieve a Product Variant - description: Retrieves a Product Variant by id - parameters: - - in: path - name: variant_id - required: true - description: The id of the Product Variant. - schema: - type: string - tags: - - Product Variant - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - variant: - $ref: '#/components/schemas/product_variant' - /variants: - get: - operationId: GetVariants - summary: Retrieve Product Variants - description: Retrieves a list of Product Variants - parameters: - - in: query - name: ids - description: A comma separated list of Product Variant ids to filter by. - schema: - type: string - tags: - - Product Variant - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - variants: - type: array - items: - $ref: '#/components/schemas/product_variant' -components: - schemas: - address: - title: Address - description: An address. - x-resourceId: address - properties: - id: - type: string - customer_id: - type: string - company: - type: string - first_name: - type: string - last_name: - type: string - address_1: - type: string - address_2: - type: string - city: - type: string - country_code: - type: string - country: - $ref: '#/components/schemas/country' - cart: - title: Cart - description: Represents a user cart - x-resourceId: cart - properties: - id: - type: string - email: - type: string - billing_address_id: - type: string - billing_address: - $ref: '#/components/schemas/address' - shipping_address_id: - type: string - shipping_address: - $ref: '#/components/schemas/address' - items: - type: array - items: - $ref: '#/components/schemas/line_item' - region_id: - type: string - region: - $ref: '#/components/schemas/region' - discounts: - type: array - items: - $ref: '#/components/schemas/region' - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - customer_id: - type: string - customer: - $ref: '#/components/schemas/customer' - payment_session: - $ref: '#/components/schemas/payment_session' - payment_sessions: - type: array - items: - $ref: '#/components/schemas/payment_session' - payment: - $ref: '#/components/schemas/payment' - shipping_methods: - type: array - items: - $ref: '#/components/schemas/shipping_method' - type: - type: string - enum: - - default - - swap - - payment_link - completed_at: - type: string - format: date-time - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - shipping_total: - type: integer - discount_total: - type: integer - tax_total: - type: integer - subtotal: - type: integer - refundable_amount: - type: integer - gift_card_total: - type: integer - claim_image: - title: Claim Image - description: Represents photo documentation of a claim. - x-resourceId: claim_image - properties: - id: - type: string - claim_item_id: - type: string - url: - type: string - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_item: - title: Claim Item - description: >- - Represents a claimed item along with information about the reasons for - the claim. - x-resourceId: claim_item - properties: - id: - type: string - images: - type: array - items: - $ref: '#/components/schemas/claim_image' - claim_order_id: - type: string - item_id: - type: string - item: - description: The Line Item that the claim refers to - $ref: '#/components/schemas/line_item' - variant_id: - type: string - variant: - description: The Product Variant that is claimed. - $ref: '#/components/schemas/product_variant' - reason: - description: The reason for the claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - note: - description: 'An optional note about the claim, for additional information' - type: string - quantity: - description: >- - The quantity of the item that is being claimed; must be less than or - equal to the amount purchased in the original order. - type: integer - tags: - description: User defined tags for easy filtering and grouping. - type: array - items: - $ref: '#/components/schemas/claim_tag' - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_order: - title: Claim Order - description: >- - Claim Orders represent a group of faulty or missing items. Each claim - order consists of a subset of items associated with an original order, - and can contain additional information about fulfillments and returns. - x-resourceId: claim_order - properties: - id: - type: string - type: - type: string - enum: - - refund - - replace - payment_status: - type: string - enum: - - na - - not_refunded - - refunded - fulfillment_status: - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - claim_items: - description: The items that have been claimed - type: array - items: - $ref: '#/components/schemas/claim_item' - additional_items: - description: >- - Refers to the new items to be shipped when the claim order has the - type `replace` - type: array - items: - $ref: '#/components/schemas/line_item' - order_id: - description: The id of the order that the claim comes from. - type: string - return_order: - description: Holds information about the return if the claim is to be returned - $ref: '#/components/schemas/return' - shipping_address_id: - description: The id of the address that the new items should be shipped to - type: string - shipping_address: - description: The address that the new items should be shipped to - $ref: '#/components/schemas/address' - shipping_methods: - description: The shipping methods that the claim order will be shipped with. - type: array - items: - $ref: '#/components/schemas/shipping_method' - fulfillments: - description: The fulfillments of the new items to be shipped - type: array - items: - $ref: '#/components/schemas/fulfillment' - refund_amount: - description: The amount that will be refunded in conjunction with the claim - type: integer - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - claim_tag: - title: Claim Tag - description: >- - Claim Tags are user defined tags that can be assigned to claim items for - easy filtering and grouping. - x-resourceId: claim_tag - properties: - id: - description: The id of the claim tag. Will be prefixed by `ctag_`. - type: string - value: - description: The value that the claim tag holds - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - country: - title: Country - description: Country details - x-resourceId: country - properties: - id: - description: The database id of the country - type: integer - iso_2: - description: The 2 character ISO code for the country. - type: string - iso_3: - description: The 3 character ISO code for the country. - type: string - num_code: - description: The numerical ISO code for the country. - type: string - name: - description: The normalized country name; in upper case. - type: string - display_name: - description: The country name appropriate for display. - type: string - currency: - title: Currency - description: Currency - x-resourceId: currency - properties: - code: - description: The 3 character ISO code for the currency. - type: string - symbol: - description: The symbol used to indicate the currency. - type: string - symbol_native: - description: The native symbol used to indicate the currency. - type: string - name: - description: The written name of the currency - type: string - customer: - title: Customer - description: Represents a customer - x-resourceId: customer - properties: - id: - type: string - email: - type: string - billing_address_id: - type: string - billing_address: - description: The Customer's billing address. - anyOf: - - $ref: '#/components/schemas/address' - shipping_addresses: - type: array - items: - $ref: '#/components/schemas/address' - first_name: - type: string - last_name: - type: string - phone: - type: string - has_account: - type: boolean - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - discount_rule: - title: Discount Rule - description: >- - Holds the rules that governs how a Discount is calculated when applied - to a Cart. - x-resourceId: discount_rule - properties: - id: - description: The id of the Discount Rule. Will be prefixed by `dru_`. - type: string - type: - description: >- - The type of the Discount, can be `fixed` for discounts that reduce - the price by a fixed amount, `percentage` for percentage reductions - or `free_shipping` for shipping vouchers. - type: string - enum: - - fixed - - percentage - - free_shipping - description: - description: A short description of the discount - type: string - value: - description: >- - The value that the discount represents; this will depend on the type - of the discount - type: integer - allocation: - description: The scope that the discount should apply to. - type: string - enum: - - total - - item - valid_for: - description: A set of Products that the discount can be used for. - type: array - items: - $ref: '#/components/schemas/product' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - discount: - title: Discount - description: >- - Represents a discount that can be applied to a cart for promotional - purposes. - x-resourceId: discount - properties: - id: - description: The id of the Discount. Will be prefixed by `disc_`. - type: string - code: - description: >- - A unique code for the discount - this will be used by the customer - to apply the discount - type: string - is_dynamic: - description: >- - A flag to indicate if multiple instances of the discount can be - generated. I.e. for newsletter discounts - type: boolean - rule: - description: The Discount Rule that governs the behaviour of the Discount - anyOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - description: >- - Whether the Discount has been disabled. Disabled discounts cannot be - applied to carts - type: boolean - parent_discount_id: - description: >- - The Discount that the discount was created from. This will always be - a dynamic discount - type: string - starts_at: - description: The time at which the discount can be used. - type: string - format: date-time - ends_at: - description: The time at which the discount can no longer be used. - type: string - format: date-time - regions: - description: The Regions in which the Discount can be used - type: array - items: - $ref: '#/components/schemas/region' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer - usage_count: - description: The number of times a discount has been used. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - fulfillment_item: - title: Fulfillment Item - description: >- - Correlates a Line Item with a Fulfillment, keeping track of the quantity - of the Line Item. - x-resourceId: fulfillment_item - properties: - fulfillment_id: - description: The id of the Fulfillment that the Fulfillment Item belongs to. - type: string - item_id: - description: The id of the Line Item that the Fulfillment Item references. - type: string - item: - description: The Line Item that the Fulfillment Item references. - anyOf: - - $ref: '#/components/schemas/line_item' - quantity: - description: The quantity of the Line Item that is included in the Fulfillment. - type: integer - fulfillment_provider: - title: Fulfillment Provider - description: >- - Represents a fulfillment provider plugin and holds its installation - status. - x-resourceId: fulfillment_provider - properties: - id: - description: The id of the fulfillment provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - fulfillment: - title: Fulfillment - description: >- - Fulfillments are created once store operators can prepare the purchased - goods. Fulfillments will eventually be shipped and hold information - about how to track shipments. Fulfillments are created through a - provider, which is typically an external shipping aggregator, shipping - partner og 3PL, most plugins will have asynchronous communications with - these providers through webhooks in order to automatically update and - synchronize the state of Fulfillments. - x-resourceId: fulfillment - properties: - id: - description: The id of the Fulfillment. This value will be prefixed by `ful_`. - type: string - claim_order_id: - description: The id of the Claim that the Fulfillment belongs to. - type: string - swap_id: - description: The id of the Swap that the Fulfillment belongs to. - type: string - order_id: - description: The id of the Order that the Fulfillment belongs to. - type: string - provider_id: - description: >- - The id of the Fulfillment Provider responsible for handling the - fulfillment - type: string - items: - description: >- - The Fulfillment Items in the Fulfillment - these hold information - about how many of each Line Item has been fulfilled. - type: array - items: - $ref: '#/components/schemas/fulfillment_item' - tracking_links: - description: >- - The Tracking Links that can be used to track the status of the - Fulfillment, these will usually be provided by the Fulfillment - Provider. - type: array - items: - $ref: '#/components/schemas/tracking_link' - tracking_numbers: - deprecated: true - description: >- - The tracking numbers that can be used to track the status of the - fulfillment. - type: array - items: - type: string - shipped_at: - description: The date with timezone at which the Fulfillment was shipped. - type: string - format: date-time - canceled_at: - description: The date with timezone at which the Fulfillment was canceled. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - gift_card_transaction: - title: Gift Card Transaction - description: >- - Gift Card Transactions are created once a Customer uses a Gift Card to - pay for their Order - x-resourceId: gift_card_transaction - properties: - id: - description: >- - The id of the Gift Card Transaction. This value will be prefixed by - `gct_`. - type: string - gift_card_id: - description: The id of the Gift Card that was used in the transaction. - type: string - gift_card: - description: The Gift Card that was used in the transaction. - anyOf: - - $ref: '#/components/schemas/gift_card' - order_id: - description: The id of the Order that the Gift Card was used to pay for. - type: string - amount: - description: The amount that was used from the Gift Card. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - gift_card: - title: Gift Card - description: >- - Gift Cards are redeemable and represent a value that can be used towards - the payment of an Order. - x-resourceId: gift_card - properties: - id: - description: The id of the Gift Card. This value will be prefixed by `gift_`. - type: string - code: - description: >- - The unique code that identifies the Gift Card. This is used by the - Customer to redeem the value of the Gift Card. - type: string - value: - description: The value that the Gift Card represents. - type: integer - balance: - description: The remaining value on the Gift Card. - type: integer - region_id: - description: The id of the Region in which the Gift Card is available. - type: string - region: - description: The Region in which the Gift Card is available. - anyOf: - - $ref: '#/components/schemas/region' - order_id: - description: The id of the Order that the Gift Card was purchased in. - type: string - is_disabled: - description: >- - Whether the Gift Card has been disabled. Disabled Gift Cards cannot - be applied to carts. - type: boolean - ends_at: - description: The time at which the Gift Card can no longer be used. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - image: - title: Image - description: Images holds a reference to a URL at which the image file can be found. - x-resourceId: image - properties: - id: - description: The id of the Image. This value will be prefixed by `img_`. - type: string - url: - description: The URL at which the image file can be found. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - update_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - line_item: - title: Line Item - description: >- - Line Items represent purchasable units that can be added to a Cart for - checkout. When Line Items are purchased they will get copied to the - resulting order and can eventually be referenced in Fulfillments and - Returns. Line Items may also be created when processing Swaps and - Claims. - x-resourceId: line_item - properties: - id: - description: The id of the Line Item. This value will be prefixed by `item_`. - type: string - cart_id: - description: The id of the Cart that the Line Item belongs to. - type: string - order_id: - description: The id of the Order that the Line Item belongs to. - type: string - swap_id: - description: The id of the Swap that the Line Item belongs to. - type: string - claim_order_id: - description: The id of the Claim that the Line Item belongs to. - type: string - title: - description: >- - The title of the Line Item, this should be easily identifiable by - the Customer. - type: string - description: - description: A more detailed description of the contents of the Line Item. - type: string - thumbnail: - description: A URL string to a small image of the contents of the Line Item. - type: string - is_giftcard: - description: Flag to indicate if the Line Item is a Gift Card. - type: boolean - should_merge: - description: >- - Flag to indicate if new Line Items with the same variant should be - merged or added as an additional Line Item. - type: boolean - allow_discounts: - description: >- - Flag to indicate if the Line Item should be included when doing - discount calculations. - type: boolean - unit_price: - description: >- - The price of one unit of the content in the Line Item. This should - be in the currency defined by the Cart/Order/Swap/Claim that the - Line Item belongs to. - type: boolean - variant_id: - description: The id of the Product Variant contained in the Line Item. - type: string - variant: - description: The Product Variant contained in the Line Item. - anyOf: - - $ref: '#/components/schemas/product_variant' - quantity: - description: The quantity of the content in the Line Item. - type: integer - fulfilled_quantity: - description: The quantity of the Line Item that has been fulfilled. - type: integer - returned_quantity: - description: The quantity of the Line Item that has been returned. - type: integer - shipped_quantity: - description: The quantity of the Line Item that has been shipped. - type: integer - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - refundable: - description: >- - The amount that can be refunded from the given Line Item. Takes - taxes and discounts into consideration. - type: integer - money_amount: - title: Money Amount - description: >- - Money Amounts represents an amount that a given Product Variant can be - purcased for. Each Money Amount either has a Currency or Region - associated with it to indicate the pricing in a given Currency or, for - fully region-based pricing, the given price in a specific Region. If - region-based pricing is used the amount will be in the currency defined - for the Reigon. - x-resourceId: money_amount - properties: - id: - description: The id of the Money Amount. This value will be prefixed by `ma_`. - type: string - currency_code: - description: The 3 character currency code that the Money Amount is given in. - type: string - amount: - description: >- - The amount in the smallest currecny unit (e.g. cents 100 cents to - charge $1) that the Product Variant will cost. - type: integer - sale_amount: - description: >- - An optional sale amount that the Product Variant will be available - for when defined. - type: integer - variant_id: - description: The id of the Product Variant that the Money Amount belongs to. - type: string - region_id: - description: The id of the Region that the Money Amount is defined for. - type: string - region: - description: The Region that the Money Amount is defined for. - anyOf: - - $ref: '#/components/schemas/region' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - notification_provider: - title: Notification Provider - description: >- - Represents a notification provider plugin and holds its installation - status. - x-resourceId: notification_provider - properties: - id: - description: The id of the notification provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - notification: - title: Notification - description: >- - Notifications a communications sent via Notification Providers as a - reaction to internal events such as `order.placed`. Notifications can be - used to show a chronological timeline for communications sent to a - Customer regarding an Order, and enables resends. - x-resourceId: notification - properties: - id: - description: The id of the Notification. This value will be prefixed by `noti_`. - type: string - event_name: - description: The name of the event that the notification was sent for. - type: string - resource_type: - description: The type of resource that the Notification refers to. - type: string - resource_id: - description: The id of the resource that the Notification refers to. - type: string - customer_id: - description: The id of the Customer that the Notification was sent to. - type: string - customer: - description: The Customer that the Notification was sent to. - anyOf: - - $ref: '#/components/schemas/customer' - to: - description: >- - The address that the Notification was sent to. This will usually be - an email address, but represent other addresses such as a chat bot - user id - type: string - data: - description: >- - The data that the Notification was sent with. This contains all the - data necessary for the Notification Provider to initiate a resend. - type: object - parent_id: - description: The id of the Notification that was originally sent. - type: string - resends: - description: >- - The resends that have been completed after the original - Notification. - type: array - items: - $ref: '#/components/schemas/notification_resend' - provider_id: - description: The id of the Notification Provider that handles the Notification. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - notification_resend: - title: Notification Resend - description: A resend of a Notification. - x-resourceId: notification_resend - properties: - id: - description: The id of the Notification. This value will be prefixed by `noti_`. - type: string - event_name: - description: The name of the event that the notification was sent for. - type: string - resource_type: - description: The type of resource that the Notification refers to. - type: string - resource_id: - description: The id of the resource that the Notification refers to. - type: string - to: - description: >- - The address that the Notification was sent to. This will usually be - an email address, but represent other addresses such as a chat bot - user id - type: string - data: - description: >- - The data that the Notification was sent with. This contains all the - data necessary for the Notification Provider to initiate a resend. - type: object - parent_id: - description: The id of the Notification that was originally sent. - type: string - provider_id: - description: The id of the Notification Provider that handles the Notification. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - order: - title: Order - description: Represents an order - x-resourceId: order - properties: - id: - type: string - status: - type: string - enum: - - pending - - completed - - archived - - canceled - - requires_action - fulfillment_status: - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - payment_status: - type: string - enum: - - not_paid - - awaiting - - captured - - partially_refunded - - refuneded - - canceled - - requires_action - display_id: - type: integer - cart_id: - type: string - currency_code: - type: string - tax_rate: - type: integer - discounts: - type: array - items: - $ref: '#/components/schemas/discount' - email: - type: string - billing_address_id: - type: string - billing_address: - anyOf: - - $ref: '#/components/schemas/address' - shipping_address_id: - type: string - shipping_address: - anyOf: - - $ref: '#/components/schemas/address' - items: - type: array - items: - $ref: '#/components/schemas/line_item' - region_id: - type: string - region: - anyOf: - - $ref: '#/components/schemas/region' - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - customer_id: - type: string - customer: - anyOf: - - $ref: '#/components/schemas/customer' - payment_session: - anyOf: - - $ref: '#/components/schemas/payment_session' - payment_sessions: - type: array - items: - $ref: '#/components/schemas/payment_session' - payments: - type: array - items: - $ref: '#/components/schemas/payment' - shipping_methods: - type: array - items: - $ref: '#/components/schemas/shipping_method' - fulfillments: - type: array - items: - $ref: '#/components/schemas/fulfillment' - returns: - type: array - items: - $ref: '#/components/schemas/return' - claims: - type: array - items: - $ref: '#/components/schemas/claim_order' - refunds: - type: array - items: - $ref: '#/components/schemas/refund' - swaps: - type: array - items: - $ref: '#/components/schemas/refund' - gift_card_transactions: - type: array - items: - $ref: '#/components/schemas/gift_card_transaction' - canceled_at: - type: string - format: date-time - created_at: - type: string - format: date-time - update_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object - shipping_total: - type: integer - discount_total: - type: integer - tax_total: - type: integer - subtotal: - type: integer - refundable_amount: - type: integer - gift_card_total: - type: integer - paid_total: - type: integer - payment_provider: - title: Payment Provider - description: Represents a Payment Provider plugin and holds its installation status. - x-resourceId: payment_provider - properties: - id: - description: The id of the payment provider as given by the plugin. - type: string - is_installed: - description: >- - Whether the plugin is installed in the current version. Plugins that - are no longer installed are not deleted by will have this field set - to `false`. - type: boolean - payment_session: - title: Payment Session - description: >- - Payment Sessions are created when a Customer initilizes the checkout - flow, and can be used to hold the state of a payment flow. Each Payment - Session is controlled by a Payment Provider, who is responsible for the - communication with external payment services. Authorized Payment - Sessions will eventually get promoted to Payments to indicate that they - are authorized for capture/refunds/etc. - x-resourceId: payment_session - properties: - id: - description: >- - The id of the Payment Session. This value will be prefixed with - `ps_`. - type: string - cart_id: - description: The id of the Cart that the Payment Session is created for. - type: string - provider_id: - description: >- - The id of the Payment Provider that is responsible for the Payment - Session - type: string - is_selected: - description: >- - A flag to indicate if the Payment Session has been selected as the - method that will be used to complete the purchase. - type: boolean - status: - description: >- - Indicates the status of the Payment Session. Will default to - `pending`, and will eventually become `authorized`. Payment Sessions - may have the status of `requires_more` to indicate that further - actions are to be completed by the Customer. - type: string - enum: - - authorized - - pending - - requires_more - - error - - canceled - data: - description: >- - The data required for the Payment Provider to identify, modify and - process the Payment Session. Typically this will be an object that - holds an id to the external payment session, but can be an empty - object if the Payment Provider doesn't hold any state. - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - payment: - title: Payment - description: >- - Payments represent an amount authorized with a given payment method, - Payments can be captured, canceled or refunded. - x-resourceId: payment - properties: - id: - description: The id of the Payment. This value will be prefixed with `pay_`. - type: string - swap_id: - description: The id of the Swap that the Payment is used for. - type: string - order_id: - description: The id of the Order that the Payment is used for. - type: string - cart_id: - description: The id of the Cart that the Payment Session is created for. - type: string - amount: - description: The amount that the Payment has been authorized for. - type: integer - currency_code: - description: The 3 character ISO currency code that the Payment is completed in. - type: string - amount_refunded: - description: >- - The amount of the original Payment amount that has been refunded - back to the Customer. - type: integer - provider_id: - description: The id of the Payment Provider that is responsible for the Payment - type: string - data: - description: >- - The data required for the Payment Provider to identify, modify and - process the Payment. Typically this will be an object that holds an - id to the external payment session, but can be an empty object if - the Payment Provider doesn't hold any state. - type: object - captured_at: - description: The date with timezone at which the Payment was captured. - type: string - format: date-time - canceled_at: - description: The date with timezone at which the Payment was canceled. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_collection: - title: Product Collection - description: Product Collections represents a group of Products that are related. - x-resourceId: product_collection - properties: - id: - description: >- - The id of the Product Collection. This value will be prefixed with - `pcol_`. - type: string - title: - description: The title that the Product Collection is identified by. - type: string - handle: - description: >- - A unique string that identifies the Product Collection - can for - example be used in slug structures. - type: string - products: - description: The Products contained in the Product Collection. - type: array - items: - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_option_value: - title: Product Option Value - description: >- - A value given to a Product Variant's option set. Product Variant have a - Product Option Value for each of the Product Options defined on the - Product. - x-resourceId: product_option_value - properties: - id: - description: >- - The id of the Product Option Value. This value will be prefixed with - `optval_`. - type: string - value: - description: >- - The value that the Product Variant has defined for the specific - Product Option (e.g. if the Product Option is "Size" this value - could be "Small", "Medium" or "Large"). - type: string - option_id: - description: >- - The id of the Product Option that the Product Option Value is - defined for. - type: string - variant_id: - description: >- - The id of the Product Variant that the Product Option Value is - defined for. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_option: - title: Product Option - description: >- - Product Options define properties that may vary between different - variants of a Product. Common Product Options are "Size" and "Color", - but Medusa doesn't limit what Product Options that can be defined. - x-resourceId: product_option - properties: - id: - description: >- - The id of the Product Option. This value will be prefixed with - `opt_`. - type: string - title: - description: The title that the Product Option is defined by (e.g. "Size"). - type: string - values: - description: The Product Option Values that are defined for the Product Option. - type: array - items: - $ref: '#/components/schemas/product_option_value' - product_id: - description: The id of the Product that the Product Option is defined for. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_tag: - title: Product Tag - description: Product Tags can be added to Products for easy filtering and grouping. - x-resourceId: product_tag - properties: - id: - description: The id of the Product Tag. This value will be prefixed with `ptag_`. - type: string - value: - description: The value that the Product Tag represents (e.g. "Pants"). - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_type: - title: Product Type - description: >- - Product Type can be added to Products for filtering and reporting - purposes. - x-resourceId: product_type - properties: - id: - description: >- - The id of the Product Type. This value will be prefixed with - `ptyp_`. - type: string - value: - description: The value that the Product Type represents (e.g. "Clothing"). - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product_variant: - title: Product Variant - description: >- - Product Variants represent a Product with a specific set of Product - Option configurations. The maximum number of Product Variants that a - Product can have is given by the number of available Product Option - combinations. - x-resourceId: product_variant - properties: - id: - description: >- - The id of the Product Variant. This value will be prefixed with - `variant_`. - type: string - title: - description: >- - A title that can be displayed for easy identification of the Product - Variant. - type: string - product_id: - description: The id of the Product that the Product Variant belongs to. - type: string - prices: - description: >- - The Money Amounts defined for the Product Variant. Each Money Amount - represents a price in a given currency or a price in a specific - Region. - type: array - items: - $ref: '#/components/schemas/money_amount' - sku: - description: >- - The unique stock keeping unit used to identify the Product Variant. - This will usually be a unqiue identifer for the item that is to be - shipped, and can be referenced across multiple systems. - type: string - barcode: - description: >- - A generic field for a GTIN number that can be used to identify the - Product Variant. - type: string - ean: - description: >- - An EAN barcode number that can be used to identify the Product - Variant. - type: string - upc: - description: >- - A UPC barcode number that can be used to identify the Product - Variant. - type: string - inventory_quantity: - description: The current quantity of the item that is stocked. - type: integer - allow_backorder: - description: >- - Whether the Product Variant should be purchasable when - `inventory_quantity` is 0. - type: boolean - manage_inventory: - description: Whether Medusa should manage inventory for the Product Variant. - type: boolean - hs_code: - description: >- - The Harmonized System code of the Product Variant. May be used by - Fulfillment Providers to pass customs information to shipping - carriers. - type: string - origin_country: - description: >- - The country in which the Product Variant was produced. May be used - by Fulfillment Providers to pass customs information to shipping - carriers. - type: string - mid_code: - description: >- - The Manufacturers Identification code that identifies the - manufacturer of the Product Variant. May be used by Fulfillment - Providers to pass customs information to shipping carriers. - type: string - material: - description: >- - The material and composition that the Product Variant is made of, - May be used by Fulfillment Providers to pass customs information to - shipping carriers. - type: string - weight: - description: >- - The weight of the Product Variant. May be used in shipping rate - calculations. - type: string - height: - description: >- - The height of the Product Variant. May be used in shipping rate - calculations. - type: string - width: - description: >- - The width of the Product Variant. May be used in shipping rate - calculations. - type: string - length: - description: >- - The length of the Product Variant. May be used in shipping rate - calculations. - type: string - options: - description: The Product Option Values specified for the Product Variant. - type: array - items: - $ref: '#/components/schemas/product_option_value' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - product: - title: Product - description: >- - Products are a grouping of Product Variants that have common properties - such as images and descriptions. Products can have multiple options - which define the properties that Product Variants differ by. - x-resourceId: product - properties: - id: - description: The id of the Product. This value will be prefixed with `prod_`. - type: string - title: - description: >- - A title that can be displayed for easy identification of the - Product. - type: string - subtitle: - description: >- - An optional subtitle that can be used to further specify the - Product. - type: string - description: - description: A short description of the Product. - type: string - handle: - description: A unique identifier for the Product (e.g. for slug structure). - type: string - is_giftcard: - description: >- - Whether the Product represents a Gift Card. Products that represent - Gift Cards will automatically generate a redeemable Gift Card code - once they are purchased. - type: boolean - images: - description: Images of the Product - type: array - items: - $ref: '#/components/schemas/image' - thumbnail: - description: A URL to an image file that can be used to identify the Product. - type: string - options: - description: >- - The Product Options that are defined for the Product. Product - Variants of the Product will have a unique combination of Product - Option Values. - type: array - items: - $ref: '#/components/schemas/product_option' - variants: - description: >- - The Product Variants that belong to the Product. Each will have a - unique combination of Product Option Values. - type: array - items: - $ref: '#/components/schemas/product_variant' - profile_id: - description: >- - The id of the Shipping Profile that the Product belongs to. Shipping - Profiles have a set of defined Shipping Options that can be used to - Fulfill a given set of Products. - type: string - hs_code: - description: >- - The Harmonized System code of the Product Variant. May be used by - Fulfillment Providers to pass customs information to shipping - carriers. - type: string - origin_country: - description: >- - The country in which the Product Variant was produced. May be used - by Fulfillment Providers to pass customs information to shipping - carriers. - type: string - mid_code: - description: >- - The Manufacturers Identification code that identifies the - manufacturer of the Product Variant. May be used by Fulfillment - Providers to pass customs information to shipping carriers. - type: string - material: - description: >- - The material and composition that the Product Variant is made of, - May be used by Fulfillment Providers to pass customs information to - shipping carriers. - type: string - weight: - description: >- - The weight of the Product Variant. May be used in shipping rate - calculations. - type: string - height: - description: >- - The height of the Product Variant. May be used in shipping rate - calculations. - type: string - width: - description: >- - The width of the Product Variant. May be used in shipping rate - calculations. - type: string - length: - description: >- - The length of the Product Variant. May be used in shipping rate - calculations. - type: string - type: - description: The Product Type of the Product (e.g. "Clothing") - anyOf: - - $ref: '#/components/schemas/product_type' - collection: - description: The Product Collection that the Product belongs to (e.g. "SS20") - anyOf: - - $ref: '#/components/schemas/product_collection' - tags: - description: The Product Tags assigned to the Product. - type: array - items: - $ref: '#/components/schemas/product_tag' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - refund: - title: Refund - description: >- - Refund represent an amount of money transfered back to the Customer for - a given reason. Refunds may occur in relation to Returns, Swaps and - Claims, but can also be initiated by a store operator. - x-resourceId: refund - properties: - id: - description: The id of the Refund. This value will be prefixed with `ref_`. - type: string - order_id: - description: The id of the Order that the Refund is related to. - type: string - amount: - description: The amount that has be refunded to the Customer. - type: integer - note: - description: An optional note explaining why the amount was refunded. - type: string - reason: - description: >- - The reason given for the Refund, will automatically be set when - processed as part of a Swap, Claim or Return. - type: string - enum: - - discount - - return - - swap - - claim - - other - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - region: - title: Region - description: >- - Regions hold settings for how Customers in a given geographical location - shop. The is, for example, where currencies and tax rates are defined. A - Region can consist of multiple countries to accomodate common shopping - settings across countries. - x-resourceId: region - properties: - id: - description: The id of the Region. This value will be prefixed with `reg_`. - type: string - name: - description: >- - The name of the region as displayed to the customer. If the Region - only has one country it is recommended to write the country name. - type: string - currency_code: - description: >- - The 3 character ISO currency code that Customers will shop in in the - Region. - type: string - tax_rate: - description: The tax rate that should be charged on purchases in the Region. - type: number - tax_code: - description: >- - The tax code used on purchases in the Region. This may be used by - other systems for accounting purposes. - type: string - countries: - description: The countries that are included in the Region. - type: array - items: - $ref: '#/components/schemas/country' - payment_providers: - description: >- - The Payment Providers that can be used to process Payments in the - Region. - type: array - items: - $ref: '#/components/schemas/payment_provider' - fulfillment_providers: - description: >- - The Fulfillment Providers that can be used to fulfill orders in the - Region. - type: array - items: - $ref: '#/components/schemas/fulfillment_provider' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - return_item: - title: Return Item - description: >- - Correlates a Line Item with a Return, keeping track of the quantity of - the Line Item that will be returned. - x-resourceId: return_item - properties: - return_id: - description: The id of the Return that the Return Item belongs to. - type: string - item_id: - description: The id of the Line Item that the Return Item references. - type: string - item: - description: The Line Item that the Return Item references. - anyOf: - - $ref: '#/components/schemas/line_item' - quantity: - description: The quantity of the Line Item that is included in the Return. - type: integer - is_requested: - description: >- - Whether the Return Item was requested initially or received - unexpectedly in the warehouse. - type: boolean - requested_quantity: - description: The quantity that was originally requested to be returned. - type: integer - recieved_quantity: - description: The quantity that was received in the warehouse. - type: integer - reason: - description: The reason for returning the item. - anyOf: - - $ref: '#/components/schemas/return_reason' - note: - description: An optional note with additional details about the Return. - type: string - metadata: - description: An optional key-value map with additional information. - type: object - return_reason: - title: Return Reason - description: >- - A Reason for why a given product is returned. A Return Reason can be - used on Return Items in order to indicate why a Line Item was returned. - x-resourceId: return_reason - properties: - id: - description: The id of the Return Reason will start with `rr_`. - type: string - description: - description: A description of the Reason. - type: string - label: - description: A text that can be displayed to the Customer as a reason. - type: string - value: - description: The value to identify the reason by. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - return: - title: Return - description: >- - Return orders hold information about Line Items that a Customer wishes - to send back, along with how the items will be returned. Returns can be - used as part of a Swap. - x-resourceId: return - properties: - id: - description: The id of the Return. This value will be prefixed with `ret_`. - type: string - status: - description: Status of the Return. - type: string - enum: - - requested - - received - - requires_action - items: - description: >- - The Return Items that will be shipped back to the warehouse. type: - array items: $ref: - swap_id: - description: The id of the Swap that the Return is a part of. - type: string - order_id: - description: The id of the Order that the Return is made from. - type: string - claim_order_id: - description: The id of the Claim that the Return is a part of. - type: string - shipping_method: - description: >- - The Shipping Method that will be used to send the Return back. Can - be null if the Customer facilitates the return shipment themselves. - anyOf: - - $ref: '#/components/schemas/shipping_method' - shipping_data: - description: >- - Data about the return shipment as provided by the Fulfilment - Provider that handles the return shipment. - type: object - refund_amount: - description: The amount that should be refunded as a result of the return. - type: integer - received_at: - description: The date with timezone at which the return was received. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - shipping_method: - title: Shipping Method - description: >- - Shipping Methods represent a way in which an Order or Return can be - shipped. Shipping Methods are built from a Shipping Option, but may - contain additional details, that can be necessary for the Fulfillment - Provider to handle the shipment. - x-resourceId: shipping_method - properties: - id: - description: >- - The id of the Shipping Method. This value will be prefixed with - `sm_`. - type: string - shipping_option_id: - description: >- - The id of the Shipping Option that the Shipping Method is built - from. - type: string - shipping_option: - description: The Shipping Option that the Shipping Method is built from. - anyOf: - - $ref: '#/components/schemas/shipping_option' - order_id: - description: The id of the Order that the Shipping Method is used on. - type: string - return_id: - description: The id of the Return that the Shipping Method is used on. - type: string - swap_id: - description: The id of the Swap that the Shipping Method is used on. - type: string - cart_id: - description: The id of the Cart that the Shipping Method is used on. - type: string - claim_order_id: - description: The id of the Claim that the Shipping Method is used on. - type: string - price: - description: >- - The amount to charge for the Shipping Method. The currency of the - price is defined by the Region that the Order that the Shipping - Method belongs to is a part of. - type: integer - data: - description: >- - Additional data that the Fulfillment Provider needs to fulfill the - shipment. This is used in combination with the Shipping Options - data, and may contain information such as a drop point id. - type: object - shipping_option_requirement: - title: Shipping Option Requirement - description: >- - A requirement that a Cart must satisfy for the Shipping Option to be - available to the Cart. - x-resourceId: shipping_option_requirement - properties: - id: - description: >- - The id of the Shipping Option Requirement. This value will be - prefixed with `sor_`. - type: string - shipping_option_id: - description: >- - The id of the Shipping Option that the Shipping Option Requirement - belongs to. - type: string - type: - description: >- - The type of the requirement, this defines how the value will be - compared to the Cart's total. `min_subtotal` requirements define the - minimum subtotal that is needed for the Shipping Option to be - available, while the `max_subtotal` defines the maximum subtotal - that the Cart can have for the Shipping Option to be available. - type: string - enum: - - min_subtotal - - max_subtotal - amount: - description: The amount to compare the Cart subtotal to. - type: integer - shipping_option: - title: Shipping Option - description: >- - Shipping Options represent a way in which an Order or Return can be - shipped. Shipping Options have an associated Fulfillment Provider that - will be used when the fulfillment of an Order is initiated. Shipping - Options themselves cannot be added to Carts, but serve as a template for - Shipping Methods. This distinction makes it possible to customize - individual Shipping Methods with additional information. - x-resourceId: shipping_option - properties: - id: - description: >- - The id of the Shipping Option. This value will be prefixed with - `so_`. - type: string - name: - description: >- - The name given to the Shipping Option - this may be displayed to the - Customer. - type: string - region_id: - description: The id of the Region that the Shipping Option belongs to. - type: string - region: - description: The id of the Region that the Shipping Option belongs to. - anyOf: - - $ref: '#/components/schemas/region' - profile_id: - description: >- - The id of the Shipping Profile that the Shipping Option belongs to. - Shipping Profiles have a set of defined Shipping Options that can be - used to Fulfill a given set of Products. - type: string - provider_id: - description: >- - The id of the Fulfillment Provider, that will be used to process - Fulfillments from the Shipping Option. - type: string - price_type: - description: >- - The type of pricing calculation that is used when creatin Shipping - Methods from the Shipping Option. Can be `flat_rate` for fixed - prices or `calculated` if the Fulfillment Provider can provide price - calulations. - type: string - enum: - - flat_rate - - calculated - amount: - description: >- - The amount to charge for shipping when the Shipping Option price - type is `flat_rate`. - type: integer - is_return: - description: >- - Flag to indicate if the Shipping Option can be used for Return - shipments. - type: boolean - requirements: - description: >- - The requirements that must be satisfied for the Shipping Option to - be available for a Cart. - type: array - items: - $ref: '#/components/schemas/shipping_option_requirement' - data: - description: >- - The data needed for the Fulfillment Provider to identify the - Shipping Option. - type: object - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - shipping_profile: - title: Shipping Profile - description: >- - Shipping Profiles have a set of defined Shipping Options that can be - used to fulfill a given set of Products. - x-resourceId: shipping_profile - properties: - id: - description: >- - The id of the Shipping Profile. This value will be prefixed with - `sp_`. - type: string - name: - description: >- - The name given to the Shipping profile - this may be displayed to - the Customer. - type: string - type: - description: >- - The type of the Shipping Profile, may be `default`, `gift_card` or - `custom`. - type: string - enum: - - default - - gift_card - - custom - products: - description: The Products that the Shipping Profile defines Shipping Options for. - type: array - items: - $ref: '#/components/schemas/product' - shipping_options: - description: >- - The Shipping Options that can be used to fulfill the Products in the - Shipping Profile. - type: array - items: - anyOf: - - $ref: '#/components/schemas/shipping_option' - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - store: - title: Store - description: 'Holds settings for the Store, such as name, currencies, etc.' - x-resourceId: store - properties: - id: - description: The id of the Store. This value will be prefixed with `store_`. - type: string - name: - description: The name of the Store - this may be displayed to the Customer. - type: string - default_currency_code: - description: >- - The default currency code used when no other currency code is - specified. - type: string - currencies: - description: The currencies that are enabled for the Store. - type: array - items: - $ref: '#/components/schemas/currency' - swap_link_template: - description: >- - A template to generate Swap links from use {{cart_id}} to include - the Swap's `cart_id` in the link. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - swap: - title: Swap - description: >- - Swaps can be created when a Customer wishes to exchange Products that - they have purchased to different Products. Swaps consist of a Return of - previously purchased Products and a Fulfillment of new Products, the - amount paid for the Products being returned will be used towards payment - for the new Products. In the case where the amount paid for the the - Products being returned exceed the amount to be paid for the new - Products, a Refund will be issued for the difference. - x-resourceId: swap - properties: - id: - description: The id of the Swap. This value will be prefixed with `swap_`. - type: string - fulfillment_status: - description: The status of the Fulfillment of the Swap. - type: string - enum: - - not_fulfilled - - partially_fulfilled - - fulfilled - - partially_shipped - - shipped - - partially_returned - - returned - - canceled - - requires_action - payment_status: - description: >- - The status of the Payment of the Swap. The payment may either refer - to the refund of an amount or the authorization of a new amount. - type: string - enum: - - not_paid - - awaiting - - captured - - canceled - - difference_refunded - - requires_action - order_id: - description: >- - The id of the Order where the Line Items to be returned where - purchased. - type: string - additional_items: - description: The new Line Items to ship to the Customer. - type: array - items: - $ref: '#/components/schemas/line_item' - return_order: - description: The Return that is issued for the return part of the Swap. - anyOf: - - $ref: '#/components/schemas/return' - fulfillments: - description: The Fulfillments used to send the new Line Items. - type: array - items: - $ref: '#/components/schemas/fulfillment' - payment: - description: >- - The Payment authorized when the Swap requires an additional amount - to be charged from the Customer. - anyOf: - - $ref: '#/components/schemas/payment' - difference_due: - description: >- - The difference that is paid or refunded as a result of the Swap. May - be negative when the amount paid for the returned items exceed the - total of the new Products. - type: integer - shipping_address: - description: >- - The Address to send the new Line Items to - in most cases this will - be the same as the shipping address on the Order. - anyOf: - - $ref: '#/components/schemas/address' - shipping_methods: - description: The Shipping Methods used to fulfill the addtional items purchased. - type: array - items: - $ref: '#/components/schemas/shipping_method' - cart_id: - description: The id of the Cart that the Customer will use to confirm the Swap. - type: string - confirmed_at: - description: >- - The date with timezone at which the Swap was confirmed by the - Customer. - type: string - format: date-time - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - tracking_link: - title: Tracking Link - description: >- - Tracking Link holds information about tracking numbers for a - Fulfillment. Tracking Links can optionally contain a URL that can be - visited to see the status of the shipment. - x-resourceId: tracking_link - properties: - id: - description: >- - The id of the Tracking Link. This value will be prefixed with - `tlink_`. - type: string - url: - description: The URL at which the status of the shipment can be tracked. - type: string - tracking_number: - description: The tracking number given by the shipping carrier. - type: string - fulfillment_id: - description: The id of the Fulfillment that the Tracking Link references. - type: string - created_at: - description: The date with timezone at which the resource was created. - type: string - format: date-time - updated_at: - description: The date with timezone at which the resource was last updated. - type: string - format: date-time - deleted_at: - description: The date with timezone at which the resource was deleted. - type: string - format: date-time - metadata: - description: An optional key-value map with additional information. - type: object - user: - title: User - description: Represents a User who can manage store settings. - x-resourceId: user - properties: - id: - description: The unique id of the User. This will be prefixed with `usr_` - type: string - email: - description: The email of the User - type: string - first_name: - type: string - last_name: - description: The Customer's billing address. - anyOf: - - $ref: '#/components/schemas/address' - created_at: - type: string - format: date-time - updated_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - metadata: - type: object diff --git a/packages/medusa/src/migrations/1622713782458-no_notification.ts b/packages/medusa/src/migrations/1622713782458-no_notification.ts deleted file mode 100644 index 0e0ac4ef00..0000000000 --- a/packages/medusa/src/migrations/1622713782458-no_notification.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class noNotification1622713782458 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} diff --git a/packages/medusa/src/migrations/1623231564533-no_notification.ts b/packages/medusa/src/migrations/1623231564533-no_notification.ts new file mode 100644 index 0000000000..2b3cac3d30 --- /dev/null +++ b/packages/medusa/src/migrations/1623231564533-no_notification.ts @@ -0,0 +1,20 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class noNotification1623231564533 implements MigrationInterface { + name = 'noNotification1623231564533' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "return" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); + await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + } + +} From 5b65345af1919d3a74eb485f857996878cb5e75b Mon Sep 17 00:00:00 2001 From: --list Date: Wed, 9 Jun 2021 16:34:03 +0200 Subject: [PATCH 26/55] began testing no_notification in different layers --- .../admin/orders/__tests__/get-order.js | 1 + .../admin/orders/__tests__/return-order.js | 82 +++++++++++++++++++ .../api/routes/admin/orders/request-return.js | 14 +++- .../medusa/src/services/__mocks__/order.js | 2 + .../medusa/src/services/__tests__/order.js | 16 ++++ .../medusa/src/services/__tests__/swap.js | 26 +++++- packages/medusa/src/services/claim.js | 10 +-- packages/medusa/src/services/order.js | 7 +- packages/medusa/src/services/return.js | 1 + packages/medusa/src/services/swap.js | 2 +- 10 files changed, 148 insertions(+), 13 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js index 5001ed0def..57cb1db7ea 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js @@ -62,6 +62,7 @@ const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] describe("GET /admin/orders", () => { diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js index 5a36010d3e..f84e0bc65a 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js @@ -2,6 +2,8 @@ import { IdMap } from "medusa-test-utils" import { request } from "../../../../../helpers/test-request" import { orders } from "../../../../../services/__mocks__/order" import { ReturnService } from "../../../../../services/__mocks__/return" +import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus" +import { OrderServiceMock } from "../../../../../services/__mocks__/order" describe("POST /admin/orders/:id/return", () => { describe("successfully returns full order", () => { @@ -21,6 +23,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: 10, + no_notification: true, }, adminSession: { jwt: { @@ -47,6 +50,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 10, + no_notification: true, shipping_method: undefined, }) }) @@ -69,6 +73,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: -1, + no_notification: true, }, adminSession: { jwt: { @@ -95,6 +100,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 0, + no_notification: true, shipping_method: undefined, }) }) @@ -118,6 +124,7 @@ describe("POST /admin/orders/:id/return", () => { ], refund: -1, }, + no_notification: true, adminSession: { jwt: { userId: IdMap.getId("admin_user"), @@ -143,6 +150,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 0, + no_notification: true, shipping_method: undefined, }) }) @@ -165,6 +173,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund: 100, + no_notification: true, return_shipping: { option_id: "opt_1234", price: 12, @@ -195,6 +204,7 @@ describe("POST /admin/orders/:id/return", () => { }, ], refund_amount: 100, + no_notification: true, shipping_method: { option_id: "opt_1234", price: 12, @@ -205,4 +215,76 @@ describe("POST /admin/orders/:id/return", () => { expect(ReturnService.fulfill).toHaveBeenCalledWith("return") }) }) + + describe("the api call overrides notification settings of order", () => { + it("eventBus is called with the proper no notification feature", async () => { + jest.clearAllMocks() + const subject = await request( + "POST", + `/admin/orders/${IdMap.getId("test-order")}/return`, + { + payload: { + items: [ + { + item_id: IdMap.getId("existingLine"), + quantity: 10, + }, + ], + refund: 100, + return_shipping: { + option_id: "opt_1234", + price: 12, + }, + no_notification: false, + }, + adminSession: { + jwt: { + userId: IdMap.getId("admin_user"), + }, + }, + } + ) + expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: false, + return_id: expect.any(String) + }) + }) + }) + + describe("the api call inherits notification settings of order", () => { + it("eventBus is called with the proper no notification feature", async () => { + jest.clearAllMocks() + await request( + "POST", + `/admin/orders/${IdMap.getId("test-order")}/return`, + { + payload: { + items: [ + { + item_id: IdMap.getId("existingLine"), + quantity: 10, + }, + ], + refund: 100, + return_shipping: { + option_id: "opt_1234", + price: 12, + }, + }, + adminSession: { + jwt: { + userId: IdMap.getId("admin_user"), + }, + }, + } + ) + + expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: true, + return_id: expect.any(String) + }) + }) + }) }) diff --git a/packages/medusa/src/api/routes/admin/orders/request-return.js b/packages/medusa/src/api/routes/admin/orders/request-return.js index 3c0b49ed9f..1d3e0c0da0 100644 --- a/packages/medusa/src/api/routes/admin/orders/request-return.js +++ b/packages/medusa/src/api/routes/admin/orders/request-return.js @@ -43,6 +43,9 @@ import { defaultRelations, defaultFields } from "./" * receive_now: * description: A flag to indicate if the Return should be registerd as received immediately. * type: boolean + * no_notification: + * description: A flag to indicate if no notifications should be emitted related to the requested Return. + * type: boolean * refund: * description: The amount to refund. * type: integer @@ -79,6 +82,7 @@ export default async (req, res) => { }) .optional(), receive_now: Validator.boolean().default(false), + no_notification: Validator.boolean().optional(), refund: Validator.number() .integer() .optional(), @@ -141,6 +145,13 @@ export default async (req, res) => { } } + let order = await orderService + .withTransaction(manager) + .retrieve(id) + + const evaluatedNoNotification = value.no_notification !== undefined ? value.no_notification : order.no_notification + returnObj.no_notification = evaluatedNoNotification + const createdReturn = await returnService .withTransaction(manager) .create(returnObj) @@ -150,12 +161,13 @@ export default async (req, res) => { .withTransaction(manager) .fulfill(createdReturn.id) } - + await eventBus .withTransaction(manager) .emit("order.return_requested", { id, return_id: createdReturn.id, + no_notification: evaluatedNoNotification }) return { diff --git a/packages/medusa/src/services/__mocks__/order.js b/packages/medusa/src/services/__mocks__/order.js index bd8d0d6c05..5779f64e3b 100644 --- a/packages/medusa/src/services/__mocks__/order.js +++ b/packages/medusa/src/services/__mocks__/order.js @@ -47,6 +47,7 @@ export const orders = { providerid: "default_provider", data: {}, }, + no_notification: true, shipping_method: [ { providerid: "default_provider", @@ -99,6 +100,7 @@ export const orders = { payment_method: { providerid: "default_provider", }, + no_notification: false, shipping_methods: [ { id: IdMap.getId("expensiveShipping"), diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 6e9755094a..2536f014e7 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1129,5 +1129,21 @@ describe("OrderService", () => { ) ).rejects.toThrow("Cannot refund more than the original order amount") }) + + it("emits correct no_notification option", async () => { + await orderService.createRefund( + IdMap.getId("order_123"), + 100, + "discount", + "note", + false + ) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: false, + refund_id: expect.any(String) + } ) + }) }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 695583da6a..99d50f750d 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -57,6 +57,7 @@ const testOrder = generateOrder( currency_code: "dkk", region_id: IdMap.getId("region"), tax_rate: 0, + no_notification: true, shipping_address: { first_name: "test", last_name: "testson", @@ -327,6 +328,7 @@ describe("SwapService", () => { order_id: IdMap.getId("test"), fulfillment_status: "not_fulfilled", payment_status: "not_paid", + no_notification: true, additional_items: [ { unit_price: 100, @@ -342,8 +344,7 @@ describe("SwapService", () => { it.each([ [true, true], [false, false], - [undefined, undefined] - ])( "passes correct notification to eventBus with %s", async (input, expected) => { + ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { await swapService.create( testOrder, @@ -357,11 +358,28 @@ describe("SwapService", () => { ) expect(eventBusService.emit).toHaveBeenCalledWith( - expect.anything(), + expect.any(String), {"id": undefined, "no_notification": expected}) }) + + it("passes inherited value of order when no no_notification value is given ", async () => { + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + } + ) + + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.anything(), + {"id": undefined, "no_notification": true}) + }) + + }) }) - }) describe("receiveReturn", () => { beforeEach(() => { diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 18ed345134..80b5858331 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -235,7 +235,7 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = noNotification ? noNotification : order.no_notification + const evaluatedNoNotification = no_notification ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, @@ -293,7 +293,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -437,7 +437,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -482,7 +482,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result @@ -533,7 +533,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, - no_notification: claim.no_notification + no_notification: result.no_notification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 5fe6fea0ac..9f4f117f99 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1112,7 +1112,7 @@ class OrderService extends BaseService { /** * Refunds a given amount back to the customer. */ - async createRefund(orderId, refundAmount, reason, note) { + async createRefund(orderId, refundAmount, reason, note, noNotification) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { select: ["refundable_amount", "total", "refunded_total", "no_notification"], @@ -1131,10 +1131,13 @@ class OrderService extends BaseService { .refundPayment(order.payments, refundAmount, reason, note) const result = await this.retrieve(orderId) + + const evaluatedNoNotification = noNotification != undefined ? noNotification : order.no_notification + this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, - no_notification: order.no_notification + no_notification: evaluatedNoNotification }) return result }) diff --git a/packages/medusa/src/services/return.js b/packages/medusa/src/services/return.js index c3399d8718..c7ae661064 100644 --- a/packages/medusa/src/services/return.js +++ b/packages/medusa/src/services/return.js @@ -330,6 +330,7 @@ class ReturnService extends BaseService { reason_id: i.reason_id, note: i.note, metadata: i.metadata, + no_notification: data.no_notification, }) ) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 07d017ee06..5eb222ec82 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -238,7 +238,7 @@ class SwapService extends BaseService { }) ) - const evaluatedNoNotification = noNotification ? noNotification : order.noNotification + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ From bd6d0c61307cb2ebb678ad5c382fa997d1e6adbf Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 10 Jun 2021 11:33:31 +0200 Subject: [PATCH 27/55] added tests to remaining components --- .../api/routes/admin/orders/create-order.js | 1 + .../api/routes/admin/orders/refund-payment.js | 6 +++++- .../api/routes/admin/orders/update-order.js | 3 ++- .../medusa/src/services/__tests__/claim.js | 21 +++++++++++++++++++ .../medusa/src/services/__tests__/order.js | 10 ++++++--- .../medusa/src/services/__tests__/swap.js | 18 +--------------- packages/medusa/src/services/claim.js | 2 +- packages/medusa/src/services/order.js | 2 +- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/create-order.js b/packages/medusa/src/api/routes/admin/orders/create-order.js index e6ff1b36df..5adce02ad8 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-order.js +++ b/packages/medusa/src/api/routes/admin/orders/create-order.js @@ -27,6 +27,7 @@ export default async (req, res) => { items: Validator.array().optional(), }) .required(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index c4629e0987..0bb0ccc616 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -25,6 +25,9 @@ import { defaultRelations, defaultFields } from "./" * note: * description: A not with additional details about the Refund. * type: string + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * tags: * - Order * responses: @@ -47,6 +50,7 @@ export default async (req, res) => { note: Validator.string() .allow("") .optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -57,7 +61,7 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createRefund(id, value.amount, value.reason, value.note) + await orderService.createRefund(id, value.amount, value.reason, value.note, value.no_notification) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/update-order.js b/packages/medusa/src/api/routes/admin/orders/update-order.js index ba1ed0bf8c..582b1b9a81 100644 --- a/packages/medusa/src/api/routes/admin/orders/update-order.js +++ b/packages/medusa/src/api/routes/admin/orders/update-order.js @@ -22,7 +22,8 @@ export default async (req, res) => { price: Validator.number(), data: Validator.object(), items: Validator.array(), - }) + }), + no_notification: Validator.boolean(), }) const { value, error } = schema.validate(req.body) diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index cedc534746..ceebac20ed 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -22,6 +22,7 @@ describe("ClaimService", () => { order: { id: "1234", region_id: "order_region", + no_notification: true, items: [ { id: "itm_1", @@ -138,6 +139,7 @@ describe("ClaimService", () => { expect(claimRepo.create).toHaveBeenCalledTimes(1) expect(claimRepo.create).toHaveBeenCalledWith({ payment_status: "not_refunded", + no_notification: true, refund_amount: 1000, type: "refund", order_id: "1234", @@ -156,6 +158,7 @@ describe("ClaimService", () => { expect(eventBusService.emit).toHaveBeenCalledTimes(1) expect(eventBusService.emit).toHaveBeenCalledWith("claim.created", { id: "claim_134", + no_notification: true, }) }) @@ -208,6 +211,24 @@ describe("ClaimService", () => { }) ).rejects.toThrow(`Claims must have at least one claim item.`) }) + + it.each( + [ + [false, false], + [undefined, true] + ], + "passes correct no_notification status to event bus", async (input, expected) => { + await claimService.create({ + ...testClaim, + no_notification: input, + }) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: expected + }) + + }) }) describe("retrieve", () => { diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 2536f014e7..a9526a8245 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1081,6 +1081,7 @@ describe("OrderService", () => { paid_total: 100, refundable_amount: 100, refunded_total: 0, + no_notification: true, }) }, }) @@ -1130,18 +1131,21 @@ describe("OrderService", () => { ).rejects.toThrow("Cannot refund more than the original order amount") }) - it("emits correct no_notification option", async () => { + it.each([ + [false, false], + [undefined, true], + ],"emits correct no_notification option", async (input, expected) => { await orderService.createRefund( IdMap.getId("order_123"), 100, "discount", "note", - false + input ) expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ id: expect.any(String), - no_notification: false, + no_notification: expected, refund_id: expect.any(String) } ) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 99d50f750d..4adb462748 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -344,6 +344,7 @@ describe("SwapService", () => { it.each([ [true, true], [false, false], + [undefined, true], ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { await swapService.create( @@ -361,23 +362,6 @@ describe("SwapService", () => { expect.any(String), {"id": undefined, "no_notification": expected}) }) - - it("passes inherited value of order when no no_notification value is given ", async () => { - await swapService.create( - testOrder, - [{ item_id: IdMap.getId("line"), quantity: 1 }], - [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], - { - id: IdMap.getId("return-shipping"), - price: 20, - } - ) - - expect(eventBusService.emit).toHaveBeenCalledWith( - expect.anything(), - {"id": undefined, "no_notification": true}) - }) - }) }) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 80b5858331..7b13d6c561 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -235,7 +235,7 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = no_notification ? no_notification : order.no_notification + const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 9f4f117f99..b834bb634f 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1132,7 +1132,7 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) - const evaluatedNoNotification = noNotification != undefined ? noNotification : order.no_notification + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, From 6a0da1a423a8db74ebbe0c8563328ae6b4208d1f Mon Sep 17 00:00:00 2001 From: --list Date: Tue, 15 Jun 2021 10:33:53 +0200 Subject: [PATCH 28/55] corrected tests and added null checks --- .../src/api/routes/admin/orders/request-return.js | 2 +- packages/medusa/src/services/__tests__/claim.js | 8 ++++---- packages/medusa/src/services/__tests__/order.js | 3 ++- packages/medusa/src/services/__tests__/swap.js | 3 ++- packages/medusa/src/services/claim.js | 10 ++++++++-- packages/medusa/src/services/notification.js | 1 + packages/medusa/src/services/order.js | 7 ++++--- packages/medusa/src/services/swap.js | 6 +++++- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/request-return.js b/packages/medusa/src/api/routes/admin/orders/request-return.js index 1d3e0c0da0..d9038668f0 100644 --- a/packages/medusa/src/api/routes/admin/orders/request-return.js +++ b/packages/medusa/src/api/routes/admin/orders/request-return.js @@ -149,7 +149,7 @@ export default async (req, res) => { .withTransaction(manager) .retrieve(id) - const evaluatedNoNotification = value.no_notification !== undefined ? value.no_notification : order.no_notification + const evaluatedNoNotification = value.no_notification !== undefined && value.no_notification !== null ? value.no_notification : order.no_notification returnObj.no_notification = evaluatedNoNotification const createdReturn = await returnService diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index ceebac20ed..648b3ecb3b 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -215,9 +215,10 @@ describe("ClaimService", () => { it.each( [ [false, false], - [undefined, true] - ], - "passes correct no_notification status to event bus", async (input, expected) => { + [undefined, true], + [null, true], + ]) + ("passes correct no_notification status to event bus, with '%s'", async (input, expected) => { await claimService.create({ ...testClaim, no_notification: input, @@ -227,7 +228,6 @@ describe("ClaimService", () => { id: expect.any(String), no_notification: expected }) - }) }) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index a9526a8245..a028318954 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1134,7 +1134,8 @@ describe("OrderService", () => { it.each([ [false, false], [undefined, true], - ],"emits correct no_notification option", async (input, expected) => { + [null, true], + ])("emits correct no_notification option with '%s'", async (input, expected) => { await orderService.createRefund( IdMap.getId("order_123"), 100, diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 4adb462748..3752bb2e64 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -345,7 +345,8 @@ describe("SwapService", () => { [true, true], [false, false], [undefined, true], - ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { + [null, true], + ])( "passes correct no_notification to eventBus with '%s'", async (input, expected) => { await swapService.create( testOrder, diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 7b13d6c561..88d119ac5e 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -101,7 +101,7 @@ class ClaimService extends BaseService { const claimRepo = manager.getCustomRepository(this.claimRepository_) const claim = await this.retrieve(id, { relations: ["shipping_methods"] }) - const { claim_items, shipping_methods, metadata } = data + const { claim_items, shipping_methods, metadata, no_notification } = data if (metadata) { claim.metadata = this.setMetadata_(claim, metadata) @@ -135,6 +135,11 @@ class ClaimService extends BaseService { } } + if(no_notification !== undefined || no_notification !== null){ + claim.no_notification = no_notification + await claimRepo.save(claim) + } + if (claim_items) { for (const i of claim_items) { if (i.id) { @@ -145,6 +150,7 @@ class ClaimService extends BaseService { } } + await this.eventBus_ .withTransaction(manager) .emit(ClaimService.Events.UPDATED, { @@ -235,7 +241,7 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification + const evaluatedNoNotification = no_notification !== undefined && no_notification !== null ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index e0165ef952..982f172e7b 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -164,6 +164,7 @@ class NotificationService extends BaseService { if (!subs) { return } + if(data['no_notification'] === true) { return } diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index b834bb634f..3b2192abc1 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -308,9 +308,12 @@ class OrderService extends BaseService { * @return {Promise} the order document */ async retrieve(orderId, config = {}) { + + const orderRepo = this.manager_.getCustomRepository(this.orderRepository_) const validatedId = this.validateId_(orderId) + const { select, relations, totalsToSelect } = this.transformQueryForTotals_( config ) @@ -330,7 +333,6 @@ class OrderService extends BaseService { const rels = query.relations delete query.relations const raw = await orderRepo.findOneWithRelations(rels, query) - if (!raw) { throw new MedusaError( MedusaError.Types.NOT_FOUND, @@ -983,7 +985,6 @@ class OrderService extends BaseService { "tax_total", "gift_card_total", "total", - "no_notification" ], relations: [ "discounts", @@ -1132,7 +1133,7 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = noNotification !== undefined && noNotification !== null ? noNotification : order.no_notification this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 5eb222ec82..8a33421d9f 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -238,7 +238,7 @@ class SwapService extends BaseService { }) ) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = noNotification !== undefined && noNotification !== null ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ @@ -363,6 +363,10 @@ class SwapService extends BaseService { swap.metadata = this.setMetadata_(swap, update.metadata) } + if("no_notification" in update){ + swap.no_notification = update.no_notification + } + if ("shipping_address" in update) { await this.updateShippingAddress_(swap, update.shipping_address) } From 24a8b242b21b6d033ab5db2f1ab98ba3943756e7 Mon Sep 17 00:00:00 2001 From: --list Date: Tue, 15 Jun 2021 17:29:42 +0200 Subject: [PATCH 29/55] added draft-cart no_notification element to allow passing this to orders as admin --- .../src/services/manual-fulfillment.js | 5 +++++ .../src/api/routes/admin/draft-orders/create-draft-order.js | 4 ++++ .../src/api/routes/admin/draft-orders/update-draft-order.js | 6 ++++++ .../medusa/src/migrations/1623231564533-no_notification.ts | 3 +++ packages/medusa/src/models/cart.ts | 2 +- packages/medusa/src/models/draft-order.ts | 5 +++++ packages/medusa/src/services/__tests__/draft-order.js | 1 + packages/medusa/src/services/draft-order.js | 5 +++-- packages/medusa/src/services/order.js | 4 +++- 9 files changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js index 389dca5127..f5e6817fa5 100644 --- a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js +++ b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js @@ -31,6 +31,11 @@ class ManualFulfillmentService extends FulfillmentService { throw Error("Manual Fulfillment service cannot calculatePrice") } + createReturn() { + // No data is being sent anywhere + return Promise.resolve({}) + } + createOrder() { // No data is being sent anywhere return Promise.resolve({}) diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js index 3c0e358a9e..91c5e70197 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js @@ -59,6 +59,9 @@ import { defaultFields, defaultRelations } from "." * customer_id: * description: The id of the customer to add on the draft order * type: string + * no_notification_order: + * description: An optional flag passed to the resulting order to determine use of notifications. + * type: boolean * shipping_methods: * description: The shipping methods for the draft order * type: array @@ -119,6 +122,7 @@ export default async (req, res) => { }) .optional(), customer_id: Validator.string().optional(), + no_notification_order: Validator.boolean().optional(), shipping_methods: Validator.array() .items({ option_id: Validator.string().required(), diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js index 6230f553d5..9a84fa5a25 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js @@ -35,6 +35,9 @@ import { defaultCartFields, defaultCartRelations, defaultFields } from "." * code: * description: "The code that a Discount is identifed by." * type: string + * no_notification_order: + * description: "An optional flag passed to the resulting order to determine use of notifications."" + * type: boolean * customer_id: * description: "The id of the Customer to associate the Draft Order with." * type: string @@ -68,6 +71,7 @@ export default async (req, res) => { }) .optional(), customer_id: Validator.string().optional(), + no_notification_order: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -88,6 +92,8 @@ export default async (req, res) => { ) } + await draftOrderService.update(draftOrder.id, value) + await cartService.update(draftOrder.cart_id, value) draftOrder.cart = await cartService.retrieve(draftOrder.cart_id, { diff --git a/packages/medusa/src/migrations/1623231564533-no_notification.ts b/packages/medusa/src/migrations/1623231564533-no_notification.ts index 2b3cac3d30..20e3f9a9a2 100644 --- a/packages/medusa/src/migrations/1623231564533-no_notification.ts +++ b/packages/medusa/src/migrations/1623231564533-no_notification.ts @@ -8,13 +8,16 @@ export class noNotification1623231564533 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean`); + await queryRunner.query(`ALTER TABLE "draft_order" ADD "no_notification_order" boolean`); } public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "draft_order" DROP COLUMN "no_notification_order"`); await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); + } } diff --git a/packages/medusa/src/models/cart.ts b/packages/medusa/src/models/cart.ts index dbb5f53b53..3190685171 100644 --- a/packages/medusa/src/models/cart.ts +++ b/packages/medusa/src/models/cart.ts @@ -246,7 +246,7 @@ export class Cart { @Column({ type: "jsonb", nullable: true }) context: any - + // Total fields shipping_total: number discount_total: number diff --git a/packages/medusa/src/models/draft-order.ts b/packages/medusa/src/models/draft-order.ts index 7430e6ee07..7c49919069 100644 --- a/packages/medusa/src/models/draft-order.ts +++ b/packages/medusa/src/models/draft-order.ts @@ -61,6 +61,9 @@ export class DraftOrder { @Column({ type: "timestamptz", nullable: true }) completed_at: Date + @Column({ nullable: true}) + no_notification_order: boolean + @Column({ type: "jsonb", nullable: true }) metadata: any @@ -115,6 +118,8 @@ export class DraftOrder { * completed_at: * type: string * format: date-time + * no_notification_order: + * type: boolean * metadata: * type: object * idempotency_key: diff --git a/packages/medusa/src/services/__tests__/draft-order.js b/packages/medusa/src/services/__tests__/draft-order.js index ab5460f553..22ebe4cc95 100644 --- a/packages/medusa/src/services/__tests__/draft-order.js +++ b/packages/medusa/src/services/__tests__/draft-order.js @@ -205,4 +205,5 @@ describe("DraftOrderService", () => { } }) }) + }) diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index e04f3ad794..41d83c9adb 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -248,7 +248,8 @@ class DraftOrderService extends BaseService { ) } - const { items, shipping_methods, discounts, ...rest } = data + const { items, shipping_methods, discounts, no_notification_order=undefined, ...rest } = data + if (discounts) { for (const { code } of discounts) { @@ -263,7 +264,7 @@ class DraftOrderService extends BaseService { .withTransaction(manager) .create({ type: "draft_order", ...rest }) - const draftOrder = draftOrderRepo.create({ cart_id: createdCart.id }) + const draftOrder = draftOrderRepo.create({ cart_id: createdCart.id, no_notification_order}) const result = await draftOrderRepo.save(draftOrder) await this.eventBus_ diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 3b2192abc1..1fedacfa89 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -507,6 +507,7 @@ class OrderService extends BaseService { .retrieveByCartId(cart.id) toCreate.draft_order_id = draft.id + toCreate.no_notification = draft.no_notification_order } const o = await orderRepo.create(toCreate) @@ -552,7 +553,8 @@ class OrderService extends BaseService { await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.PLACED, { - id: result.id + id: result.id, + no_notification: result.no_notification }) return result From 90e157a5ac76ffe4226ab281315e4c67b74cd1fb Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 08:39:03 +0200 Subject: [PATCH 30/55] removed conflict --- packages/medusa/src/services/order.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index b0d765324c..b946de5848 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1136,11 +1136,7 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) -<<<<<<< HEAD - const evaluatedNoNotification = noNotification !== undefined && noNotification !== null ? noNotification : order.no_notification -======= const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, From 0f2fe26b0e72ecd040eedd3defe702e76bd44e76 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 08:51:57 +0200 Subject: [PATCH 31/55] properly removed all merge conflicts --- .../src/api/routes/admin/orders/request-return.js | 4 ---- .../src/migrations/1623231564533-no_notification.ts | 9 --------- packages/medusa/src/services/__tests__/claim.js | 11 ----------- packages/medusa/src/services/__tests__/order.js | 5 ----- packages/medusa/src/services/__tests__/swap.js | 5 ----- packages/medusa/src/services/claim.js | 4 ---- packages/medusa/src/services/swap.js | 4 ---- 7 files changed, 42 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/request-return.js b/packages/medusa/src/api/routes/admin/orders/request-return.js index b1c406881a..1d3e0c0da0 100644 --- a/packages/medusa/src/api/routes/admin/orders/request-return.js +++ b/packages/medusa/src/api/routes/admin/orders/request-return.js @@ -149,11 +149,7 @@ export default async (req, res) => { .withTransaction(manager) .retrieve(id) -<<<<<<< HEAD - const evaluatedNoNotification = value.no_notification !== undefined && value.no_notification !== null ? value.no_notification : order.no_notification -======= const evaluatedNoNotification = value.no_notification !== undefined ? value.no_notification : order.no_notification ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 returnObj.no_notification = evaluatedNoNotification const createdReturn = await returnService diff --git a/packages/medusa/src/migrations/1623231564533-no_notification.ts b/packages/medusa/src/migrations/1623231564533-no_notification.ts index 8720f89bfc..20e3f9a9a2 100644 --- a/packages/medusa/src/migrations/1623231564533-no_notification.ts +++ b/packages/medusa/src/migrations/1623231564533-no_notification.ts @@ -8,25 +8,16 @@ export class noNotification1623231564533 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "claim_order" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean`); -<<<<<<< HEAD await queryRunner.query(`ALTER TABLE "draft_order" ADD "no_notification_order" boolean`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "draft_order" DROP COLUMN "no_notification_order"`); -======= - } - - public async down(queryRunner: QueryRunner): Promise { ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "claim_order" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "return" DROP COLUMN "no_notification"`); -<<<<<<< HEAD -======= ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 } } diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index 63c742540b..00cc35fe7e 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -215,16 +215,9 @@ describe("ClaimService", () => { it.each( [ [false, false], -<<<<<<< HEAD - [undefined, true], - [null, true], - ]) - ("passes correct no_notification status to event bus, with '%s'", async (input, expected) => { -======= [undefined, true] ], "passes correct no_notification status to event bus", async (input, expected) => { ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 await claimService.create({ ...testClaim, no_notification: input, @@ -234,10 +227,6 @@ describe("ClaimService", () => { id: expect.any(String), no_notification: expected }) -<<<<<<< HEAD -======= - ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 }) }) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 33f41d94b4..a64b18a688 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1134,12 +1134,7 @@ describe("OrderService", () => { it.each([ [false, false], [undefined, true], -<<<<<<< HEAD - [null, true], ])("emits correct no_notification option with '%s'", async (input, expected) => { -======= - ],"emits correct no_notification option", async (input, expected) => { ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 await orderService.createRefund( IdMap.getId("order_123"), 100, diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 3e6c6264b0..4adb462748 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -345,12 +345,7 @@ describe("SwapService", () => { [true, true], [false, false], [undefined, true], -<<<<<<< HEAD - [null, true], - ])( "passes correct no_notification to eventBus with '%s'", async (input, expected) => { -======= ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 await swapService.create( testOrder, diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 7387136ef1..469ef9543c 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -241,11 +241,7 @@ class ClaimService extends BaseService { ) ) -<<<<<<< HEAD - const evaluatedNoNotification = no_notification !== undefined && no_notification !== null ? no_notification : order.no_notification -======= const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 const created = claimRepo.create({ shipping_address_id: addressId, diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 47ee78822c..3d213d4299 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -238,11 +238,7 @@ class SwapService extends BaseService { }) ) -<<<<<<< HEAD - const evaluatedNoNotification = noNotification !== undefined && noNotification !== null ? noNotification : order.no_notification -======= const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification ->>>>>>> 04fe5292f7e9dcd14cb1a4ea17db8978f9b52c03 const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ From 7ce8001906dc4bb4e7d1264b5e5620ab707a7618 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 09:35:29 +0200 Subject: [PATCH 32/55] removed changes not to core --- .../src/services/manual-fulfillment.js | 5 --- packages/medusa/src/services/claim.js | 2 +- packages/medusa/src/services/draft-order.js | 31 +++++++++++++++++++ packages/medusa/src/services/order.js | 4 +++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js index f5e6817fa5..389dca5127 100644 --- a/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js +++ b/packages/medusa-fulfillment-manual/src/services/manual-fulfillment.js @@ -31,11 +31,6 @@ class ManualFulfillmentService extends FulfillmentService { throw Error("Manual Fulfillment service cannot calculatePrice") } - createReturn() { - // No data is being sent anywhere - return Promise.resolve({}) - } - createOrder() { // No data is being sent anywhere return Promise.resolve({}) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 469ef9543c..d49d3558d6 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -135,7 +135,7 @@ class ClaimService extends BaseService { } } - if(no_notification !== undefined || no_notification !== null){ + if(no_notification !== undefined){ claim.no_notification = no_notification await claimRepo.save(claim) } diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index 41d83c9adb..94b59ca33f 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -10,6 +10,7 @@ import { Brackets } from "typeorm" class DraftOrderService extends BaseService { static Events = { CREATED: "draft_order.created", + UPDATED: "draft_order.updated", } constructor({ @@ -336,6 +337,36 @@ class DraftOrderService extends BaseService { await draftOrderRepo.save(draftOrder) }) } + /** + * + * @param {String} doId + * @param {} data + * @returns + */ + async update(doId, data){ + return this.atomicPhase_(async manager => { + const doRepo = manager.getCustomRepository(this.draftOrderRepository_) + const draftOrder = await this.retrieve(doId) + let touched = false + + if(data.no_notification_order !== undefined){ + touched = true + draftOrder.no_notification_order = data.no_notification_order + } + + if(touched){ + doRepo.save(draftOrder) + + await this.eventBus_ + .withTransaction(manager) + .emit(DraftOrderService.Events.UPDATED, { + id: draftOrder.id + }) + } + + return draftOrder + }) + } } export default DraftOrderService diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index b946de5848..90aca0542e 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -805,6 +805,10 @@ class OrderService extends BaseService { await this.updateBillingAddress_(order, update.billing_address) } + if("no_notification" in update){ + order.no_notification = update.no_notification + } + if ("items" in update) { for (const item of update.items) { await this.lineItemService_.withTransaction(manager).create({ From 0223b89a733eda655643a022ccb1166a0bab6b41 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 10:11:32 +0200 Subject: [PATCH 33/55] removed wrong select --- packages/medusa/src/services/draft-order.js | 32 ++++++++++----------- packages/medusa/src/services/order.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index 94b59ca33f..bb60c9197f 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -345,26 +345,26 @@ class DraftOrderService extends BaseService { */ async update(doId, data){ return this.atomicPhase_(async manager => { - const doRepo = manager.getCustomRepository(this.draftOrderRepository_) - const draftOrder = await this.retrieve(doId) - let touched = false + // const doRepo = manager.getCustomRepository(this.draftOrderRepository_) + // const draftOrder = await this.retrieve(doId) + // let touched = false - if(data.no_notification_order !== undefined){ - touched = true - draftOrder.no_notification_order = data.no_notification_order - } + // if(data.no_notification_order !== undefined){ + // touched = true + // draftOrder.no_notification_order = data.no_notification_order + // } - if(touched){ - doRepo.save(draftOrder) + // if(touched){ + // doRepo.save(draftOrder) - await this.eventBus_ - .withTransaction(manager) - .emit(DraftOrderService.Events.UPDATED, { - id: draftOrder.id - }) - } + // await this.eventBus_ + // .withTransaction(manager) + // .emit(DraftOrderService.Events.UPDATED, { + // id: draftOrder.id + // }) + // } - return draftOrder + // return draftOrder }) } } diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 90aca0542e..a5cd27680a 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -508,6 +508,7 @@ class OrderService extends BaseService { toCreate.draft_order_id = draft.id toCreate.no_notification = draft.no_notification_order + } const o = await orderRepo.create(toCreate) @@ -991,7 +992,6 @@ class OrderService extends BaseService { "tax_total", "gift_card_total", "total", - "no_notification" ], relations: [ "discounts", From cc430e3f4dc7caa55bc0a7a92169ddce182a1a19 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 10:40:16 +0200 Subject: [PATCH 34/55] reintroduced update for draft order --- .../src/services/__tests__/draft-order.js | 5 +++ packages/medusa/src/services/draft-order.js | 40 +++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/packages/medusa/src/services/__tests__/draft-order.js b/packages/medusa/src/services/__tests__/draft-order.js index 22ebe4cc95..f151650d73 100644 --- a/packages/medusa/src/services/__tests__/draft-order.js +++ b/packages/medusa/src/services/__tests__/draft-order.js @@ -206,4 +206,9 @@ describe("DraftOrderService", () => { }) }) + describe("update", () => { + + fail('implement tests for update'); + }) + }) diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index bb60c9197f..dd1ac31a6f 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -338,33 +338,33 @@ class DraftOrderService extends BaseService { }) } /** - * - * @param {String} doId - * @param {} data - * @returns + * Updates a draft order with the given data + * @param {String} doId - id of the draft order + * @param {DraftOrder} data - values to update the order with + * @returns {Promise} the updated draft order */ async update(doId, data){ return this.atomicPhase_(async manager => { - // const doRepo = manager.getCustomRepository(this.draftOrderRepository_) - // const draftOrder = await this.retrieve(doId) - // let touched = false + const doRepo = manager.getCustomRepository(this.draftOrderRepository_) + const draftOrder = await this.retrieve(doId) + let touched = false - // if(data.no_notification_order !== undefined){ - // touched = true - // draftOrder.no_notification_order = data.no_notification_order - // } + if(data.no_notification_order !== undefined){ + touched = true + draftOrder.no_notification_order = data.no_notification_order + } - // if(touched){ - // doRepo.save(draftOrder) + if(touched){ + doRepo.save(draftOrder) - // await this.eventBus_ - // .withTransaction(manager) - // .emit(DraftOrderService.Events.UPDATED, { - // id: draftOrder.id - // }) - // } + await this.eventBus_ + .withTransaction(manager) + .emit(DraftOrderService.Events.UPDATED, { + id: draftOrder.id + }) + } - // return draftOrder + return draftOrder }) } } From 8cd4e2e818e3d06f9ff173d7f4234a1f512c2874 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 17 Jun 2021 16:55:05 +0200 Subject: [PATCH 35/55] added expect-relations helper and used it to test get-cart --- integration-tests/api/__tests__/store/cart.js | 54 +++++++++++++++++++ .../api/helpers/expect-relations.js | 20 +++++++ .../api/helpers/product-seeder.js | 10 +++- integration-tests/helpers/use-db.js | 5 +- .../api/routes/admin/draft-orders/index.js | 2 + .../src/api/routes/store/carts/index.js | 4 +- .../src/api/routes/store/orders/index.js | 1 + packages/medusa/src/models/line-item.ts | 2 +- packages/medusa/src/models/product-variant.ts | 3 ++ 9 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 integration-tests/api/helpers/expect-relations.js diff --git a/integration-tests/api/__tests__/store/cart.js b/integration-tests/api/__tests__/store/cart.js index 9b5ceeb22b..71c036b72d 100644 --- a/integration-tests/api/__tests__/store/cart.js +++ b/integration-tests/api/__tests__/store/cart.js @@ -5,8 +5,10 @@ const { Region } = require("@medusajs/medusa"); const setupServer = require("../../../helpers/setup-server"); const { useApi } = require("../../../helpers/use-api"); const { initDb } = require("../../../helpers/use-db"); +const { expectRelations } = require("../../helpers/expect-relations"); const cartSeeder = require("../../helpers/cart-seeder"); +const productSeeder = require("../../helpers/product-seeder"); jest.setTimeout(30000); @@ -330,4 +332,56 @@ describe("/store/carts", () => { expect(response.status).toEqual(200); }); }); + + describe("get-cart returns expected relations", () => { + beforeEach(async () => { + try { + await productSeeder(dbConnection); + await cartSeeder(dbConnection); + } catch (err) { + console.log(err); + throw err; + } + }); + + afterEach(async () => { + const manager = dbConnection.manager; + await doAfterEach(manager); + }); + + + it("returns default relations", async () => { + const api = useApi(); + + const expectedRelations = [ + "gift_cards", + "region", + "items.variant.prices", + "payment", + "shipping_address", + "billing_address", + "region.countries", + "region.payment_providers", + "payment_sessions", + "shipping_methods.shipping_option", + "discounts", + ] + + await api.post("/store/carts/test-cart/line-items", { + quantity: 1, + variant_id: "test-variant", + }) + + // await api.post("/store/carts/test-cart/shipping-methods", { + // option_id: "test-option" + // }) + + + const response = await api.get("/store/carts/test-cart") + + console.log(response.data.cart) + expectRelations(expectedRelations, response.data.cart) + + }); + }); }); diff --git a/integration-tests/api/helpers/expect-relations.js b/integration-tests/api/helpers/expect-relations.js new file mode 100644 index 0000000000..6d9a8850dc --- /dev/null +++ b/integration-tests/api/helpers/expect-relations.js @@ -0,0 +1,20 @@ +const { expect } = require("@jest/globals") + +export function expectRelations(expected, actual){ + expected.forEach(a => expectRelations_(a, actual)) +} + +function expectRelations_(expected, actual){ + const items = expected.split("."); + let data_ = actual; + + for(const i in items){ + data_ = data_[items[i]]; + + if(data_ instanceof Array && data_.length > 0) { + data_ = data_[0]; + } + + expect(data_).toBeDefined(); + } +} diff --git a/integration-tests/api/helpers/product-seeder.js b/integration-tests/api/helpers/product-seeder.js index 79e6f4eb97..e2cfda35a2 100644 --- a/integration-tests/api/helpers/product-seeder.js +++ b/integration-tests/api/helpers/product-seeder.js @@ -6,6 +6,7 @@ const { Product, ShippingProfile, ProductVariant, + MoneyAmount, Image, } = require("@medusajs/medusa"); @@ -74,7 +75,14 @@ module.exports = async (connection, data = {}) => { inventory_quantity: 10, title: "Test variant", product_id: "test-product", - prices: [{ id: "test-price", currency_code: "usd", amount: 100 }], + prices: [], options: [{ id: "test-variant-option", value: "Default variant" }], }); + + await manager.insert(MoneyAmount, { + variant_id: "test-variant", + id: "test-price", + currency_code: "usd", + amount: 100, + }); }; diff --git a/integration-tests/helpers/use-db.js b/integration-tests/helpers/use-db.js index c9be67e7ae..74e420ec24 100644 --- a/integration-tests/helpers/use-db.js +++ b/integration-tests/helpers/use-db.js @@ -36,8 +36,10 @@ module.exports = { ); const databaseName = "medusa-integration"; - await createDatabase({ databaseName }); + await createDatabase({ databaseName }); + + const connection = await createConnection({ type: "postgres", url: "postgres://localhost/medusa-integration", @@ -66,6 +68,7 @@ module.exports = { instance.setDb(dbConnection); return dbConnection; + }, useDb: function () { return instance; diff --git a/packages/medusa/src/api/routes/admin/draft-orders/index.js b/packages/medusa/src/api/routes/admin/draft-orders/index.js index 10b9e65f30..4bdacfde84 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/index.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/index.js @@ -49,6 +49,8 @@ export const defaultRelations = ["order", "cart"] export const defaultCartRelations = [ "region", "items", + "items.variant", + "items.variant.prices", "payment", "shipping_address", "billing_address", diff --git a/packages/medusa/src/api/routes/store/carts/index.js b/packages/medusa/src/api/routes/store/carts/index.js index 0ec18e79fe..c87135e378 100644 --- a/packages/medusa/src/api/routes/store/carts/index.js +++ b/packages/medusa/src/api/routes/store/carts/index.js @@ -101,13 +101,15 @@ export const defaultRelations = [ "gift_cards", "region", "items", + "items.variant", + "items.variant.prices", "payment", "shipping_address", "billing_address", "region.countries", "region.payment_providers", - "shipping_methods", "payment_sessions", + "shipping_methods", "shipping_methods.shipping_option", "discounts", ] diff --git a/packages/medusa/src/api/routes/store/orders/index.js b/packages/medusa/src/api/routes/store/orders/index.js index 4405a86ba7..72e802c90e 100644 --- a/packages/medusa/src/api/routes/store/orders/index.js +++ b/packages/medusa/src/api/routes/store/orders/index.js @@ -33,6 +33,7 @@ export const defaultRelations = [ "items", "items.variant", "items.variant.product", + "items.variant.prices", "shipping_methods", "discounts", "customer", diff --git a/packages/medusa/src/models/line-item.ts b/packages/medusa/src/models/line-item.ts index 3060050646..e8d30aecff 100644 --- a/packages/medusa/src/models/line-item.ts +++ b/packages/medusa/src/models/line-item.ts @@ -99,7 +99,7 @@ export class LineItem { @Column({ nullable: true }) variant_id: string - @ManyToOne(() => ProductVariant, { eager: true }) + @ManyToOne(() => ProductVariant) @JoinColumn({ name: "variant_id" }) variant: ProductVariant diff --git a/packages/medusa/src/models/product-variant.ts b/packages/medusa/src/models/product-variant.ts index 7b97b6ea2a..0a3c569f9b 100644 --- a/packages/medusa/src/models/product-variant.ts +++ b/packages/medusa/src/models/product-variant.ts @@ -19,6 +19,9 @@ import { Product } from "./product" import { MoneyAmount } from "./money-amount" import { ProductOptionValue } from "./product-option-value" + + + @Entity() export class ProductVariant { @PrimaryColumn() From 7a071cc8178ecefd5ba77b04d663720fcb9e0a01 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 24 Jun 2021 16:12:09 +0200 Subject: [PATCH 36/55] added some more tests --- .../orders/__tests__/create-fulfillment.js | 3 + .../routes/admin/orders/create-fulfillment.js | 6 +- .../routes/admin/orders/create-shipment.js | 7 +- .../api/routes/admin/orders/refund-payment.js | 1 + .../routes/admin/returns/receive-return.js | 3 + .../src/services/__tests__/draft-order.js | 87 ++++++++++++++++++- .../medusa/src/services/__tests__/order.js | 46 ++++++++++ packages/medusa/src/services/draft-order.js | 7 ++ packages/medusa/src/services/order.js | 27 +++--- 9 files changed, 174 insertions(+), 13 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js index 971eb227e6..4a3f04c0ed 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js @@ -1,6 +1,7 @@ import { IdMap } from "medusa-test-utils" import { request } from "../../../../../helpers/test-request" import { OrderServiceMock } from "../../../../../services/__mocks__/order" +import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus" describe("POST /admin/orders/:id/fulfillment", () => { describe("successfully fulfills an order", () => { @@ -42,6 +43,7 @@ describe("POST /admin/orders/:id/fulfillment", () => { quantity: 1, }, ], + undefined, undefined ) }) @@ -51,5 +53,6 @@ describe("POST /admin/orders/:id/fulfillment", () => { expect(subject.body.order.id).toEqual(IdMap.getId("test-order")) expect(subject.body.order.fulfillment_status).toEqual("fulfilled") }) + }) }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js index f8ccab4ac1..4d3351a745 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js @@ -24,6 +24,9 @@ import { defaultRelations, defaultFields } from "./" * quantity: * description: The quantity of the Line Item to fulfill. * type: integer + * no_notification: + * description: If set to true no notification will be send related to this Swap. + * type: boolean * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object @@ -49,6 +52,7 @@ export default async (req, res) => { quantity: Validator.number().required(), }) .required(), + no_notification: Validator.boolean().optional(), metadata: Validator.object().optional(), }) @@ -60,7 +64,7 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createFulfillment(id, value.items, value.metadata) + await orderService.createFulfillment(id, value.items, value.no_notification, value.metadata) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/create-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-shipment.js index a371ef244f..9c6efdd2dc 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-shipment.js @@ -21,6 +21,9 @@ import { defaultRelations, defaultFields } from "./" * type: array * items: * type: string + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * tags: * - Order * responses: @@ -41,6 +44,7 @@ export default async (req, res) => { tracking_numbers: Validator.array() .items(Validator.string()) .optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -54,7 +58,8 @@ export default async (req, res) => { await orderService.createShipment( id, value.fulfillment_id, - value.tracking_numbers.map(n => ({ tracking_number: n })) + value.tracking_numbers.map(n => ({ tracking_number: n })), + value.no_notification, ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index 0bb0ccc616..2c253dea46 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -54,6 +54,7 @@ export default async (req, res) => { }) const { value, error } = schema.validate(req.body) + if (error) { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } diff --git a/packages/medusa/src/api/routes/admin/returns/receive-return.js b/packages/medusa/src/api/routes/admin/returns/receive-return.js index dce7cf18f4..404ee7d69d 100644 --- a/packages/medusa/src/api/routes/admin/returns/receive-return.js +++ b/packages/medusa/src/api/routes/admin/returns/receive-return.js @@ -54,10 +54,13 @@ export default async (req, res) => { }) const { value, error } = schema.validate(req.body) + if (error) { + console.log(error) throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } + try { const returnService = req.scope.resolve("returnService") const orderService = req.scope.resolve("orderService") diff --git a/packages/medusa/src/services/__tests__/draft-order.js b/packages/medusa/src/services/__tests__/draft-order.js index f151650d73..53c170d310 100644 --- a/packages/medusa/src/services/__tests__/draft-order.js +++ b/packages/medusa/src/services/__tests__/draft-order.js @@ -1,7 +1,9 @@ import _ from "lodash" import { IdMap, MockRepository, MockManager } from "medusa-test-utils" +import { EventBusServiceMock } from "../__mocks__/event-bus" import DraftOrderService from "../draft-order" + const eventBusService = { emit: jest.fn(), withTransaction: function() { @@ -207,8 +209,91 @@ describe("DraftOrderService", () => { }) describe("update", () => { + + const testOrder = { + region_id: "test-region", + shipping_address_id: "test-shipping", + billing_address_id: "test-billing", + customer_id: "test-customer", + items: [{ variant_id: "test-variant", quantity: 2, metadata: {} }], + shipping_methods: [ + { + option_id: "test-option", + data: {}, + }, + ], + } + + const completedOrder = { + status: "completed", + ...testOrder + } + + const draftOrderRepository = MockRepository({ + create: d => ({ + ...d, + }), + save: d => ({ + id: "test-draft-order", + ...d, + }), + findOne: (q) => { + switch (q.where.id) { + case "completed": + return Promise.resolve(completedOrder) + default: + return Promise.resolve(testOrder) + } + } + }) + + + const draftOrderService = new DraftOrderService({ + manager: MockManager, + regionService: undefined, + cartService: undefined, + shippingOptionService: undefined, + lineItemService: undefined, + productVariantService: undefined, + draftOrderRepository, + addressRepository: undefined, + eventBusService: EventBusServiceMock, + }) + + beforeEach(async () => { + jest.clearAllMocks() + }) - fail('implement tests for update'); + it("calls draftOrder model functions", async () => { + await draftOrderService.update("test-draft-order", { + no_notification_order: true, + }) + + expect(draftOrderRepository.save).toHaveBeenCalledTimes(1) + expect(draftOrderRepository.save).toHaveBeenCalledWith({ + no_notification_order: true, + billing_address_id: "test-billing", + customer_id: "test-customer", + items: [ { + metadata: {}, + quantity: 2, + variant_id: "test-variant" + }], + region_id: "test-region", + shipping_address_id: "test-shipping", + shipping_methods: [{ + data: {}, + option_id: "test-option" + }] + }) + }) + + it("fails to update draftOrder when already complete", async () => { + await expect( + draftOrderService.update("completed", {}) + ).rejects.toThrow("Can't update a draft order which is complete") + + }) }) }) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index a64b18a688..e2783d38e1 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1,5 +1,6 @@ import { IdMap, MockManager, MockRepository } from "medusa-test-utils" import OrderService from "../order" +import { EventBusServiceMock } from "../__mocks__/event-bus" describe("OrderService", () => { const totalsService = { @@ -711,6 +712,7 @@ describe("OrderService", () => { const order = { fulfillments: [], shipping_methods: [{ id: "ship" }], + no_notification: true, items: [ { id: "item_1", @@ -859,8 +861,32 @@ describe("OrderService", () => { fulfillment_status: "partially_fulfilled", }) }) + + it.each([ + [true, true], + [false, false], + [undefined, true], + ])("emits correct no_notification option with '%s'", async (input, expected) => { + await orderService.createFulfillment( + "test-order", + [ + { + item_id: "item_1", + quantity: 1, + }, + ], + input + ) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: expected, + }) + }) }) + + describe("registerReturnReceived", () => { const order = { items: [ @@ -975,6 +1001,7 @@ describe("OrderService", () => { fulfilled_quantity: 0, }, ], + no_notification: true, } const orderRepo = MockRepository({ @@ -1048,6 +1075,25 @@ describe("OrderService", () => { fulfillment_status: "shipped", }) }) + + it.each([ + [true, true], + [false, false], + [undefined, true], + ])("2emits correct no_notification option with '%s'", async (input, expected) => { + await orderService.createShipment( + IdMap.getId("test"), + IdMap.getId("fulfillment"), + [{ tracking_number: "1234" }, { tracking_number: "2345" }], + input, + {} + ) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ + id: expect.any(String), + no_notification: expected, + }) + }) }) describe("createRefund", () => { diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index dd1ac31a6f..2954d6ef39 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -348,6 +348,13 @@ class DraftOrderService extends BaseService { const doRepo = manager.getCustomRepository(this.draftOrderRepository_) const draftOrder = await this.retrieve(doId) let touched = false + + if(draftOrder.status === "completed"){ + throw new MedusaError( + MedusaError.Types.NOT_ALLOWED, + "Can't update a draft order which is complete" + ) + } if(data.no_notification_order !== undefined){ touched = true diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index a0fe677397..57637ad4ac 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -574,7 +574,7 @@ class OrderService extends BaseService { * the fulfillment * @return {order} the resulting order following the update. */ - async createShipment(orderId, fulfillmentId, trackingLinks, metadata = {}) { + async createShipment(orderId, fulfillmentId, trackingLinks, noNotification = undefined, metadata = {}) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { relations: ["items"] }) const shipment = await this.fulfillmentService_.retrieve(fulfillmentId) @@ -612,12 +612,14 @@ class OrderService extends BaseService { const orderRepo = manager.getCustomRepository(this.orderRepository_) const result = await orderRepo.save(order) + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.SHIPMENT_CREATED, { id: orderId, fulfillment_id: shipmentRes.id, - no_notification: order.no_notification + no_notification: evaluatedNoNotification }) return result @@ -909,7 +911,8 @@ class OrderService extends BaseService { .emit(OrderService.Events.PAYMENT_CAPTURE_FAILED, { id: orderId, payment_id: p.id, - error: err + error: err, + no_notification: order.no_notification }) }) @@ -982,7 +985,7 @@ class OrderService extends BaseService { * @param {string} orderId - id of order to cancel. * @return {Promise} result of the update operation. */ - async createFulfillment(orderId, itemsToFulfill, metadata = {}) { + async createFulfillment(orderId, itemsToFulfill, noNotification = undefined, metadata = {}) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { select: [ @@ -991,6 +994,8 @@ class OrderService extends BaseService { "discount_total", "tax_total", "gift_card_total", + "no_notification", + "id", "total", ], relations: [ @@ -1058,13 +1063,15 @@ class OrderService extends BaseService { order.fulfillments = [...order.fulfillments, ...fulfillments] const result = await orderRepo.save(order) + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + for (const fulfillment of fulfillments) { await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.FULFILLMENT_CREATED, { id: orderId, fulfillment_id: fulfillment.id, - no_notification: order.no_notification + no_notification: evaluatedNoNotification }) } @@ -1120,10 +1127,10 @@ class OrderService extends BaseService { /** * Refunds a given amount back to the customer. */ - async createRefund(orderId, refundAmount, reason, note, noNotification) { + async createRefund(orderId, refundAmount, reason, note, noNotification = undefined) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["refundable_amount", "total", "refunded_total", "no_notification"], + select: ["refundable_amount", "total", "refunded_total"], relations: ["payments"], }) @@ -1226,7 +1233,7 @@ class OrderService extends BaseService { async registerReturnReceived(orderId, receivedReturn, customRefundAmount) { return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { - select: ["total", "refunded_total", "refundable_amount", "no_notification"], + select: ["total", "refunded_total", "refundable_amount"], relations: ["items", "returns", "payments"], }) @@ -1249,7 +1256,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.RETURN_ACTION_REQUIRED, { id: result.id, return_id: receivedReturn.id, - no_notification: order.no_notification + no_notification: receivedReturn.no_notification }) return result } @@ -1281,7 +1288,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.ITEMS_RETURNED, { id: order.id, return_id: receivedReturn.id, - no_notification: order.no_notification + no_notification: receivedReturn.no_notification }) return result }) From c789e01fdda5b62379be7bc014816b1b1b9eb178 Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 24 Jun 2021 16:31:12 +0200 Subject: [PATCH 37/55] corrected indent and duplications --- docs/api/admin-spec3.yaml | 3156 +++++++++-------- docs/api/store-spec3.json | 1688 +++++---- docs/api/store-spec3.yaml | 1407 ++++---- .../admin/draft-orders/update-draft-order.js | 2 +- .../routes/admin/returns/receive-return.js | 1 - .../medusa/src/services/__tests__/swap.js | 2 - packages/medusa/src/services/notification.js | 4 - packages/medusa/src/services/order.js | 2 - 8 files changed, 3120 insertions(+), 3142 deletions(-) diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index 2301d0681f..f2e31cce28 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,148 +85,6 @@ paths: properties: user: $ref: '#/components/schemas/user' - /collections: - post: - operationId: PostCollections - summary: Create a Product Collection - description: Creates a Product Collection. - requestBody: - content: - application/json: - schema: - required: - - title - properties: - title: - type: string - description: The title to identify the Collection by. - handle: - type: string - description: >- - An optional handle to be used in slugs, if none is provided - we will kebab-case the title. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - get: - operationId: GetCollections - summary: List Product Collections - description: Retrieve a list of Product Collection. - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - '/collections/{id}': - delete: - operationId: DeleteCollectionsCollection - summary: Delete a Product Collection - description: Deletes a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Collection. - schema: - type: string - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Collection - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetCollectionsCollection - summary: Retrieve a Product Collection - description: Retrieves a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Product Collection - schema: - type: string - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' - post: - operationId: PostCollectionsCollection - summary: Update a Product Collection - description: Updates a Product Collection. - parameters: - - in: path - name: id - required: true - description: The id of the Collection. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - title: - type: string - description: The title to identify the Collection by. - handle: - type: string - description: >- - An optional handle to be used in slugs, if none is provided - we will kebab-case the title. - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Collection - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - collection: - $ref: '#/components/schemas/product_collection' '/discounts/{id}/regions/{region_id}': post: operationId: PostDiscountsDiscountRegionsRegion @@ -608,46 +466,33 @@ paths: properties: discount: $ref: '#/components/schemas/discount' - /gift-cards: + /collections: post: - operationId: PostGiftCards - summary: Create a Gift Card - description: >- - Creates a Gift Card that can redeemed by its unique code. The Gift Card - is only valid within 1 region. + operationId: PostCollections + summary: Create a Product Collection + description: Creates a Product Collection. requestBody: content: application/json: schema: + required: + - title properties: - value: - type: integer - description: >- - The value (excluding VAT) that the Gift Card should - represent. - is_disabled: - type: boolean - description: >- - Whether the Gift Card is disabled on creation. You will have - to enable it later to make it available to Customers. - ends_at: + title: + type: string + description: The title to identify the Collection by. + handle: type: string - format: date-time description: >- - The time at which the Gift Card should no longer be - available. - region_id: - description: The id of the Region in which the Gift Card can be used. - type: array - items: - type: string + An optional handle to be used in slugs, if none is provided + we will kebab-case the title. metadata: description: >- An optional set of key-value pairs to hold additional information. type: object tags: - - Gift Card + - Collection responses: '200': description: OK @@ -655,14 +500,14 @@ paths: application/json: schema: properties: - gift_card: - $ref: '#/components/schemas/gift_card' + collection: + $ref: '#/components/schemas/product_collection' get: - operationId: GetGiftCards - summary: List Gift Cards - description: Retrieves a list of Gift Cards. + operationId: GetCollections + summary: List Product Collections + description: Retrieve a list of Product Collection. tags: - - Gift Card + - Collection responses: '200': description: OK @@ -670,24 +515,22 @@ paths: application/json: schema: properties: - gift_cards: - type: array - items: - $ref: '#/components/schemas/gift_card' - '/gift-cards/{id}': + collection: + $ref: '#/components/schemas/product_collection' + '/collections/{id}': delete: - operationId: DeleteGiftCardsGiftCard - summary: Delete a Gift Card - description: Deletes a Gift Card + operationId: DeleteCollectionsCollection + summary: Delete a Product Collection + description: Deletes a Product Collection. parameters: - in: path name: id required: true - description: The id of the Gift Card to delete. + description: The id of the Collection. schema: type: string tags: - - Gift Card + - Collection responses: '200': description: OK @@ -697,25 +540,25 @@ paths: properties: id: type: string - description: The id of the deleted Gift Card + description: The id of the deleted Collection object: type: string description: The type of the object that was deleted. deleted: type: boolean get: - operationId: GetGiftCardsGiftCard - summary: Retrieve a Gift Card - description: Retrieves a Gift Card. + operationId: GetCollectionsCollection + summary: Retrieve a Product Collection + description: Retrieves a Product Collection. parameters: - in: path name: id required: true - description: The id of the Gift Card. + description: The id of the Product Collection schema: type: string tags: - - Gift Card + - Collection responses: '200': description: OK @@ -723,19 +566,17 @@ paths: application/json: schema: properties: - gift_card: - $ref: '#/components/schemas/gift_card' + collection: + $ref: '#/components/schemas/product_collection' post: - operationId: PostGiftCardsGiftCard - summary: Create a Gift Card - description: >- - Creates a Gift Card that can redeemed by its unique code. The Gift Card - is only valid within 1 region. + operationId: PostCollectionsCollection + summary: Update a Product Collection + description: Updates a Product Collection. parameters: - in: path name: id required: true - description: The id of the Gift Card. + description: The id of the Collection. schema: type: string requestBody: @@ -743,34 +584,21 @@ paths: application/json: schema: properties: - balance: - type: integer - description: >- - The value (excluding VAT) that the Gift Card should - represent. - is_disabled: - type: boolean - description: >- - Whether the Gift Card is disabled on creation. You will have - to enable it later to make it available to Customers. - ends_at: + title: + type: string + description: The title to identify the Collection by. + handle: type: string - format: date-time description: >- - The time at which the Gift Card should no longer be - available. - region_id: - description: The id of the Region in which the Gift Card can be used. - type: array - items: - type: string + An optional handle to be used in slugs, if none is provided + we will kebab-case the title. metadata: description: >- An optional set of key-value pairs to hold additional information. type: object tags: - - Gift Card + - Collection responses: '200': description: OK @@ -778,8 +606,8 @@ paths: application/json: schema: properties: - gift_card: - $ref: '#/components/schemas/gift_card' + collection: + $ref: '#/components/schemas/product_collection' /customers: post: operationId: PostCustomers @@ -955,6 +783,11 @@ paths: customer_id: description: The id of the customer to add on the draft order type: string + no_notification_order: + description: >- + An optional flag passed to the resulting order to determine + use of notifications. + type: boolean shipping_methods: description: The shipping methods for the draft order type: array @@ -1218,6 +1051,11 @@ paths: code: description: The code that a Discount is identifed by. type: string + no_notification_order: + description: >- + An optional flag passed to the resulting order to determine + use of notifications. + type: boolean customer_id: description: The id of the Customer to associate the Draft Order with. type: string @@ -1232,6 +1070,178 @@ paths: properties: draft_order: $ref: '#/components/schemas/draft-order' + /gift-cards: + post: + operationId: PostGiftCards + summary: Create a Gift Card + description: >- + Creates a Gift Card that can redeemed by its unique code. The Gift Card + is only valid within 1 region. + requestBody: + content: + application/json: + schema: + properties: + value: + type: integer + description: >- + The value (excluding VAT) that the Gift Card should + represent. + is_disabled: + type: boolean + description: >- + Whether the Gift Card is disabled on creation. You will have + to enable it later to make it available to Customers. + ends_at: + type: string + format: date-time + description: >- + The time at which the Gift Card should no longer be + available. + region_id: + description: The id of the Region in which the Gift Card can be used. + type: array + items: + type: string + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + get: + operationId: GetGiftCards + summary: List Gift Cards + description: Retrieves a list of Gift Cards. + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_cards: + type: array + items: + $ref: '#/components/schemas/gift_card' + '/gift-cards/{id}': + delete: + operationId: DeleteGiftCardsGiftCard + summary: Delete a Gift Card + description: Deletes a Gift Card + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card to delete. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Gift Card + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetGiftCardsGiftCard + summary: Retrieve a Gift Card + description: Retrieves a Gift Card. + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' + post: + operationId: PostGiftCardsGiftCard + summary: Create a Gift Card + description: >- + Creates a Gift Card that can redeemed by its unique code. The Gift Card + is only valid within 1 region. + parameters: + - in: path + name: id + required: true + description: The id of the Gift Card. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + balance: + type: integer + description: >- + The value (excluding VAT) that the Gift Card should + represent. + is_disabled: + type: boolean + description: >- + Whether the Gift Card is disabled on creation. You will have + to enable it later to make it available to Customers. + ends_at: + type: string + format: date-time + description: >- + The time at which the Gift Card should no longer be + available. + region_id: + description: The id of the Region in which the Gift Card can be used. + type: array + items: + type: string + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + gift_card: + $ref: '#/components/schemas/gift_card' /notifications: get: operationId: GetNotifications @@ -1275,1322 +1285,6 @@ paths: properties: notification: $ref: '#/components/schemas/notification' - '/orders/{id}/shipping-methods': - post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: - description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. - type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - shipping_address: - type: object - description: >- - An optional shipping address to send the claim to. Defaults - to the parent order's shipping address - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Claim. - type: boolean - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': - get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: - type: array - items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': - post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. - type: string - note: - description: A not with additional details about the Refund. - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/regions/{id}/countries': - post: - operationId: PostRegionsRegionCountries - summary: Add Country - description: Adds a Country to the list of Countries in a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - country_code: - description: The 2 character ISO code for the Country. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-providers': - post: - operationId: PostRegionsRegionFulfillmentProviders - summary: Add Fulfillment Provider - description: Adds a Fulfillment Provider to a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - provider_id: - description: The id of the Fulfillment Provider to add. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/payment-providers': - post: - operationId: PostRegionsRegionPaymentProviders - summary: Add Payment Provider - description: Adds a Payment Provider to a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - provider_id: - description: The id of the Payment Provider to add. - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - /regions: - post: - operationId: PostRegions - summary: Create a Region - description: Creates a Region - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Region - type: string - currency_code: - description: The 3 character ISO currency code to use for the Region. - type: string - tax_code: - description: An optional tax code the Region. - type: string - tax_rate: - description: The tax rate to use on Orders in the Region. - type: number - payment_providers: - description: >- - A list of Payment Providers that should be enabled for the - Region - type: array - items: - type: string - fulfillment_providers: - description: >- - A list of Fulfillment Providers that should be enabled for - the Region - type: array - items: - type: string - countries: - description: A list of countries that should be included in the Region. - type: array - items: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - get: - operationId: GetRegions - summary: List Regions - description: Retrieves a list of Regions. - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - regions: - type: array - items: - $ref: '#/components/schemas/region' - '/regions/{id}/metadata/{key}': - delete: - operationId: DeleteRegionsRegionMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}': - delete: - operationId: DeleteRegionsRegion - summary: Delete a Region - description: Deletes a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Region. - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetRegionsRegion - summary: Retrieve a Region - description: Retrieves a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - post: - operationId: PostRegionsRegion - summary: Update a Region - description: Updates a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - name: - description: The name of the Region - type: string - currency_code: - description: The 3 character ISO currency code to use for the Region. - type: string - tax_code: - description: An optional tax code the Region. - type: string - tax_rate: - description: The tax rate to use on Orders in the Region. - type: number - payment_providers: - description: >- - A list of Payment Providers that should be enabled for the - Region - type: array - items: - type: string - fulfillment_providers: - description: >- - A list of Fulfillment Providers that should be enabled for - the Region - type: array - items: - type: string - countries: - description: A list of countries that should be included in the Region. - type: array - items: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-options': - get: - operationId: GetRegionsRegionFulfillmentOptions - summary: List Fulfillment Options available in the Region - description: Gathers all the fulfillment options available to in the Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - fulfillment_options: - type: array - items: - type: object - '/regions/{id}/countries/{country_code}': - delete: - operationId: PostRegionsRegionCountriesCountry - summary: Remove Country - description: Removes a Country from the list of Countries in a Region - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: country_code - required: true - description: The 2 character ISO code for the Country. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/fulfillment-providers/{provider_id}': - delete: - operationId: PostRegionsRegionFulfillmentProvidersProvider - summary: Remove Fulfillment Provider - description: Removes a Fulfillment Provider. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: provider_id - required: true - description: The id of the Fulfillment Provider. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - '/regions/{id}/payment-providers/{provider_id}': - delete: - operationId: PostRegionsRegionPaymentProvidersProvider - summary: Remove Payment Provider - description: Removes a Payment Provider. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - - in: path - name: provider_id - required: true - description: The id of the Payment Provider. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -3496,6 +2190,68 @@ paths: type: array items: $ref: '#/components/schemas/product_type' + /returns: + get: + operationId: GetReturns + summary: List Returns + description: Retrieves a list of Returns + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + returns: + type: array + items: + $ref: '#/components/schemas/return' + '/returns/{id}receive': + post: + operationId: PostReturnsReturnReceive + summary: Receive a Return + description: >- + Registers a Return as received. Updates statuses on Orders and Swaps + accordingly. + parameters: + - in: path + name: id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' /return-reasons: post: operationId: PostReturnReasons @@ -3616,13 +2372,28 @@ paths: properties: return_reason: $ref: '#/components/schemas/return_reason' - /returns: - get: - operationId: GetReturns - summary: List Returns - description: Retrieves a list of Returns + '/regions/{id}/countries': + post: + operationId: PostRegionsRegionCountries + summary: Add Country + description: Adds a Country to the list of Countries in a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + country_code: + description: The 2 character ISO code for the Country. + type: string tags: - - Return + - Region responses: '200': description: OK @@ -3630,22 +2401,1067 @@ paths: application/json: schema: properties: - returns: - type: array - items: - $ref: '#/components/schemas/return' - '/returns/{id}receive': + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-providers': post: - operationId: PostReturnsReturnReceive - summary: Receive a Return - description: >- - Registers a Return as received. Updates statuses on Orders and Swaps - accordingly. + operationId: PostRegionsRegionFulfillmentProviders + summary: Add Fulfillment Provider + description: Adds a Fulfillment Provider to a Region parameters: - in: path name: id required: true - description: The id of the Return. + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + provider_id: + description: The id of the Fulfillment Provider to add. + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/payment-providers': + post: + operationId: PostRegionsRegionPaymentProviders + summary: Add Payment Provider + description: Adds a Payment Provider to a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + provider_id: + description: The id of the Payment Provider to add. + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + /regions: + post: + operationId: PostRegions + summary: Create a Region + description: Creates a Region + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Region + type: string + currency_code: + description: The 3 character ISO currency code to use for the Region. + type: string + tax_code: + description: An optional tax code the Region. + type: string + tax_rate: + description: The tax rate to use on Orders in the Region. + type: number + payment_providers: + description: >- + A list of Payment Providers that should be enabled for the + Region + type: array + items: + type: string + fulfillment_providers: + description: >- + A list of Fulfillment Providers that should be enabled for + the Region + type: array + items: + type: string + countries: + description: A list of countries that should be included in the Region. + type: array + items: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + get: + operationId: GetRegions + summary: List Regions + description: Retrieves a list of Regions. + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + regions: + type: array + items: + $ref: '#/components/schemas/region' + '/regions/{id}/metadata/{key}': + delete: + operationId: DeleteRegionsRegionMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}': + delete: + operationId: DeleteRegionsRegion + summary: Delete a Region + description: Deletes a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: string + description: The id of the deleted Region. + object: + type: string + description: The type of the object that was deleted. + deleted: + type: boolean + get: + operationId: GetRegionsRegion + summary: Retrieve a Region + description: Retrieves a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + post: + operationId: PostRegionsRegion + summary: Update a Region + description: Updates a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + name: + description: The name of the Region + type: string + currency_code: + description: The 3 character ISO currency code to use for the Region. + type: string + tax_code: + description: An optional tax code the Region. + type: string + tax_rate: + description: The tax rate to use on Orders in the Region. + type: number + payment_providers: + description: >- + A list of Payment Providers that should be enabled for the + Region + type: array + items: + type: string + fulfillment_providers: + description: >- + A list of Fulfillment Providers that should be enabled for + the Region + type: array + items: + type: string + countries: + description: A list of countries that should be included in the Region. + type: array + items: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-options': + get: + operationId: GetRegionsRegionFulfillmentOptions + summary: List Fulfillment Options available in the Region + description: Gathers all the fulfillment options available to in the Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + fulfillment_options: + type: array + items: + type: object + '/regions/{id}/countries/{country_code}': + delete: + operationId: PostRegionsRegionCountriesCountry + summary: Remove Country + description: Removes a Country from the list of Countries in a Region + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: country_code + required: true + description: The 2 character ISO code for the Country. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/fulfillment-providers/{provider_id}': + delete: + operationId: PostRegionsRegionFulfillmentProvidersProvider + summary: Remove Fulfillment Provider + description: Removes a Fulfillment Provider. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: provider_id + required: true + description: The id of the Fulfillment Provider. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/regions/{id}/payment-providers/{provider_id}': + delete: + operationId: PostRegionsRegionPaymentProvidersProvider + summary: Remove Payment Provider + description: Removes a Payment Provider. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + - in: path + name: provider_id + required: true + description: The id of the Payment Provider. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + shipping_address: + type: object + description: >- + An optional shipping address to send the claim to. Defaults + to the parent order's shipping address + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Claim. + type: boolean + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + no_notification: + description: >- + If set to true no notification will be send related to this + Claim. + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. schema: type: string requestBody: @@ -3664,11 +3480,8 @@ paths: quantity: description: The quantity of the Line Item. type: integer - refund: - description: The amount to refund. - type: integer tags: - - Return + - Order responses: '200': description: OK @@ -3676,8 +3489,225 @@ paths: application/json: schema: properties: - return: - $ref: '#/components/schemas/return' + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + no_notification: + description: >- + A flag to indicate if no notifications should be emitted + related to the requested Return. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + no_notification: + description: >- + If set to true no notification will be send related to this + Swap. + type: boolean + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' /shipping-options: post: operationId: PostShippingOptions @@ -4402,6 +4432,9 @@ components: type: string format: date-time no_notification: + description: >- + Flag for describing whether or not notifications related to this + should be send. type: boolean metadata: type: object @@ -4672,6 +4705,8 @@ components: completed_at: type: string format: date-time + no_notification_order: + type: boolean metadata: type: object idempotency_key: @@ -5297,6 +5332,9 @@ components: paid_total: type: integer no_notification: + description: >- + Flag for describing whether or not notifications related to this + should be send. type: boolean payment_provider: title: Payment Provider diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 5f7a2b994d..9fcf3c6e85 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -199,6 +199,746 @@ } } }, + "/carts/{id}/shipping-methods": { + "post": { + "operationId": "PostCartsCartShippingMethod", + "description": "Adds a Shipping Method to the Cart.", + "summary": "Add a Shipping Method", + "tags": [ + "Cart" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The cart id.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "A successful response", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "option_id" + ], + "properties": { + "option_id": { + "type": "string", + "description": "id of the shipping option to create the method from" + }, + "data": { + "type": "object", + "description": "Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send." + } + } + } + } + } + } + } + }, + "/carts/{id}/complete": { + "post": { + "summary": "Complete a Cart", + "operationId": "PostCartsCartComplete", + "description": "Completes a cart. The following steps will be performed. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header `Idempotency-Key`. If not provided, we will generate one for the request.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The Cart id.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "If a cart was successfully authorized, but requires further action from the user the response body will contain the cart with an updated payment session. If the Cart was successfully completed the response body will contain the newly created Order.", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "type": "object", + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + }, + { + "type": "object", + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + ] + } + } + } + } + } + } + }, + "/carts": { + "post": { + "summary": "Create a Cart", + "operationId": "PostCart", + "description": "Creates a Cart within the given region and with the initial items. If no `region_id` is provided the cart will be associated with the first Region available. If no items are provided the cart will be empty after creation. If a user is logged in the cart's customer id and email will be set.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "region_id": { + "type": "string", + "description": "The id of the Region to create the Cart in." + }, + "country_code": { + "type": "string", + "description": "The 2 character ISO country code to create the Cart in." + }, + "items": { + "description": "An optional array of `variant_id`, `quantity` pairs to generate Line Items from.", + "type": "array", + "items": { + "properties": { + "variant_id": { + "description": "The id of the Product Variant to generate a Line Item from.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Product Variant to add", + "type": "integer" + } + } + } + }, + "context": { + "description": "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "Successfully created a new Cart", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/line-items": { + "post": { + "operationId": "PostCartsCartLineItems", + "summary": "Add a Line Item", + "description": "Generates a Line Item with a given Product Variant and adds it to the Cart", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart to add the Line Item to.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "variant_id", + "quantity" + ], + "properties": { + "variant_id": { + "type": "string", + "description": "The id of the Product Variant to generate the Line Item from." + }, + "quantity": { + "type": "integer", + "description": "The quantity of the Product Variant to add to the Line Item." + }, + "metadata": { + "type": "object", + "description": "An optional key-value map with additional details about the Line Item." + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-sessions": { + "post": { + "operationId": "PostCartsCartPaymentSessions", + "summary": "Initialize Payment Sessions", + "description": "Creates Payment Sessions for each of the available Payment Providers in the Cart's Region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/discounts/{code}": { + "delete": { + "operationId": "DeleteCartsCartDiscountsDiscount", + "description": "Removes a Discount from a Cart.", + "summary": "Remove Discount from Cart", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "code", + "required": true, + "description": "The unique Discount code.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/line-items/{line_id}": { + "delete": { + "operationId": "DeleteCartsCartLineItemsItem", + "summary": "Delete a Line Item", + "description": "Removes a Line Item from a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "line_id", + "required": true, + "description": "The id of the Line Item.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCartsCartLineItemsItem", + "summary": "Update a Line Item", + "description": "Updates a Line Item if the desired quantity can be fulfilled.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "line_id", + "required": true, + "description": "The id of the Line Item.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "quantity" + ], + "properties": { + "quantity": { + "type": "integer", + "description": "The quantity to set the Line Item to." + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-sessions/{provider_id}": { + "delete": { + "operationId": "DeleteCartsCartPaymentSessionsSession", + "summary": "Delete a Payment Session", + "description": "Deletes a Payment Session on a Cart. May be useful if a payment has failed.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "provider_id", + "required": true, + "description": "The id of the Payment Provider used to create the Payment Session to be deleted.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostCartsCartPaymentSessionUpdate", + "summary": "Update a Payment Session", + "description": "Updates a Payment Session with additional data.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "provider_id", + "required": true, + "description": "The id of the payment provider.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "provider_id", + "data" + ], + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider responsible for the Payment Session to update." + }, + "data": { + "type": "object", + "description": "The data to update the payment session with." + } + } + } + } + } + } + } + }, + "/carts/{id}": { + "get": { + "operationId": "GetCartsCart", + "summary": "Retrieve a Cart", + "description": "Retrieves a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, + "/carts/{id}/payment-session": { + "post": { + "operationId": "PostCartsCartPaymentSession", + "summary": "Select a Payment Session", + "description": "Selects a Payment Session as the session intended to be used towards the completion of the Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "provider_id" + ], + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider." + } + } + } + } + } + } + } + }, + "/store/carts/{id}": { + "post": { + "operationId": "PostCartsCart", + "summary": "Update a Cart\"", + "description": "Updates a Cart.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Cart.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "region_id": { + "type": "string", + "description": "The id of the Region to create the Cart in." + }, + "country_code": { + "type": "string", + "description": "The 2 character ISO country code to create the Cart in." + }, + "email": { + "type": "string", + "description": "An email to be used on the Cart." + }, + "billing_address": { + "description": "The Address to be used for billing purposes.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "shipping_address": { + "description": "The Address to be used for shipping.", + "anyOf": [ + { + "$ref": "#/components/schemas/address" + } + ] + }, + "gift_cards": { + "description": "An array of Gift Card codes to add to the Cart.", + "type": "array", + "items": { + "properties": { + "code": { + "description": "The code that a Gift Card is identified by.", + "type": "string" + } + } + } + }, + "discounts": { + "description": "An array of Discount codes to add to the Cart.", + "type": "array", + "items": { + "properties": { + "code": { + "description": "The code that a Discount is identifed by.", + "type": "string" + } + } + } + }, + "customer_id": { + "description": "The id of the Customer to associate the Cart with.", + "type": "string" + }, + "context": { + "description": "An optional object to provide context to the Cart.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Cart" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "cart": { + "$ref": "#/components/schemas/cart" + } + } + } + } + } + } + } + } + }, "/gift-cards/{code}": { "get": { "operationId": "GetGiftCardsCode", @@ -753,783 +1493,6 @@ } } }, - "/carts/{id}/shipping-methods": { - "post": { - "operationId": "PostCartsCartShippingMethod", - "description": "Adds a Shipping Method to the Cart.", - "summary": "Add a Shipping Method", - "tags": [ - "Cart" - ], - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The cart id.", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "A successful response", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "option_id" - ], - "properties": { - "option_id": { - "type": "string", - "description": "id of the shipping option to create the method from" - }, - "data": { - "type": "object", - "description": "Used to hold any data that the shipping method may need to process the fulfillment of the order. Look at the documentation for your installed fulfillment providers to find out what to send." - } - } - } - } - } - } - } - }, - "/carts/{id}/complete-cart": { - "post": { - "summary": "Complete a Cart", - "operationId": "PostCartsCartComplete", - "description": "Completes a cart. The following steps will be performed. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header `Idempotency-Key`. If not provided, we will generate one for the request.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The Cart id.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "If a cart was successfully authorized, but requires further action from the user the response body will contain the cart with an updated payment session. If the Cart was successfully completed the response body will contain the newly created Order.", - "content": { - "application/json": { - "schema": { - "oneOf": [ - { - "type": "object", - "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - }, - { - "type": "object", - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - ] - } - } - } - } - } - } - }, - "/carts": { - "post": { - "summary": "Create a Cart", - "operationId": "PostCart", - "description": "Creates a Cart within the given region and with the initial items. If no `region_id` is provided the cart will be associated with the first Region available. If no items are provided the cart will be empty after creation. If a user is logged in the cart's customer id and email will be set.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "region_id": { - "type": "string", - "description": "The id of the Region to create the Cart in." - }, - "country_code": { - "type": "string", - "description": "The 2 character ISO country code to create the Cart in." - }, - "items": { - "description": "An optional array of `variant_id`, `quantity` pairs to generate Line Items from.", - "type": "array", - "items": { - "properties": { - "variant_id": { - "description": "The id of the Product Variant to generate a Line Item from.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Product Variant to add", - "type": "integer" - } - } - } - }, - "context": { - "description": "An optional object to provide context to the Cart. The `context` field is automatically populated with `ip` and `user_agent`", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "Successfully created a new Cart", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/line-items": { - "post": { - "operationId": "PostCartsCartLineItems", - "summary": "Add a Line Item", - "description": "Generates a Line Item with a given Product Variant and adds it to the Cart", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart to add the Line Item to.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "variant_id", - "quantity" - ], - "properties": { - "variant_id": { - "type": "string", - "description": "The id of the Product Variant to generate the Line Item from." - }, - "quantity": { - "type": "integer", - "description": "The quantity of the Product Variant to add to the Line Item." - }, - "metadata": { - "type": "object", - "description": "An optional key-value map with additional details about the Line Item." - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-sessions": { - "post": { - "operationId": "PostCartsCartPaymentSessions", - "summary": "Initialize Payment Sessions", - "description": "Creates Payment Sessions for each of the available Payment Providers in the Cart's Region.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/discounts/{code}": { - "delete": { - "operationId": "DeleteCartsCartDiscountsDiscount", - "description": "Removes a Discount from a Cart.", - "summary": "Remove Discount from Cart", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "code", - "required": true, - "description": "The unique Discount code.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/line-items/{line_id}": { - "delete": { - "operationId": "DeleteCartsCartLineItemsItem", - "summary": "Delete a Line Item", - "description": "Removes a Line Item from a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "line_id", - "required": true, - "description": "The id of the Line Item.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCartsCartLineItemsItem", - "summary": "Update a Line Item", - "description": "Updates a Line Item if the desired quantity can be fulfilled.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "line_id", - "required": true, - "description": "The id of the Line Item.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "quantity" - ], - "properties": { - "quantity": { - "type": "integer", - "description": "The quantity to set the Line Item to." - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-sessions/{provider_id}": { - "delete": { - "operationId": "DeleteCartsCartPaymentSessionsSession", - "summary": "Delete a Payment Session", - "description": "Deletes a Payment Session on a Cart. May be useful if a payment has failed.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "provider_id", - "required": true, - "description": "The id of the Payment Provider used to create the Payment Session to be deleted.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCartsCartPaymentSessionsSession", - "summary": "Refresh a Payment Session", - "description": "Refreshes a Payment Session to ensure that it is in sync with the Cart - this is usually not necessary.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "provider_id", - "required": true, - "description": "The id of the Payment Provider that created the Payment Session to be refreshed.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}": { - "get": { - "operationId": "GetCartsCart", - "summary": "Retrieve a Cart", - "description": "Retrieves a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-session": { - "post": { - "operationId": "PostCartsCartPaymentSession", - "summary": "Select a Payment Session", - "description": "Selects a Payment Session as the session intended to be used towards the completion of the Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "provider_id" - ], - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider." - } - } - } - } - } - } - } - }, - "/store/carts/{id}": { - "post": { - "operationId": "PostCartsCart", - "summary": "Update a Cart\"", - "description": "Updates a Cart.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "region_id": { - "type": "string", - "description": "The id of the Region to create the Cart in." - }, - "country_code": { - "type": "string", - "description": "The 2 character ISO country code to create the Cart in." - }, - "email": { - "type": "string", - "description": "An email to be used on the Cart." - }, - "billing_address": { - "description": "The Address to be used for billing purposes.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "shipping_address": { - "description": "The Address to be used for shipping.", - "anyOf": [ - { - "$ref": "#/components/schemas/address" - } - ] - }, - "gift_cards": { - "description": "An array of Gift Card codes to add to the Cart.", - "type": "array", - "items": { - "properties": { - "code": { - "description": "The code that a Gift Card is identified by.", - "type": "string" - } - } - } - }, - "discounts": { - "description": "An array of Discount codes to add to the Cart.", - "type": "array", - "items": { - "properties": { - "code": { - "description": "The code that a Discount is identifed by.", - "type": "string" - } - } - } - }, - "customer_id": { - "description": "The id of the Customer to associate the Cart with.", - "type": "string" - }, - "context": { - "description": "An optional object to provide context to the Cart.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - } - } - }, - "/carts/{id}/payment-session/update": { - "post": { - "operationId": "PostCartsCartPaymentSessionUpdate", - "summary": "Update a Payment Session", - "description": "Updates a Payment Session with additional data.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Cart.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Cart" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "cart": { - "$ref": "#/components/schemas/cart" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "provider_id", - "data" - ], - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider responsible for the Payment Session to update." - }, - "data": { - "type": "object", - "description": "The data to update the payment session with." - } - } - } - } - } - } - } - }, "/orders/cart/{cart_id}": { "get": { "operationId": "GetOrdersOrderCartId", @@ -1728,6 +1691,72 @@ } } }, + "/returns": { + "post": { + "operationId": "PostReturns", + "summary": "Create Return", + "description": "Creates a Return for an Order.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "order_id": { + "type": "string", + "description": "The id of the Order to create the Return from." + }, + "items": { + "description": "The items to include in the Return.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item from the Order.", + "type": "string" + }, + "quantity": { + "description": "The quantity to return.", + "type": "integer" + } + } + } + }, + "return_shipping": { + "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", + "type": "object", + "properties": { + "option_id": { + "type": "string", + "description": "The id of the Shipping Option to create the Shipping Method from." + } + } + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" + } + } + } + } + } + } + } + } + }, "/return-reasons/{id}": { "get": { "operationId": "GetReturnReasonsReason", @@ -1872,53 +1901,24 @@ } } }, - "/returns": { - "post": { - "operationId": "PostReturns", - "summary": "Create Return", - "description": "Creates a Return for an Order.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "order_id": { - "type": "string", - "description": "The id of the Order to create the Return from." - }, - "items": { - "description": "The items to include in the Return.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item from the Order.", - "type": "string" - }, - "quantity": { - "description": "The quantity to return.", - "type": "integer" - } - } - } - }, - "return_shipping": { - "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", - "type": "object", - "properties": { - "option_id": { - "type": "string", - "description": "The id of the Shipping Option to create the Shipping Method from." - } - } - } - } - } + "/swaps/{cart_id}": { + "get": { + "operationId": "GetSwapsSwapCartId", + "summary": "Retrieve Swap by Cart id", + "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", + "parameters": [ + { + "in": "path", + "name": "cart_id", + "required": true, + "description": "The id of the Cart", + "schema": { + "type": "string" } } - }, + ], "tags": [ - "Return" + "Swap" ], "responses": { "200": { @@ -1927,8 +1927,8 @@ "application/json": { "schema": { "properties": { - "return": { - "$ref": "#/components/schemas/return" + "swap": { + "$ref": "#/components/schemas/swap" } } } @@ -2033,43 +2033,6 @@ } } }, - "/swaps/{cart_id}": { - "get": { - "operationId": "GetSwapsSwapCartId", - "summary": "Retrieve Swap by Cart id", - "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", - "parameters": [ - { - "in": "path", - "name": "cart_id", - "required": true, - "description": "The id of the Cart", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Swap" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "swap": { - "$ref": "#/components/schemas/swap" - } - } - } - } - } - } - } - } - }, "/variants/{variant_id}": { "get": { "operationId": "GetVariantsVariant", @@ -2506,6 +2469,7 @@ "format": "date-time" }, "no_notification": { + "description": "Flag for describing whether or not notifications related to this should be send.", "type": "boolean" }, "metadata": { @@ -2857,6 +2821,9 @@ "type": "string", "format": "date-time" }, + "no_notification_order": { + "type": "boolean" + }, "metadata": { "type": "object" }, @@ -3623,6 +3590,7 @@ "type": "integer" }, "no_notification": { + "description": "Flag for describing whether or not notifications related to this should be send.", "type": "boolean" } } diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index b36b9dd521..3ac9dc6bd0 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -121,570 +121,6 @@ paths: properties: exists: type: boolean - '/carts/{id}/shipping-methods': - post: - operationId: PostCartsCartShippingMethod - description: Adds a Shipping Method to the Cart. - summary: Add a Shipping Method - tags: - - Cart - parameters: - - in: path - name: id - required: true - description: The cart id. - schema: - type: string - responses: - '200': - description: A successful response - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - option_id - properties: - option_id: - type: string - description: id of the shipping option to create the method from - data: - type: object - description: >- - Used to hold any data that the shipping method may need to - process the fulfillment of the order. Look at the - documentation for your installed fulfillment providers to - find out what to send. - '/carts/{id}/complete-cart': - post: - summary: Complete a Cart - operationId: PostCartsCartComplete - description: >- - Completes a cart. The following steps will be performed. Payment - authorization is attempted and if more work is required, we simply - return the cart for further updates. If payment is authorized and order - is not yet created, we make sure to do so. The completion of a cart can - be performed idempotently with a provided header `Idempotency-Key`. If - not provided, we will generate one for the request. - parameters: - - in: path - name: id - required: true - description: The Cart id. - schema: - type: string - tags: - - Cart - responses: - '200': - description: >- - If a cart was successfully authorized, but requires further action - from the user the response body will contain the cart with an - updated payment session. If the Cart was successfully completed the - response body will contain the newly created Order. - content: - application/json: - schema: - oneOf: - - type: object - properties: - order: - $ref: '#/components/schemas/order' - - type: object - properties: - cart: - $ref: '#/components/schemas/cart' - /carts: - post: - summary: Create a Cart - operationId: PostCart - description: >- - Creates a Cart within the given region and with the initial items. If no - `region_id` is provided the cart will be associated with the first - Region available. If no items are provided the cart will be empty after - creation. If a user is logged in the cart's customer id and email will - be set. - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - items: - description: >- - An optional array of `variant_id`, `quantity` pairs to - generate Line Items from. - type: array - items: - properties: - variant_id: - description: >- - The id of the Product Variant to generate a Line Item - from. - type: string - quantity: - description: The quantity of the Product Variant to add - type: integer - context: - description: >- - An optional object to provide context to the Cart. The - `context` field is automatically populated with `ip` and - `user_agent` - type: object - tags: - - Cart - responses: - '200': - description: Successfully created a new Cart - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items': - post: - operationId: PostCartsCartLineItems - summary: Add a Line Item - description: >- - Generates a Line Item with a given Product Variant and adds it to the - Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart to add the Line Item to. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - variant_id - - quantity - properties: - variant_id: - type: string - description: >- - The id of the Product Variant to generate the Line Item - from. - quantity: - type: integer - description: The quantity of the Product Variant to add to the Line Item. - metadata: - type: object - description: >- - An optional key-value map with additional details about the - Line Item. - '/carts/{id}/payment-sessions': - post: - operationId: PostCartsCartPaymentSessions - summary: Initialize Payment Sessions - description: >- - Creates Payment Sessions for each of the available Payment Providers in - the Cart's Region. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/discounts/{code}': - delete: - operationId: DeleteCartsCartDiscountsDiscount - description: Removes a Discount from a Cart. - summary: Remove Discount from Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: code - required: true - description: The unique Discount code. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items/{line_id}': - delete: - operationId: DeleteCartsCartLineItemsItem - summary: Delete a Line Item - description: Removes a Line Item from a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartLineItemsItem - summary: Update a Line Item - description: Updates a Line Item if the desired quantity can be fulfilled. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - quantity - properties: - quantity: - type: integer - description: The quantity to set the Line Item to. - '/carts/{id}/payment-sessions/{provider_id}': - delete: - operationId: DeleteCartsCartPaymentSessionsSession - summary: Delete a Payment Session - description: >- - Deletes a Payment Session on a Cart. May be useful if a payment has - failed. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: >- - The id of the Payment Provider used to create the Payment Session to - be deleted. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartPaymentSessionsSession - summary: Refresh a Payment Session - description: >- - Refreshes a Payment Session to ensure that it is in sync with the Cart - - this is usually not necessary. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: >- - The id of the Payment Provider that created the Payment Session to - be refreshed. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}': - get: - operationId: GetCartsCart - summary: Retrieve a Cart - description: Retrieves a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session': - post: - operationId: PostCartsCartPaymentSession - summary: Select a Payment Session - description: >- - Selects a Payment Session as the session intended to be used towards the - completion of the Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - properties: - provider_id: - type: string - description: The id of the Payment Provider. - '/store/carts/{id}': - post: - operationId: PostCartsCart - summary: Update a Cart" - description: Updates a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - email: - type: string - description: An email to be used on the Cart. - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - shipping_address: - description: The Address to be used for shipping. - anyOf: - - $ref: '#/components/schemas/address' - gift_cards: - description: An array of Gift Card codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Gift Card is identified by. - type: string - discounts: - description: An array of Discount codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Discount is identifed by. - type: string - customer_id: - description: The id of the Customer to associate the Cart with. - type: string - context: - description: An optional object to provide context to the Cart. - type: object - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session/update': - post: - operationId: PostCartsCartPaymentSessionUpdate - summary: Update a Payment Session - description: Updates a Payment Session with additional data. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - - data - properties: - provider_id: - type: string - description: >- - The id of the Payment Provider responsible for the Payment - Session to update. - data: - type: object - description: The data to update the payment session with. - '/gift-cards/{code}': - get: - operationId: GetGiftCardsCode - summary: Retrieve Gift Card by Code - description: Retrieves a Gift Card by its associated unqiue code. - parameters: - - in: path - name: code - required: true - description: The unique Gift Card code. - schema: - type: string - tags: - - Gift Card - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - description: The id of the Gift Card - code: - description: The code of the Gift Card - value: - description: The original value of the Gift Card. - balance: - description: The current balanace of the Gift Card - region: - $ref: '#/components/schemas/region' '/customers/{id}/addresses': post: operationId: PostCustomersCustomerAddresses @@ -1017,77 +453,155 @@ paths: password: type: string description: The new password to set for the Customer. - '/orders/cart/{cart_id}': - get: - operationId: GetOrdersOrderCartId - summary: Retrieves Order by Cart id - description: >- - Retrieves an Order by the id of the Cart that was used to create the - Order. - parameters: - - in: path - name: cart_id - required: true - description: The id of Cart. - schema: - type: string + '/carts/{id}/shipping-methods': + post: + operationId: PostCartsCartShippingMethod + description: Adds a Shipping Method to the Cart. + summary: Add a Shipping Method tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': - get: - operationId: GetOrdersOrder - summary: Retrieves an Order - description: Retrieves an Order + - Cart parameters: - in: path name: id required: true - description: The id of the Order. + description: The cart id. schema: type: string - tags: - - Order responses: '200': - description: OK + description: A successful response content: application/json: schema: properties: - customer: - $ref: '#/components/schemas/customer' - /orders: - get: - operationId: GetOrders - summary: Look Up an Order + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - option_id + properties: + option_id: + type: string + description: id of the shipping option to create the method from + data: + type: object + description: >- + Used to hold any data that the shipping method may need to + process the fulfillment of the order. Look at the + documentation for your installed fulfillment providers to + find out what to send. + '/carts/{id}/complete': + post: + summary: Complete a Cart + operationId: PostCartsCartComplete description: >- - Looks for an Order with a given `display_id`, `email` pair. The - `display_id`, `email` pair must match in order for the Order to be - returned. + Completes a cart. The following steps will be performed. Payment + authorization is attempted and if more work is required, we simply + return the cart for further updates. If payment is authorized and order + is not yet created, we make sure to do so. The completion of a cart can + be performed idempotently with a provided header `Idempotency-Key`. If + not provided, we will generate one for the request. parameters: - - in: query - name: display_id + - in: path + name: id required: true - description: The display id given to the Order. - schema: - type: number - - in: query - name: email - required: true - description: The email of the Order with the given display_id. + description: The Cart id. schema: type: string tags: - - Order + - Cart + responses: + '200': + description: >- + If a cart was successfully authorized, but requires further action + from the user the response body will contain the cart with an + updated payment session. If the Cart was successfully completed the + response body will contain the newly created Order. + content: + application/json: + schema: + oneOf: + - type: object + properties: + order: + $ref: '#/components/schemas/order' + - type: object + properties: + cart: + $ref: '#/components/schemas/cart' + /carts: + post: + summary: Create a Cart + operationId: PostCart + description: >- + Creates a Cart within the given region and with the initial items. If no + `region_id` is provided the cart will be associated with the first + Region available. If no items are provided the cart will be empty after + creation. If a user is logged in the cart's customer id and email will + be set. + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + items: + description: >- + An optional array of `variant_id`, `quantity` pairs to + generate Line Items from. + type: array + items: + properties: + variant_id: + description: >- + The id of the Product Variant to generate a Line Item + from. + type: string + quantity: + description: The quantity of the Product Variant to add + type: integer + context: + description: >- + An optional object to provide context to the Cart. The + `context` field is automatically populated with `ip` and + `user_agent` + type: object + tags: + - Cart + responses: + '200': + description: Successfully created a new Cart + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items': + post: + operationId: PostCartsCartLineItems + summary: Add a Line Item + description: >- + Generates a Line Item with a given Product Variant and adds it to the + Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart to add the Line Item to. + schema: + type: string + tags: + - Cart responses: '200': description: OK @@ -1095,8 +609,387 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - variant_id + - quantity + properties: + variant_id: + type: string + description: >- + The id of the Product Variant to generate the Line Item + from. + quantity: + type: integer + description: The quantity of the Product Variant to add to the Line Item. + metadata: + type: object + description: >- + An optional key-value map with additional details about the + Line Item. + '/carts/{id}/payment-sessions': + post: + operationId: PostCartsCartPaymentSessions + summary: Initialize Payment Sessions + description: >- + Creates Payment Sessions for each of the available Payment Providers in + the Cart's Region. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/discounts/{code}': + delete: + operationId: DeleteCartsCartDiscountsDiscount + description: Removes a Discount from a Cart. + summary: Remove Discount from Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: code + required: true + description: The unique Discount code. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items/{line_id}': + delete: + operationId: DeleteCartsCartLineItemsItem + summary: Delete a Line Item + description: Removes a Line Item from a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartLineItemsItem + summary: Update a Line Item + description: Updates a Line Item if the desired quantity can be fulfilled. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - quantity + properties: + quantity: + type: integer + description: The quantity to set the Line Item to. + '/carts/{id}/payment-sessions/{provider_id}': + delete: + operationId: DeleteCartsCartPaymentSessionsSession + summary: Delete a Payment Session + description: >- + Deletes a Payment Session on a Cart. May be useful if a payment has + failed. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: >- + The id of the Payment Provider used to create the Payment Session to + be deleted. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartPaymentSessionUpdate + summary: Update a Payment Session + description: Updates a Payment Session with additional data. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: The id of the payment provider. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + - data + properties: + provider_id: + type: string + description: >- + The id of the Payment Provider responsible for the Payment + Session to update. + data: + type: object + description: The data to update the payment session with. + '/carts/{id}': + get: + operationId: GetCartsCart + summary: Retrieve a Cart + description: Retrieves a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/payment-session': + post: + operationId: PostCartsCartPaymentSession + summary: Select a Payment Session + description: >- + Selects a Payment Session as the session intended to be used towards the + completion of the Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + properties: + provider_id: + type: string + description: The id of the Payment Provider. + '/store/carts/{id}': + post: + operationId: PostCartsCart + summary: Update a Cart" + description: Updates a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + email: + type: string + description: An email to be used on the Cart. + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + shipping_address: + description: The Address to be used for shipping. + anyOf: + - $ref: '#/components/schemas/address' + gift_cards: + description: An array of Gift Card codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Gift Card is identified by. + type: string + discounts: + description: An array of Discount codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Discount is identifed by. + type: string + customer_id: + description: The id of the Customer to associate the Cart with. + type: string + context: + description: An optional object to provide context to the Cart. + type: object + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/gift-cards/{code}': + get: + operationId: GetGiftCardsCode + summary: Retrieve Gift Card by Code + description: Retrieves a Gift Card by its associated unqiue code. + parameters: + - in: path + name: code + required: true + description: The unique Gift Card code. + schema: + type: string + tags: + - Gift Card + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + description: The id of the Gift Card + code: + description: The code of the Gift Card + value: + description: The original value of the Gift Card. + balance: + description: The current balanace of the Gift Card + region: + $ref: '#/components/schemas/region' '/products/{id}': get: operationId: GetProductsProduct @@ -1197,44 +1090,22 @@ paths: type: array items: $ref: '#/components/schemas/region' - /returns: - post: - operationId: PostReturns - summary: Create Return - description: Creates a Return for an Order. - requestBody: - content: - application/json: - schema: - properties: - order_id: - type: string - description: The id of the Order to create the Return from. - items: - description: The items to include in the Return. - type: array - items: - properties: - item_id: - description: The id of the Line Item from the Order. - type: string - quantity: - description: The quantity to return. - type: integer - return_shipping: - description: >- - If the Return is to be handled by the store operator the - Customer can choose a Return Shipping Method. Alternatvely - the Customer can handle the Return themselves. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. + '/orders/cart/{cart_id}': + get: + operationId: GetOrdersOrderCartId + summary: Retrieves Order by Cart id + description: >- + Retrieves an Order by the id of the Cart that was used to create the + Order. + parameters: + - in: path + name: cart_id + required: true + description: The id of Cart. + schema: + type: string tags: - - Return + - Order responses: '200': description: OK @@ -1242,8 +1113,104 @@ paths: application/json: schema: properties: - return: - $ref: '#/components/schemas/return' + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieves an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + customer: + $ref: '#/components/schemas/customer' + /orders: + get: + operationId: GetOrders + summary: Look Up an Order + description: >- + Looks for an Order with a given `display_id`, `email` pair. The + `display_id`, `email` pair must match in order for the Order to be + returned. + parameters: + - in: query + name: display_id + required: true + description: The display id given to the Order. + schema: + type: number + - in: query + name: email + required: true + description: The email of the Order with the given display_id. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. + parameters: + - in: path + name: id + required: true + description: The id of the Return Reason. + schema: + type: string + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reason: + $ref: '#/components/schemas/return_reason' + /return-reasons: + get: + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. + tags: + - Return Reason + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return_reasons: + type: array + items: + $ref: '#/components/schemas/return_reason' /shipping-options: get: operationId: GetShippingOptions @@ -1305,20 +1272,44 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string + /returns: + post: + operationId: PostReturns + summary: Create Return + description: Creates a Return for an Order. + requestBody: + content: + application/json: + schema: + properties: + order_id: + type: string + description: The id of the Order to create the Return from. + items: + description: The items to include in the Return. + type: array + items: + properties: + item_id: + description: The id of the Line Item from the Order. + type: string + quantity: + description: The quantity to return. + type: integer + return_shipping: + description: >- + If the Return is to be handled by the store operator the + Customer can choose a Return Shipping Method. Alternatvely + the Customer can handle the Return themselves. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. tags: - - Return Reason + - Return responses: '200': description: OK @@ -1326,49 +1317,8 @@ paths: application/json: schema: properties: - return_reason: - $ref: '#/components/schemas/return_reason' - /return-reasons: - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' + return: + $ref: '#/components/schemas/return' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1416,6 +1366,29 @@ paths: type: array items: $ref: '#/components/schemas/product_variant' + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string + tags: + - Swap + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + swap: + $ref: '#/components/schemas/swap' components: schemas: address: @@ -1683,6 +1656,9 @@ components: type: string format: date-time no_notification: + description: >- + Flag for describing whether or not notifications related to this + should be send. type: boolean metadata: type: object @@ -1953,6 +1929,8 @@ components: completed_at: type: string format: date-time + no_notification_order: + type: boolean metadata: type: object idempotency_key: @@ -2578,6 +2556,9 @@ components: paid_total: type: integer no_notification: + description: >- + Flag for describing whether or not notifications related to this + should be send. type: boolean payment_provider: title: Payment Provider diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js index 9a84fa5a25..6fff5d598b 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js @@ -36,7 +36,7 @@ import { defaultCartFields, defaultCartRelations, defaultFields } from "." * description: "The code that a Discount is identifed by." * type: string * no_notification_order: - * description: "An optional flag passed to the resulting order to determine use of notifications."" + * description: "An optional flag passed to the resulting order to determine use of notifications." * type: boolean * customer_id: * description: "The id of the Customer to associate the Draft Order with." diff --git a/packages/medusa/src/api/routes/admin/returns/receive-return.js b/packages/medusa/src/api/routes/admin/returns/receive-return.js index 404ee7d69d..8e77f55fd9 100644 --- a/packages/medusa/src/api/routes/admin/returns/receive-return.js +++ b/packages/medusa/src/api/routes/admin/returns/receive-return.js @@ -56,7 +56,6 @@ export default async (req, res) => { const { value, error } = schema.validate(req.body) if (error) { - console.log(error) throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index 4adb462748..ef56621044 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -942,6 +942,4 @@ describe("SwapService", () => { }) }) }) - - }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index 9332cd3fe5..e0165ef952 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -168,10 +168,6 @@ class NotificationService extends BaseService { return } - if(data['no_notification'] === true) { - return - } - return Promise.all( subs.map(async providerId => { return this.send(eventName, data, providerId).catch(err => { diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 57637ad4ac..b8c79e459b 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -309,11 +309,9 @@ class OrderService extends BaseService { */ async retrieve(orderId, config = {}) { - const orderRepo = this.manager_.getCustomRepository(this.orderRepository_) const validatedId = this.validateId_(orderId) - const { select, relations, totalsToSelect } = this.transformQueryForTotals_( config ) From 99f4e6f465fa670ba32f369b287ed56fbce63fdc Mon Sep 17 00:00:00 2001 From: --list Date: Thu, 24 Jun 2021 16:32:28 +0200 Subject: [PATCH 38/55] reverted changes to doc files --- docs/api/admin-spec3.json | 1520 +++++++++--------- docs/api/admin-spec3.yaml | 3077 ++++++++++++++++--------------------- docs/api/store-spec3.json | 569 ++++--- docs/api/store-spec3.yaml | 1437 +++++++++-------- 4 files changed, 3011 insertions(+), 3592 deletions(-) diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index de03c84c1d..5da7fcc4b6 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -145,183 +145,6 @@ } } }, - "/customers": { - "post": { - "operationId": "PostCustomers", - "summary": "Create a Customer", - "description": "Creates a Customer.", - "parameters": [], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "email", - "first_name", - "last_name" - ], - "properties": { - "email": { - "type": "string", - "description": "The Customer's email address." - }, - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "type": "string", - "description": "The Customer's phone number." - } - } - } - } - } - } - }, - "get": { - "operationId": "GetCustomers", - "summary": "List Customers", - "description": "Retrieves a list of Customers.", - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/customers/{id}": { - "get": { - "operationId": "GetCustomersCustomer", - "summary": "Retrieve a Customer", - "description": "Retrieves a Customer.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostCustomersCustomer", - "summary": "Update a Customer", - "description": "Updates a Customer.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Customer.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "first_name": { - "type": "string", - "description": "The Customer's first name." - }, - "last_name": { - "type": "string", - "description": "The Customer's last name." - }, - "phone": { - "description": "The Customer's phone number.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Customer" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, "/collections": { "post": { "operationId": "PostCollections", @@ -534,47 +357,14 @@ } } }, - "/gift-cards": { + "/customers": { "post": { - "operationId": "PostGiftCards", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "value": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { - "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." - }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } - }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", - "type": "object" - } - } - } - } - } - }, + "operationId": "PostCustomers", + "summary": "Create a Customer", + "description": "Creates a Customer.", + "parameters": [], "tags": [ - "Gift Card" + "Customer" ], "responses": { "200": { @@ -583,22 +373,54 @@ "application/json": { "schema": { "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" + "customer": { + "$ref": "#/components/schemas/customer" } } } } } } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "email", + "first_name", + "last_name" + ], + "properties": { + "email": { + "type": "string", + "description": "The Customer's email address." + }, + "first_name": { + "type": "string", + "description": "The Customer's first name." + }, + "last_name": { + "type": "string", + "description": "The Customer's last name." + }, + "phone": { + "type": "string", + "description": "The Customer's phone number." + } + } + } + } + } } }, "get": { - "operationId": "GetGiftCards", - "summary": "List Gift Cards", - "description": "Retrieves a list of Gift Cards.", + "operationId": "GetCustomers", + "summary": "List Customers", + "description": "Retrieves a list of Customers.", "tags": [ - "Gift Card" + "Customer" ], "responses": { "200": { @@ -607,11 +429,8 @@ "application/json": { "schema": { "properties": { - "gift_cards": { - "type": "array", - "items": { - "$ref": "#/components/schemas/gift_card" - } + "customer": { + "$ref": "#/components/schemas/customer" } } } @@ -621,67 +440,24 @@ } } }, - "/gift-cards/{id}": { - "delete": { - "operationId": "DeleteGiftCardsGiftCard", - "summary": "Delete a Gift Card", - "description": "Deletes a Gift Card", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Gift Card to delete.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Gift Card" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Gift Card" - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, + "/customers/{id}": { "get": { - "operationId": "GetGiftCardsGiftCard", - "summary": "Retrieve a Gift Card", - "description": "Retrieves a Gift Card.", + "operationId": "GetCustomersCustomer", + "summary": "Retrieve a Customer", + "description": "Retrieves a Customer.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Gift Card.", + "description": "The id of the Customer.", "schema": { "type": "string" } } ], "tags": [ - "Gift Card" + "Customer" ], "responses": { "200": { @@ -690,8 +466,8 @@ "application/json": { "schema": { "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" + "customer": { + "$ref": "#/components/schemas/customer" } } } @@ -701,15 +477,15 @@ } }, "post": { - "operationId": "PostGiftCardsGiftCard", - "summary": "Create a Gift Card", - "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "operationId": "PostCustomersCustomer", + "summary": "Update a Customer", + "description": "Updates a Customer.", "parameters": [ { "in": "path", "name": "id", "required": true, - "description": "The id of the Gift Card.", + "description": "The id of the Customer.", "schema": { "type": "string" } @@ -720,28 +496,16 @@ "application/json": { "schema": { "properties": { - "balance": { - "type": "integer", - "description": "The value (excluding VAT) that the Gift Card should represent." - }, - "is_disabled": { - "type": "boolean", - "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." - }, - "ends_at": { + "first_name": { "type": "string", - "format": "date-time", - "description": "The time at which the Gift Card should no longer be available." + "description": "The Customer's first name." }, - "region_id": { - "description": "The id of the Region in which the Gift Card can be used.", - "type": "array", - "items": { - "type": "string" - } + "last_name": { + "type": "string", + "description": "The Customer's last name." }, - "metadata": { - "description": "An optional set of key-value pairs to hold additional information.", + "phone": { + "description": "The Customer's phone number.", "type": "object" } } @@ -750,7 +514,7 @@ } }, "tags": [ - "Gift Card" + "Customer" ], "responses": { "200": { @@ -759,8 +523,8 @@ "application/json": { "schema": { "properties": { - "gift_card": { - "$ref": "#/components/schemas/gift_card" + "customer": { + "$ref": "#/components/schemas/customer" } } } @@ -953,10 +717,6 @@ "type": "string" } }, - "usage_limit": { - "type": "number", - "description": "Maximum times the discount can be used" - }, "metadata": { "description": "An optional set of key-value pairs to hold additional information.", "type": "object" @@ -1278,6 +1038,242 @@ } } }, + "/gift-cards": { + "post": { + "operationId": "PostGiftCards", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "value": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCards", + "summary": "List Gift Cards", + "description": "Retrieves a list of Gift Cards.", + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_cards": { + "type": "array", + "items": { + "$ref": "#/components/schemas/gift_card" + } + } + } + } + } + } + } + } + } + }, + "/gift-cards/{id}": { + "delete": { + "operationId": "DeleteGiftCardsGiftCard", + "summary": "Delete a Gift Card", + "description": "Deletes a Gift Card", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card to delete.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Gift Card" + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetGiftCardsGiftCard", + "summary": "Retrieve a Gift Card", + "description": "Retrieves a Gift Card.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostGiftCardsGiftCard", + "summary": "Create a Gift Card", + "description": "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Gift Card.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "balance": { + "type": "integer", + "description": "The value (excluding VAT) that the Gift Card should represent." + }, + "is_disabled": { + "type": "boolean", + "description": "Whether the Gift Card is disabled on creation. You will have to enable it later to make it available to Customers." + }, + "ends_at": { + "type": "string", + "format": "date-time", + "description": "The time at which the Gift Card should no longer be available." + }, + "region_id": { + "description": "The id of the Region in which the Gift Card can be used.", + "type": "array", + "items": { + "type": "string" + } + }, + "metadata": { + "description": "An optional set of key-value pairs to hold additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Gift Card" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "gift_card": { + "$ref": "#/components/schemas/gift_card" + } + } + } + } + } + } + } + } + }, "/notifications": { "get": { "operationId": "GetNotifications", @@ -1964,10 +1960,6 @@ } } } - }, - "no_notification": { - "description": "If set to true no notification will be send", - "type": "boolean" } } } @@ -2273,6 +2265,82 @@ } } }, + "/orders/{id}/returns/{return_id}/receive": { + "post": { + "operationId": "PostOrdersOrderReturnsReturnReceive", + "summary": "Receive a Return", + "description": "Registers a Return as received.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Order.", + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "return_id", + "required": true, + "description": "The id of the Return.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "items": { + "description": "The Line Items that have been received.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item.", + "type": "string" + }, + "quantity": { + "description": "The quantity of the Line Item.", + "type": "integer" + } + } + } + }, + "refund": { + "description": "The amount to refund.", + "type": "integer" + } + } + } + } + } + }, + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + }, "/orders/{id}/swaps/{swap_id}/receive": { "post": { "operationId": "PostOrdersOrderSwapsSwapReceive", @@ -3858,183 +3926,6 @@ } } }, - "/return-reasons": { - "post": { - "operationId": "PostReturnReasons", - "summary": "Create a Return Reason", - "description": "Creates a Return Reason", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetReturnReasons", - "summary": "List Return Reasons", - "description": "Retrieves a list of Return Reasons.", - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reasons": { - "type": "array", - "items": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - } - }, - "/return-reasons/{id}": { - "get": { - "operationId": "GetReturnReasonsReason", - "summary": "Retrieve a Return Reason", - "description": "Retrieves a Return Reason.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostReturnReasonsReason", - "summary": "Update a Return Reason", - "description": "Updates a Return Reason", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return Reason.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "label": { - "description": "The label to display to the Customer.", - "type": "string" - }, - "value": { - "description": "The value that the Return Reason will be identified by. Must be unique.", - "type": "string" - }, - "description": { - "description": "An optional description to for the Reason.", - "type": "string" - }, - "metadata": { - "description": "An optional set of key-value pairs with additional information.", - "type": "object" - } - } - } - } - } - }, - "tags": [ - "Return Reason" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return_reason": { - "$ref": "#/components/schemas/return_reason" - } - } - } - } - } - } - } - } - }, "/regions/{id}/countries": { "post": { "operationId": "PostRegionsRegionCountries", @@ -4674,6 +4565,183 @@ } } }, + "/return-reasons": { + "post": { + "operationId": "PostReturnReasons", + "summary": "Create a Return Reason", + "description": "Creates a Return Reason", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetReturnReasons", + "summary": "List Return Reasons", + "description": "Retrieves a list of Return Reasons.", + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reasons": { + "type": "array", + "items": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + } + }, + "/return-reasons/{id}": { + "get": { + "operationId": "GetReturnReasonsReason", + "summary": "Retrieve a Return Reason", + "description": "Retrieves a Return Reason.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostReturnReasonsReason", + "summary": "Update a Return Reason", + "description": "Updates a Return Reason", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Return Reason.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "label": { + "description": "The label to display to the Customer.", + "type": "string" + }, + "value": { + "description": "The value that the Return Reason will be identified by. Must be unique.", + "type": "string" + }, + "description": { + "description": "An optional description to for the Reason.", + "type": "string" + }, + "metadata": { + "description": "An optional set of key-value pairs with additional information.", + "type": "object" + } + } + } + } + } + }, + "tags": [ + "Return Reason" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return_reason": { + "$ref": "#/components/schemas/return_reason" + } + } + } + } + } + } + } + } + }, "/returns": { "get": { "operationId": "GetReturns", @@ -4703,269 +4771,6 @@ } } }, - "/returns/{id}receive": { - "post": { - "operationId": "PostReturnsReturnReceive", - "summary": "Receive a Return", - "description": "Registers a Return as received. Updates statuses on Orders and Swaps accordingly.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Return.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "items": { - "description": "The Line Items that have been received.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item.", - "type": "string" - }, - "quantity": { - "description": "The quantity of the Line Item.", - "type": "integer" - } - } - } - }, - "refund": { - "description": "The amount to refund.", - "type": "integer" - } - } - } - } - } - }, - "tags": [ - "Return" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return": { - "$ref": "#/components/schemas/return" - } - } - } - } - } - } - } - } - }, - "/shipping-profiles": { - "post": { - "operationId": "PostShippingProfiles", - "summary": "Create a Shipping Profile", - "description": "Creates a Shipping Profile", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfiles", - "summary": "List Shipping Profiles", - "description": "Retrieves a list of Shipping Profile.", - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - } - }, - "/shipping-profiles/{id}": { - "delete": { - "operationId": "DeleteShippingProfilesProfile", - "summary": "Delete a Shipping Profile", - "description": "Deletes a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "id": { - "type": "string", - "description": "The id of the deleted Shipping Profile." - }, - "object": { - "type": "string", - "description": "The type of the object that was deleted." - }, - "deleted": { - "type": "boolean" - } - } - } - } - } - } - } - }, - "get": { - "operationId": "GetShippingProfilesProfile", - "summary": "Retrieve a Shipping Profile", - "description": "Retrieves a Shipping Profile.", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profile": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - }, - "post": { - "operationId": "PostShippingProfilesProfile", - "summary": "Update a Shipping Profiles", - "description": "Updates a Shipping Profile", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Shipping Profile.", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "name": { - "description": "The name of the Shipping Profile", - "type": "string" - } - } - } - } - } - }, - "tags": [ - "Shipping Profile" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "shipping_profiles": { - "$ref": "#/components/schemas/shipping_profile" - } - } - } - } - } - } - } - } - }, "/shipping-options": { "post": { "operationId": "PostShippingOptions", @@ -5238,6 +5043,202 @@ } } }, + "/shipping-profiles": { + "post": { + "operationId": "PostShippingProfiles", + "summary": "Create a Shipping Profile", + "description": "Creates a Shipping Profile", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfiles", + "summary": "List Shipping Profiles", + "description": "Retrieves a list of Shipping Profile.", + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + } + }, + "/shipping-profiles/{id}": { + "delete": { + "operationId": "DeleteShippingProfilesProfile", + "summary": "Delete a Shipping Profile", + "description": "Deletes a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "string", + "description": "The id of the deleted Shipping Profile." + }, + "object": { + "type": "string", + "description": "The type of the object that was deleted." + }, + "deleted": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "get": { + "operationId": "GetShippingProfilesProfile", + "summary": "Retrieve a Shipping Profile", + "description": "Retrieves a Shipping Profile.", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profile": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + }, + "post": { + "operationId": "PostShippingProfilesProfile", + "summary": "Update a Shipping Profiles", + "description": "Updates a Shipping Profile", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Shipping Profile.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the Shipping Profile", + "type": "string" + } + } + } + } + } + }, + "tags": [ + "Shipping Profile" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "shipping_profiles": { + "$ref": "#/components/schemas/shipping_profile" + } + } + } + } + } + } + } + } + }, "/store/currencies/{code}": { "post": { "operationId": "PostStoreCurrenciesCode", @@ -6019,6 +6020,10 @@ "$ref": "#/components/schemas/product" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6090,14 +6095,6 @@ "$ref": "#/components/schemas/region" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, - "usage_count": { - "description": "The number of times a discount has been used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -6872,9 +6869,6 @@ }, "gift_card_total": { "type": "integer" - }, - "paid_total": { - "type": "integer" } } }, diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index f2e31cce28..048de24094 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -85,387 +85,6 @@ paths: properties: user: $ref: '#/components/schemas/user' - '/discounts/{id}/regions/{region_id}': - post: - operationId: PostDiscountsDiscountRegionsRegion - summary: Adds Region availability - description: Adds a Region to the list of Regions that a Discount can be used in. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: region_id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - delete: - operationId: DeleteDiscountsDiscountRegionsRegion - summary: Remove Region availability - description: >- - Removes a Region from the list of Regions that a Discount can be used - in. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: region_id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/products/{product_id}': - post: - operationId: DeleteDiscountsDiscountProductsProduct - summary: Remove Product availability - description: >- - Removes a Product from the list of Products that a Discount can be used - for. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - - in: path - name: product_id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - /discounts: - post: - operationId: PostDiscounts - summary: Creates a Discount - description: >- - Creates a Discount with a given set of rules that define how the - Discount behaves. - requestBody: - content: - application/json: - schema: - properties: - code: - type: string - description: A unique code that will be used to redeem the Discount - is_dynamic: - type: string - description: >- - Whether the Discount should have multiple instances of - itself, each with a different code. This can be useful for - automatically generated codes that all have to follow a - common set of rules. - rule: - description: The Discount Rule that defines how Discounts are calculated - oneOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - type: boolean - description: >- - Whether the Discount code is disabled on creation. You will - have to enable it later to make it available to Customers. - starts_at: - type: string - format: date-time - description: The time at which the Discount should be available. - ends_at: - type: string - format: date-time - description: >- - The time at which the Discount should no longer be - available. - regions: - description: >- - A list of Region ids representing the Regions in which the - Discount can be used. - type: array - items: - type: string - usage_limit: - type: number - description: Maximum times the discount can be used - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - get: - operationId: GetDiscounts - summary: List Discounts - description: Retrieves a list of Discounts - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/dynamic-codes': - post: - operationId: PostDiscountsDiscountDynamicCodes - summary: Create a dynamic Discount code - description: >- - Creates a unique code that can map to a parent Discount. This is useful - if you want to automatically generate codes with the same behaviour. - parameters: - - in: path - name: id - required: true - description: The id of the Discount to create the dynamic code from." - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - requestBody: - content: - application/json: - schema: - type: object - required: - - code - properties: - code: - type: string - description: The unique code that will be used to redeem the Discount. - metadata: - type: object - description: >- - An optional set of key-value paris to hold additional - information. - '/discounts/{id}': - delete: - operationId: DeleteDiscountsDiscount - summary: Delete a Discount - description: Deletes a Discount. - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - id: - type: string - description: The id of the deleted Discount - object: - type: string - description: The type of the object that was deleted. - deleted: - type: boolean - get: - operationId: GetDiscountsDiscount - summary: Retrieve a Discount - description: Retrieves a Discount - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - post: - operationId: PostDiscountsDiscount - summary: Update a Discount - description: >- - Updates a Discount with a given set of rules that define how the - Discount behaves. - parameters: - - in: path - name: id - required: true - description: The id of the Discount. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - code: - type: string - description: A unique code that will be used to redeem the Discount - is_dynamic: - type: string - description: >- - Whether the Discount should have multiple instances of - itself, each with a different code. This can be useful for - automatically generated codes that all have to follow a - common set of rules. - rule: - description: The Discount Rule that defines how Discounts are calculated - oneOf: - - $ref: '#/components/schemas/discount_rule' - is_disabled: - type: boolean - description: >- - Whether the Discount code is disabled on creation. You will - have to enable it later to make it available to Customers. - starts_at: - type: string - format: date-time - description: The time at which the Discount should be available. - ends_at: - type: string - format: date-time - description: >- - The time at which the Discount should no longer be - available. - regions: - description: >- - A list of Region ids representing the Regions in which the - Discount can be used. - type: array - items: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/{id}/dynamic-codes/{code}': - delete: - operationId: DeleteDiscountsDiscountDynamicCodesCode - summary: Delete a dynamic code - description: Deletes a dynamic code from a Discount. - parameters: - - in: path - name: id - required: true - description: The id of the Discount - schema: - type: string - - in: path - name: code - required: true - description: The id of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' - '/discounts/code/{id}': - get: - operationId: GetDiscountsDiscountCode - summary: Retrieve a Discount by code - description: Retrieves a Discount by its discount code - parameters: - - in: path - name: code - required: true - description: The code of the Discount - schema: - type: string - tags: - - Discount - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - discount: - $ref: '#/components/schemas/discount' /collections: post: operationId: PostCollections @@ -721,174 +340,230 @@ paths: properties: customer: $ref: '#/components/schemas/customer' - /draft-orders: + '/discounts/{id}/regions/{region_id}': post: - operationId: PostDraftOrders - summary: Create a Draft Order - description: Creates a Draft Order - requestBody: - content: - application/json: - schema: - properties: - status: - description: The status of the draft order - type: string - email: - description: The email of the customer of the draft order - type: string - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - shipping_address: - description: The Address to be used for shipping. - anyOf: - - $ref: '#/components/schemas/address' - items: - description: The Line Items that have been received. - type: array - items: - properties: - variant_id: - description: >- - The id of the Product Variant to generate the Line - Item from. - type: string - unit_price: - description: The potential custom price of the item. - type: integer - title: - description: The potential custom title of the item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - metadata: - description: >- - The optional key-value map with additional details - about the Line Item. - type: object - region_id: - description: The id of the region for the draft order - type: string - discounts: - description: The discounts to add on the draft order - type: array - items: - properties: - code: - description: The code of the discount to apply - type: string - customer_id: - description: The id of the customer to add on the draft order - type: string - no_notification_order: - description: >- - An optional flag passed to the resulting order to determine - use of notifications. - type: boolean - shipping_methods: - description: The shipping methods for the draft order - type: array - items: - properties: - option_id: - description: The id of the shipping option in use - type: string - data: - description: >- - The optional additional data needed for the shipping - method - type: object - price: - description: The potential custom price of the shipping - type: integer - metadata: - description: >- - The optional key-value map with additional details about the - Draft Order. - type: object - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' - get: - operationId: GetDraftOrders - summary: List Draft Orders - description: Retrieves an list of Draft Orders - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' - '/draft-orders/{id}/line-items': - post: - operationId: PostDraftOrdersDraftOrderLineItems - summary: Create a Line Item for Draft Order - description: Creates a Line Item for the Draft Order - requestBody: - content: - application/json: - schema: - properties: - variant_id: - description: >- - The id of the Product Variant to generate the Line Item - from. - type: string - unit_price: - description: The potential custom price of the item. - type: integer - title: - description: The potential custom title of the item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - metadata: - description: >- - The optional key-value map with additional details about the - Line Item. - type: object - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' - '/draft-orders/{id}': - delete: - operationId: DeleteDraftOrdersDraftOrder - summary: Delete a Draft Order - description: Deletes a Draft Order + operationId: PostDiscountsDiscountRegionsRegion + summary: Adds Region availability + description: Adds a Region to the list of Regions that a Discount can be used in. parameters: - in: path name: id required: true - description: The id of the Draft Order. + description: The id of the Discount. + schema: + type: string + - in: path + name: region_id + required: true + description: The id of the Region. schema: type: string tags: - - Draft Order + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + delete: + operationId: DeleteDiscountsDiscountRegionsRegion + summary: Remove Region availability + description: >- + Removes a Region from the list of Regions that a Discount can be used + in. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + - in: path + name: region_id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/products/{product_id}': + post: + operationId: DeleteDiscountsDiscountProductsProduct + summary: Remove Product availability + description: >- + Removes a Product from the list of Products that a Discount can be used + for. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string + - in: path + name: product_id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + /discounts: + post: + operationId: PostDiscounts + summary: Creates a Discount + description: >- + Creates a Discount with a given set of rules that define how the + Discount behaves. + requestBody: + content: + application/json: + schema: + properties: + code: + type: string + description: A unique code that will be used to redeem the Discount + is_dynamic: + type: string + description: >- + Whether the Discount should have multiple instances of + itself, each with a different code. This can be useful for + automatically generated codes that all have to follow a + common set of rules. + rule: + description: The Discount Rule that defines how Discounts are calculated + oneOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + type: boolean + description: >- + Whether the Discount code is disabled on creation. You will + have to enable it later to make it available to Customers. + starts_at: + type: string + format: date-time + description: The time at which the Discount should be available. + ends_at: + type: string + format: date-time + description: >- + The time at which the Discount should no longer be + available. + regions: + description: >- + A list of Region ids representing the Regions in which the + Discount can be used. + type: array + items: + type: string + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + get: + operationId: GetDiscounts + summary: List Discounts + description: Retrieves a list of Discounts + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/dynamic-codes': + post: + operationId: PostDiscountsDiscountDynamicCodes + summary: Create a dynamic Discount code + description: >- + Creates a unique code that can map to a parent Discount. This is useful + if you want to automatically generate codes with the same behaviour. + parameters: + - in: path + name: id + required: true + description: The id of the Discount to create the dynamic code from." + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' + requestBody: + content: + application/json: + schema: + type: object + required: + - code + properties: + code: + type: string + description: The unique code that will be used to redeem the Discount. + metadata: + type: object + description: >- + An optional set of key-value paris to hold additional + information. + '/discounts/{id}': + delete: + operationId: DeleteDiscountsDiscount + summary: Delete a Discount + description: Deletes a Discount. + parameters: + - in: path + name: id + required: true + description: The id of the Discount + schema: + type: string + tags: + - Discount responses: '200': description: OK @@ -898,25 +573,25 @@ paths: properties: id: type: string - description: The id of the deleted Draft Order. + description: The id of the deleted Discount object: type: string description: The type of the object that was deleted. deleted: type: boolean get: - operationId: GetDraftOrdersDraftOrder - summary: Retrieve a Draft Order - description: Retrieves a Draft Order. + operationId: GetDiscountsDiscount + summary: Retrieve a Discount + description: Retrieves a Discount parameters: - in: path name: id required: true - description: The id of the Draft Order. + description: The id of the Discount schema: type: string tags: - - Draft Order + - Discount responses: '200': description: OK @@ -924,143 +599,64 @@ paths: application/json: schema: properties: - draft_order: - $ref: '#/components/schemas/draft-order' - '/draft-orders/{id}/line-items/{line_id}': - delete: - operationId: DeleteDraftOrdersDraftOrderLineItemsItem - summary: Delete a Line Item - description: Removes a Line Item from a Draft Order. - parameters: - - in: path - name: id - required: true - description: The id of the Draft Order. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Draft Order. - schema: - type: string - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' + discount: + $ref: '#/components/schemas/discount' post: - operationId: PostDraftOrdersDraftOrderLineItemsItem - summary: Update a Line Item for a Draft Order - description: Updates a Line Item for a Draft Order + operationId: PostDiscountsDiscount + summary: Update a Discount + description: >- + Updates a Discount with a given set of rules that define how the + Discount behaves. + parameters: + - in: path + name: id + required: true + description: The id of the Discount. + schema: + type: string requestBody: content: application/json: schema: properties: - unit_price: - description: The potential custom price of the item. - type: integer - title: - description: The potential custom title of the item. + code: + type: string + description: A unique code that will be used to redeem the Discount + is_dynamic: type: string - quantity: - description: The quantity of the Line Item. - type: integer - metadata: description: >- - The optional key-value map with additional details about the - Line Item. - type: object - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' - '/draft-orders/{id}/register-payment': - post: - summary: Registers a payment for a Draft Order - operationId: PostDraftOrdersDraftOrderRegisterPayment - description: Registers a payment for a Draft Order. - parameters: - - in: path - name: id - required: true - description: The Draft Order id. - schema: - type: string - tags: - - Draft Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - draft_order: - $ref: '#/components/schemas/draft-order' - '/admin/draft-orders/{id}': - post: - operationId: PostDraftOrdersDraftOrder - summary: Update a Draft Order" - description: Updates a Draft Order. - parameters: - - in: path - name: id - required: true - description: The id of the Draft Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - region_id: + Whether the Discount should have multiple instances of + itself, each with a different code. This can be useful for + automatically generated codes that all have to follow a + common set of rules. + rule: + description: The Discount Rule that defines how Discounts are calculated + oneOf: + - $ref: '#/components/schemas/discount_rule' + is_disabled: + type: boolean + description: >- + Whether the Discount code is disabled on creation. You will + have to enable it later to make it available to Customers. + starts_at: type: string - description: The id of the Region to create the Draft Order in. - email: + format: date-time + description: The time at which the Discount should be available. + ends_at: type: string - description: An email to be used on the Draft Order. - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - shipping_address: - description: The Address to be used for shipping. - anyOf: - - $ref: '#/components/schemas/address' - discounts: - description: An array of Discount codes to add to the Draft Order. + format: date-time + description: >- + The time at which the Discount should no longer be + available. + regions: + description: >- + A list of Region ids representing the Regions in which the + Discount can be used. type: array items: - properties: - code: - description: The code that a Discount is identifed by. - type: string - no_notification_order: - description: >- - An optional flag passed to the resulting order to determine - use of notifications. - type: boolean - customer_id: - description: The id of the Customer to associate the Draft Order with. - type: string + type: string tags: - - Draft Order + - Discount responses: '200': description: OK @@ -1068,8 +664,37 @@ paths: application/json: schema: properties: - draft_order: - $ref: '#/components/schemas/draft-order' + discount: + $ref: '#/components/schemas/discount' + '/discounts/{id}/dynamic-codes/{code}': + delete: + operationId: DeleteDiscountsDiscountDynamicCodesCode + summary: Delete a dynamic code + description: Deletes a dynamic code from a Discount. + parameters: + - in: path + name: id + required: true + description: The id of the Discount + schema: + type: string + - in: path + name: code + required: true + description: The id of the Discount + schema: + type: string + tags: + - Discount + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + discount: + $ref: '#/components/schemas/discount' /gift-cards: post: operationId: PostGiftCards @@ -1285,6 +910,938 @@ paths: properties: notification: $ref: '#/components/schemas/notification' + '/orders/{id}/shipping-methods': + post: + operationId: PostOrdersOrderShippingMethods + summary: Add a Shipping Method + description: >- + Adds a Shipping Method to an Order. If another Shipping Method exists + with the same Shipping Profile, the previous Shipping Method will be + replaced. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + requestBody: + content: + application/json: + schema: + type: object + required: + - price + - option_id + - data + properties: + price: + type: integer + description: >- + The price (excluding VAT) that should be charged for the + Shipping Method + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping Method + from. + data: + type: object + description: >- + The data required for the Shipping Option to create a + Shipping Method. This will depend on the Fulfillment + Provider. + '/orders/{id}/cancel': + post: + operationId: PostOrdersOrderCancel + summary: Cancel an Order + description: >- + Registers an Order as canceled. This triggers a flow that will cancel + any created Fulfillments and Payments, may fail if the Payment or + Fulfillment Provider is unable to cancel the Payment/Fulfillment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/capture': + post: + operationId: PostOrdersOrderCapture + summary: Capture an Order + description: Captures all the Payments associated with an Order. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/shipments': + post: + operationId: PostOrdersOrderClaimsClaimShipments + summary: Create Claim Shipment + description: Registers a Claim Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims': + post: + operationId: PostOrdersOrderClaims + summary: Create a Claim + description: Creates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + type: + description: >- + The type of the Claim. This will determine how the Claim is + treated: `replace` Claims will result in a Fulfillment with + new items being created, while a `refund` Claim will refund + the amount paid for the claimed items. + type: string + enum: + - replace + - refund + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + return_shipping: + description: >- + Optional details for the Return Shipping Method, if the + items are to be sent back. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: >- + The new items to send to the Customer when the Claim type is + Replace. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + refund_amount: + description: >- + The amount to refund the Customer when the Claim type is + `refund`. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/fulfillments': + post: + operationId: PostOrdersOrderFulfillments + summary: Create a Fulfillment + description: >- + Creates a Fulfillment of an Order - will notify Fulfillment Providers to + prepare a shipment. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items to include in the Fulfillment. + type: array + items: + properties: + item_id: + description: The id of Line Item to fulfill. + type: string + quantity: + description: The quantity of the Line Item to fulfill. + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/shipment': + post: + operationId: PostOrdersOrderShipment + summary: Create a Shipment + description: Registers a Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/shipments': + post: + operationId: PostOrdersOrderSwapsSwapShipments + summary: Create Swap Shipment + description: Registers a Swap Fulfillment as shipped. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + fulfillment_id: + description: The id of the Fulfillment. + type: string + tracking_numbers: + description: The tracking numbers for the shipment. + type: array + items: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/swaps': + post: + operationId: PostOrdersOrderSwaps + summary: Create a Swap + description: >- + Creates a Swap. Swaps are used to handle Return of previously purchased + goods and Fulfillment of replacements simultaneously. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + return_items: + description: The Line Items to return as part of the Swap. + type: array + items: + properties: + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + return_shipping: + description: How the Swap will be returned. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + additional_items: + description: The new items to send to the Customer. + type: array + items: + properties: + variant_id: + description: The id of the Product Variant to ship. + type: string + quantity: + description: The quantity of the Product Variant to ship. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/metadata/{key}': + delete: + operationId: DeleteOrdersOrderMetadataKey + summary: Delete Metadata + description: Deletes a metadata key. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: key + required: true + description: The metadata key. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/claims/{claim_id}/fulfillments': + post: + operationId: PostOrdersOrderClaimsClaimFulfillments + summary: Create a Claim Fulfillment + description: Creates a Fulfillment for a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/fulfillments': + post: + operationId: PostOrdersOrderSwapsSwapFulfillments + summary: Create a Swap Fulfillment + description: Creates a Fulfillment for a Swap. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}': + get: + operationId: GetOrdersOrder + summary: Retrieve an Order + description: Retrieves an Order + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + /orders: + get: + operationId: GetOrders + summary: List Orders + description: Retrieves a list of Orders + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + orders: + type: array + items: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/process-payment': + post: + operationId: PostOrdersOrderSwapsSwapProcessPayment + summary: Process a Swap difference + description: >- + When there are differences between the returned and shipped Products in + a Swap, the difference must be processed. Either a Refund will be issued + or a Payment will be captured. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns/{return_id}/receive': + post: + operationId: PostOrdersOrderReturnsReturnReceive + summary: Receive a Return + description: Registers a Return as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: return_id + required: true + description: The id of the Return. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/swaps/{swap_id}/receive': + post: + operationId: PostOrdersOrderSwapsSwapReceive + summary: Receive a Swap + description: Registers a Swap as received. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: swap_id + required: true + description: The id of the Swap. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that have been received. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/refunds': + post: + operationId: PostOrdersOrderRefunds + summary: Create a Refund + description: Issues a Refund. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + required: + - amount + - reason + properties: + amount: + description: The amount to refund. + type: integer + reason: + description: The reason for the Refund. + type: string + note: + description: A not with additional details about the Refund. + type: string + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/orders/{id}/returns': + post: + operationId: PostOrdersOrderReturns + summary: Request a Return + description: >- + Requests a Return. If applicable a return label will be created and + other plugins notified. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + items: + description: The Line Items that will be returned. + type: array + items: + properties: + item_id: + description: The id of the Line Item. + type: string + reason_id: + description: The id of the Return Reason to use. + type: string + note: + description: An optional note with information about the Return. + type: string + quantity: + description: The quantity of the Line Item. + type: integer + return_shipping: + description: >- + The Shipping Method to be used to handle the return + shipment. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + price: + type: integer + description: The price to charge for the Shipping Method. + receive_now: + description: >- + A flag to indicate if the Return should be registerd as + received immediately. + type: boolean + refund: + description: The amount to refund. + type: integer + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' + '/order/{id}/claims/{claim_id}': + post: + operationId: PostOrdersOrderClaimsClaim + summary: Update a Claim + description: Updates a Claim. + parameters: + - in: path + name: id + required: true + description: The id of the Order. + schema: + type: string + - in: path + name: claim_id + required: true + description: The id of the Claim. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + claim_items: + description: The Claim Items that the Claim will consist of. + type: array + items: + properties: + id: + description: The id of the Claim Item. + type: string + item_id: + description: The id of the Line Item that will be claimed. + type: string + quantity: + description: The number of items that will be returned + type: integer + note: + description: >- + Short text describing the Claim Item in further + detail. + type: string + reason: + description: The reason for the Claim + type: string + enum: + - missing_item + - wrong_item + - production_failure + - other + tags: + description: A list o tags to add to the Claim Item + type: array + items: + type: string + images: + description: >- + A list of image URL's that will be associated with the + Claim + items: + type: string + shipping_methods: + description: The Shipping Methods to send the additional Line Items with. + type: array + items: + properties: + id: + description: The id of an existing Shipping Method + type: string + option_id: + description: >- + The id of the Shipping Option to create a Shipping + Method from + type: string + price: + description: The price to charge for the Shipping Method + type: integer + metadata: + description: >- + An optional set of key-value pairs to hold additional + information. + type: object + tags: + - Order + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + order: + $ref: '#/components/schemas/order' '/products/{id}/options': post: operationId: PostProductsProductOptions @@ -2190,188 +2747,6 @@ paths: type: array items: $ref: '#/components/schemas/product_type' - /returns: - get: - operationId: GetReturns - summary: List Returns - description: Retrieves a list of Returns - tags: - - Return - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - returns: - type: array - items: - $ref: '#/components/schemas/return' - '/returns/{id}receive': - post: - operationId: PostReturnsReturnReceive - summary: Receive a Return - description: >- - Registers a Return as received. Updates statuses on Orders and Swaps - accordingly. - parameters: - - in: path - name: id - required: true - description: The id of the Return. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - refund: - description: The amount to refund. - type: integer - tags: - - Return - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return: - $ref: '#/components/schemas/return' - /return-reasons: - post: - operationId: PostReturnReasons - summary: Create a Return Reason - description: Creates a Return Reason - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - get: - operationId: GetReturnReasons - summary: List Return Reasons - description: Retrieves a list of Return Reasons. - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reasons: - type: array - items: - $ref: '#/components/schemas/return_reason' - '/return-reasons/{id}': - get: - operationId: GetReturnReasonsReason - summary: Retrieve a Return Reason - description: Retrieves a Return Reason. - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' - post: - operationId: PostReturnReasonsReason - summary: Update a Return Reason - description: Updates a Return Reason - parameters: - - in: path - name: id - required: true - description: The id of the Return Reason. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - label: - description: The label to display to the Customer. - type: string - value: - description: >- - The value that the Return Reason will be identified by. Must - be unique. - type: string - description: - description: An optional description to for the Reason. - type: string - metadata: - description: >- - An optional set of key-value pairs with additional - information. - type: object - tags: - - Return Reason - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - return_reason: - $ref: '#/components/schemas/return_reason' '/regions/{id}/countries': post: operationId: PostRegionsRegionCountries @@ -2784,276 +3159,34 @@ paths: properties: region: $ref: '#/components/schemas/region' - '/orders/{id}/shipping-methods': + /return-reasons: post: - operationId: PostOrdersOrderShippingMethods - summary: Add a Shipping Method - description: >- - Adds a Shipping Method to an Order. If another Shipping Method exists - with the same Shipping Profile, the previous Shipping Method will be - replaced. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - requestBody: - content: - application/json: - schema: - type: object - required: - - price - - option_id - - data - properties: - price: - type: integer - description: >- - The price (excluding VAT) that should be charged for the - Shipping Method - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping Method - from. - data: - type: object - description: >- - The data required for the Shipping Option to create a - Shipping Method. This will depend on the Fulfillment - Provider. - '/orders/{id}/cancel': - post: - operationId: PostOrdersOrderCancel - summary: Cancel an Order - description: >- - Registers an Order as canceled. This triggers a flow that will cancel - any created Fulfillments and Payments, may fail if the Payment or - Fulfillment Provider is unable to cancel the Payment/Fulfillment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/capture': - post: - operationId: PostOrdersOrderCapture - summary: Capture an Order - description: Captures all the Payments associated with an Order. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/shipments': - post: - operationId: PostOrdersOrderClaimsClaimShipments - summary: Create Claim Shipment - description: Registers a Claim Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string + operationId: PostReturnReasons + summary: Create a Return Reason + description: Creates a Return Reason requestBody: content: application/json: schema: properties: - fulfillment_id: - description: The id of the Fulfillment. + label: + description: The label to display to the Customer. type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims': - post: - operationId: PostOrdersOrderClaims - summary: Create a Claim - description: Creates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - type: + value: description: >- - The type of the Claim. This will determine how the Claim is - treated: `replace` Claims will result in a Fulfillment with - new items being created, while a `refund` Claim will refund - the amount paid for the claimed items. + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - enum: - - replace - - refund - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - return_shipping: - description: >- - Optional details for the Return Shipping Method, if the - items are to be sent back. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: >- - The new items to send to the Customer when the Claim type is - Replace. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - shipping_address: - type: object - description: >- - An optional shipping address to send the claim to. Defaults - to the parent order's shipping address - refund_amount: - description: >- - The amount to refund the Customer when the Claim type is - `refund`. - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Claim. - type: boolean metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -3061,332 +3194,14 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/fulfillments': - post: - operationId: PostOrdersOrderFulfillments - summary: Create a Fulfillment - description: >- - Creates a Fulfillment of an Order - will notify Fulfillment Providers to - prepare a shipment. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items to include in the Fulfillment. - type: array - items: - properties: - item_id: - description: The id of Line Item to fulfill. - type: string - quantity: - description: The quantity of the Line Item to fulfill. - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/shipment': - post: - operationId: PostOrdersOrderShipment - summary: Create a Shipment - description: Registers a Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - no_notification: - description: >- - If set to true no notification will be send related to this - Claim. - type: boolean - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/shipments': - post: - operationId: PostOrdersOrderSwapsSwapShipments - summary: Create Swap Shipment - description: Registers a Swap Fulfillment as shipped. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - fulfillment_id: - description: The id of the Fulfillment. - type: string - tracking_numbers: - description: The tracking numbers for the shipment. - type: array - items: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/swaps': - post: - operationId: PostOrdersOrderSwaps - summary: Create a Swap - description: >- - Creates a Swap. Swaps are used to handle Return of previously purchased - goods and Fulfillment of replacements simultaneously. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - return_items: - description: The Line Items to return as part of the Swap. - type: array - items: - properties: - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - return_shipping: - description: How the Swap will be returned. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - additional_items: - description: The new items to send to the Customer. - type: array - items: - properties: - variant_id: - description: The id of the Product Variant to ship. - type: string - quantity: - description: The quantity of the Product Variant to ship. - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/metadata/{key}': - delete: - operationId: DeleteOrdersOrderMetadataKey - summary: Delete Metadata - description: Deletes a metadata key. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: key - required: true - description: The metadata key. - schema: - type: string - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/claims/{claim_id}/fulfillments': - post: - operationId: PostOrdersOrderClaimsClaimFulfillments - summary: Create a Claim Fulfillment - description: Creates a Fulfillment for a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/fulfillments': - post: - operationId: PostOrdersOrderSwapsSwapFulfillments - summary: Create a Swap Fulfillment - description: Creates a Fulfillment for a Swap. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - metadata: - description: >- - An optional set of key-value pairs to hold additional - information. - type: object - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}': + return_reason: + $ref: '#/components/schemas/return_reason' get: - operationId: GetOrdersOrder - summary: Retrieve an Order - description: Retrieves an Order - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string + operationId: GetReturnReasons + summary: List Return Reasons + description: Retrieves a list of Return Reasons. tags: - - Order + - Return Reason responses: '200': description: OK @@ -3394,49 +3209,24 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - /orders: - get: - operationId: GetOrders - summary: List Orders - description: Retrieves a list of Orders - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - orders: + return_reasons: type: array items: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/process-payment': - post: - operationId: PostOrdersOrderSwapsSwapProcessPayment - summary: Process a Swap difference - description: >- - When there are differences between the returned and shipped Products in - a Swap, the difference must be processed. Either a Refund will be issued - or a Payment will be captured. + $ref: '#/components/schemas/return_reason' + '/return-reasons/{id}': + get: + operationId: GetReturnReasonsReason + summary: Retrieve a Return Reason + description: Retrieves a Return Reason. parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string tags: - - Order + - Return Reason responses: '200': description: OK @@ -3444,24 +3234,17 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/swaps/{swap_id}/receive': + return_reason: + $ref: '#/components/schemas/return_reason' post: - operationId: PostOrdersOrderSwapsSwapReceive - summary: Receive a Swap - description: Registers a Swap as received. + operationId: PostReturnReasonsReason + summary: Update a Return Reason + description: Updates a Return Reason parameters: - in: path name: id required: true - description: The id of the Order. - schema: - type: string - - in: path - name: swap_id - required: true - description: The id of the Swap. + description: The id of the Return Reason. schema: type: string requestBody: @@ -3469,236 +3252,24 @@ paths: application/json: schema: properties: - items: - description: The Line Items that have been received. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/refunds': - post: - operationId: PostOrdersOrderRefunds - summary: Create a Refund - description: Issues a Refund. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - required: - - amount - - reason - properties: - amount: - description: The amount to refund. - type: integer - reason: - description: The reason for the Refund. + label: + description: The label to display to the Customer. type: string - note: - description: A not with additional details about the Refund. + value: + description: >- + The value that the Return Reason will be identified by. Must + be unique. + type: string + description: + description: An optional description to for the Reason. type: string - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/orders/{id}/returns': - post: - operationId: PostOrdersOrderReturns - summary: Request a Return - description: >- - Requests a Return. If applicable a return label will be created and - other plugins notified. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - items: - description: The Line Items that will be returned. - type: array - items: - properties: - item_id: - description: The id of the Line Item. - type: string - reason_id: - description: The id of the Return Reason to use. - type: string - note: - description: An optional note with information about the Return. - type: string - quantity: - description: The quantity of the Line Item. - type: integer - return_shipping: - description: >- - The Shipping Method to be used to handle the return - shipment. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. - price: - type: integer - description: The price to charge for the Shipping Method. - receive_now: - description: >- - A flag to indicate if the Return should be registerd as - received immediately. - type: boolean - no_notification: - description: >- - A flag to indicate if no notifications should be emitted - related to the requested Return. - type: boolean - refund: - description: The amount to refund. - type: integer - tags: - - Order - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - order: - $ref: '#/components/schemas/order' - '/order/{id}/claims/{claim_id}': - post: - operationId: PostOrdersOrderClaimsClaim - summary: Update a Claim - description: Updates a Claim. - parameters: - - in: path - name: id - required: true - description: The id of the Order. - schema: - type: string - - in: path - name: claim_id - required: true - description: The id of the Claim. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - claim_items: - description: The Claim Items that the Claim will consist of. - type: array - items: - properties: - id: - description: The id of the Claim Item. - type: string - item_id: - description: The id of the Line Item that will be claimed. - type: string - quantity: - description: The number of items that will be returned - type: integer - note: - description: >- - Short text describing the Claim Item in further - detail. - type: string - reason: - description: The reason for the Claim - type: string - enum: - - missing_item - - wrong_item - - production_failure - - other - tags: - description: A list o tags to add to the Claim Item - type: array - items: - type: string - images: - description: >- - A list of image URL's that will be associated with the - Claim - items: - type: string - shipping_methods: - description: The Shipping Methods to send the additional Line Items with. - type: array - items: - properties: - id: - description: The id of an existing Shipping Method - type: string - option_id: - description: >- - The id of the Shipping Option to create a Shipping - Method from - type: string - price: - description: The price to charge for the Shipping Method - type: integer - no_notification: - description: >- - If set to true no notification will be send related to this - Swap. - type: boolean metadata: description: >- - An optional set of key-value pairs to hold additional + An optional set of key-value pairs with additional information. type: object tags: - - Order + - Return Reason responses: '200': description: OK @@ -3706,8 +3277,26 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + return_reason: + $ref: '#/components/schemas/return_reason' + /returns: + get: + operationId: GetReturns + summary: List Returns + description: Retrieves a list of Returns + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + returns: + type: array + items: + $ref: '#/components/schemas/return' /shipping-options: post: operationId: PostShippingOptions @@ -4431,11 +4020,6 @@ components: deleted_at: type: string format: date-time - no_notification: - description: >- - Flag for describing whether or not notifications related to this - should be send. - type: boolean metadata: type: object claim_tag: @@ -4583,6 +4167,9 @@ components: type: array items: $ref: '#/components/schemas/product' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4645,12 +4232,6 @@ components: type: array items: $ref: '#/components/schemas/region' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer - usage_count: - description: The number of times a discount has been used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -4666,51 +4247,6 @@ components: metadata: description: An optional key-value map with additional information. type: object - draft-order: - title: DraftOrder - description: Represents a draft order - x-resourceId: draft-order - properties: - id: - type: string - status: - type: string - enum: - - open - - completed - display_id: - type: string - cart_id: - type: string - cart: - anyOf: - - $ref: '#/components/schemas/cart' - order_id: - type: string - order: - anyOf: - - $ref: '#/components/schemas/order' - canceled_at: - type: string - format: date-time - created_at: - type: string - format: date-time - update_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - completed_at: - type: string - format: date-time - no_notification_order: - type: boolean - metadata: - type: object - idempotency_key: - type: string fulfillment_item: title: Fulfillment Item description: >- @@ -5329,13 +4865,6 @@ components: type: integer gift_card_total: type: integer - paid_total: - type: integer - no_notification: - description: >- - Flag for describing whether or not notifications related to this - should be send. - type: boolean payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. @@ -6141,11 +5670,6 @@ components: description: The date with timezone at which the resource was last updated. type: string format: date-time - no_notification: - description: >- - When set to true, no notification will be sent related to this - return. - type: boolean metadata: description: An optional key-value map with additional information. type: object @@ -6506,9 +6030,6 @@ components: description: The date with timezone at which the resource was last updated. type: string format: date-time - no_notification: - description: 'If set to true, no notification will be sent related to this swap' - type: boolean metadata: description: An optional key-value map with additional information. type: object diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index 9fcf3c6e85..5727ac1234 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -258,7 +258,7 @@ } } }, - "/carts/{id}/complete": { + "/carts/{id}/complete-cart": { "post": { "summary": "Complete a Cart", "operationId": "PostCartsCartComplete", @@ -673,9 +673,9 @@ } }, "post": { - "operationId": "PostCartsCartPaymentSessionUpdate", - "summary": "Update a Payment Session", - "description": "Updates a Payment Session with additional data.", + "operationId": "PostCartsCartPaymentSessionsSession", + "summary": "Refresh a Payment Session", + "description": "Refreshes a Payment Session to ensure that it is in sync with the Cart - this is usually not necessary.", "parameters": [ { "in": "path", @@ -690,7 +690,7 @@ "in": "path", "name": "provider_id", "required": true, - "description": "The id of the payment provider.", + "description": "The id of the Payment Provider that created the Payment Session to be refreshed.", "schema": { "type": "string" } @@ -714,29 +714,6 @@ } } } - }, - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "provider_id", - "data" - ], - "properties": { - "provider_id": { - "type": "string", - "description": "The id of the Payment Provider responsible for the Payment Session to update." - }, - "data": { - "type": "object", - "description": "The data to update the payment session with." - } - } - } - } - } } } }, @@ -939,24 +916,24 @@ } } }, - "/gift-cards/{code}": { - "get": { - "operationId": "GetGiftCardsCode", - "summary": "Retrieve Gift Card by Code", - "description": "Retrieves a Gift Card by its associated unqiue code.", + "/carts/{id}/payment-session/update": { + "post": { + "operationId": "PostCartsCartPaymentSessionUpdate", + "summary": "Update a Payment Session", + "description": "Updates a Payment Session with additional data.", "parameters": [ { "in": "path", - "name": "code", + "name": "id", "required": true, - "description": "The unique Gift Card code.", + "description": "The id of the Cart.", "schema": { "type": "string" } } ], "tags": [ - "Gift Card" + "Cart" ], "responses": { "200": { @@ -965,26 +942,37 @@ "application/json": { "schema": { "properties": { - "id": { - "description": "The id of the Gift Card" - }, - "code": { - "description": "The code of the Gift Card" - }, - "value": { - "description": "The original value of the Gift Card." - }, - "balance": { - "description": "The current balanace of the Gift Card" - }, - "region": { - "$ref": "#/components/schemas/region" + "cart": { + "$ref": "#/components/schemas/cart" } } } } } } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "provider_id", + "data" + ], + "properties": { + "provider_id": { + "type": "string", + "description": "The id of the Payment Provider responsible for the Payment Session to update." + }, + "data": { + "type": "object", + "description": "The data to update the payment session with." + } + } + } + } + } } } }, @@ -1493,24 +1481,24 @@ } } }, - "/orders/cart/{cart_id}": { + "/gift-cards/{code}": { "get": { - "operationId": "GetOrdersOrderCartId", - "summary": "Retrieves Order by Cart id", - "description": "Retrieves an Order by the id of the Cart that was used to create the Order.", + "operationId": "GetGiftCardsCode", + "summary": "Retrieve Gift Card by Code", + "description": "Retrieves a Gift Card by its associated unqiue code.", "parameters": [ { "in": "path", - "name": "cart_id", + "name": "code", "required": true, - "description": "The id of Cart.", + "description": "The unique Gift Card code.", "schema": { "type": "string" } } ], "tags": [ - "Order" + "Gift Card" ], "responses": { "200": { @@ -1519,91 +1507,20 @@ "application/json": { "schema": { "properties": { - "order": { - "$ref": "#/components/schemas/order" - } - } - } - } - } - } - } - } - }, - "/orders/{id}": { - "get": { - "operationId": "GetOrdersOrder", - "summary": "Retrieves an Order", - "description": "Retrieves an Order", - "parameters": [ - { - "in": "path", - "name": "id", - "required": true, - "description": "The id of the Order.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "customer": { - "$ref": "#/components/schemas/customer" - } - } - } - } - } - } - } - } - }, - "/orders": { - "get": { - "operationId": "GetOrders", - "summary": "Look Up an Order", - "description": "Looks for an Order with a given `display_id`, `email` pair. The `display_id`, `email` pair must match in order for the Order to be returned.", - "parameters": [ - { - "in": "query", - "name": "display_id", - "required": true, - "description": "The display id given to the Order.", - "schema": { - "type": "number" - } - }, - { - "in": "query", - "name": "email", - "required": true, - "description": "The email of the Order with the given display_id.", - "schema": { - "type": "string" - } - } - ], - "tags": [ - "Order" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "order": { - "$ref": "#/components/schemas/order" + "id": { + "description": "The id of the Gift Card" + }, + "code": { + "description": "The code of the Gift Card" + }, + "value": { + "description": "The original value of the Gift Card." + }, + "balance": { + "description": "The current balanace of the Gift Card" + }, + "region": { + "$ref": "#/components/schemas/region" } } } @@ -1691,72 +1608,6 @@ } } }, - "/returns": { - "post": { - "operationId": "PostReturns", - "summary": "Create Return", - "description": "Creates a Return for an Order.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "order_id": { - "type": "string", - "description": "The id of the Order to create the Return from." - }, - "items": { - "description": "The items to include in the Return.", - "type": "array", - "items": { - "properties": { - "item_id": { - "description": "The id of the Line Item from the Order.", - "type": "string" - }, - "quantity": { - "description": "The quantity to return.", - "type": "integer" - } - } - } - }, - "return_shipping": { - "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", - "type": "object", - "properties": { - "option_id": { - "type": "string", - "description": "The id of the Shipping Option to create the Shipping Method from." - } - } - } - } - } - } - } - }, - "tags": [ - "Return" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "properties": { - "return": { - "$ref": "#/components/schemas/return" - } - } - } - } - } - } - } - } - }, "/return-reasons/{id}": { "get": { "operationId": "GetReturnReasonsReason", @@ -1901,24 +1752,24 @@ } } }, - "/swaps/{cart_id}": { + "/orders/cart/{cart_id}": { "get": { - "operationId": "GetSwapsSwapCartId", - "summary": "Retrieve Swap by Cart id", - "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", + "operationId": "GetOrdersOrderCartId", + "summary": "Retrieves Order by Cart id", + "description": "Retrieves an Order by the id of the Cart that was used to create the Order.", "parameters": [ { "in": "path", "name": "cart_id", "required": true, - "description": "The id of the Cart", + "description": "The id of Cart.", "schema": { "type": "string" } } ], "tags": [ - "Swap" + "Order" ], "responses": { "200": { @@ -1927,8 +1778,157 @@ "application/json": { "schema": { "properties": { - "swap": { - "$ref": "#/components/schemas/swap" + "order": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + }, + "/orders/{id}": { + "get": { + "operationId": "GetOrdersOrder", + "summary": "Retrieves an Order", + "description": "Retrieves an Order", + "parameters": [ + { + "in": "path", + "name": "id", + "required": true, + "description": "The id of the Order.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "customer": { + "$ref": "#/components/schemas/customer" + } + } + } + } + } + } + } + } + }, + "/orders": { + "get": { + "operationId": "GetOrders", + "summary": "Look Up an Order", + "description": "Looks for an Order with a given `display_id`, `email` pair. The `display_id`, `email` pair must match in order for the Order to be returned.", + "parameters": [ + { + "in": "query", + "name": "display_id", + "required": true, + "description": "The display id given to the Order.", + "schema": { + "type": "number" + } + }, + { + "in": "query", + "name": "email", + "required": true, + "description": "The email of the Order with the given display_id.", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Order" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "order": { + "$ref": "#/components/schemas/order" + } + } + } + } + } + } + } + } + }, + "/returns": { + "post": { + "operationId": "PostReturns", + "summary": "Create Return", + "description": "Creates a Return for an Order.", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "order_id": { + "type": "string", + "description": "The id of the Order to create the Return from." + }, + "items": { + "description": "The items to include in the Return.", + "type": "array", + "items": { + "properties": { + "item_id": { + "description": "The id of the Line Item from the Order.", + "type": "string" + }, + "quantity": { + "description": "The quantity to return.", + "type": "integer" + } + } + } + }, + "return_shipping": { + "description": "If the Return is to be handled by the store operator the Customer can choose a Return Shipping Method. Alternatvely the Customer can handle the Return themselves.", + "type": "object", + "properties": { + "option_id": { + "type": "string", + "description": "The id of the Shipping Option to create the Shipping Method from." + } + } + } + } + } + } + } + }, + "tags": [ + "Return" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "return": { + "$ref": "#/components/schemas/return" } } } @@ -2033,6 +2033,43 @@ } } }, + "/swaps/{cart_id}": { + "get": { + "operationId": "GetSwapsSwapCartId", + "summary": "Retrieve Swap by Cart id", + "description": "Retrieves a Swap by the id of the Cart used to confirm the Swap.", + "parameters": [ + { + "in": "path", + "name": "cart_id", + "required": true, + "description": "The id of the Cart", + "schema": { + "type": "string" + } + } + ], + "tags": [ + "Swap" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "properties": { + "swap": { + "$ref": "#/components/schemas/swap" + } + } + } + } + } + } + } + } + }, "/variants/{variant_id}": { "get": { "operationId": "GetVariantsVariant", @@ -2468,10 +2505,6 @@ "type": "string", "format": "date-time" }, - "no_notification": { - "description": "Flag for describing whether or not notifications related to this should be send.", - "type": "boolean" - }, "metadata": { "type": "object" } @@ -2663,6 +2696,10 @@ "$ref": "#/components/schemas/product" } }, + "usage_limit": { + "description": "The maximum number of times that a discount can be used.", + "type": "integer" + }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2734,14 +2771,6 @@ "$ref": "#/components/schemas/region" } }, - "usage_limit": { - "description": "The maximum number of times that a discount can be used.", - "type": "integer" - }, - "usage_count": { - "description": "The number of times a discount has been used.", - "type": "integer" - }, "created_at": { "description": "The date with timezone at which the resource was created.", "type": "string", @@ -2763,75 +2792,6 @@ } } }, - "draft-order": { - "title": "DraftOrder", - "description": "Represents a draft order", - "x-resourceId": "draft-order", - "properties": { - "id": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "open", - "completed" - ] - }, - "display_id": { - "type": "string" - }, - "cart_id": { - "type": "string" - }, - "cart": { - "anyOf": [ - { - "$ref": "#/components/schemas/cart" - } - ] - }, - "order_id": { - "type": "string" - }, - "order": { - "anyOf": [ - { - "$ref": "#/components/schemas/order" - } - ] - }, - "canceled_at": { - "type": "string", - "format": "date-time" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "update_at": { - "type": "string", - "format": "date-time" - }, - "deleted_at": { - "type": "string", - "format": "date-time" - }, - "completed_at": { - "type": "string", - "format": "date-time" - }, - "no_notification_order": { - "type": "boolean" - }, - "metadata": { - "type": "object" - }, - "idempotency_key": { - "type": "string" - } - } - }, "fulfillment_item": { "title": "Fulfillment Item", "description": "Correlates a Line Item with a Fulfillment, keeping track of the quantity of the Line Item.", @@ -3585,13 +3545,6 @@ }, "gift_card_total": { "type": "integer" - }, - "paid_total": { - "type": "integer" - }, - "no_notification": { - "description": "Flag for describing whether or not notifications related to this should be send.", - "type": "boolean" } } }, @@ -4447,10 +4400,6 @@ "type": "string", "format": "date-time" }, - "no_notification": { - "description": "When set to true, no notification will be sent related to this return.", - "type": "boolean" - }, "metadata": { "description": "An optional key-value map with additional information.", "type": "object" @@ -4829,10 +4778,6 @@ "type": "string", "format": "date-time" }, - "no_notification": { - "description": "If set to true, no notification will be sent related to this swap", - "type": "boolean" - }, "metadata": { "description": "An optional key-value map with additional information.", "type": "object" diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 3ac9dc6bd0..43e7a49d17 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -121,6 +121,539 @@ paths: properties: exists: type: boolean + '/carts/{id}/shipping-methods': + post: + operationId: PostCartsCartShippingMethod + description: Adds a Shipping Method to the Cart. + summary: Add a Shipping Method + tags: + - Cart + parameters: + - in: path + name: id + required: true + description: The cart id. + schema: + type: string + responses: + '200': + description: A successful response + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - option_id + properties: + option_id: + type: string + description: id of the shipping option to create the method from + data: + type: object + description: >- + Used to hold any data that the shipping method may need to + process the fulfillment of the order. Look at the + documentation for your installed fulfillment providers to + find out what to send. + '/carts/{id}/complete-cart': + post: + summary: Complete a Cart + operationId: PostCartsCartComplete + description: >- + Completes a cart. The following steps will be performed. Payment + authorization is attempted and if more work is required, we simply + return the cart for further updates. If payment is authorized and order + is not yet created, we make sure to do so. The completion of a cart can + be performed idempotently with a provided header `Idempotency-Key`. If + not provided, we will generate one for the request. + parameters: + - in: path + name: id + required: true + description: The Cart id. + schema: + type: string + tags: + - Cart + responses: + '200': + description: >- + If a cart was successfully authorized, but requires further action + from the user the response body will contain the cart with an + updated payment session. If the Cart was successfully completed the + response body will contain the newly created Order. + content: + application/json: + schema: + oneOf: + - type: object + properties: + order: + $ref: '#/components/schemas/order' + - type: object + properties: + cart: + $ref: '#/components/schemas/cart' + /carts: + post: + summary: Create a Cart + operationId: PostCart + description: >- + Creates a Cart within the given region and with the initial items. If no + `region_id` is provided the cart will be associated with the first + Region available. If no items are provided the cart will be empty after + creation. If a user is logged in the cart's customer id and email will + be set. + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + items: + description: >- + An optional array of `variant_id`, `quantity` pairs to + generate Line Items from. + type: array + items: + properties: + variant_id: + description: >- + The id of the Product Variant to generate a Line Item + from. + type: string + quantity: + description: The quantity of the Product Variant to add + type: integer + context: + description: >- + An optional object to provide context to the Cart. The + `context` field is automatically populated with `ip` and + `user_agent` + type: object + tags: + - Cart + responses: + '200': + description: Successfully created a new Cart + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items': + post: + operationId: PostCartsCartLineItems + summary: Add a Line Item + description: >- + Generates a Line Item with a given Product Variant and adds it to the + Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart to add the Line Item to. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - variant_id + - quantity + properties: + variant_id: + type: string + description: >- + The id of the Product Variant to generate the Line Item + from. + quantity: + type: integer + description: The quantity of the Product Variant to add to the Line Item. + metadata: + type: object + description: >- + An optional key-value map with additional details about the + Line Item. + '/carts/{id}/payment-sessions': + post: + operationId: PostCartsCartPaymentSessions + summary: Initialize Payment Sessions + description: >- + Creates Payment Sessions for each of the available Payment Providers in + the Cart's Region. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/discounts/{code}': + delete: + operationId: DeleteCartsCartDiscountsDiscount + description: Removes a Discount from a Cart. + summary: Remove Discount from Cart + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: code + required: true + description: The unique Discount code. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/line-items/{line_id}': + delete: + operationId: DeleteCartsCartLineItemsItem + summary: Delete a Line Item + description: Removes a Line Item from a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartLineItemsItem + summary: Update a Line Item + description: Updates a Line Item if the desired quantity can be fulfilled. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: line_id + required: true + description: The id of the Line Item. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - quantity + properties: + quantity: + type: integer + description: The quantity to set the Line Item to. + '/carts/{id}/payment-sessions/{provider_id}': + delete: + operationId: DeleteCartsCartPaymentSessionsSession + summary: Delete a Payment Session + description: >- + Deletes a Payment Session on a Cart. May be useful if a payment has + failed. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: >- + The id of the Payment Provider used to create the Payment Session to + be deleted. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + post: + operationId: PostCartsCartPaymentSessionsSession + summary: Refresh a Payment Session + description: >- + Refreshes a Payment Session to ensure that it is in sync with the Cart - + this is usually not necessary. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + - in: path + name: provider_id + required: true + description: >- + The id of the Payment Provider that created the Payment Session to + be refreshed. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}': + get: + operationId: GetCartsCart + summary: Retrieve a Cart + description: Retrieves a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/payment-session': + post: + operationId: PostCartsCartPaymentSession + summary: Select a Payment Session + description: >- + Selects a Payment Session as the session intended to be used towards the + completion of the Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + properties: + provider_id: + type: string + description: The id of the Payment Provider. + '/store/carts/{id}': + post: + operationId: PostCartsCart + summary: Update a Cart" + description: Updates a Cart. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + region_id: + type: string + description: The id of the Region to create the Cart in. + country_code: + type: string + description: The 2 character ISO country code to create the Cart in. + email: + type: string + description: An email to be used on the Cart. + billing_address: + description: The Address to be used for billing purposes. + anyOf: + - $ref: '#/components/schemas/address' + shipping_address: + description: The Address to be used for shipping. + anyOf: + - $ref: '#/components/schemas/address' + gift_cards: + description: An array of Gift Card codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Gift Card is identified by. + type: string + discounts: + description: An array of Discount codes to add to the Cart. + type: array + items: + properties: + code: + description: The code that a Discount is identifed by. + type: string + customer_id: + description: The id of the Customer to associate the Cart with. + type: string + context: + description: An optional object to provide context to the Cart. + type: object + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + '/carts/{id}/payment-session/update': + post: + operationId: PostCartsCartPaymentSessionUpdate + summary: Update a Payment Session + description: Updates a Payment Session with additional data. + parameters: + - in: path + name: id + required: true + description: The id of the Cart. + schema: + type: string + tags: + - Cart + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + cart: + $ref: '#/components/schemas/cart' + requestBody: + content: + application/json: + schema: + type: object + required: + - provider_id + - data + properties: + provider_id: + type: string + description: >- + The id of the Payment Provider responsible for the Payment + Session to update. + data: + type: object + description: The data to update the payment session with. '/customers/{id}/addresses': post: operationId: PostCustomersCustomerAddresses @@ -453,512 +986,6 @@ paths: password: type: string description: The new password to set for the Customer. - '/carts/{id}/shipping-methods': - post: - operationId: PostCartsCartShippingMethod - description: Adds a Shipping Method to the Cart. - summary: Add a Shipping Method - tags: - - Cart - parameters: - - in: path - name: id - required: true - description: The cart id. - schema: - type: string - responses: - '200': - description: A successful response - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - option_id - properties: - option_id: - type: string - description: id of the shipping option to create the method from - data: - type: object - description: >- - Used to hold any data that the shipping method may need to - process the fulfillment of the order. Look at the - documentation for your installed fulfillment providers to - find out what to send. - '/carts/{id}/complete': - post: - summary: Complete a Cart - operationId: PostCartsCartComplete - description: >- - Completes a cart. The following steps will be performed. Payment - authorization is attempted and if more work is required, we simply - return the cart for further updates. If payment is authorized and order - is not yet created, we make sure to do so. The completion of a cart can - be performed idempotently with a provided header `Idempotency-Key`. If - not provided, we will generate one for the request. - parameters: - - in: path - name: id - required: true - description: The Cart id. - schema: - type: string - tags: - - Cart - responses: - '200': - description: >- - If a cart was successfully authorized, but requires further action - from the user the response body will contain the cart with an - updated payment session. If the Cart was successfully completed the - response body will contain the newly created Order. - content: - application/json: - schema: - oneOf: - - type: object - properties: - order: - $ref: '#/components/schemas/order' - - type: object - properties: - cart: - $ref: '#/components/schemas/cart' - /carts: - post: - summary: Create a Cart - operationId: PostCart - description: >- - Creates a Cart within the given region and with the initial items. If no - `region_id` is provided the cart will be associated with the first - Region available. If no items are provided the cart will be empty after - creation. If a user is logged in the cart's customer id and email will - be set. - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - items: - description: >- - An optional array of `variant_id`, `quantity` pairs to - generate Line Items from. - type: array - items: - properties: - variant_id: - description: >- - The id of the Product Variant to generate a Line Item - from. - type: string - quantity: - description: The quantity of the Product Variant to add - type: integer - context: - description: >- - An optional object to provide context to the Cart. The - `context` field is automatically populated with `ip` and - `user_agent` - type: object - tags: - - Cart - responses: - '200': - description: Successfully created a new Cart - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items': - post: - operationId: PostCartsCartLineItems - summary: Add a Line Item - description: >- - Generates a Line Item with a given Product Variant and adds it to the - Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart to add the Line Item to. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - variant_id - - quantity - properties: - variant_id: - type: string - description: >- - The id of the Product Variant to generate the Line Item - from. - quantity: - type: integer - description: The quantity of the Product Variant to add to the Line Item. - metadata: - type: object - description: >- - An optional key-value map with additional details about the - Line Item. - '/carts/{id}/payment-sessions': - post: - operationId: PostCartsCartPaymentSessions - summary: Initialize Payment Sessions - description: >- - Creates Payment Sessions for each of the available Payment Providers in - the Cart's Region. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/discounts/{code}': - delete: - operationId: DeleteCartsCartDiscountsDiscount - description: Removes a Discount from a Cart. - summary: Remove Discount from Cart - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: code - required: true - description: The unique Discount code. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/line-items/{line_id}': - delete: - operationId: DeleteCartsCartLineItemsItem - summary: Delete a Line Item - description: Removes a Line Item from a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartLineItemsItem - summary: Update a Line Item - description: Updates a Line Item if the desired quantity can be fulfilled. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: line_id - required: true - description: The id of the Line Item. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - quantity - properties: - quantity: - type: integer - description: The quantity to set the Line Item to. - '/carts/{id}/payment-sessions/{provider_id}': - delete: - operationId: DeleteCartsCartPaymentSessionsSession - summary: Delete a Payment Session - description: >- - Deletes a Payment Session on a Cart. May be useful if a payment has - failed. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: >- - The id of the Payment Provider used to create the Payment Session to - be deleted. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - post: - operationId: PostCartsCartPaymentSessionUpdate - summary: Update a Payment Session - description: Updates a Payment Session with additional data. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - - in: path - name: provider_id - required: true - description: The id of the payment provider. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - - data - properties: - provider_id: - type: string - description: >- - The id of the Payment Provider responsible for the Payment - Session to update. - data: - type: object - description: The data to update the payment session with. - '/carts/{id}': - get: - operationId: GetCartsCart - summary: Retrieve a Cart - description: Retrieves a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - '/carts/{id}/payment-session': - post: - operationId: PostCartsCartPaymentSession - summary: Select a Payment Session - description: >- - Selects a Payment Session as the session intended to be used towards the - completion of the Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' - requestBody: - content: - application/json: - schema: - type: object - required: - - provider_id - properties: - provider_id: - type: string - description: The id of the Payment Provider. - '/store/carts/{id}': - post: - operationId: PostCartsCart - summary: Update a Cart" - description: Updates a Cart. - parameters: - - in: path - name: id - required: true - description: The id of the Cart. - schema: - type: string - requestBody: - content: - application/json: - schema: - properties: - region_id: - type: string - description: The id of the Region to create the Cart in. - country_code: - type: string - description: The 2 character ISO country code to create the Cart in. - email: - type: string - description: An email to be used on the Cart. - billing_address: - description: The Address to be used for billing purposes. - anyOf: - - $ref: '#/components/schemas/address' - shipping_address: - description: The Address to be used for shipping. - anyOf: - - $ref: '#/components/schemas/address' - gift_cards: - description: An array of Gift Card codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Gift Card is identified by. - type: string - discounts: - description: An array of Discount codes to add to the Cart. - type: array - items: - properties: - code: - description: The code that a Discount is identifed by. - type: string - customer_id: - description: The id of the Customer to associate the Cart with. - type: string - context: - description: An optional object to provide context to the Cart. - type: object - tags: - - Cart - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - cart: - $ref: '#/components/schemas/cart' '/gift-cards/{code}': get: operationId: GetGiftCardsCode @@ -990,106 +1017,6 @@ paths: description: The current balanace of the Gift Card region: $ref: '#/components/schemas/region' - '/products/{id}': - get: - operationId: GetProductsProduct - summary: Retrieves a Product - description: Retrieves a Product. - parameters: - - in: path - name: id - required: true - description: The id of the Product. - schema: - type: string - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - product: - $ref: '#/components/schemas/product' - /products: - get: - operationId: GetProducts - summary: List Products - description: Retrieves a list of Products. - tags: - - Product - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - count: - description: The total number of Products. - type: integer - offset: - description: The offset for pagination. - type: integer - limit: - description: 'The maxmimum number of Products to return,' - type: integer - products: - type: array - items: - $ref: '#/components/schemas/product' - '/regions/{id}': - get: - operationId: GetRegionsRegion - summary: Retrieves a Region - description: Retrieves a Region. - parameters: - - in: path - name: id - required: true - description: The id of the Region. - schema: - type: string - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - region: - $ref: '#/components/schemas/region' - /regions: - get: - operationId: GetRegions - summary: List Regions - description: Retrieves a list of Regions. - tags: - - Region - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - count: - description: The total number of regions. - type: integer - offset: - description: The offset for pagination. - type: integer - limit: - description: 'The maxmimum number of regions to return,' - type: integer - regions: - type: array - items: - $ref: '#/components/schemas/region' '/orders/cart/{cart_id}': get: operationId: GetOrdersOrderCartId @@ -1170,6 +1097,56 @@ paths: properties: order: $ref: '#/components/schemas/order' + '/products/{id}': + get: + operationId: GetProductsProduct + summary: Retrieves a Product + description: Retrieves a Product. + parameters: + - in: path + name: id + required: true + description: The id of the Product. + schema: + type: string + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + product: + $ref: '#/components/schemas/product' + /products: + get: + operationId: GetProducts + summary: List Products + description: Retrieves a list of Products. + tags: + - Product + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + count: + description: The total number of Products. + type: integer + offset: + description: The offset for pagination. + type: integer + limit: + description: 'The maxmimum number of Products to return,' + type: integer + products: + type: array + items: + $ref: '#/components/schemas/product' '/return-reasons/{id}': get: operationId: GetReturnReasonsReason @@ -1211,6 +1188,103 @@ paths: type: array items: $ref: '#/components/schemas/return_reason' + '/regions/{id}': + get: + operationId: GetRegionsRegion + summary: Retrieves a Region + description: Retrieves a Region. + parameters: + - in: path + name: id + required: true + description: The id of the Region. + schema: + type: string + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + region: + $ref: '#/components/schemas/region' + /regions: + get: + operationId: GetRegions + summary: List Regions + description: Retrieves a list of Regions. + tags: + - Region + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + count: + description: The total number of regions. + type: integer + offset: + description: The offset for pagination. + type: integer + limit: + description: 'The maxmimum number of regions to return,' + type: integer + regions: + type: array + items: + $ref: '#/components/schemas/region' + /returns: + post: + operationId: PostReturns + summary: Create Return + description: Creates a Return for an Order. + requestBody: + content: + application/json: + schema: + properties: + order_id: + type: string + description: The id of the Order to create the Return from. + items: + description: The items to include in the Return. + type: array + items: + properties: + item_id: + description: The id of the Line Item from the Order. + type: string + quantity: + description: The quantity to return. + type: integer + return_shipping: + description: >- + If the Return is to be handled by the store operator the + Customer can choose a Return Shipping Method. Alternatvely + the Customer can handle the Return themselves. + type: object + properties: + option_id: + type: string + description: >- + The id of the Shipping Option to create the Shipping + Method from. + tags: + - Return + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + return: + $ref: '#/components/schemas/return' /shipping-options: get: operationId: GetShippingOptions @@ -1272,44 +1346,20 @@ paths: type: array items: $ref: '#/components/schemas/shipping_option' - /returns: - post: - operationId: PostReturns - summary: Create Return - description: Creates a Return for an Order. - requestBody: - content: - application/json: - schema: - properties: - order_id: - type: string - description: The id of the Order to create the Return from. - items: - description: The items to include in the Return. - type: array - items: - properties: - item_id: - description: The id of the Line Item from the Order. - type: string - quantity: - description: The quantity to return. - type: integer - return_shipping: - description: >- - If the Return is to be handled by the store operator the - Customer can choose a Return Shipping Method. Alternatvely - the Customer can handle the Return themselves. - type: object - properties: - option_id: - type: string - description: >- - The id of the Shipping Option to create the Shipping - Method from. + '/swaps/{cart_id}': + get: + operationId: GetSwapsSwapCartId + summary: Retrieve Swap by Cart id + description: Retrieves a Swap by the id of the Cart used to confirm the Swap. + parameters: + - in: path + name: cart_id + required: true + description: The id of the Cart + schema: + type: string tags: - - Return + - Swap responses: '200': description: OK @@ -1317,8 +1367,8 @@ paths: application/json: schema: properties: - return: - $ref: '#/components/schemas/return' + swap: + $ref: '#/components/schemas/swap' '/variants/{variant_id}': get: operationId: GetVariantsVariant @@ -1366,29 +1416,6 @@ paths: type: array items: $ref: '#/components/schemas/product_variant' - '/swaps/{cart_id}': - get: - operationId: GetSwapsSwapCartId - summary: Retrieve Swap by Cart id - description: Retrieves a Swap by the id of the Cart used to confirm the Swap. - parameters: - - in: path - name: cart_id - required: true - description: The id of the Cart - schema: - type: string - tags: - - Swap - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - swap: - $ref: '#/components/schemas/swap' components: schemas: address: @@ -1655,11 +1682,6 @@ components: deleted_at: type: string format: date-time - no_notification: - description: >- - Flag for describing whether or not notifications related to this - should be send. - type: boolean metadata: type: object claim_tag: @@ -1807,6 +1829,9 @@ components: type: array items: $ref: '#/components/schemas/product' + usage_limit: + description: The maximum number of times that a discount can be used. + type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1869,12 +1894,6 @@ components: type: array items: $ref: '#/components/schemas/region' - usage_limit: - description: The maximum number of times that a discount can be used. - type: integer - usage_count: - description: The number of times a discount has been used. - type: integer created_at: description: The date with timezone at which the resource was created. type: string @@ -1890,51 +1909,6 @@ components: metadata: description: An optional key-value map with additional information. type: object - draft-order: - title: DraftOrder - description: Represents a draft order - x-resourceId: draft-order - properties: - id: - type: string - status: - type: string - enum: - - open - - completed - display_id: - type: string - cart_id: - type: string - cart: - anyOf: - - $ref: '#/components/schemas/cart' - order_id: - type: string - order: - anyOf: - - $ref: '#/components/schemas/order' - canceled_at: - type: string - format: date-time - created_at: - type: string - format: date-time - update_at: - type: string - format: date-time - deleted_at: - type: string - format: date-time - completed_at: - type: string - format: date-time - no_notification_order: - type: boolean - metadata: - type: object - idempotency_key: - type: string fulfillment_item: title: Fulfillment Item description: >- @@ -2553,13 +2527,6 @@ components: type: integer gift_card_total: type: integer - paid_total: - type: integer - no_notification: - description: >- - Flag for describing whether or not notifications related to this - should be send. - type: boolean payment_provider: title: Payment Provider description: Represents a Payment Provider plugin and holds its installation status. @@ -3365,11 +3332,6 @@ components: description: The date with timezone at which the resource was last updated. type: string format: date-time - no_notification: - description: >- - When set to true, no notification will be sent related to this - return. - type: boolean metadata: description: An optional key-value map with additional information. type: object @@ -3730,9 +3692,6 @@ components: description: The date with timezone at which the resource was last updated. type: string format: date-time - no_notification: - description: 'If set to true, no notification will be sent related to this swap' - type: boolean metadata: description: An optional key-value map with additional information. type: object From b62d4a703815b6edb811abc414583a1a32f5f4ed Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 25 Jun 2021 15:04:24 +0200 Subject: [PATCH 39/55] post code-review discussion --- .../admin/gift-cards/update-gift-card.js | 1 + packages/medusa/src/services/swap.js | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js index 6c90578dd2..eb28ec062d 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js +++ b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js @@ -1,4 +1,5 @@ import { MedusaError, Validator } from "medusa-core-utils" +import { defaultFields, defaultRelations } from "./" /** * @oas [post] /gift-cards/{id} diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 3d213d4299..258761bb21 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -257,6 +257,7 @@ class SwapService extends BaseService { order_id: order.id, items: returnItems, shipping_method: returnShipping, + no_notification: evaluatedNoNotification, }) await this.eventBus_ @@ -300,19 +301,24 @@ class SwapService extends BaseService { } catch (err) { swap.payment_status = "requires_action" const result = await swapRepo.save(swap) + + // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) .emit(SwapService.Events.PROCESS_REFUND_FAILED, result) - return result + + return result } swap.payment_status = "difference_refunded" const result = await swapRepo.save(swap) + // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) .emit(SwapService.Events.REFUND_PROCESSED, result) + return result } else if (swap.difference_due === 0) { if (swap.payment_status === "difference_refunded") { @@ -322,9 +328,12 @@ class SwapService extends BaseService { swap.payment_status = "difference_refunded" const result = await swapRepo.save(swap) + + // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) .emit(SwapService.Events.REFUND_PROCESSED, result) + return result } @@ -339,19 +348,25 @@ class SwapService extends BaseService { } catch (err) { swap.payment_status = "requires_action" const result = await swapRepo.save(swap) + + // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) .emit(SwapService.Events.PAYMENT_CAPTURE_FAILED, result) + return result } swap.payment_status = "captured" const result = await swapRepo.save(swap) + + // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) .emit(SwapService.Events.PAYMENT_CAPTURED, result) - return result + + return result }) } @@ -707,6 +722,9 @@ class SwapService extends BaseService { const swapRepo = manager.getCustomRepository(this.swapRepository_) const result = await swapRepo.save(swap) + + // TODO: EMIT swap.fulfillment_created + return result }) } From e86f4656a9045544ec1224fdf24459e31eea6ab9 Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 28 Jun 2021 12:42:26 +0200 Subject: [PATCH 40/55] testing --- .../admin/draft-orders/create-draft-order.js | 2 +- packages/medusa/src/api/routes/admin/index.js | 2 +- .../api/routes/admin/orders/create-claim.js | 4 +- .../routes/admin/orders/create-fulfillment.js | 5 +- .../routes/admin/orders/create-shipment.js | 4 +- .../admin/orders/create-swap-shipment.js | 7 +- .../api/routes/admin/orders/create-swap.js | 5 +- .../api/routes/admin/orders/fulfill-claim.js | 9 ++- .../api/routes/admin/orders/fulfill-swap.js | 9 ++- .../api/routes/admin/orders/refund-payment.js | 2 +- packages/medusa/src/index.js | 1 + .../1623231564533-no_notification.ts | 2 + packages/medusa/src/models/fulfillment.ts | 6 ++ packages/medusa/src/services/claim.js | 23 +++++- packages/medusa/src/services/fulfillment.js | 12 ++- packages/medusa/src/services/notification.js | 2 +- packages/medusa/src/services/order.js | 32 ++++++-- packages/medusa/src/services/swap.js | 74 ++++++++++++++----- packages/medusa/yarn.lock | 36 ++++----- 19 files changed, 174 insertions(+), 63 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js index 5e1cbe3b51..03db073d58 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js @@ -155,7 +155,7 @@ export default async (req, res) => { draftOrder = await draftOrderService.retrieve(draftOrder.id, { relations: defaultRelations, select: defaultFields, - }) + }) // res.status(200).json({ draft_order: draftOrder }) } catch (err) { diff --git a/packages/medusa/src/api/routes/admin/index.js b/packages/medusa/src/api/routes/admin/index.js index c5b5d4b557..febf93e467 100644 --- a/packages/medusa/src/api/routes/admin/index.js +++ b/packages/medusa/src/api/routes/admin/index.js @@ -65,7 +65,7 @@ export default (app, container, config) => { returnRoutes(route) variantRoutes(route) draftOrderRoutes(route) - collectionRoutes(route) + collectionRoutes(route) //test notificationRoutes(route) returnReasonRoutes(route) diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.js b/packages/medusa/src/api/routes/admin/orders/create-claim.js index 5e0e207f58..365f4f8023 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.js @@ -110,7 +110,7 @@ import { defaultRelations, defaultFields } from "./" * $ref: "#/components/schemas/order" */ export default async (req, res) => { - const { id } = req.params + const { id } = req.params const schema = Validator.object().keys({ type: Validator.string() @@ -165,7 +165,7 @@ export default async (req, res) => { const { value, error } = schema.validate(req.body) if (error) { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) - } + } const idempotencyKeyService = req.scope.resolve("idempotencyKeyService") diff --git a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js index 4d3351a745..798bd9a2ae 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js @@ -64,7 +64,10 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createFulfillment(id, value.items, value.no_notification, value.metadata) + await orderService.createFulfillment(id, value.items, { + metadata: value.metadata, + noNotification: value.no_notification + }) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/create-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-shipment.js index 9c6efdd2dc..36b2a41dc5 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-shipment.js @@ -44,7 +44,7 @@ export default async (req, res) => { tracking_numbers: Validator.array() .items(Validator.string()) .optional(), - no_notification: Validator.boolean().optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -59,7 +59,7 @@ export default async (req, res) => { id, value.fulfillment_id, value.tracking_numbers.map(n => ({ tracking_number: n })), - value.no_notification, + {noNotification: value.no_notification}, ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js index 702d886cb5..6d5d0e5134 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js @@ -22,6 +22,9 @@ import { defaultFields, defaultRelations } from "./" * type: array * items: * type: string + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * tags: * - Order * responses: @@ -42,6 +45,7 @@ export default async (req, res) => { tracking_numbers: Validator.array() .items(Validator.string()) .optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -56,7 +60,8 @@ export default async (req, res) => { await swapService.createShipment( swap_id, value.fulfillment_id, - value.tracking_numbers.map(n => ({ tracking_number: n })) + value.tracking_numbers.map(n => ({ tracking_number: n })), + {noNotification: value.no_notification}, ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 648aed1aab..29a984d34d 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -90,6 +90,8 @@ export default async (req, res) => { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } + console.log("..>") + const idempotencyKeyService = req.scope.resolve("idempotencyKeyService") const headerKey = req.get("Idempotency-Key") || "" @@ -138,8 +140,7 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, - value.no_notification, - { idempotency_key: idempotencyKey.idempotency_key } + { idempotency_key: idempotencyKey.idempotency_key, noNotification: value.no_notification } ) await swapService.withTransaction(manager).createCart(swap.id) diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js index 50668a16c2..a3a4d9e88d 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js @@ -17,6 +17,9 @@ import { defaultRelations, defaultFields } from "./" * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * tags: * - Order * responses: @@ -34,6 +37,7 @@ export default async (req, res) => { const schema = Validator.object().keys({ metadata: Validator.object().optional(), + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -49,7 +53,10 @@ export default async (req, res) => { await entityManager.transaction(async manager => { await claimService .withTransaction(manager) - .createFulfillment(claim_id, value.metadata) + .createFulfillment(claim_id, { + metadata: value.metadata, + noNotification: value.no_notification, + }) }) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js index 7212614f49..289f45eff9 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js @@ -17,6 +17,9 @@ import { defaultRelations, defaultFields } from "./" * metadata: * description: An optional set of key-value pairs to hold additional information. * type: object + * no_notification: + * description: If set to true no notification will be send related to this Claim. + * type: boolean * tags: * - Order * responses: @@ -34,6 +37,7 @@ export default async (req, res) => { const schema = Validator.object().keys({ metadata: Validator.object().optional(), + no_notification: Validator.boolean().optional, }) const { value, error } = schema.validate(req.body) @@ -49,7 +53,10 @@ export default async (req, res) => { await entityManager.transaction(async manager => { await swapService .withTransaction(manager) - .createFulfillment(swap_id, value.metadata) + .createFulfillment(swap_id, { + metadata: value.metadata, + noNotification: value.no_notification, + }) const order = await orderService.withTransaction(manager).retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index 2c253dea46..1f6b6a728e 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -62,7 +62,7 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createRefund(id, value.amount, value.reason, value.note, value.no_notification) + await orderService.createRefund(id, value.amount, value.reason, value.note, {noNotification: value.no_notification}) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/index.js b/packages/medusa/src/index.js index c5c3367cd6..e9088f2917 100644 --- a/packages/medusa/src/index.js +++ b/packages/medusa/src/index.js @@ -43,3 +43,4 @@ export { Swap } from "./models/swap" export { User } from "./models/user" export { DraftOrder } from "./models/draft-order" export { ReturnReason } from "./models/return-reason" + diff --git a/packages/medusa/src/migrations/1623231564533-no_notification.ts b/packages/medusa/src/migrations/1623231564533-no_notification.ts index 20e3f9a9a2..dcd56690b0 100644 --- a/packages/medusa/src/migrations/1623231564533-no_notification.ts +++ b/packages/medusa/src/migrations/1623231564533-no_notification.ts @@ -9,9 +9,11 @@ export class noNotification1623231564533 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "swap" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "order" ADD "no_notification" boolean`); await queryRunner.query(`ALTER TABLE "draft_order" ADD "no_notification_order" boolean`); + await queryRunner.query(`ALTER TABLE "fulfillment" ADD "no_notification" boolean`); } public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "fulfillment" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "draft_order" DROP COLUMN "no_notification_order"`); await queryRunner.query(`ALTER TABLE "order" DROP COLUMN "no_notification"`); await queryRunner.query(`ALTER TABLE "swap" DROP COLUMN "no_notification"`); diff --git a/packages/medusa/src/models/fulfillment.ts b/packages/medusa/src/models/fulfillment.ts index 4f14943e90..30fc17986e 100644 --- a/packages/medusa/src/models/fulfillment.ts +++ b/packages/medusa/src/models/fulfillment.ts @@ -62,6 +62,9 @@ export class Fulfillment { @JoinColumn({ name: "order_id" }) order: Order + @Column({ type: "boolean", nullable: true}) + no_notification: Boolean + @Index() @Column() provider_id: string @@ -157,6 +160,9 @@ export class Fulfillment { * description: "The date with timezone at which the Fulfillment was shipped." * type: string * format: date-time + * no_notification: + * description: "Flag for describing whether or not notifications related to this should be send." + * type: boolean * canceled_at: * description: "The date with timezone at which the Fulfillment was canceled." * type: string diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index d49d3558d6..fc9521266e 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -135,7 +135,7 @@ class ClaimService extends BaseService { } } - if(no_notification !== undefined){ + if( no_notification !== undefined ){ claim.no_notification = no_notification await claimRepo.save(claim) } @@ -306,7 +306,12 @@ class ClaimService extends BaseService { }) } - createFulfillment(id, metadata = {}) { + createFulfillment(id, config = { + metadata: {}, + noNotification: undefined, + }) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const claim = await this.retrieve(id, { relations: [ @@ -343,6 +348,8 @@ class ClaimService extends BaseService { ) } + const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification + const fulfillments = await this.fulfillmentService_ .withTransaction(manager) .createFulfillment( @@ -359,6 +366,7 @@ class ClaimService extends BaseService { items: claim.additional_items, shipping_methods: claim.shipping_methods, is_claim: true, + no_notification: evaluatedNoNotification, }, claim.additional_items.map(i => ({ item_id: i.id, @@ -450,15 +458,22 @@ class ClaimService extends BaseService { }) } - async createShipment(id, fulfillmentId, trackingLinks, metadata = []) { + async createShipment(id, fulfillmentId, trackingLinks, config = { + metadata: [], + noNotification: undefined, + }) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const claim = await this.retrieve(id, { relations: ["additional_items"], }) + const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification + const shipment = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, metadata) + .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) claim.fulfillment_status = "shipped" diff --git a/packages/medusa/src/services/fulfillment.js b/packages/medusa/src/services/fulfillment.js index b05363978d..3290814f8d 100644 --- a/packages/medusa/src/services/fulfillment.js +++ b/packages/medusa/src/services/fulfillment.js @@ -165,10 +165,15 @@ class FulfillmentService extends BaseService { * those partitions. * @param {Order} order - order to create fulfillment for * @param {{ item_id: string, quantity: number}[]} itemsToFulfill - the items in the order to fulfill - * @param {object} metadata - potential metadata to add + * @param {object} config - potential configurations, including metadata to add * @return {Fulfillment[]} the created fulfillments */ - async createFulfillment(order, itemsToFulfill, custom = {}) { + async createFulfillment(order, itemsToFulfill, config = { + noNotification: undefined, + custom: {}, + }) { + const {custom, noNotification} = config + return this.atomicPhase_(async manager => { const fulfillmentRepository = manager.getCustomRepository( this.fulfillmentRepository_ @@ -180,6 +185,8 @@ class FulfillmentService extends BaseService { this.validateFulfillmentLineItem_ ) + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const { shipping_methods } = order // partition order items to their dedicated shipping method @@ -191,6 +198,7 @@ class FulfillmentService extends BaseService { ...custom, provider_id: shipping_method.shipping_option.provider_id, items: items.map(i => ({ item_id: i.id, quantity: i.quantity })), + no_notification: evaluatedNoNotification, data: {}, }) diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index e0165ef952..1df7dd7577 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -28,7 +28,7 @@ class NotificationService extends BaseService { this.notificationProviderRepository_ = notificationProviderRepository this.subscribers_ = {} - this.attachmentGenerator_ = null + this.attachmentGenerator_ = null } /** diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index b8c79e459b..8b426e6a0e 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1,3 +1,4 @@ +import { metadata } from "core-js/fn/reflect" import _ from "lodash" import { Validator, MedusaError } from "medusa-core-utils" import { BaseService } from "medusa-interfaces" @@ -572,7 +573,12 @@ class OrderService extends BaseService { * the fulfillment * @return {order} the resulting order following the update. */ - async createShipment(orderId, fulfillmentId, trackingLinks, noNotification = undefined, metadata = {}) { + async createShipment(orderId, fulfillmentId, trackingLinks, config = { + metadata: {}, + noNotification: undefined, + }) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { relations: ["items"] }) const shipment = await this.fulfillmentService_.retrieve(fulfillmentId) @@ -584,9 +590,11 @@ class OrderService extends BaseService { ) } + const evaluatedNoNotification = noNotification !== undefined ? noNotification : shipment.no_notification + const shipmentRes = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, metadata) + .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) order.fulfillment_status = "shipped" for (const item of order.items) { @@ -610,8 +618,6 @@ class OrderService extends BaseService { const orderRepo = manager.getCustomRepository(this.orderRepository_) const result = await orderRepo.save(order) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification - await this.eventBus_ .withTransaction(manager) .emit(OrderService.Events.SHIPMENT_CREATED, { @@ -983,7 +989,12 @@ class OrderService extends BaseService { * @param {string} orderId - id of order to cancel. * @return {Promise} result of the update operation. */ - async createFulfillment(orderId, itemsToFulfill, noNotification = undefined, metadata = {}) { + async createFulfillment(orderId, itemsToFulfill, config = { + noNotification: undefined, + metadata: {}, + }) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { select: [ @@ -1011,18 +1022,23 @@ class OrderService extends BaseService { ], }) + + console.log("metadata:" + metadata) + if (!order.shipping_methods?.length) { throw new MedusaError( MedusaError.Types.NOT_ALLOWED, "Cannot fulfill an order that lacks shipping methods" ) } + const fulfillments = await this.fulfillmentService_ .withTransaction(manager) .createFulfillment(order, itemsToFulfill, { metadata, order_id: orderId, + no_notification: noNotification }) let successfullyFulfilled = [] for (const f of fulfillments) { @@ -1125,7 +1141,11 @@ class OrderService extends BaseService { /** * Refunds a given amount back to the customer. */ - async createRefund(orderId, refundAmount, reason, note, noNotification = undefined) { + async createRefund(orderId, refundAmount, reason, note, config = { + noNotification: undefined, + }) { + const { noNotification } = config + return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { select: ["refundable_amount", "total", "refunded_total"], diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 258761bb21..01b1833bc0 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -16,6 +16,7 @@ class SwapService extends BaseService { PAYMENT_CAPTURE_FAILED: "swap.payment_capture_failed", PROCESS_REFUND_FAILED: "swap.process_refund_failed", REFUND_PROCESSED: "swap.refund_processed", + FULFILLMENT_CREATED: "swap.fulfillment_created", } constructor({ @@ -214,9 +215,13 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, - noNotification, - custom = {} + config = { + custom: {}, + noNotification: undefined, + } ) { + const { noNotification, custom } = config + return this.atomicPhase_(async manager => { if ( order.fulfillment_status === "not_fulfilled" || @@ -302,10 +307,12 @@ class SwapService extends BaseService { swap.payment_status = "requires_action" const result = await swapRepo.save(swap) - // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.PROCESS_REFUND_FAILED, result) + .emit(SwapService.Events.PROCESS_REFUND_FAILED, { + id: result.id, + no_notification: swap.no_notification, + }) return result } @@ -314,10 +321,12 @@ class SwapService extends BaseService { const result = await swapRepo.save(swap) - // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.REFUND_PROCESSED, result) + .emit(SwapService.Events.REFUND_PROCESSED, { + id: result.id, + no_notification: swap.no_notification, + }) return result } else if (swap.difference_due === 0) { @@ -329,10 +338,12 @@ class SwapService extends BaseService { const result = await swapRepo.save(swap) - // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.REFUND_PROCESSED, result) + .emit(SwapService.Events.REFUND_PROCESSED, { + id: result.id, + no_notification: swap.no_notification, + }) return result } @@ -349,10 +360,12 @@ class SwapService extends BaseService { swap.payment_status = "requires_action" const result = await swapRepo.save(swap) - // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.PAYMENT_CAPTURE_FAILED, result) + .emit(SwapService.Events.PAYMENT_CAPTURE_FAILED, { + id: swap.id, + no_notification: swap.no_notification, + }) return result } @@ -361,10 +374,12 @@ class SwapService extends BaseService { const result = await swapRepo.save(swap) - // TODO: event payload should not contain full result but just { id: result.id ... } await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.PAYMENT_CAPTURED, result) + .emit(SwapService.Events.PAYMENT_CAPTURED, { + id: result.id, + no_notification: swap.no_notification, + }) return result }) @@ -374,15 +389,15 @@ class SwapService extends BaseService { return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId) - if ("metadata" in update) { + if ( "metadata" in update ) { swap.metadata = this.setMetadata_(swap, update.metadata) } - if("no_notification" in update){ + if( "no_notification" in update ){ swap.no_notification = update.no_notification } - if ("shipping_address" in update) { + if ( "shipping_address" in update ) { await this.updateShippingAddress_(swap, update.shipping_address) } @@ -634,7 +649,12 @@ class SwapService extends BaseService { * @param {object} metadata - optional metadata to attach to the fulfillment. * @returns {Promise} the updated swap with new status and fulfillments. */ - async createFulfillment(swapId, metadata = {}) { + async createFulfillment(swapId, config = { + metadata: {}, + noNotification: undefined + }) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId, { relations: [ @@ -664,6 +684,8 @@ class SwapService extends BaseService { ) } + const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification + swap.fulfillments = await this.fulfillmentService_ .withTransaction(manager) .createFulfillment( @@ -680,6 +702,7 @@ class SwapService extends BaseService { items: swap.additional_items, shipping_methods: swap.shipping_methods, is_swap: true, + no_notification: evaluatedNoNotification, }, swap.additional_items.map(i => ({ item_id: i.id, @@ -723,7 +746,13 @@ class SwapService extends BaseService { const swapRepo = manager.getCustomRepository(this.swapRepository_) const result = await swapRepo.save(swap) - // TODO: EMIT swap.fulfillment_created + await this.eventBus_ + .withTransaction(manager) + .emit(SwapService.Events.FULFILLMENT_CREATED, { + id: swapId, + fulfillment_id: shipment.id, + no_notification: evaluatedNoNotification + }) return result }) @@ -739,16 +768,23 @@ class SwapService extends BaseService { * @param {object} metadata - optional metadata to attach to the shipment. * @returns {Promise} the updated swap with new fulfillments and status. */ - async createShipment(swapId, fulfillmentId, trackingLinks, metadata = {}) { + async createShipment(swapId, fulfillmentId, trackingLinks, config = { + metadata: {}, + noNotification: undefined, + } ) { + const { metadata, noNotification } = config + return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId, { relations: ["additional_items"], }) + const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification + // Update the fulfillment to register const shipment = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, metadata) + .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) swap.fulfillment_status = "shipped" diff --git a/packages/medusa/yarn.lock b/packages/medusa/yarn.lock index 897f3496c4..329b52b506 100644 --- a/packages/medusa/yarn.lock +++ b/packages/medusa/yarn.lock @@ -1673,10 +1673,10 @@ babel-preset-jest@^25.5.0: babel-plugin-jest-hoist "^25.5.0" babel-preset-current-node-syntax "^0.1.2" -babel-preset-medusa-package@^1.1.5-next.0: - version "1.1.5-next.0" - resolved "https://registry.yarnpkg.com/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.5-next.0.tgz#3ab62092742ae4976f80e2d0f9ff887866d7f032" - integrity sha512-M+DDbIi2VLZdir+svQIpWhUACHTE/1Cx2aQ8zU/n+0kb29yxMVNWqZto9m4Uh3c9PkoSnZfOYpu1AG/5RPByjw== +babel-preset-medusa-package@^1.1.8: + version "1.1.9" + resolved "https://registry.yarnpkg.com/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.9.tgz#4bd3f588e9d84d5888279a82dd69559965326cdc" + integrity sha512-U+5QM2N2kQ0Rxy8/8tUXzCbckrkju7E+bvPitFLctAR9V6RAWrJuZ11joZ+tE8upIkS1/b4uEbrVnoM0pq+nNA== dependencies: "@babel/plugin-proposal-class-properties" "^7.12.1" "@babel/plugin-proposal-decorators" "^7.12.1" @@ -4545,28 +4545,28 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.1.11-next.0, medusa-core-utils@^1.1.11-next.0+60da043: - version "1.1.11-next.0" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.11-next.0.tgz#c65ec751f48a3abf530bea598793fbbb96b84796" - integrity sha512-v4qqsRAOBvueJcKeMD8uL2Qb9dvR+qh3sDvW8C+1bpbnjuTbIq2D+d/xT+963mx3+e445XRoePjXNLltUcSicw== +medusa-core-utils@^1.1.14, medusa-core-utils@^1.1.15: + version "1.1.15" + resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.15.tgz#0fe98e1a451b5554b03421d241c973b67f00ff9b" + integrity sha512-sK1+Q0k68Rsz0XDAYLVDJ9hshQssMTxceUk+9umXxZgZlPhrPcHMMi8BwwrKOEaSk+nxmN38/h0XiHJ92Pts8g== dependencies: joi "^17.3.0" joi-objectid "^3.0.1" -medusa-interfaces@^1.1.12-next.0: - version "1.1.12-next.0" - resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-1.1.12-next.0.tgz#12f0b6eb068c729b10a66b693462e765a7661954" - integrity sha512-55CrFN4QHtUo32XQ88qKw1/CfqwikQxNnR2u05Xyyc63efoxlk6tlGg5o8PH74rA3kwQgmztjfG859GtwBRoOg== +medusa-interfaces@^1.1.15: + version "1.1.16" + resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-1.1.16.tgz#1b693759359faa2811966c9420f20f865591cf05" + integrity sha512-ghy4radBy1RIrkRThXIQ2q86htxPPnIFA1LMNyxViPKVZ+QPv350NNow6gSXsm6diTV5lWH0Bvl/hH6AbjA8vA== dependencies: - medusa-core-utils "^1.1.11-next.0+60da043" + medusa-core-utils "^1.1.15" -medusa-test-utils@^1.1.14-next.0: - version "1.1.14-next.0" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.14-next.0.tgz#29a85e7f08da811e3f2c735de5a906522de23948" - integrity sha512-NMUP7d1HH91piXLZGeF6ifEiyI4cA8jp7OTrD8+i/miS0HwilGxsXxqfzolzgsB/2AWiDrLdWg+pFF8JREQT2Q== +medusa-test-utils@^1.1.17: + version "1.1.18" + resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.18.tgz#4660f1cbec47abf5f17fc9469bb7ec5543b93c85" + integrity sha512-M25eFBvxlBzKu4dHQFz2ijMqjQIYgG5eNIxo1NE+3CLrgRNl+nrG+LwUBE0ouVDa9fi1TMSXXeTD17/7o7UOAA== dependencies: "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.1.11-next.0+60da043" + medusa-core-utils "^1.1.15" randomatic "^3.1.1" merge-descriptors@1.0.1: From bb85edb5ca83bc27edf6bcdd1d7d7fa13a5fd111 Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 28 Jun 2021 15:03:03 +0200 Subject: [PATCH 41/55] revamped way of propegating noNotification, now redo tests --- .../medusa/src/api/routes/admin/orders/create-swap.js | 2 -- packages/medusa/src/api/routes/admin/orders/index.js | 7 +++++++ .../medusa/src/api/routes/admin/swaps/get-swap.js | 3 +++ packages/medusa/src/services/fulfillment.js | 11 ++++------- packages/medusa/src/services/order.js | 5 +---- packages/medusa/src/services/swap.js | 10 ++++------ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 29a984d34d..53c0151f4e 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -90,8 +90,6 @@ export default async (req, res) => { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } - console.log("..>") - const idempotencyKeyService = req.scope.resolve("idempotencyKeyService") const headerKey = req.get("Idempotency-Key") || "" diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 29ce86e109..1af7932c46 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -191,13 +191,20 @@ export const defaultRelations = [ "returns.items.reason", "gift_cards", "gift_card_transactions", + "items", + "items.variant", + "items.variant.product", "claims", "claims.return_order", "claims.shipping_methods", "claims.shipping_address", "claims.additional_items", + "claims.additional_items.variant", + "claims.additional_items.variant.product", "claims.fulfillments", "claims.claim_items", + "claims.claim_items.variant", + "claims.claim_items.variant.product", "claims.claim_items.images", // "claims.claim_items.tags", "swaps", diff --git a/packages/medusa/src/api/routes/admin/swaps/get-swap.js b/packages/medusa/src/api/routes/admin/swaps/get-swap.js index 114a641a69..c395f4974e 100644 --- a/packages/medusa/src/api/routes/admin/swaps/get-swap.js +++ b/packages/medusa/src/api/routes/admin/swaps/get-swap.js @@ -11,6 +11,9 @@ export default async (req, res) => { "return_order", "fulfillments", "payment", + "items", + "items.variant", + "items.variant.product", "shipping_address", "shipping_methods", "cart", diff --git a/packages/medusa/src/services/fulfillment.js b/packages/medusa/src/services/fulfillment.js index 3290814f8d..45598c8b47 100644 --- a/packages/medusa/src/services/fulfillment.js +++ b/packages/medusa/src/services/fulfillment.js @@ -168,12 +168,7 @@ class FulfillmentService extends BaseService { * @param {object} config - potential configurations, including metadata to add * @return {Fulfillment[]} the created fulfillments */ - async createFulfillment(order, itemsToFulfill, config = { - noNotification: undefined, - custom: {}, - }) { - const {custom, noNotification} = config - + async createFulfillment(order, itemsToFulfill, custom = {}) { return this.atomicPhase_(async manager => { const fulfillmentRepository = manager.getCustomRepository( this.fulfillmentRepository_ @@ -185,6 +180,8 @@ class FulfillmentService extends BaseService { this.validateFulfillmentLineItem_ ) + const { noNotification, ...rest} = custom + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification const { shipping_methods } = order @@ -195,7 +192,7 @@ class FulfillmentService extends BaseService { const created = await Promise.all( fulfillments.map(async ({ shipping_method, items }) => { const ful = fulfillmentRepository.create({ - ...custom, + ...rest, provider_id: shipping_method.shipping_option.provider_id, items: items.map(i => ({ item_id: i.id, quantity: i.quantity })), no_notification: evaluatedNoNotification, diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 89d5a9e62d..962f24ba1a 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1025,9 +1025,6 @@ class OrderService extends BaseService { ], }) - - console.log("metadata:" + metadata) - if (!order.shipping_methods?.length) { throw new MedusaError( MedusaError.Types.NOT_ALLOWED, @@ -1040,8 +1037,8 @@ class OrderService extends BaseService { .withTransaction(manager) .createFulfillment(order, itemsToFulfill, { metadata, + noNotification: noNotification, order_id: orderId, - no_notification: noNotification }) let successfullyFulfilled = [] for (const f of fulfillments) { diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 01b1833bc0..09f467d82b 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -215,12 +215,8 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, - config = { - custom: {}, - noNotification: undefined, - } + custom = {} ) { - const { noNotification, custom } = config return this.atomicPhase_(async manager => { if ( @@ -243,11 +239,13 @@ class SwapService extends BaseService { }) ) + const { noNotification, ...rest } = custom + const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ - ...custom, + ...rest , fulfillment_status: "not_fulfilled", payment_status: "not_paid", order_id: order.id, From 46a3cb3710c3796a3cef96a995d57db04796b574 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 10:53:27 +0200 Subject: [PATCH 42/55] corrected tests --- packages/medusa/.vscode/settings.json | 11 ++ packages/medusa/src/api/routes/admin/index.js | 2 +- .../orders/__tests__/create-fulfillment.js | 3 +- .../admin/orders/__tests__/get-order.js | 7 ++ .../medusa/src/services/__tests__/claim.js | 38 +++--- .../medusa/src/services/__tests__/order.js | 108 ++++++++++-------- .../medusa/src/services/__tests__/swap.js | 2 +- packages/medusa/src/services/claim.js | 4 +- packages/medusa/src/services/order.js | 77 ++++++++----- packages/medusa/src/services/swap.js | 16 +-- 10 files changed, 164 insertions(+), 104 deletions(-) create mode 100644 packages/medusa/.vscode/settings.json diff --git a/packages/medusa/.vscode/settings.json b/packages/medusa/.vscode/settings.json new file mode 100644 index 0000000000..f78775143f --- /dev/null +++ b/packages/medusa/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "editor.formatOnSave": true, + "[javascript]": { + "editor.formatOnSave": true + }, + "eslint.format.enable": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} \ No newline at end of file diff --git a/packages/medusa/src/api/routes/admin/index.js b/packages/medusa/src/api/routes/admin/index.js index febf93e467..a4be5a9c59 100644 --- a/packages/medusa/src/api/routes/admin/index.js +++ b/packages/medusa/src/api/routes/admin/index.js @@ -65,7 +65,7 @@ export default (app, container, config) => { returnRoutes(route) variantRoutes(route) draftOrderRoutes(route) - collectionRoutes(route) //test + collectionRoutes(route) notificationRoutes(route) returnReasonRoutes(route) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js index 4a3f04c0ed..c4a074f899 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js @@ -43,8 +43,7 @@ describe("POST /admin/orders/:id/fulfillment", () => { quantity: 1, }, ], - undefined, - undefined + {"metadata": undefined, "noNotification": undefined} ) }) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js index 57cb1db7ea..42b676dccb 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js @@ -17,13 +17,20 @@ const defaultRelations = [ "returns.items.reason", "gift_cards", "gift_card_transactions", + "items", + "items.variant", + "items.variant.product", "claims", "claims.return_order", "claims.shipping_methods", "claims.shipping_address", "claims.additional_items", + "claims.additional_items.variant", + "claims.additional_items.variant.product", "claims.fulfillments", "claims.claim_items", + "claims.claim_items.variant", + "claims.claim_items.variant.product", "claims.claim_items.images", "swaps", "swaps.return_order", diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index 00cc35fe7e..61b6f03ef4 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -215,19 +215,21 @@ describe("ClaimService", () => { it.each( [ [false, false], - [undefined, true] + [undefined, true], ], - "passes correct no_notification status to event bus", async (input, expected) => { + "passes correct no_notification status to event bus", + async (input, expected) => { await claimService.create({ - ...testClaim, - no_notification: input, - }) - - expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: expected + ...testClaim, + no_notification: input, }) - }) + + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { + id: expect.any(String), + no_notification: expected, + }) + } + ) }) describe("retrieve", () => { @@ -314,7 +316,9 @@ describe("ClaimService", () => { }) it("successfully creates fulfillment", async () => { - await claimService.createFulfillment("claim_id", { meta: "data" }) + await claimService.createFulfillment("claim_id", { + metadata: { meta: "data" }, + }) expect(withTransactionMock).toHaveBeenCalledTimes(3) expect(withTransactionMock).toHaveBeenCalledWith("eventBus") @@ -434,7 +438,10 @@ describe("ClaimService", () => { ) await claimService.createShipment("claim", "ful_123", ["track1234"], { - meta: "data", + metadata: { + meta: "data", + }, + noNotification: false, }) expect(withTransactionMock).toHaveBeenCalledTimes(3) @@ -446,7 +453,12 @@ describe("ClaimService", () => { expect(fulfillmentService.createShipment).toHaveBeenCalledWith( "ful_123", ["track1234"], - { meta: "data" } + { + metadata: { + meta: "data", + }, + noNotification: false, + } ) expect(lineItemService.update).toHaveBeenCalledTimes(1) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index e2783d38e1..4b89496653 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -866,27 +866,28 @@ describe("OrderService", () => { [true, true], [false, false], [undefined, true], - ])("emits correct no_notification option with '%s'", async (input, expected) => { - await orderService.createFulfillment( - "test-order", - [ - { - item_id: "item_1", - quantity: 1, - }, - ], - input - ) + ])( + "emits correct no_notification option with '%s'", + async (input, expected) => { + await orderService.createFulfillment( + "test-order", + [ + { + item_id: "item_1", + quantity: 1, + }, + ], + { noNotification: input } + ) - expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: expected, - }) - }) + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { + id: expect.any(String), + no_notification: expected, + }) + } + ) }) - - describe("registerReturnReceived", () => { const order = { items: [ @@ -1023,7 +1024,11 @@ describe("OrderService", () => { } const fulfillmentService = { - retrieve: () => Promise.resolve({ order_id: IdMap.getId("test") }), + retrieve: () => + Promise.resolve({ + order_id: IdMap.getId("test"), + no_notification: true, + }), createShipment: jest .fn() .mockImplementation((shipmentId, tracking, meta) => { @@ -1063,10 +1068,12 @@ describe("OrderService", () => { ) expect(fulfillmentService.createShipment).toHaveBeenCalledTimes(1) - expect(fulfillmentService.createShipment).toHaveBeenCalledWith( + expect( + fulfillmentService.createShipment + ).toHaveBeenCalledWith( IdMap.getId("fulfillment"), [{ tracking_number: "1234" }, { tracking_number: "2345" }], - {} + { metadata: undefined, noNotification: true } ) expect(orderRepo.save).toHaveBeenCalledTimes(1) @@ -1080,20 +1087,22 @@ describe("OrderService", () => { [true, true], [false, false], [undefined, true], - ])("2emits correct no_notification option with '%s'", async (input, expected) => { - await orderService.createShipment( - IdMap.getId("test"), - IdMap.getId("fulfillment"), - [{ tracking_number: "1234" }, { tracking_number: "2345" }], - input, - {} - ) + ])( + "emits correct no_notification option with '%s'", + async (input, expected) => { + await orderService.createShipment( + IdMap.getId("test"), + IdMap.getId("fulfillment"), + [{ tracking_number: "1234" }, { tracking_number: "2345" }], + { noNotification: input } + ) - expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: expected, - }) - }) + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { + id: expect.any(String), + no_notification: expected, + }) + } + ) }) describe("createRefund", () => { @@ -1180,20 +1189,23 @@ describe("OrderService", () => { it.each([ [false, false], [undefined, true], - ])("emits correct no_notification option with '%s'", async (input, expected) => { - await orderService.createRefund( - IdMap.getId("order_123"), - 100, - "discount", - "note", - input - ) + ])( + "emits correct no_notification option with '%s'", + async (input, expected) => { + await orderService.createRefund( + IdMap.getId("order_123"), + 100, + "discount", + "note", + { noNotification: input } + ) - expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: expected, - refund_id: expect.any(String) - } ) - }) + expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { + id: expect.any(String), + no_notification: expected, + refund_id: expect.any(String), + }) + } + ) }) }) diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index ef56621044..ba9834c456 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -355,7 +355,7 @@ describe("SwapService", () => { id: IdMap.getId("return-shipping"), price: 20, }, - input + {noNotification: input} ) expect(eventBusService.emit).toHaveBeenCalledWith( diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index fc9521266e..68c7d24887 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -459,7 +459,7 @@ class ClaimService extends BaseService { } async createShipment(id, fulfillmentId, trackingLinks, config = { - metadata: [], + metadata: {}, noNotification: undefined, }) { const { metadata, noNotification } = config @@ -503,7 +503,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, - no_notification: result.no_notification + no_notification: evaluatedNoNotification }) return result diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 962f24ba1a..7409fa4a6e 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -1,4 +1,3 @@ -import { metadata } from "core-js/fn/reflect" import _ from "lodash" import { Validator, MedusaError } from "medusa-core-utils" import { BaseService } from "medusa-interfaces" @@ -312,7 +311,6 @@ class OrderService extends BaseService { * @return {Promise} the order document */ async retrieve(orderId, config = {}) { - const orderRepo = this.manager_.getCustomRepository(this.orderRepository_) const validatedId = this.validateId_(orderId) @@ -409,7 +407,7 @@ class OrderService extends BaseService { OrderService.Events.COMPLETED, { id: orderId, - no_notification: order.no_notification + no_notification: order.no_notification, } ) @@ -510,7 +508,6 @@ class OrderService extends BaseService { toCreate.draft_order_id = draft.id toCreate.no_notification = draft.no_notification_order - } const o = await orderRepo.create(toCreate) @@ -557,7 +554,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PLACED, { id: result.id, - no_notification: result.no_notification + no_notification: result.no_notification, }) return result @@ -576,10 +573,15 @@ class OrderService extends BaseService { * the fulfillment * @return {order} the resulting order following the update. */ - async createShipment(orderId, fulfillmentId, trackingLinks, config = { - metadata: {}, - noNotification: undefined, - }) { + async createShipment( + orderId, + fulfillmentId, + trackingLinks, + config = { + metadata: {}, + noNotification: undefined, + } + ) { const { metadata, noNotification } = config return this.atomicPhase_(async manager => { @@ -593,11 +595,15 @@ class OrderService extends BaseService { ) } - const evaluatedNoNotification = noNotification !== undefined ? noNotification : shipment.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : shipment.no_notification const shipmentRes = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) + .createShipment(fulfillmentId, trackingLinks, { + metadata, + noNotification: evaluatedNoNotification, + }) order.fulfillment_status = "shipped" for (const item of order.items) { @@ -626,7 +632,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.SHIPMENT_CREATED, { id: orderId, fulfillment_id: shipmentRes.id, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) return result @@ -647,7 +653,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PLACED, { id: result.id, - no_notification: order.no_notification + no_notification: order.no_notification, }) return result }) @@ -815,7 +821,7 @@ class OrderService extends BaseService { await this.updateBillingAddress_(order, update.billing_address) } - if("no_notification" in update){ + if ("no_notification" in update) { order.no_notification = update.no_notification } @@ -839,7 +845,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.UPDATED, { id: orderId, - no_notification: order.no_notification + no_notification: order.no_notification, }) return result }) @@ -890,7 +896,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.CANCELED, { id: order.id, - no_notification: order.no_notification + no_notification: order.no_notification, }) return result }) @@ -919,7 +925,7 @@ class OrderService extends BaseService { id: orderId, payment_id: p.id, error: err, - no_notification: order.no_notification + no_notification: order.no_notification, }) }) @@ -945,7 +951,7 @@ class OrderService extends BaseService { .withTransaction(manager) .emit(OrderService.Events.PAYMENT_CAPTURED, { id: result.id, - no_notification: order.no_notification + no_notification: order.no_notification, }) } @@ -992,10 +998,14 @@ class OrderService extends BaseService { * @param {string} orderId - id of order to cancel. * @return {Promise} result of the update operation. */ - async createFulfillment(orderId, itemsToFulfill, config = { + async createFulfillment( + orderId, + itemsToFulfill, + config = { noNotification: undefined, metadata: {}, - }) { + } + ) { const { metadata, noNotification } = config return this.atomicPhase_(async manager => { @@ -1031,7 +1041,6 @@ class OrderService extends BaseService { "Cannot fulfill an order that lacks shipping methods" ) } - const fulfillments = await this.fulfillmentService_ .withTransaction(manager) @@ -1077,7 +1086,8 @@ class OrderService extends BaseService { order.fulfillments = [...order.fulfillments, ...fulfillments] const result = await orderRepo.save(order) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : order.no_notification for (const fulfillment of fulfillments) { await this.eventBus_ @@ -1085,7 +1095,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.FULFILLMENT_CREATED, { id: orderId, fulfillment_id: fulfillment.id, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) } @@ -1141,9 +1151,15 @@ class OrderService extends BaseService { /** * Refunds a given amount back to the customer. */ - async createRefund(orderId, refundAmount, reason, note, config = { - noNotification: undefined, - }) { + async createRefund( + orderId, + refundAmount, + reason, + note, + config = { + noNotification: undefined, + } + ) { const { noNotification } = config return this.atomicPhase_(async manager => { @@ -1165,12 +1181,13 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : order.no_notification this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, refund_id: refund.id, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) return result }) @@ -1274,7 +1291,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.RETURN_ACTION_REQUIRED, { id: result.id, return_id: receivedReturn.id, - no_notification: receivedReturn.no_notification + no_notification: receivedReturn.no_notification, }) return result } @@ -1306,7 +1323,7 @@ class OrderService extends BaseService { .emit(OrderService.Events.ITEMS_RETURNED, { id: order.id, return_id: receivedReturn.id, - no_notification: receivedReturn.no_notification + no_notification: receivedReturn.no_notification, }) return result }) diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 09f467d82b..2b4217bdf1 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -215,9 +215,11 @@ class SwapService extends BaseService { returnItems, additionalItems, returnShipping, - custom = {} - ) { - + custom = { + noNotification: undefined + } + ){ + const { noNotification, ...rest } = custom return this.atomicPhase_(async manager => { if ( order.fulfillment_status === "not_fulfilled" || @@ -239,8 +241,6 @@ class SwapService extends BaseService { }) ) - const { noNotification, ...rest } = custom - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) @@ -746,9 +746,11 @@ class SwapService extends BaseService { await this.eventBus_ .withTransaction(manager) - .emit(SwapService.Events.FULFILLMENT_CREATED, { + .emit(SwapService.Events.FULFILLMENT_CREATED, + + { id: swapId, - fulfillment_id: shipment.id, + fulfillment_id: result.id, no_notification: evaluatedNoNotification }) From 02b6c1939160c9ba377172f67e102925410562d2 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:11:09 +0200 Subject: [PATCH 43/55] added changes --- .../routes/admin/orders/create-shipment.js | 4 +- .../api/routes/admin/orders/refund-payment.js | 10 +++- packages/medusa/src/services/claim.js | 58 ++++++++++++------- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/create-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-shipment.js index 36b2a41dc5..c8d093bf70 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-shipment.js @@ -22,7 +22,7 @@ import { defaultRelations, defaultFields } from "./" * items: * type: string * no_notification: - * description: If set to true no notification will be send related to this Claim. + * description: If set to true no notification will be send related to this Shipment. * type: boolean * tags: * - Order @@ -59,7 +59,7 @@ export default async (req, res) => { id, value.fulfillment_id, value.tracking_numbers.map(n => ({ tracking_number: n })), - {noNotification: value.no_notification}, + { noNotification: value.no_notification } ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index 1f6b6a728e..54381137f3 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -26,7 +26,7 @@ import { defaultRelations, defaultFields } from "./" * description: A not with additional details about the Refund. * type: string * no_notification: - * description: If set to true no notification will be send related to this Swap. + * description: If set to true no notification will be send related to this Refund. * type: boolean * tags: * - Order @@ -62,7 +62,13 @@ export default async (req, res) => { try { const orderService = req.scope.resolve("orderService") - await orderService.createRefund(id, value.amount, value.reason, value.note, {noNotification: value.no_notification}) + await orderService.createRefund( + id, + value.amount, + value.reason, + value.note, + { noNotification: value.no_notification } + ) const order = await orderService.retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 68c7d24887..37161d9d37 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -135,7 +135,7 @@ class ClaimService extends BaseService { } } - if( no_notification !== undefined ){ + if (no_notification !== undefined) { claim.no_notification = no_notification await claimRepo.save(claim) } @@ -150,12 +150,11 @@ class ClaimService extends BaseService { } } - await this.eventBus_ .withTransaction(manager) .emit(ClaimService.Events.UPDATED, { id: claim.id, - no_notification: claim.no_notification + no_notification: claim.no_notification, }) return claim @@ -241,7 +240,8 @@ class ClaimService extends BaseService { ) ) - const evaluatedNoNotification = no_notification !== undefined ? no_notification : order.no_notification + const evaluatedNoNotification = + no_notification !== undefined ? no_notification : order.no_notification const created = claimRepo.create({ shipping_address_id: addressId, @@ -251,7 +251,7 @@ class ClaimService extends BaseService { type, additional_items: newItems, order_id: order.id, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) const result = await claimRepo.save(created) @@ -292,6 +292,7 @@ class ClaimService extends BaseService { metadata: ci.metadata, })), shipping_method: return_shipping, + no_notification: evaluatedNoNotification, }) } @@ -299,17 +300,20 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CREATED, { id: result.id, - no_notification: result.no_notification + no_notification: result.no_notification, }) return result }) } - createFulfillment(id, config = { - metadata: {}, - noNotification: undefined, - }) { + createFulfillment( + id, + config = { + metadata: {}, + noNotification: undefined, + } + ) { const { metadata, noNotification } = config return this.atomicPhase_(async manager => { @@ -348,7 +352,8 @@ class ClaimService extends BaseService { ) } - const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : claim.no_notification const fulfillments = await this.fulfillmentService_ .withTransaction(manager) @@ -415,7 +420,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.FULFILLMENT_CREATED, { id: id, fulfillment_id: fulfillment.id, - no_notification: claim.no_notification + no_notification: claim.no_notification, }) } @@ -451,29 +456,38 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.REFUND_PROCESSED, { id, - no_notification: result.no_notification + no_notification: result.no_notification, }) return result }) } - async createShipment(id, fulfillmentId, trackingLinks, config = { - metadata: {}, - noNotification: undefined, - }) { + async createShipment( + id, + fulfillmentId, + trackingLinks, + config = { + metadata: {}, + noNotification: undefined, + } + ) { const { metadata, noNotification } = config - + return this.atomicPhase_(async manager => { const claim = await this.retrieve(id, { relations: ["additional_items"], }) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : claim.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : claim.no_notification const shipment = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) + .createShipment(fulfillmentId, trackingLinks, { + metadata, + noNotification: evaluatedNoNotification, + }) claim.fulfillment_status = "shipped" @@ -503,7 +517,7 @@ class ClaimService extends BaseService { .emit(ClaimService.Events.SHIPMENT_CREATED, { id, fulfillment_id: shipment.id, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) return result @@ -554,7 +568,7 @@ class ClaimService extends BaseService { .withTransaction(manager) .emit(ClaimService.Events.CANCELED, { id: result.id, - no_notification: result.no_notification + no_notification: result.no_notification, }) return result From 7cecc021f41f571db6381dc525d36f5398e85b61 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:31:44 +0200 Subject: [PATCH 44/55] corrected formatting based on walkthrough of pr --- .../routes/admin/returns/receive-return.js | 1 - packages/medusa/src/models/product-variant.ts | 3 - packages/medusa/src/services/draft-order.js | 36 +++++--- packages/medusa/src/services/swap.js | 90 +++++++++++-------- 4 files changed, 74 insertions(+), 56 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/returns/receive-return.js b/packages/medusa/src/api/routes/admin/returns/receive-return.js index 8e77f55fd9..5baadcc5d6 100644 --- a/packages/medusa/src/api/routes/admin/returns/receive-return.js +++ b/packages/medusa/src/api/routes/admin/returns/receive-return.js @@ -59,7 +59,6 @@ export default async (req, res) => { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) } - try { const returnService = req.scope.resolve("returnService") const orderService = req.scope.resolve("orderService") diff --git a/packages/medusa/src/models/product-variant.ts b/packages/medusa/src/models/product-variant.ts index 9ee30dee66..fd5730765f 100644 --- a/packages/medusa/src/models/product-variant.ts +++ b/packages/medusa/src/models/product-variant.ts @@ -19,9 +19,6 @@ import { Product } from "./product" import { MoneyAmount } from "./money-amount" import { ProductOptionValue } from "./product-option-value" - - - @Entity() export class ProductVariant { @PrimaryColumn() diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index 2954d6ef39..d2ec54bfcd 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -249,8 +249,13 @@ class DraftOrderService extends BaseService { ) } - const { items, shipping_methods, discounts, no_notification_order=undefined, ...rest } = data - + const { + items, + shipping_methods, + discounts, + no_notification_order = undefined, + ...rest + } = data if (discounts) { for (const { code } of discounts) { @@ -265,7 +270,10 @@ class DraftOrderService extends BaseService { .withTransaction(manager) .create({ type: "draft_order", ...rest }) - const draftOrder = draftOrderRepo.create({ cart_id: createdCart.id, no_notification_order}) + const draftOrder = draftOrderRepo.create({ + cart_id: createdCart.id, + no_notification_order, + }) const result = await draftOrderRepo.save(draftOrder) await this.eventBus_ @@ -343,34 +351,34 @@ class DraftOrderService extends BaseService { * @param {DraftOrder} data - values to update the order with * @returns {Promise} the updated draft order */ - async update(doId, data){ + async update(doId, data) { return this.atomicPhase_(async manager => { const doRepo = manager.getCustomRepository(this.draftOrderRepository_) const draftOrder = await this.retrieve(doId) let touched = false - - if(draftOrder.status === "completed"){ + + if (draftOrder.status === "completed") { throw new MedusaError( MedusaError.Types.NOT_ALLOWED, "Can't update a draft order which is complete" ) } - - if(data.no_notification_order !== undefined){ + + if (data.no_notification_order !== undefined) { touched = true draftOrder.no_notification_order = data.no_notification_order } - if(touched){ + if (touched) { doRepo.save(draftOrder) await this.eventBus_ - .withTransaction(manager) - .emit(DraftOrderService.Events.UPDATED, { - id: draftOrder.id - }) + .withTransaction(manager) + .emit(DraftOrderService.Events.UPDATED, { + id: draftOrder.id, + }) } - + return draftOrder }) } diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 2b4217bdf1..6db06e4785 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -205,8 +205,8 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. - * @param {boolean?} noNotification - an optional flag to disable sending - * notification when creating swap. If set, it overrules the attribute inherited + * @param {boolean?} noNotification - an optional flag to disable sending + * notification when creating swap. If set, it overrules the attribute inherited * from the order. * @returns {Promise} the newly created swap. */ @@ -216,10 +216,10 @@ class SwapService extends BaseService { additionalItems, returnShipping, custom = { - noNotification: undefined + noNotification: undefined, } - ){ - const { noNotification, ...rest } = custom + ) { + const { noNotification, ...rest } = custom return this.atomicPhase_(async manager => { if ( order.fulfillment_status === "not_fulfilled" || @@ -241,16 +241,17 @@ class SwapService extends BaseService { }) ) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ - ...rest , + ...rest, fulfillment_status: "not_fulfilled", payment_status: "not_paid", order_id: order.id, additional_items: newItems, - no_notification: evaluatedNoNotification + no_notification: evaluatedNoNotification, }) const result = await swapRepo.save(created) @@ -311,8 +312,8 @@ class SwapService extends BaseService { id: result.id, no_notification: swap.no_notification, }) - - return result + + return result } swap.payment_status = "difference_refunded" @@ -378,8 +379,8 @@ class SwapService extends BaseService { id: result.id, no_notification: swap.no_notification, }) - - return result + + return result }) } @@ -387,15 +388,15 @@ class SwapService extends BaseService { return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId) - if ( "metadata" in update ) { + if ("metadata" in update) { swap.metadata = this.setMetadata_(swap, update.metadata) } - if( "no_notification" in update ){ + if ("no_notification" in update) { swap.no_notification = update.no_notification } - if ( "shipping_address" in update ) { + if ("shipping_address" in update) { await this.updateShippingAddress_(swap, update.shipping_address) } @@ -596,7 +597,7 @@ class SwapService extends BaseService { .withTransaction(manager) .emit(SwapService.Events.PAYMENT_COMPLETED, { id: swap.id, - no_notification: swap.no_notification + no_notification: swap.no_notification, }) return result @@ -644,13 +645,16 @@ class SwapService extends BaseService { * Fulfills the addtional items associated with the swap. Will call the * fulfillment providers associated with the shipping methods. * @param {string} swapId - the id of the swap to fulfill, - * @param {object} metadata - optional metadata to attach to the fulfillment. + * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. * @returns {Promise} the updated swap with new status and fulfillments. */ - async createFulfillment(swapId, config = { - metadata: {}, - noNotification: undefined - }) { + async createFulfillment( + swapId, + config = { + metadata: {}, + noNotification: undefined, + } + ) { const { metadata, noNotification } = config return this.atomicPhase_(async manager => { @@ -682,7 +686,8 @@ class SwapService extends BaseService { ) } - const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : swap.no_notification swap.fulfillments = await this.fulfillmentService_ .withTransaction(manager) @@ -744,15 +749,15 @@ class SwapService extends BaseService { const swapRepo = manager.getCustomRepository(this.swapRepository_) const result = await swapRepo.save(swap) - await this.eventBus_ - .withTransaction(manager) - .emit(SwapService.Events.FULFILLMENT_CREATED, - - { + await this.eventBus_.withTransaction(manager).emit( + SwapService.Events.FULFILLMENT_CREATED, + + { id: swapId, fulfillment_id: result.id, - no_notification: evaluatedNoNotification - }) + no_notification: evaluatedNoNotification, + } + ) return result }) @@ -765,13 +770,18 @@ class SwapService extends BaseService { * has been shipped * @param {TrackingLink[]} trackingLinks - the tracking numbers associated * with the shipment - * @param {object} metadata - optional metadata to attach to the shipment. + * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. * @returns {Promise} the updated swap with new fulfillments and status. */ - async createShipment(swapId, fulfillmentId, trackingLinks, config = { - metadata: {}, - noNotification: undefined, - } ) { + async createShipment( + swapId, + fulfillmentId, + trackingLinks, + config = { + metadata: {}, + noNotification: undefined, + } + ) { const { metadata, noNotification } = config return this.atomicPhase_(async manager => { @@ -779,12 +789,16 @@ class SwapService extends BaseService { relations: ["additional_items"], }) - const evaluatedNoNotification = noNotification !== undefined ? noNotification : swap.no_notification + const evaluatedNoNotification = + noNotification !== undefined ? noNotification : swap.no_notification // Update the fulfillment to register const shipment = await this.fulfillmentService_ .withTransaction(manager) - .createShipment(fulfillmentId, trackingLinks, {metadata, noNotification: evaluatedNoNotification}) + .createShipment(fulfillmentId, trackingLinks, { + metadata, + noNotification: evaluatedNoNotification, + }) swap.fulfillment_status = "shipped" @@ -814,7 +828,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.SHIPMENT_CREATED, { id: swapId, fulfillment_id: shipment.id, - no_notification: swap.no_notification + no_notification: swap.no_notification, }) return result }) @@ -871,7 +885,7 @@ class SwapService extends BaseService { .emit(SwapService.Events.RECEIVED, { id: id, order_id: result.order_id, - no_notification: swap.no_notification + no_notification: swap.no_notification, }) return result From 927a270c6b908c78df4aa048993d00fee807f54a Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:38:46 +0200 Subject: [PATCH 45/55] removed changes wrongfully included --- integration-tests/api/__tests__/store/cart.js | 54 ------------------- .../api/helpers/product-seeder.js | 10 +--- integration-tests/helpers/use-db.js | 5 +- packages/medusa/src/models/line-item.ts | 2 +- 4 files changed, 3 insertions(+), 68 deletions(-) diff --git a/integration-tests/api/__tests__/store/cart.js b/integration-tests/api/__tests__/store/cart.js index 71c036b72d..9b5ceeb22b 100644 --- a/integration-tests/api/__tests__/store/cart.js +++ b/integration-tests/api/__tests__/store/cart.js @@ -5,10 +5,8 @@ const { Region } = require("@medusajs/medusa"); const setupServer = require("../../../helpers/setup-server"); const { useApi } = require("../../../helpers/use-api"); const { initDb } = require("../../../helpers/use-db"); -const { expectRelations } = require("../../helpers/expect-relations"); const cartSeeder = require("../../helpers/cart-seeder"); -const productSeeder = require("../../helpers/product-seeder"); jest.setTimeout(30000); @@ -332,56 +330,4 @@ describe("/store/carts", () => { expect(response.status).toEqual(200); }); }); - - describe("get-cart returns expected relations", () => { - beforeEach(async () => { - try { - await productSeeder(dbConnection); - await cartSeeder(dbConnection); - } catch (err) { - console.log(err); - throw err; - } - }); - - afterEach(async () => { - const manager = dbConnection.manager; - await doAfterEach(manager); - }); - - - it("returns default relations", async () => { - const api = useApi(); - - const expectedRelations = [ - "gift_cards", - "region", - "items.variant.prices", - "payment", - "shipping_address", - "billing_address", - "region.countries", - "region.payment_providers", - "payment_sessions", - "shipping_methods.shipping_option", - "discounts", - ] - - await api.post("/store/carts/test-cart/line-items", { - quantity: 1, - variant_id: "test-variant", - }) - - // await api.post("/store/carts/test-cart/shipping-methods", { - // option_id: "test-option" - // }) - - - const response = await api.get("/store/carts/test-cart") - - console.log(response.data.cart) - expectRelations(expectedRelations, response.data.cart) - - }); - }); }); diff --git a/integration-tests/api/helpers/product-seeder.js b/integration-tests/api/helpers/product-seeder.js index f11f70859b..77fd31a034 100644 --- a/integration-tests/api/helpers/product-seeder.js +++ b/integration-tests/api/helpers/product-seeder.js @@ -6,7 +6,6 @@ const { Product, ShippingProfile, ProductVariant, - MoneyAmount, Image, } = require("@medusajs/medusa"); @@ -81,14 +80,7 @@ module.exports = async (connection, data = {}) => { upc: "test-upc", barcode: "test-barcode", product_id: "test-product", - prices: [], + prices: [{ id: "test-price", currency_code: "usd", amount: 100 }], options: [{ id: "test-variant-option", value: "Default variant" }], }); - - await manager.insert(MoneyAmount, { - variant_id: "test-variant", - id: "test-price", - currency_code: "usd", - amount: 100, - }); }; diff --git a/integration-tests/helpers/use-db.js b/integration-tests/helpers/use-db.js index 74e420ec24..c9be67e7ae 100644 --- a/integration-tests/helpers/use-db.js +++ b/integration-tests/helpers/use-db.js @@ -36,10 +36,8 @@ module.exports = { ); const databaseName = "medusa-integration"; - await createDatabase({ databaseName }); - - + const connection = await createConnection({ type: "postgres", url: "postgres://localhost/medusa-integration", @@ -68,7 +66,6 @@ module.exports = { instance.setDb(dbConnection); return dbConnection; - }, useDb: function () { return instance; diff --git a/packages/medusa/src/models/line-item.ts b/packages/medusa/src/models/line-item.ts index e8d30aecff..3060050646 100644 --- a/packages/medusa/src/models/line-item.ts +++ b/packages/medusa/src/models/line-item.ts @@ -99,7 +99,7 @@ export class LineItem { @Column({ nullable: true }) variant_id: string - @ManyToOne(() => ProductVariant) + @ManyToOne(() => ProductVariant, { eager: true }) @JoinColumn({ name: "variant_id" }) variant: ProductVariant From 100352ad0965aab42f4920ca23cad5f6f70d3c31 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:45:54 +0200 Subject: [PATCH 46/55] removed errornous changes --- .../api/routes/admin/draft-orders/index.js | 2 -- .../admin/gift-cards/update-gift-card.js | 1 - .../admin/orders/__tests__/get-order.js | 8 ----- .../src/api/routes/admin/orders/index.js | 9 ----- .../src/api/routes/admin/swaps/get-swap.js | 3 -- .../src/api/routes/store/carts/index.js | 4 +-- .../src/api/routes/store/orders/index.js | 1 - packages/medusa/yarn.lock | 36 +++++++++---------- 8 files changed, 19 insertions(+), 45 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/draft-orders/index.js b/packages/medusa/src/api/routes/admin/draft-orders/index.js index 4bdacfde84..10b9e65f30 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/index.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/index.js @@ -49,8 +49,6 @@ export const defaultRelations = ["order", "cart"] export const defaultCartRelations = [ "region", "items", - "items.variant", - "items.variant.prices", "payment", "shipping_address", "billing_address", diff --git a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js index eb28ec062d..6c90578dd2 100644 --- a/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js +++ b/packages/medusa/src/api/routes/admin/gift-cards/update-gift-card.js @@ -1,5 +1,4 @@ import { MedusaError, Validator } from "medusa-core-utils" -import { defaultFields, defaultRelations } from "./" /** * @oas [post] /gift-cards/{id} diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js index 42b676dccb..5001ed0def 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js @@ -17,20 +17,13 @@ const defaultRelations = [ "returns.items.reason", "gift_cards", "gift_card_transactions", - "items", - "items.variant", - "items.variant.product", "claims", "claims.return_order", "claims.shipping_methods", "claims.shipping_address", "claims.additional_items", - "claims.additional_items.variant", - "claims.additional_items.variant.product", "claims.fulfillments", "claims.claim_items", - "claims.claim_items.variant", - "claims.claim_items.variant.product", "claims.claim_items.images", "swaps", "swaps.return_order", @@ -69,7 +62,6 @@ const defaultFields = [ "total", "paid_total", "refundable_amount", - "no_notification", ] describe("GET /admin/orders", () => { diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 1af7932c46..98e72e599c 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -191,20 +191,13 @@ export const defaultRelations = [ "returns.items.reason", "gift_cards", "gift_card_transactions", - "items", - "items.variant", - "items.variant.product", "claims", "claims.return_order", "claims.shipping_methods", "claims.shipping_address", "claims.additional_items", - "claims.additional_items.variant", - "claims.additional_items.variant.product", "claims.fulfillments", "claims.claim_items", - "claims.claim_items.variant", - "claims.claim_items.variant.product", "claims.claim_items.images", // "claims.claim_items.tags", "swaps", @@ -244,7 +237,6 @@ export const defaultFields = [ "total", "paid_total", "refundable_amount", - "no_notification", ] export const allowedFields = [ @@ -273,7 +265,6 @@ export const allowedFields = [ "total", "paid_total", "refundable_amount", - "no_notification", ] export const allowedRelations = [ diff --git a/packages/medusa/src/api/routes/admin/swaps/get-swap.js b/packages/medusa/src/api/routes/admin/swaps/get-swap.js index c395f4974e..114a641a69 100644 --- a/packages/medusa/src/api/routes/admin/swaps/get-swap.js +++ b/packages/medusa/src/api/routes/admin/swaps/get-swap.js @@ -11,9 +11,6 @@ export default async (req, res) => { "return_order", "fulfillments", "payment", - "items", - "items.variant", - "items.variant.product", "shipping_address", "shipping_methods", "cart", diff --git a/packages/medusa/src/api/routes/store/carts/index.js b/packages/medusa/src/api/routes/store/carts/index.js index ce5dfdf06b..42363bd12c 100644 --- a/packages/medusa/src/api/routes/store/carts/index.js +++ b/packages/medusa/src/api/routes/store/carts/index.js @@ -107,15 +107,13 @@ export const defaultRelations = [ "gift_cards", "region", "items", - "items.variant", - "items.variant.prices", "payment", "shipping_address", "billing_address", "region.countries", "region.payment_providers", - "payment_sessions", "shipping_methods", + "payment_sessions", "shipping_methods.shipping_option", "discounts", ] diff --git a/packages/medusa/src/api/routes/store/orders/index.js b/packages/medusa/src/api/routes/store/orders/index.js index 72e802c90e..4405a86ba7 100644 --- a/packages/medusa/src/api/routes/store/orders/index.js +++ b/packages/medusa/src/api/routes/store/orders/index.js @@ -33,7 +33,6 @@ export const defaultRelations = [ "items", "items.variant", "items.variant.product", - "items.variant.prices", "shipping_methods", "discounts", "customer", diff --git a/packages/medusa/yarn.lock b/packages/medusa/yarn.lock index 329b52b506..897f3496c4 100644 --- a/packages/medusa/yarn.lock +++ b/packages/medusa/yarn.lock @@ -1673,10 +1673,10 @@ babel-preset-jest@^25.5.0: babel-plugin-jest-hoist "^25.5.0" babel-preset-current-node-syntax "^0.1.2" -babel-preset-medusa-package@^1.1.8: - version "1.1.9" - resolved "https://registry.yarnpkg.com/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.9.tgz#4bd3f588e9d84d5888279a82dd69559965326cdc" - integrity sha512-U+5QM2N2kQ0Rxy8/8tUXzCbckrkju7E+bvPitFLctAR9V6RAWrJuZ11joZ+tE8upIkS1/b4uEbrVnoM0pq+nNA== +babel-preset-medusa-package@^1.1.5-next.0: + version "1.1.5-next.0" + resolved "https://registry.yarnpkg.com/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.5-next.0.tgz#3ab62092742ae4976f80e2d0f9ff887866d7f032" + integrity sha512-M+DDbIi2VLZdir+svQIpWhUACHTE/1Cx2aQ8zU/n+0kb29yxMVNWqZto9m4Uh3c9PkoSnZfOYpu1AG/5RPByjw== dependencies: "@babel/plugin-proposal-class-properties" "^7.12.1" "@babel/plugin-proposal-decorators" "^7.12.1" @@ -4545,28 +4545,28 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= -medusa-core-utils@^1.1.14, medusa-core-utils@^1.1.15: - version "1.1.15" - resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.15.tgz#0fe98e1a451b5554b03421d241c973b67f00ff9b" - integrity sha512-sK1+Q0k68Rsz0XDAYLVDJ9hshQssMTxceUk+9umXxZgZlPhrPcHMMi8BwwrKOEaSk+nxmN38/h0XiHJ92Pts8g== +medusa-core-utils@^1.1.11-next.0, medusa-core-utils@^1.1.11-next.0+60da043: + version "1.1.11-next.0" + resolved "https://registry.yarnpkg.com/medusa-core-utils/-/medusa-core-utils-1.1.11-next.0.tgz#c65ec751f48a3abf530bea598793fbbb96b84796" + integrity sha512-v4qqsRAOBvueJcKeMD8uL2Qb9dvR+qh3sDvW8C+1bpbnjuTbIq2D+d/xT+963mx3+e445XRoePjXNLltUcSicw== dependencies: joi "^17.3.0" joi-objectid "^3.0.1" -medusa-interfaces@^1.1.15: - version "1.1.16" - resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-1.1.16.tgz#1b693759359faa2811966c9420f20f865591cf05" - integrity sha512-ghy4radBy1RIrkRThXIQ2q86htxPPnIFA1LMNyxViPKVZ+QPv350NNow6gSXsm6diTV5lWH0Bvl/hH6AbjA8vA== +medusa-interfaces@^1.1.12-next.0: + version "1.1.12-next.0" + resolved "https://registry.yarnpkg.com/medusa-interfaces/-/medusa-interfaces-1.1.12-next.0.tgz#12f0b6eb068c729b10a66b693462e765a7661954" + integrity sha512-55CrFN4QHtUo32XQ88qKw1/CfqwikQxNnR2u05Xyyc63efoxlk6tlGg5o8PH74rA3kwQgmztjfG859GtwBRoOg== dependencies: - medusa-core-utils "^1.1.15" + medusa-core-utils "^1.1.11-next.0+60da043" -medusa-test-utils@^1.1.17: - version "1.1.18" - resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.18.tgz#4660f1cbec47abf5f17fc9469bb7ec5543b93c85" - integrity sha512-M25eFBvxlBzKu4dHQFz2ijMqjQIYgG5eNIxo1NE+3CLrgRNl+nrG+LwUBE0ouVDa9fi1TMSXXeTD17/7o7UOAA== +medusa-test-utils@^1.1.14-next.0: + version "1.1.14-next.0" + resolved "https://registry.yarnpkg.com/medusa-test-utils/-/medusa-test-utils-1.1.14-next.0.tgz#29a85e7f08da811e3f2c735de5a906522de23948" + integrity sha512-NMUP7d1HH91piXLZGeF6ifEiyI4cA8jp7OTrD8+i/miS0HwilGxsXxqfzolzgsB/2AWiDrLdWg+pFF8JREQT2Q== dependencies: "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "^1.1.15" + medusa-core-utils "^1.1.11-next.0+60da043" randomatic "^3.1.1" merge-descriptors@1.0.1: From 8e66861c952409af03334969b687711452c488b0 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 12:47:13 +0200 Subject: [PATCH 47/55] removed remaining files --- .../api/helpers/expect-relations.js | 20 ------------------- packages/medusa/.vscode/settings.json | 11 ---------- 2 files changed, 31 deletions(-) delete mode 100644 integration-tests/api/helpers/expect-relations.js delete mode 100644 packages/medusa/.vscode/settings.json diff --git a/integration-tests/api/helpers/expect-relations.js b/integration-tests/api/helpers/expect-relations.js deleted file mode 100644 index 6d9a8850dc..0000000000 --- a/integration-tests/api/helpers/expect-relations.js +++ /dev/null @@ -1,20 +0,0 @@ -const { expect } = require("@jest/globals") - -export function expectRelations(expected, actual){ - expected.forEach(a => expectRelations_(a, actual)) -} - -function expectRelations_(expected, actual){ - const items = expected.split("."); - let data_ = actual; - - for(const i in items){ - data_ = data_[items[i]]; - - if(data_ instanceof Array && data_.length > 0) { - data_ = data_[0]; - } - - expect(data_).toBeDefined(); - } -} diff --git a/packages/medusa/.vscode/settings.json b/packages/medusa/.vscode/settings.json deleted file mode 100644 index f78775143f..0000000000 --- a/packages/medusa/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "editor.formatOnSave": true, - "[javascript]": { - "editor.formatOnSave": true - }, - "eslint.format.enable": true, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, - "editor.defaultFormatter": "esbenp.prettier-vscode" -} \ No newline at end of file From c1a14a647fa53f20a27ad3591b6705fba2a8e892 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 15:19:23 +0200 Subject: [PATCH 48/55] readded needed relations to GET order --- packages/medusa/src/api/routes/admin/orders/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/medusa/src/api/routes/admin/orders/index.js b/packages/medusa/src/api/routes/admin/orders/index.js index 98e72e599c..29ce86e109 100644 --- a/packages/medusa/src/api/routes/admin/orders/index.js +++ b/packages/medusa/src/api/routes/admin/orders/index.js @@ -237,6 +237,7 @@ export const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedFields = [ @@ -265,6 +266,7 @@ export const allowedFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] export const allowedRelations = [ From 38a59b2c2ec21d90305dc874b423e3d79e66c822 Mon Sep 17 00:00:00 2001 From: --list Date: Fri, 2 Jul 2021 15:29:49 +0200 Subject: [PATCH 49/55] incl. order notification for draft-order --- packages/medusa/src/api/routes/admin/draft-orders/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/medusa/src/api/routes/admin/draft-orders/index.js b/packages/medusa/src/api/routes/admin/draft-orders/index.js index 10b9e65f30..d5a08f41ce 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/index.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/index.js @@ -78,6 +78,7 @@ export const defaultFields = [ "created_at", "updated_at", "metadata", + "no_notification_order", ] export const allowedFields = [ @@ -89,6 +90,7 @@ export const allowedFields = [ "created_at", "updated_at", "metadata", + "no_notification_order", ] export const allowedRelations = ["cart"] From 243fbe7e79d4e25fc55733c00d354b8ae0230b8a Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 08:35:15 +0200 Subject: [PATCH 50/55] corrected failing tests --- .../medusa/src/api/routes/admin/orders/__tests__/get-order.js | 1 + packages/medusa/src/services/__tests__/claim.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js index 5001ed0def..57cb1db7ea 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/get-order.js @@ -62,6 +62,7 @@ const defaultFields = [ "total", "paid_total", "refundable_amount", + "no_notification", ] describe("GET /admin/orders", () => { diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index 61b6f03ef4..8b88cb7d42 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -114,6 +114,7 @@ describe("ClaimService", () => { quantity: 1, }, ], + no_notification: true, }) expect(withTransactionMock).toHaveBeenCalledWith("lineItem") From fa3cde07ac9f422f495bf2ddbb5708356e4a8d6b Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 09:49:58 +0200 Subject: [PATCH 51/55] snake_cased noNotification and other minor changes --- .../admin/draft-orders/create-draft-order.js | 2 +- .../admin/draft-orders/update-draft-order.js | 7 +++- packages/medusa/src/api/routes/admin/index.js | 2 +- .../orders/__tests__/create-fulfillment.js | 3 +- .../api/routes/admin/orders/create-claim.js | 6 +-- .../routes/admin/orders/create-fulfillment.js | 4 +- .../routes/admin/orders/create-shipment.js | 2 +- .../admin/orders/create-swap-shipment.js | 2 +- .../api/routes/admin/orders/create-swap.js | 9 +++-- .../api/routes/admin/orders/fulfill-claim.js | 10 ++--- .../api/routes/admin/orders/fulfill-swap.js | 10 ++--- .../api/routes/admin/orders/refund-payment.js | 2 +- .../api/routes/store/returns/create-return.js | 5 +-- .../medusa/src/services/__tests__/claim.js | 4 +- .../medusa/src/services/__tests__/order.js | 8 ++-- .../medusa/src/services/__tests__/swap.js | 39 ++++++++++--------- packages/medusa/src/services/claim.js | 14 +++---- packages/medusa/src/services/draft-order.js | 3 +- packages/medusa/src/services/fulfillment.js | 5 ++- packages/medusa/src/services/notification.js | 4 +- packages/medusa/src/services/order.js | 24 ++++++------ packages/medusa/src/services/swap.js | 28 ++++++------- 22 files changed, 100 insertions(+), 93 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js index 03db073d58..5e1cbe3b51 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.js @@ -155,7 +155,7 @@ export default async (req, res) => { draftOrder = await draftOrderService.retrieve(draftOrder.id, { relations: defaultRelations, select: defaultFields, - }) // + }) res.status(200).json({ draft_order: draftOrder }) } catch (err) { diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js index 6fff5d598b..5de8e9545a 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.js @@ -92,7 +92,12 @@ export default async (req, res) => { ) } - await draftOrderService.update(draftOrder.id, value) + if ("no_notification_order" in value) { + await draftOrderService.update(draftOrder.id, { + no_notification_order: value.no_notification_order, + }) + delete value.no_notification_order + } await cartService.update(draftOrder.cart_id, value) diff --git a/packages/medusa/src/api/routes/admin/index.js b/packages/medusa/src/api/routes/admin/index.js index a4be5a9c59..c5b5d4b557 100644 --- a/packages/medusa/src/api/routes/admin/index.js +++ b/packages/medusa/src/api/routes/admin/index.js @@ -65,7 +65,7 @@ export default (app, container, config) => { returnRoutes(route) variantRoutes(route) draftOrderRoutes(route) - collectionRoutes(route) + collectionRoutes(route) notificationRoutes(route) returnReasonRoutes(route) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js index c4a074f899..9ba6e8a2b1 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js @@ -43,7 +43,7 @@ describe("POST /admin/orders/:id/fulfillment", () => { quantity: 1, }, ], - {"metadata": undefined, "noNotification": undefined} + { metadata: undefined, no_notification: undefined } ) }) @@ -52,6 +52,5 @@ describe("POST /admin/orders/:id/fulfillment", () => { expect(subject.body.order.id).toEqual(IdMap.getId("test-order")) expect(subject.body.order.fulfillment_status).toEqual("fulfilled") }) - }) }) diff --git a/packages/medusa/src/api/routes/admin/orders/create-claim.js b/packages/medusa/src/api/routes/admin/orders/create-claim.js index 365f4f8023..ade142b418 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/create-claim.js @@ -110,8 +110,7 @@ import { defaultRelations, defaultFields } from "./" * $ref: "#/components/schemas/order" */ export default async (req, res) => { - const { id } = req.params - + const { id } = req.params const schema = Validator.object().keys({ type: Validator.string() .valid("replace", "refund") @@ -165,8 +164,7 @@ export default async (req, res) => { const { value, error } = schema.validate(req.body) if (error) { throw new MedusaError(MedusaError.Types.INVALID_DATA, error.details) - } - + } const idempotencyKeyService = req.scope.resolve("idempotencyKeyService") const headerKey = req.get("Idempotency-Key") || "" diff --git a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js index 798bd9a2ae..11e41323ce 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-fulfillment.js @@ -65,8 +65,8 @@ export default async (req, res) => { const orderService = req.scope.resolve("orderService") await orderService.createFulfillment(id, value.items, { - metadata: value.metadata, - noNotification: value.no_notification + metadata: value.metadata, + no_notification: value.no_notification, }) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/create-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-shipment.js index c8d093bf70..915e15f26d 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-shipment.js @@ -59,7 +59,7 @@ export default async (req, res) => { id, value.fulfillment_id, value.tracking_numbers.map(n => ({ tracking_number: n })), - { noNotification: value.no_notification } + { no_notification: value.no_notification } ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js index 6d5d0e5134..edf8572f51 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap-shipment.js @@ -61,7 +61,7 @@ export default async (req, res) => { swap_id, value.fulfillment_id, value.tracking_numbers.map(n => ({ tracking_number: n })), - {noNotification: value.no_notification}, + { no_notification: value.no_notification } ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/create-swap.js b/packages/medusa/src/api/routes/admin/orders/create-swap.js index 53c0151f4e..25ad45604e 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -68,7 +68,7 @@ export default async (req, res) => { .items({ item_id: Validator.string().required(), quantity: Validator.number().required(), - }) + }) .required(), return_shipping: Validator.object() .keys({ @@ -82,7 +82,7 @@ export default async (req, res) => { variant_id: Validator.string().required(), quantity: Validator.number().required(), }), - no_notification: Validator.boolean().optional() + no_notification: Validator.boolean().optional(), }) const { value, error } = schema.validate(req.body) @@ -138,7 +138,10 @@ export default async (req, res) => { value.return_items, value.additional_items, value.return_shipping, - { idempotency_key: idempotencyKey.idempotency_key, noNotification: value.no_notification } + { + idempotency_key: idempotencyKey.idempotency_key, + no_notification: value.no_notification, + } ) await swapService.withTransaction(manager).createCart(swap.id) diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js index a3a4d9e88d..6c017c8517 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-claim.js @@ -51,12 +51,10 @@ export default async (req, res) => { const entityManager = req.scope.resolve("manager") await entityManager.transaction(async manager => { - await claimService - .withTransaction(manager) - .createFulfillment(claim_id, { - metadata: value.metadata, - noNotification: value.no_notification, - }) + await claimService.withTransaction(manager).createFulfillment(claim_id, { + metadata: value.metadata, + no_notification: value.no_notification, + }) }) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js index 289f45eff9..aa8f680464 100644 --- a/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/fulfill-swap.js @@ -51,12 +51,10 @@ export default async (req, res) => { const entityManager = req.scope.resolve("manager") await entityManager.transaction(async manager => { - await swapService - .withTransaction(manager) - .createFulfillment(swap_id, { - metadata: value.metadata, - noNotification: value.no_notification, - }) + await swapService.withTransaction(manager).createFulfillment(swap_id, { + metadata: value.metadata, + no_notification: value.no_notification, + }) const order = await orderService.withTransaction(manager).retrieve(id, { select: defaultFields, diff --git a/packages/medusa/src/api/routes/admin/orders/refund-payment.js b/packages/medusa/src/api/routes/admin/orders/refund-payment.js index 54381137f3..b0bc76bf9d 100644 --- a/packages/medusa/src/api/routes/admin/orders/refund-payment.js +++ b/packages/medusa/src/api/routes/admin/orders/refund-payment.js @@ -67,7 +67,7 @@ export default async (req, res) => { value.amount, value.reason, value.note, - { noNotification: value.no_notification } + { no_notification: value.no_notification } ) const order = await orderService.retrieve(id, { diff --git a/packages/medusa/src/api/routes/store/returns/create-return.js b/packages/medusa/src/api/routes/store/returns/create-return.js index 1101dbd08e..e04bf44037 100644 --- a/packages/medusa/src/api/routes/store/returns/create-return.js +++ b/packages/medusa/src/api/routes/store/returns/create-return.js @@ -31,7 +31,6 @@ import { MedusaError, Validator } from "medusa-core-utils" * option_id: * type: string * description: The id of the Shipping Option to create the Shipping Method from. - * * tags: * - Return * responses: @@ -59,7 +58,7 @@ export default async (req, res) => { .keys({ option_id: Validator.string().optional(), }) - .optional() + .optional(), }) const { value, error } = schema.validate(req.body) @@ -132,7 +131,7 @@ export default async (req, res) => { .withTransaction(manager) .emit("order.return_requested", { id: value.order_id, - return_id: createdReturn.id + return_id: createdReturn.id, }) return { diff --git a/packages/medusa/src/services/__tests__/claim.js b/packages/medusa/src/services/__tests__/claim.js index 8b88cb7d42..feae278cb3 100644 --- a/packages/medusa/src/services/__tests__/claim.js +++ b/packages/medusa/src/services/__tests__/claim.js @@ -442,7 +442,7 @@ describe("ClaimService", () => { metadata: { meta: "data", }, - noNotification: false, + no_notification: false, }) expect(withTransactionMock).toHaveBeenCalledTimes(3) @@ -458,7 +458,7 @@ describe("ClaimService", () => { metadata: { meta: "data", }, - noNotification: false, + no_notification: false, } ) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 4b89496653..02a8bfc76e 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -877,7 +877,7 @@ describe("OrderService", () => { quantity: 1, }, ], - { noNotification: input } + { no_notification: input } ) expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { @@ -1073,7 +1073,7 @@ describe("OrderService", () => { ).toHaveBeenCalledWith( IdMap.getId("fulfillment"), [{ tracking_number: "1234" }, { tracking_number: "2345" }], - { metadata: undefined, noNotification: true } + { metadata: undefined, no_notification: true } ) expect(orderRepo.save).toHaveBeenCalledTimes(1) @@ -1094,7 +1094,7 @@ describe("OrderService", () => { IdMap.getId("test"), IdMap.getId("fulfillment"), [{ tracking_number: "1234" }, { tracking_number: "2345" }], - { noNotification: input } + { no_notification: input } ) expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { @@ -1197,7 +1197,7 @@ describe("OrderService", () => { 100, "discount", "note", - { noNotification: input } + { no_notification: input } ) expect(eventBusService.emit).toHaveBeenCalledWith(expect.any(String), { diff --git a/packages/medusa/src/services/__tests__/swap.js b/packages/medusa/src/services/__tests__/swap.js index ba9834c456..a3368b0a03 100644 --- a/packages/medusa/src/services/__tests__/swap.js +++ b/packages/medusa/src/services/__tests__/swap.js @@ -340,30 +340,33 @@ describe("SwapService", () => { expect(returnService.create).toHaveBeenCalledTimes(1) }) - + it.each([ [true, true], [false, false], [undefined, true], - ])( "passes correct no_notification to eventBus with %s", async (input, expected) => { + ])( + "passes correct no_notification to eventBus with %s", + async (input, expected) => { + await swapService.create( + testOrder, + [{ item_id: IdMap.getId("line"), quantity: 1 }], + [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], + { + id: IdMap.getId("return-shipping"), + price: 20, + }, + { no_notification: input } + ) - await swapService.create( - testOrder, - [{ item_id: IdMap.getId("line"), quantity: 1 }], - [{ variant_id: IdMap.getId("new-variant"), quantity: 1 }], - { - id: IdMap.getId("return-shipping"), - price: 20, - }, - {noNotification: input} - ) - - expect(eventBusService.emit).toHaveBeenCalledWith( - expect.any(String), - {"id": undefined, "no_notification": expected}) - }) - }) + expect(eventBusService.emit).toHaveBeenCalledWith( + expect.any(String), + { id: undefined, no_notification: expected } + ) + } + ) }) + }) describe("receiveReturn", () => { beforeEach(() => { diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 37161d9d37..72cb5491ce 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -311,10 +311,10 @@ class ClaimService extends BaseService { id, config = { metadata: {}, - noNotification: undefined, + no_notification: undefined, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const claim = await this.retrieve(id, { @@ -353,7 +353,7 @@ class ClaimService extends BaseService { } const evaluatedNoNotification = - noNotification !== undefined ? noNotification : claim.no_notification + no_notification !== undefined ? no_notification : claim.no_notification const fulfillments = await this.fulfillmentService_ .withTransaction(manager) @@ -469,10 +469,10 @@ class ClaimService extends BaseService { trackingLinks, config = { metadata: {}, - noNotification: undefined, + no_notification: undefined, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const claim = await this.retrieve(id, { @@ -480,13 +480,13 @@ class ClaimService extends BaseService { }) const evaluatedNoNotification = - noNotification !== undefined ? noNotification : claim.no_notification + no_notification !== undefined ? no_notification : claim.no_notification const shipment = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { metadata, - noNotification: evaluatedNoNotification, + no_notification: evaluatedNoNotification, }) claim.fulfillment_status = "shipped" diff --git a/packages/medusa/src/services/draft-order.js b/packages/medusa/src/services/draft-order.js index d2ec54bfcd..d16044b43b 100644 --- a/packages/medusa/src/services/draft-order.js +++ b/packages/medusa/src/services/draft-order.js @@ -253,7 +253,7 @@ class DraftOrderService extends BaseService { items, shipping_methods, discounts, - no_notification_order = undefined, + no_notification_order, ...rest } = data @@ -345,6 +345,7 @@ class DraftOrderService extends BaseService { await draftOrderRepo.save(draftOrder) }) } + /** * Updates a draft order with the given data * @param {String} doId - id of the draft order diff --git a/packages/medusa/src/services/fulfillment.js b/packages/medusa/src/services/fulfillment.js index 45598c8b47..0fdb0a4027 100644 --- a/packages/medusa/src/services/fulfillment.js +++ b/packages/medusa/src/services/fulfillment.js @@ -180,9 +180,10 @@ class FulfillmentService extends BaseService { this.validateFulfillmentLineItem_ ) - const { noNotification, ...rest} = custom + const { no_notification, ...rest } = custom - const evaluatedNoNotification = noNotification !== undefined ? noNotification : order.no_notification + const evaluatedNoNotification = + no_notification !== undefined ? no_notification : order.no_notification const { shipping_methods } = order diff --git a/packages/medusa/src/services/notification.js b/packages/medusa/src/services/notification.js index 62bdd688eb..8dcf7962a0 100644 --- a/packages/medusa/src/services/notification.js +++ b/packages/medusa/src/services/notification.js @@ -28,7 +28,7 @@ class NotificationService extends BaseService { this.notificationProviderRepository_ = notificationProviderRepository this.subscribers_ = {} - this.attachmentGenerator_ = null + this.attachmentGenerator_ = null } /** @@ -164,7 +164,7 @@ class NotificationService extends BaseService { if (!subs) { return Promise.resolve() } - if(data['no_notification'] === true) { + if (data["no_notification"] === true) { return } diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 7409fa4a6e..7cf6f42858 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -579,10 +579,10 @@ class OrderService extends BaseService { trackingLinks, config = { metadata: {}, - noNotification: undefined, + no_notification: undefined, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { relations: ["items"] }) @@ -596,13 +596,15 @@ class OrderService extends BaseService { } const evaluatedNoNotification = - noNotification !== undefined ? noNotification : shipment.no_notification + no_notification !== undefined + ? no_notification + : shipment.no_notification const shipmentRes = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { metadata, - noNotification: evaluatedNoNotification, + no_notification: evaluatedNoNotification, }) order.fulfillment_status = "shipped" @@ -1002,11 +1004,11 @@ class OrderService extends BaseService { orderId, itemsToFulfill, config = { - noNotification: undefined, + no_notification: undefined, metadata: {}, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { @@ -1046,7 +1048,7 @@ class OrderService extends BaseService { .withTransaction(manager) .createFulfillment(order, itemsToFulfill, { metadata, - noNotification: noNotification, + no_notification: no_notification, order_id: orderId, }) let successfullyFulfilled = [] @@ -1087,7 +1089,7 @@ class OrderService extends BaseService { const result = await orderRepo.save(order) const evaluatedNoNotification = - noNotification !== undefined ? noNotification : order.no_notification + no_notification !== undefined ? no_notification : order.no_notification for (const fulfillment of fulfillments) { await this.eventBus_ @@ -1157,10 +1159,10 @@ class OrderService extends BaseService { reason, note, config = { - noNotification: undefined, + no_notification: undefined, } ) { - const { noNotification } = config + const { no_notification } = config return this.atomicPhase_(async manager => { const order = await this.retrieve(orderId, { @@ -1182,7 +1184,7 @@ class OrderService extends BaseService { const result = await this.retrieve(orderId) const evaluatedNoNotification = - noNotification !== undefined ? noNotification : order.no_notification + no_notification !== undefined ? no_notification : order.no_notification this.eventBus_.emit(OrderService.Events.REFUND_CREATED, { id: result.id, diff --git a/packages/medusa/src/services/swap.js b/packages/medusa/src/services/swap.js index 6db06e4785..ec5d850881 100644 --- a/packages/medusa/src/services/swap.js +++ b/packages/medusa/src/services/swap.js @@ -205,9 +205,9 @@ class SwapService extends BaseService { * the customer. * @param {ReturnShipping?} returnShipping - an optional shipping method for * returning the returnItems. - * @param {boolean?} noNotification - an optional flag to disable sending - * notification when creating swap. If set, it overrules the attribute inherited - * from the order. + * @param {Object} custom - contains relevant custom information. This object may + * include no_notification which will disable sending notification when creating + * swap. If set, it overrules the attribute inherited from the order. * @returns {Promise} the newly created swap. */ async create( @@ -216,10 +216,10 @@ class SwapService extends BaseService { additionalItems, returnShipping, custom = { - noNotification: undefined, + no_notification: undefined, } ) { - const { noNotification, ...rest } = custom + const { no_notification, ...rest } = custom return this.atomicPhase_(async manager => { if ( order.fulfillment_status === "not_fulfilled" || @@ -242,7 +242,7 @@ class SwapService extends BaseService { ) const evaluatedNoNotification = - noNotification !== undefined ? noNotification : order.no_notification + no_notification !== undefined ? no_notification : order.no_notification const swapRepo = manager.getCustomRepository(this.swapRepository_) const created = swapRepo.create({ @@ -645,17 +645,17 @@ class SwapService extends BaseService { * Fulfills the addtional items associated with the swap. Will call the * fulfillment providers associated with the shipping methods. * @param {string} swapId - the id of the swap to fulfill, - * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a noNotification flag. + * @param {object} config - optional configurations, includes optional metadata to attach to the shipment, and a no_notification flag. * @returns {Promise} the updated swap with new status and fulfillments. */ async createFulfillment( swapId, config = { metadata: {}, - noNotification: undefined, + no_notification: undefined, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId, { @@ -687,7 +687,7 @@ class SwapService extends BaseService { } const evaluatedNoNotification = - noNotification !== undefined ? noNotification : swap.no_notification + no_notification !== undefined ? no_notification : swap.no_notification swap.fulfillments = await this.fulfillmentService_ .withTransaction(manager) @@ -779,10 +779,10 @@ class SwapService extends BaseService { trackingLinks, config = { metadata: {}, - noNotification: undefined, + no_notification: undefined, } ) { - const { metadata, noNotification } = config + const { metadata, no_notification } = config return this.atomicPhase_(async manager => { const swap = await this.retrieve(swapId, { @@ -790,14 +790,14 @@ class SwapService extends BaseService { }) const evaluatedNoNotification = - noNotification !== undefined ? noNotification : swap.no_notification + no_notification !== undefined ? no_notification : swap.no_notification // Update the fulfillment to register const shipment = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { metadata, - noNotification: evaluatedNoNotification, + no_notification: evaluatedNoNotification, }) swap.fulfillment_status = "shipped" From c3304edb79a83a17b2619bdf0337120ba33c0697 Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 10:47:26 +0200 Subject: [PATCH 52/55] added no_notification to fulfillment createShipment --- packages/medusa/src/services/fulfillment.js | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/medusa/src/services/fulfillment.js b/packages/medusa/src/services/fulfillment.js index 0fdb0a4027..64183e6aca 100644 --- a/packages/medusa/src/services/fulfillment.js +++ b/packages/medusa/src/services/fulfillment.js @@ -165,7 +165,7 @@ class FulfillmentService extends BaseService { * those partitions. * @param {Order} order - order to create fulfillment for * @param {{ item_id: string, quantity: number}[]} itemsToFulfill - the items in the order to fulfill - * @param {object} config - potential configurations, including metadata to add + * @param {object} metadata - potential metadata to add * @return {Fulfillment[]} the created fulfillments */ async createFulfillment(order, itemsToFulfill, custom = {}) { @@ -180,11 +180,6 @@ class FulfillmentService extends BaseService { this.validateFulfillmentLineItem_ ) - const { no_notification, ...rest } = custom - - const evaluatedNoNotification = - no_notification !== undefined ? no_notification : order.no_notification - const { shipping_methods } = order // partition order items to their dedicated shipping method @@ -193,10 +188,9 @@ class FulfillmentService extends BaseService { const created = await Promise.all( fulfillments.map(async ({ shipping_method, items }) => { const ful = fulfillmentRepository.create({ - ...rest, + ...custom, provider_id: shipping_method.shipping_option.provider_id, items: items.map(i => ({ item_id: i.id, quantity: i.quantity })), - no_notification: evaluatedNoNotification, data: {}, }) @@ -247,10 +241,19 @@ class FulfillmentService extends BaseService { * tracking numbers and potentially more metadata. * @param {Order} fulfillmentId - the fulfillment to ship * @param {TrackingLink[]} trackingNumbers - tracking numbers for the shipment - * @param {object} metadata - potential metadata to add + * @param {object} config - potential configuration settings, such as no_notification and metadata * @return {Fulfillment} the shipped fulfillment */ - async createShipment(fulfillmentId, trackingLinks, metadata) { + async createShipment( + fulfillmentId, + trackingLinks, + config = { + metadata: {}, + no_notification: undefined, + } + ) { + const { metadata, no_notification } = config + return this.atomicPhase_(async manager => { const fulfillmentRepository = manager.getCustomRepository( this.fulfillmentRepository_ @@ -270,6 +273,10 @@ class FulfillmentService extends BaseService { trackingLinkRepo.create(tl) ) + if (no_notification) { + fulfillment.no_notification = no_notification + } + fulfillment.metadata = { ...fulfillment.metadata, ...metadata, From 0773da0f94bc4b043b4f2a617dd5c560e5e9a103 Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 10:48:21 +0200 Subject: [PATCH 53/55] updated to explicit metadata assignment for createShipment calls --- packages/medusa/src/services/claim.js | 2 +- packages/medusa/src/services/order.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index 72cb5491ce..a6968fdff4 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -485,7 +485,7 @@ class ClaimService extends BaseService { const shipment = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { - metadata, + metadata: metadata, no_notification: evaluatedNoNotification, }) diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 7cf6f42858..730ca5163d 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -603,7 +603,7 @@ class OrderService extends BaseService { const shipmentRes = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { - metadata, + metadata: metadata, no_notification: evaluatedNoNotification, }) From 368c30c9348d6ef9a56b23f32588d2335ea3d46c Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 10:52:02 +0200 Subject: [PATCH 54/55] redid metadata change --- packages/medusa/src/services/claim.js | 2 +- packages/medusa/src/services/order.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/services/claim.js b/packages/medusa/src/services/claim.js index a6968fdff4..72cb5491ce 100644 --- a/packages/medusa/src/services/claim.js +++ b/packages/medusa/src/services/claim.js @@ -485,7 +485,7 @@ class ClaimService extends BaseService { const shipment = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { - metadata: metadata, + metadata, no_notification: evaluatedNoNotification, }) diff --git a/packages/medusa/src/services/order.js b/packages/medusa/src/services/order.js index 730ca5163d..7cf6f42858 100644 --- a/packages/medusa/src/services/order.js +++ b/packages/medusa/src/services/order.js @@ -603,7 +603,7 @@ class OrderService extends BaseService { const shipmentRes = await this.fulfillmentService_ .withTransaction(manager) .createShipment(fulfillmentId, trackingLinks, { - metadata: metadata, + metadata, no_notification: evaluatedNoNotification, }) From 96e6c73a33c3870f22ab8cf2af1210df452244ea Mon Sep 17 00:00:00 2001 From: --list Date: Mon, 5 Jul 2021 11:03:44 +0200 Subject: [PATCH 55/55] removed unused imports --- .../orders/__tests__/create-fulfillment.js | 1 - .../admin/orders/__tests__/return-order.js | 28 ++++++------ .../src/services/__tests__/draft-order.js | 43 +++++++++---------- .../medusa/src/services/__tests__/order.js | 1 - 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js index 9ba6e8a2b1..95350aa0d7 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/create-fulfillment.js @@ -1,7 +1,6 @@ import { IdMap } from "medusa-test-utils" import { request } from "../../../../../helpers/test-request" import { OrderServiceMock } from "../../../../../services/__mocks__/order" -import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus" describe("POST /admin/orders/:id/fulfillment", () => { describe("successfully fulfills an order", () => { diff --git a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js index f84e0bc65a..661a5498a9 100644 --- a/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js +++ b/packages/medusa/src/api/routes/admin/orders/__tests__/return-order.js @@ -1,9 +1,7 @@ import { IdMap } from "medusa-test-utils" import { request } from "../../../../../helpers/test-request" -import { orders } from "../../../../../services/__mocks__/order" import { ReturnService } from "../../../../../services/__mocks__/return" import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus" -import { OrderServiceMock } from "../../../../../services/__mocks__/order" describe("POST /admin/orders/:id/return", () => { describe("successfully returns full order", () => { @@ -244,11 +242,14 @@ describe("POST /admin/orders/:id/return", () => { }, } ) - expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: false, - return_id: expect.any(String) - }) + expect(EventBusServiceMock.emit).toHaveBeenCalledWith( + expect.any(String), + { + id: expect.any(String), + no_notification: false, + return_id: expect.any(String), + } + ) }) }) @@ -280,11 +281,14 @@ describe("POST /admin/orders/:id/return", () => { } ) - expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{ - id: expect.any(String), - no_notification: true, - return_id: expect.any(String) - }) + expect(EventBusServiceMock.emit).toHaveBeenCalledWith( + expect.any(String), + { + id: expect.any(String), + no_notification: true, + return_id: expect.any(String), + } + ) }) }) }) diff --git a/packages/medusa/src/services/__tests__/draft-order.js b/packages/medusa/src/services/__tests__/draft-order.js index 53c170d310..dceedd6091 100644 --- a/packages/medusa/src/services/__tests__/draft-order.js +++ b/packages/medusa/src/services/__tests__/draft-order.js @@ -1,9 +1,8 @@ import _ from "lodash" -import { IdMap, MockRepository, MockManager } from "medusa-test-utils" +import { MockRepository, MockManager } from "medusa-test-utils" import { EventBusServiceMock } from "../__mocks__/event-bus" import DraftOrderService from "../draft-order" - const eventBusService = { emit: jest.fn(), withTransaction: function() { @@ -209,7 +208,6 @@ describe("DraftOrderService", () => { }) describe("update", () => { - const testOrder = { region_id: "test-region", shipping_address_id: "test-shipping", @@ -226,7 +224,7 @@ describe("DraftOrderService", () => { const completedOrder = { status: "completed", - ...testOrder + ...testOrder, } const draftOrderRepository = MockRepository({ @@ -237,17 +235,16 @@ describe("DraftOrderService", () => { id: "test-draft-order", ...d, }), - findOne: (q) => { + findOne: q => { switch (q.where.id) { case "completed": return Promise.resolve(completedOrder) default: return Promise.resolve(testOrder) } - } + }, }) - const draftOrderService = new DraftOrderService({ manager: MockManager, regionService: undefined, @@ -263,7 +260,7 @@ describe("DraftOrderService", () => { beforeEach(async () => { jest.clearAllMocks() }) - + it("calls draftOrder model functions", async () => { await draftOrderService.update("test-draft-order", { no_notification_order: true, @@ -274,26 +271,28 @@ describe("DraftOrderService", () => { no_notification_order: true, billing_address_id: "test-billing", customer_id: "test-customer", - items: [ { - metadata: {}, - quantity: 2, - variant_id: "test-variant" - }], + items: [ + { + metadata: {}, + quantity: 2, + variant_id: "test-variant", + }, + ], region_id: "test-region", shipping_address_id: "test-shipping", - shipping_methods: [{ - data: {}, - option_id: "test-option" - }] + shipping_methods: [ + { + data: {}, + option_id: "test-option", + }, + ], }) }) it("fails to update draftOrder when already complete", async () => { - await expect( - draftOrderService.update("completed", {}) - ).rejects.toThrow("Can't update a draft order which is complete") - + await expect(draftOrderService.update("completed", {})).rejects.toThrow( + "Can't update a draft order which is complete" + ) }) }) - }) diff --git a/packages/medusa/src/services/__tests__/order.js b/packages/medusa/src/services/__tests__/order.js index 02a8bfc76e..e9667752ba 100644 --- a/packages/medusa/src/services/__tests__/order.js +++ b/packages/medusa/src/services/__tests__/order.js @@ -1,6 +1,5 @@ import { IdMap, MockManager, MockRepository } from "medusa-test-utils" import OrderService from "../order" -import { EventBusServiceMock } from "../__mocks__/event-bus" describe("OrderService", () => { const totalsService = {