diff --git a/docs-util/fixture-gen/__tests__/admin/auth.js b/docs-util/fixture-gen/__tests__/admin/auth.js new file mode 100644 index 0000000000..f29f15aff2 --- /dev/null +++ b/docs-util/fixture-gen/__tests__/admin/auth.js @@ -0,0 +1,62 @@ +const { dropDatabase } = require("pg-god"); +const path = require("path"); + +const setupServer = require("../../../helpers/setup-server"); +const { useApi } = require("../../../helpers/use-api"); +const { initDb } = require("../../../helpers/use-db"); + +const adminSeeder = require("../../helpers/admin-seeder"); + +const fixtureWriter = require("../../utils/write-fixture").default; + +jest.setTimeout(30000); + +describe("/admin/auth", () => { + let medusaProcess; + let dbConnection; + + beforeAll(async () => { + const cwd = path.resolve(path.join(__dirname, "..", "..")); + dbConnection = await initDb({ cwd }); + medusaProcess = await setupServer({ cwd }); + }); + + afterAll(async () => { + await dbConnection.close(); + await dropDatabase({ databaseName: "medusa-fixtures" }); + + medusaProcess.kill(); + }); + + describe("POST /admin/products", () => { + beforeEach(async () => { + try { + await adminSeeder(dbConnection); + } catch (err) { + console.log(err); + throw err; + } + }); + + afterEach(async () => { + const manager = dbConnection.manager; + await manager.query(`DELETE FROM "user"`); + }); + + it("authenticates user", async () => { + const api = useApi(); + + const response = await api + .post("/admin/auth", { + email: "admin@medusa.js", + password: "secret_password", + }) + .catch((err) => { + console.log(err); + }); + expect(response.status).toEqual(200); + + fixtureWriter.addFixture("user", response.data.user); + }); + }); +}); diff --git a/docs-util/fixture-gen/__tests__/admin/order.js b/docs-util/fixture-gen/__tests__/admin/order.js index d364398ac8..01eb53021f 100644 --- a/docs-util/fixture-gen/__tests__/admin/order.js +++ b/docs-util/fixture-gen/__tests__/admin/order.js @@ -1,5 +1,6 @@ const { dropDatabase } = require("pg-god"); const path = require("path"); +const { ProductVariant } = require("@medusajs/medusa"); const setupServer = require("../../../helpers/setup-server"); const { useApi } = require("../../../helpers/use-api"); @@ -161,4 +162,93 @@ describe("/admin/orders", () => { fixtureWriter.addFixture("return", response.data.order.returns[0]); }); }); + + describe("POST /admin/orders/:id/swaps", () => { + let id; + let varId; + beforeEach(async () => { + try { + await adminSeeder(dbConnection); + const order = await orderSeeder(dbConnection, { + fulfillment_status: "fulfilled", + payment_status: "captured", + }); + id = order.id; + + const pVar = await dbConnection.manager.findOne(ProductVariant, {}); + varId = pVar.id; + } catch (err) { + console.log(err); + throw err; + } + }); + + afterEach(async () => { + const manager = dbConnection.manager; + await manager.query(`DELETE FROM "fulfillment_item"`); + await manager.query(`DELETE FROM "fulfillment"`); + await manager.query(`DELETE FROM "return_item"`); + await manager.query(`DELETE FROM "return"`); + await manager.query(`DELETE FROM "claim_image"`); + await manager.query(`DELETE FROM "claim_tag"`); + await manager.query(`DELETE FROM "claim_item"`); + await manager.query(`DELETE FROM "shipping_method"`); + await manager.query(`DELETE FROM "line_item"`); + await manager.query(`DELETE FROM "swap"`); + await manager.query(`DELETE FROM "cart"`); + await manager.query(`DELETE FROM "claim_order"`); + await manager.query(`DELETE FROM "money_amount"`); + await manager.query(`DELETE FROM "product_option_value"`); + await manager.query(`DELETE FROM "product_option"`); + await manager.query(`DELETE FROM "product_variant"`); + await manager.query(`DELETE FROM "product"`); + await manager.query(`DELETE FROM "shipping_option"`); + await manager.query(`DELETE FROM "discount"`); + await manager.query(`DELETE FROM "payment"`); + await manager.query(`DELETE FROM "order"`); + await manager.query(`DELETE FROM "customer"`); + await manager.query( + `UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'` + ); + await manager.query(`DELETE FROM "region"`); + await manager.query(`DELETE FROM "user"`); + }); + + it("creates a swap", async () => { + const api = useApi(); + + const { data } = await api.get(`/admin/orders/${id}`, { + headers: { + authorization: "Bearer test_token", + }, + }); + const order = data.order; + + const response = await api.post( + `/admin/orders/${id}/swaps`, + { + return_items: [ + { + item_id: order.items[0].id, + quantity: 1, + }, + ], + additional_items: [ + { + variant_id: varId, + quantity: 2, + }, + ], + }, + { + headers: { + authorization: "Bearer test_token", + }, + } + ); + expect(response.status).toEqual(200); + + fixtureWriter.addFixture("swap", response.data.order.swaps[0]); + }); + }); }); diff --git a/docs-util/fixture-gen/__tests__/admin/shipping-option.js b/docs-util/fixture-gen/__tests__/admin/shipping-option.js index 353a0c515d..da8e687599 100644 --- a/docs-util/fixture-gen/__tests__/admin/shipping-option.js +++ b/docs-util/fixture-gen/__tests__/admin/shipping-option.js @@ -78,10 +78,6 @@ describe("/shipping-options", () => { fixtureWriter.addFixture("region", getRes.data.shipping_option.region); fixtureWriter.addFixture("shipping_option", getRes.data.shipping_option); - fixtureWriter.addFixture( - "shipping_profile", - getRes.data.shipping_option.shipping_profile - ); }); }); }); diff --git a/docs-util/fixture-gen/__tests__/admin/shipping-profile.js b/docs-util/fixture-gen/__tests__/admin/shipping-profile.js new file mode 100644 index 0000000000..3f347ab4ca --- /dev/null +++ b/docs-util/fixture-gen/__tests__/admin/shipping-profile.js @@ -0,0 +1,74 @@ +const { dropDatabase } = require("pg-god"); +const path = require("path"); +const { Region } = require("@medusajs/medusa"); + +const setupServer = require("../../../helpers/setup-server"); +const { useApi } = require("../../../helpers/use-api"); +const { initDb } = require("../../../helpers/use-db"); + +const adminSeeder = require("../../helpers/admin-seeder"); + +const fixtureWriter = require("../../utils/write-fixture").default; + +jest.setTimeout(30000); + +describe("/shipping-profiles", () => { + let medusaProcess; + let dbConnection; + + beforeAll(async () => { + const cwd = path.resolve(path.join(__dirname, "..", "..")); + dbConnection = await initDb({ cwd }); + medusaProcess = await setupServer({ cwd }); + }); + + afterAll(async () => { + dbConnection.close(); + await dropDatabase({ databaseName: "medusa-fixtures" }); + + medusaProcess.kill(); + }); + + describe("POST /admin/shipping-profiles", () => { + let regId; + beforeEach(async () => { + await adminSeeder(dbConnection); + const manager = dbConnection.manager; + const created = manager.create(Region, { + name: "Test Region", + currency_code: "usd", + tax_rate: 0, + fulfillment_providers: [ + { + id: "test-ful", + }, + ], + }); + const newReg = await manager.save(created); + regId = newReg.id; + }); + + afterEach(async () => { + const manager = dbConnection.manager; + await manager.query(`DELETE FROM "shipping_option"`); + await manager.query(`DELETE FROM "region"`); + await manager.query(`DELETE FROM "user"`); + }); + + it("creates a cart", async () => { + const api = useApi(); + + const getRes = await api.get(`/admin/shipping-profiles`, { + headers: { + Authorization: "Bearer test_token", + }, + }); + expect(getRes.status).toEqual(200); + + fixtureWriter.addFixture( + "shipping_profile", + getRes.data.shipping_profiles[0] + ); + }); + }); +}); diff --git a/docs-util/fixture-gen/__tests__/admin/store.js b/docs-util/fixture-gen/__tests__/admin/store.js new file mode 100644 index 0000000000..950fa13168 --- /dev/null +++ b/docs-util/fixture-gen/__tests__/admin/store.js @@ -0,0 +1,56 @@ +const { dropDatabase } = require("pg-god"); +const path = require("path"); +const { Region } = require("@medusajs/medusa"); + +const setupServer = require("../../../helpers/setup-server"); +const { useApi } = require("../../../helpers/use-api"); +const { initDb } = require("../../../helpers/use-db"); + +const adminSeeder = require("../../helpers/admin-seeder"); + +const fixtureWriter = require("../../utils/write-fixture").default; + +jest.setTimeout(30000); + +describe("/shipping-profiles", () => { + let medusaProcess; + let dbConnection; + + beforeAll(async () => { + const cwd = path.resolve(path.join(__dirname, "..", "..")); + dbConnection = await initDb({ cwd }); + medusaProcess = await setupServer({ cwd }); + }); + + afterAll(async () => { + dbConnection.close(); + await dropDatabase({ databaseName: "medusa-fixtures" }); + + medusaProcess.kill(); + }); + + describe("GET /admin/store", () => { + let regId; + beforeEach(async () => { + await adminSeeder(dbConnection); + }); + + afterEach(async () => { + const manager = dbConnection.manager; + await manager.query(`DELETE FROM "user"`); + }); + + it("creates a cart", async () => { + const api = useApi(); + + const getRes = await api.get(`/admin/store`, { + headers: { + Authorization: "Bearer test_token", + }, + }); + expect(getRes.status).toEqual(200); + + fixtureWriter.addFixture("store", getRes.data.store); + }); + }); +}); diff --git a/docs-util/fixture-gen/helpers/order-seeder.js b/docs-util/fixture-gen/helpers/order-seeder.js index c1393f980c..c1c27bb330 100644 --- a/docs-util/fixture-gen/helpers/order-seeder.js +++ b/docs-util/fixture-gen/helpers/order-seeder.js @@ -43,7 +43,7 @@ module.exports = async (connection, data = {}) => { }, ], }); - const newProdVar = manager.save(prodVar); + const newProdVar = await manager.save(prodVar); const ma = manager.create(MoneyAmount, { variant_id: newProdVar.id, diff --git a/docs-util/fixture-gen/package.json b/docs-util/fixture-gen/package.json index d4af7e7693..8ec893ae04 100644 --- a/docs-util/fixture-gen/package.json +++ b/docs-util/fixture-gen/package.json @@ -7,13 +7,13 @@ "build": "babel src -d dist --extensions \".ts,.js\"" }, "dependencies": { - "@medusajs/medusa": "1.1.11-dev-1615546466988", - "medusa-interfaces": "1.1.1-dev-1615546466988" + "@medusajs/medusa": "1.1.11-dev-1615929449260", + "medusa-interfaces": "1.1.1-dev-1615929449260" }, "devDependencies": { "@babel/cli": "^7.12.10", "@babel/core": "^7.12.10", "@babel/node": "^7.12.10", - "babel-preset-medusa-package": "1.1.0-dev-1615546466988" + "babel-preset-medusa-package": "1.1.0-dev-1615929449260" } } diff --git a/docs-util/fixture-gen/yarn.lock b/docs-util/fixture-gen/yarn.lock index e42289e335..58525fae53 100644 --- a/docs-util/fixture-gen/yarn.lock +++ b/docs-util/fixture-gen/yarn.lock @@ -946,10 +946,10 @@ dependencies: "@hapi/hoek" "^9.0.0" -"@medusajs/medusa@1.1.11-dev-1615546466988": - version "1.1.11-dev-1615546466988" - resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.11-dev-1615546466988.tgz#6d09c9ae174cee30a70e76e7e50e69bfc7d4b92a" - integrity sha512-Y9gB8VXoZ/SN00UB8hRJ4xWRdSZX3mCz19ls2SDP4SrqUlWcG04LZDYeKbXQqXRKFFzwR/yNnWOCkLvlrK+69w== +"@medusajs/medusa@1.1.11-dev-1615929449260": + version "1.1.11-dev-1615929449260" + resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.11-dev-1615929449260.tgz#4635d197df491fa10ad80c6fda5818edb6cbe9ad" + integrity sha512-Yx94TuEWe76MLslv1PmDOIDrEJ5lQz8cL2rikK7OquK4oyt0Y8xCE5MNgiiZCP71/sv3TMCoTx0GZxrl02vk8w== dependencies: "@babel/plugin-transform-classes" "^7.9.5" "@hapi/joi" "^16.1.8" @@ -971,8 +971,8 @@ joi "^17.3.0" joi-objectid "^3.0.1" jsonwebtoken "^8.5.1" - medusa-core-utils "1.1.0-dev-1615546466988" - medusa-test-utils "1.1.3-dev-1615546466988" + medusa-core-utils "1.1.0-dev-1615929449260" + medusa-test-utils "1.1.3-dev-1615929449260" morgan "^1.9.1" multer "^1.4.2" passport "^0.4.0" @@ -1184,10 +1184,10 @@ babel-plugin-transform-typescript-metadata@^0.3.1: dependencies: "@babel/helper-plugin-utils" "^7.0.0" -babel-preset-medusa-package@1.1.0-dev-1615546466988: - version "1.1.0-dev-1615546466988" - resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.0-dev-1615546466988.tgz#7b99e2a01c4aa9ccd0f293ca6015c866cae941b5" - integrity sha512-lMNL7fpsVgHJsiX69p7VLmNh7wCjA6nRZq9nslRisBYgeZ4O5fpatlXvL22kU4HaxGhhhF6n5LdpovCcvXoJYg== +babel-preset-medusa-package@1.1.0-dev-1615929449260: + version "1.1.0-dev-1615929449260" + resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.0-dev-1615929449260.tgz#668c9d5f7e385ca1f3b0c681b6e90f0195d45025" + integrity sha512-y3GY3HFPPWOCY6OZ3rh3Ybms/LI6PzvD6Mo+nP6RBw1us6p4UAle1EoQrOp4gXYb5WX9PsYN5TwVUwgDNO7uwg== dependencies: "@babel/plugin-proposal-class-properties" "^7.12.1" "@babel/plugin-proposal-decorators" "^7.12.1" @@ -2649,28 +2649,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.0-dev-1615546466988: - version "1.1.0-dev-1615546466988" - resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.0-dev-1615546466988.tgz#dfcc316b59d24c0c03c2f3eb53f8c9fe9771cc03" - integrity sha512-LHKb/CiNTgbCDHJPt32QCnm4/J39uMasv19TUSB3/8Np85RWalXWQjMWmQF+f/pFuzB0/6bx7z4SFiYK6dw7YQ== +medusa-core-utils@1.1.0-dev-1615929449260: + version "1.1.0-dev-1615929449260" + resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.0-dev-1615929449260.tgz#ad6334e195a77cbf1764ea637f6071a4441adf68" + integrity sha512-udhVtrOWoab7Mljb4r427+iCZ1vy/XJb+yr6Q8xZe535on6DYpjahEiuLgkyy19wX50kVv5yt3raTE4Vg3yKEw== dependencies: joi "^17.3.0" joi-objectid "^3.0.1" -medusa-interfaces@1.1.1-dev-1615546466988: - version "1.1.1-dev-1615546466988" - resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.1-dev-1615546466988.tgz#0e109781d8691b8495c79e4d3bccd5c63668fcf0" - integrity sha512-Hc+aSqTwPU63HJDi11eGj5uP3ebCi3BC5YEDptumMf/JRDDZdwq8SRcwtCNKMBSIlPpsqjBqHcm8Dn7uvwXhhA== +medusa-interfaces@1.1.1-dev-1615929449260: + version "1.1.1-dev-1615929449260" + resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.1-dev-1615929449260.tgz#6034b9f472591b85294430ecce8c68a8b05bd58a" + integrity sha512-w4ORNLHtec/DbMTLCfWatcUU9uVZfQtiOV12/quxg+N9K/2yk7jl8SAWhFiCc0gbT7Trwy1+V8esGEaAIPqMkQ== dependencies: - medusa-core-utils "1.1.0-dev-1615546466988" + medusa-core-utils "1.1.0-dev-1615929449260" -medusa-test-utils@1.1.3-dev-1615546466988: - version "1.1.3-dev-1615546466988" - resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.3-dev-1615546466988.tgz#85e3f5b435fe4259cab3ac69bad9a23d1b301c4f" - integrity sha512-ZBqX7+UEFYXcdoRFnNiv6uv3UR+bU2IBLMVdAk+/FpxX9GYBW385LKoUiCs6oRIAtHqFICHh+RNuakI2v7ra7A== +medusa-test-utils@1.1.3-dev-1615929449260: + version "1.1.3-dev-1615929449260" + resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.3-dev-1615929449260.tgz#7b6d81c6eae1147e5f36d7242021f9f245e8662d" + integrity sha512-Kqxf8/HjusYvVLf6jjdC62ci68JGyE20P1W8suB7cM8qnXNJHuKh5EXhFJRFX00tgr3N2oq68qrAUNcakB0IKA== dependencies: "@babel/plugin-transform-classes" "^7.9.5" - medusa-core-utils "1.1.0-dev-1615546466988" + medusa-core-utils "1.1.0-dev-1615929449260" randomatic "^3.1.1" merge-descriptors@1.0.1: diff --git a/docs-util/helpers/test-server.js b/docs-util/helpers/test-server.js index 1ce58decd7..785c39fd7d 100644 --- a/docs-util/helpers/test-server.js +++ b/docs-util/helpers/test-server.js @@ -6,8 +6,8 @@ const importFrom = require("import-from"); const initialize = async () => { const app = express(); - const loaders = importFrom(process.cwd(), "@medusajs/medusa/dist/loaders") - .default; + const cwd = process.cwd(); + const loaders = importFrom(cwd, "@medusajs/medusa/dist/loaders").default; const { dbConnection } = await loaders({ directory: path.resolve(process.cwd()), diff --git a/docs/api/admin-spec3.json b/docs/api/admin-spec3.json index c17e044fb7..5da7fcc4b6 100644 --- a/docs/api/admin-spec3.json +++ b/docs/api/admin-spec3.json @@ -87,7 +87,7 @@ "application/json": { "schema": { "properties": { - "customer": { + "user": { "$ref": "#/components/schemas/user" } } @@ -134,7 +134,7 @@ "application/json": { "schema": { "properties": { - "customer": { + "user": { "$ref": "#/components/schemas/user" } } @@ -1904,7 +1904,7 @@ "in": "path", "name": "id", "required": true, - "description": "The id of the Swap.", + "description": "The id of the Order.", "schema": { "type": "string" } @@ -2194,7 +2194,7 @@ "get": { "operationId": "GetOrders", "summary": "List Orders", - "description": "Retrieves an list of Orders", + "description": "Retrieves a list of Orders", "tags": [ "Order" ], @@ -2205,8 +2205,11 @@ "application/json": { "schema": { "properties": { - "order": { - "$ref": "#/components/schemas/order" + "orders": { + "type": "array", + "items": { + "$ref": "#/components/schemas/order" + } } } } @@ -2503,6 +2506,14 @@ "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" @@ -4554,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", @@ -5051,35 +5239,6 @@ } } }, - "/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", @@ -5253,6 +5412,35 @@ } } }, + "/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", @@ -7412,6 +7600,60 @@ "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" diff --git a/docs/api/admin-spec3.yaml b/docs/api/admin-spec3.yaml index fbf371478a..048de24094 100644 --- a/docs/api/admin-spec3.yaml +++ b/docs/api/admin-spec3.yaml @@ -53,7 +53,7 @@ paths: application/json: schema: properties: - customer: + user: $ref: '#/components/schemas/user' requestBody: content: @@ -83,7 +83,7 @@ paths: application/json: schema: properties: - customer: + user: $ref: '#/components/schemas/user' /collections: post: @@ -1314,7 +1314,7 @@ paths: - in: path name: id required: true - description: The id of the Swap. + description: The id of the Order. schema: type: string requestBody: @@ -1501,7 +1501,7 @@ paths: get: operationId: GetOrders summary: List Orders - description: Retrieves an list of Orders + description: Retrieves a list of Orders tags: - Order responses: @@ -1511,8 +1511,10 @@ paths: application/json: schema: properties: - order: - $ref: '#/components/schemas/order' + orders: + type: array + items: + $ref: '#/components/schemas/order' '/orders/{id}/swaps/{swap_id}/process-payment': post: operationId: PostOrdersOrderSwapsSwapProcessPayment @@ -1705,6 +1707,12 @@ paths: 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 @@ -2739,24 +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' '/regions/{id}/countries': post: operationId: PostRegionsRegionCountries @@ -3169,6 +3159,144 @@ 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 + 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 @@ -5441,6 +5569,47 @@ components: 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 diff --git a/docs/api/fixtures.json b/docs/api/fixtures.json index ebd064e427..dd9dbc39d3 100644 --- a/docs/api/fixtures.json +++ b/docs/api/fixtures.json @@ -1,389 +1,74 @@ { "resources": { - "customer": { - "id": "cus_01F0K18KCA0FNCJHWYV7HYPENX", - "email": "test1@email.com", - "first_name": null, - "last_name": null, - "billing_address_id": null, - "password_hash": null, - "phone": null, - "has_account": false, - "orders": [], - "created_at": "2021-03-12T10:56:08.074Z", - "updated_at": "2021-03-12T10:56:08.074Z", + "region": { + "id": "reg_01F0YES4R67TXXC1QBQ8P54A8Y", + "name": "Test Region", + "currency_code": "usd", + "tax_rate": "0", + "tax_code": null, + "payment_providers": [], + "fulfillment_providers": [ + { + "id": "test-ful", + "is_installed": true + } + ], + "created_at": "2021-03-16T21:24:00.389Z", + "updated_at": "2021-03-16T21:24:00.389Z", "deleted_at": null, "metadata": null }, - "order": { - "id": "order_01F0K17W8Z3T61W1MHSQRRCKH4", - "status": "pending", - "fulfillment_status": "not_fulfilled", - "payment_status": "not_paid", - "display_id": 1, - "cart_id": null, - "customer_id": "cus_01F0K17W7MAHJX7WWJRM6TK5EY", - "customer": { - "id": "cus_01F0K17W7MAHJX7WWJRM6TK5EY", - "email": "test@email.com", - "first_name": null, - "last_name": null, - "billing_address_id": null, - "password_hash": null, - "phone": null, - "has_account": false, - "created_at": "2021-03-12T10:55:44.372Z", - "updated_at": "2021-03-12T10:55:44.372Z", - "deleted_at": null, - "metadata": null - }, - "email": "test@email.com", - "billing_address": { - "id": "addr_01F0K17W8ZDQS2S1EX8A293RTZ", - "customer_id": null, - "company": null, - "first_name": "lebron", - "last_name": null, - "address_1": null, - "address_2": null, - "city": null, - "country_code": null, - "province": null, - "postal_code": null, - "phone": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "deleted_at": null, - "metadata": null - }, - "shipping_address": { - "id": "addr_01F0K17W8ZV35SS5XHM1RMA4BF", - "customer_id": null, - "company": null, - "first_name": "lebron", - "last_name": null, - "address_1": null, - "address_2": null, - "city": null, - "country_code": "us", - "province": null, - "postal_code": null, - "phone": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "deleted_at": null, - "metadata": null - }, - "region_id": "reg_01F0K17W77HC1F9NB27M6R1AP0", + "shipping_option": { + "id": "so_01F0YES4T6ZHH52Z4KZEDT1312", + "name": "Free Shipping", + "region_id": "reg_01F0YES4R67TXXC1QBQ8P54A8Y", "region": { - "id": "reg_01F0K17W77HC1F9NB27M6R1AP0", + "id": "reg_01F0YES4R67TXXC1QBQ8P54A8Y", "name": "Test Region", "currency_code": "usd", "tax_rate": "0", "tax_code": null, "payment_providers": [], - "fulfillment_providers": [], - "created_at": "2021-03-12T10:55:44.359Z", - "updated_at": "2021-03-12T10:55:44.359Z", + "fulfillment_providers": [ + { + "id": "test-ful", + "is_installed": true + } + ], + "created_at": "2021-03-16T21:24:00.389Z", + "updated_at": "2021-03-16T21:24:00.389Z", "deleted_at": null, "metadata": null }, - "currency_code": "usd", - "tax_rate": 0, - "discounts": [ - { - "id": "test-discount", - "code": "TEST134", - "is_dynamic": false, - "rule_id": "dru_01F0K17W8ZM2ZX3F1WSBHK7CGS", - "rule": { - "id": "dru_01F0K17W8ZM2ZX3F1WSBHK7CGS", - "description": "Test Discount", - "type": "percentage", - "value": 10, - "allocation": "total", - "usage_limit": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "deleted_at": null, - "metadata": null - }, - "is_disabled": false, - "parent_discount_id": null, - "starts_at": "2021-03-12T10:55:44.415Z", - "ends_at": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "deleted_at": null, - "metadata": null - } - ], - "gift_cards": [], - "shipping_methods": [ - { - "id": "sm_01F0K17WA1GJXPNM9PZ5TCS2QV", - "shipping_option_id": "so_01F0K17W7VA316M9Y0PHBDCD9P", - "order_id": "order_01F0K17W8Z3T61W1MHSQRRCKH4", - "claim_order_id": null, - "cart_id": null, - "swap_id": null, - "return_id": null, - "shipping_option": { - "id": "so_01F0K17W7VA316M9Y0PHBDCD9P", - "name": "test-option", - "region_id": "reg_01F0K17W77HC1F9NB27M6R1AP0", - "profile_id": "sp_01F0K17W52ZB0BKW4S0QKQBSGC", - "provider_id": "test-ful", - "price_type": "flat_rate", - "amount": 1000, - "is_return": false, - "data": {}, - "created_at": "2021-03-12T10:55:44.379Z", - "updated_at": "2021-03-12T10:55:44.379Z", - "deleted_at": null, - "metadata": null - }, - "price": 1000, - "data": {} - } - ], - "payments": [ - { - "id": "test-payment", - "swap_id": null, - "cart_id": null, - "order_id": "order_01F0K17W8Z3T61W1MHSQRRCKH4", - "amount": 10000, - "currency_code": "usd", - "amount_refunded": 0, - "provider_id": "test", - "data": {}, - "captured_at": null, - "canceled_at": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "metadata": null, - "idempotency_key": null - } - ], - "fulfillments": [], - "returns": [], - "claims": [], - "refunds": [], - "swaps": [], - "items": [ - { - "id": "test-item", - "cart_id": null, - "order_id": "order_01F0K17W8Z3T61W1MHSQRRCKH4", - "swap_id": null, - "claim_order_id": null, - "title": "Line Item", - "description": "Line Item Desc", - "thumbnail": "https://test.js/1234", - "is_giftcard": false, - "should_merge": true, - "allow_discounts": true, - "has_shipping": null, - "unit_price": 8000, - "variant_id": null, - "variant": null, - "quantity": 1, - "fulfilled_quantity": 1, - "returned_quantity": null, - "shipped_quantity": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "metadata": null, - "refundable": 7200 - } - ], - "gift_card_transactions": [], - "canceled_at": null, - "created_at": "2021-03-12T10:55:44.415Z", - "updated_at": "2021-03-12T10:55:44.415Z", - "metadata": null, - "shipping_total": 1000, - "gift_card_total": 0, - "discount_total": 800, - "tax_total": 0, - "subtotal": 8000, - "total": 8200, - "refunded_total": 0, - "refundable_amount": 8200 - }, - "product": { - "id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "title": "Test product", - "subtitle": null, - "description": "test-product-description", - "handle": "test-product", - "is_giftcard": false, - "images": [], - "thumbnail": null, - "options": [ - { - "id": "opt_01F0K1814KYQSBS6ESDGGV703V", - "title": "size", - "product_id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - }, - { - "id": "opt_01F0K1814MV2PBHXFVTHAD8KA8", - "title": "color", - "product_id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - } - ], - "variants": [ - { - "id": "variant_01F0K1815DA13R050ETD3QE8CG", - "title": "Test variant", - "product_id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "product": { - "id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "title": "Test product", - "subtitle": null, - "description": "test-product-description", - "handle": "test-product", - "is_giftcard": false, - "thumbnail": null, - "profile_id": "sp_01F0K1810TK56G1RQFJJTN3ZCN", - "weight": null, - "length": null, - "height": null, - "width": null, - "hs_code": null, - "origin_country": null, - "mid_code": null, - "material": null, - "collection_id": "test-collection", - "type_id": "test-type", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - }, - "prices": [ - { - "id": "ma_01F0K1815N7BMYYVP6Z63VS49A", - "currency_code": "usd", - "amount": 100, - "sale_amount": null, - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "region_id": null, - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null - } - ], - "sku": null, - "barcode": null, - "ean": null, - "upc": null, - "inventory_quantity": 10, - "allow_backorder": false, - "manage_inventory": true, - "hs_code": null, - "origin_country": null, - "mid_code": null, - "material": null, - "weight": null, - "length": null, - "height": null, - "width": null, - "options": [ - { - "id": "optval_01F0K1815D5D7KMHJ4EF9HFMH2", - "value": "large", - "option_id": "opt_01F0K1814KYQSBS6ESDGGV703V", - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - }, - { - "id": "optval_01F0K1815EZ5KV8N3QB5AAAEED", - "value": "green", - "option_id": "opt_01F0K1814MV2PBHXFVTHAD8KA8", - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - } - ], - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - } - ], - "profile_id": "sp_01F0K1810TK56G1RQFJJTN3ZCN", - "weight": null, - "length": null, - "height": null, - "width": null, - "hs_code": null, - "origin_country": null, - "mid_code": null, - "material": null, - "collection_id": "test-collection", - "collection": { - "id": "test-collection", - "title": "Test collection", - "handle": null, - "created_at": "2021-03-12T10:55:49.309Z", - "updated_at": "2021-03-12T10:55:49.309Z", + "profile_id": "sp_01F0YES4Q77FGG18GPFWW5BZP9", + "profile": { + "id": "sp_01F0YES4Q77FGG18GPFWW5BZP9", + "name": "Default Shipping Profile", + "type": "default", + "created_at": "2021-03-16T21:24:00.307Z", + "updated_at": "2021-03-16T21:24:00.307Z", "deleted_at": null, "metadata": null }, - "type_id": "test-type", - "type": { - "id": "test-type", - "value": "test-type", - "created_at": "2021-03-12T10:55:49.332Z", - "updated_at": "2021-03-12T10:55:49.332Z", - "deleted_at": null, - "metadata": null - }, - "tags": [ - { - "id": "tag1", - "value": "123", - "created_at": "2021-03-12T10:55:49.326Z", - "updated_at": "2021-03-12T10:55:49.326Z", - "deleted_at": null, - "metadata": null - }, - { - "id": "ptag_01F0K1814933N3JKMQH1VYRY5P", - "value": "456", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", - "deleted_at": null, - "metadata": null - } - ], - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "provider_id": "test-ful", + "price_type": "flat_rate", + "amount": 100, + "is_return": false, + "requirements": [], + "data": {}, + "created_at": "2021-03-16T21:24:00.439Z", + "updated_at": "2021-03-16T21:24:00.439Z", + "deleted_at": null, "metadata": null }, "cart": { - "id": "cart_01F0K18Q13W272V5GVAKDEX36X", + "id": "cart_01F0YES82DA12W88KQ90EY6W4C", "email": null, "billing_address_id": null, "billing_address": null, - "shipping_address_id": "addr_01F0K18Q13X1YVRPS0QDP1CKEQ", + "shipping_address_id": "addr_01F0YES82D4Y16JKGF0NFSSS3P", "shipping_address": { - "id": "addr_01F0K18Q13X1YVRPS0QDP1CKEQ", + "id": "addr_01F0YES82D4Y16JKGF0NFSSS3P", "customer_id": null, "company": null, "first_name": null, @@ -395,8 +80,8 @@ "province": null, "postal_code": null, "phone": null, - "created_at": "2021-03-12T10:56:11.787Z", - "updated_at": "2021-03-12T10:56:11.787Z", + "created_at": "2021-03-16T21:24:03.766Z", + "updated_at": "2021-03-16T21:24:03.766Z", "deleted_at": null, "metadata": null }, @@ -421,8 +106,8 @@ ], "payment_providers": [], "fulfillment_providers": [], - "created_at": "2021-03-12T10:56:11.763Z", - "updated_at": "2021-03-12T10:56:11.763Z", + "created_at": "2021-03-16T21:24:03.743Z", + "updated_at": "2021-03-16T21:24:03.743Z", "deleted_at": null, "metadata": null }, @@ -435,8 +120,8 @@ "shipping_methods": [], "type": "default", "completed_at": null, - "created_at": "2021-03-12T10:56:11.787Z", - "updated_at": "2021-03-12T10:56:11.875Z", + "created_at": "2021-03-16T21:24:03.766Z", + "updated_at": "2021-03-16T21:24:03.857Z", "deleted_at": null, "metadata": null, "idempotency_key": null, @@ -452,53 +137,217 @@ "total": 0 }, "product_collection": { - "id": "pcol_01F0K18VNNBZ2PEC74BW6NEF7X", + "id": "pcol_01F0YESBFAZ0DV6V831JXWH0BG", "title": "Summer Collection", "handle": "summer-collection", - "created_at": "2021-03-12T10:56:16.564Z", - "updated_at": "2021-03-12T10:56:16.564Z", + "created_at": "2021-03-16T21:24:07.273Z", + "updated_at": "2021-03-16T21:24:07.273Z", "deleted_at": null, "metadata": null }, - "discount": { - "id": "disc_01F0K188KEVS1K6GZV087EF46E", - "code": "10DISC", - "is_dynamic": false, - "rule_id": "dru_01F0K188JR04H4Z843MRMRC6SS", - "rule": { - "id": "dru_01F0K188JR04H4Z843MRMRC6SS", - "description": "10 Percent", - "type": "percentage", - "value": 10, - "allocation": "total", - "usage_limit": null, - "created_at": "2021-03-12T10:55:57.004Z", - "updated_at": "2021-03-12T10:55:57.004Z", + "gift_card": { + "id": "gift_01F0YESEKYJ5578VCAPV4XYFDP", + "code": "1J3U-WXO0-SZ0H-O5QU", + "value": 1000, + "balance": 1000, + "region_id": "reg_01F0YESEJP4H8Q517XSPGK6TD6", + "region": { + "id": "reg_01F0YESEJP4H8Q517XSPGK6TD6", + "name": "Test Region", + "currency_code": "usd", + "tax_rate": "0", + "tax_code": null, + "payment_providers": [], + "fulfillment_providers": [], + "created_at": "2021-03-16T21:24:10.454Z", + "updated_at": "2021-03-16T21:24:10.454Z", "deleted_at": null, "metadata": null }, "is_disabled": false, - "parent_discount_id": null, - "starts_at": "2021-03-12T10:55:57.004Z", "ends_at": null, - "created_at": "2021-03-12T10:55:57.004Z", - "updated_at": "2021-03-12T10:55:57.004Z", + "created_at": "2021-03-16T21:24:10.484Z", + "updated_at": "2021-03-16T21:24:10.484Z", "deleted_at": null, "metadata": null }, + "product": { + "id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "title": "Test product", + "subtitle": null, + "description": "test-product-description", + "handle": "test-product", + "is_giftcard": false, + "images": [], + "thumbnail": null, + "options": [ + { + "id": "opt_01F0YESHQBZVKCEXJ24BS6PCX3", + "title": "size", + "product_id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + }, + { + "id": "opt_01F0YESHQBV8MMNN4V7WSDMH6G", + "title": "color", + "product_id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + } + ], + "variants": [ + { + "id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "title": "Test variant", + "product_id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "product": { + "id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "title": "Test product", + "subtitle": null, + "description": "test-product-description", + "handle": "test-product", + "is_giftcard": false, + "thumbnail": null, + "profile_id": "sp_01F0YESHMKRB4V3B7F6MVQHGNN", + "weight": null, + "length": null, + "height": null, + "width": null, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "collection_id": "test-collection", + "type_id": "test-type", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + }, + "prices": [ + { + "id": "ma_01F0YESHRFQNH5S8Q0PK84YYZN", + "currency_code": "usd", + "amount": 100, + "sale_amount": null, + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "region_id": null, + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null + } + ], + "sku": null, + "barcode": null, + "ean": null, + "upc": null, + "inventory_quantity": 10, + "allow_backorder": false, + "manage_inventory": true, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "weight": null, + "length": null, + "height": null, + "width": null, + "options": [ + { + "id": "optval_01F0YESHR7S6ECD03RF6W12DSJ", + "value": "large", + "option_id": "opt_01F0YESHQBZVKCEXJ24BS6PCX3", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + }, + { + "id": "optval_01F0YESHR7N2GHM1RN3GKYPN6P", + "value": "green", + "option_id": "opt_01F0YESHQBV8MMNN4V7WSDMH6G", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + } + ], + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + } + ], + "profile_id": "sp_01F0YESHMKRB4V3B7F6MVQHGNN", + "weight": null, + "length": null, + "height": null, + "width": null, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "collection_id": "test-collection", + "collection": { + "id": "test-collection", + "title": "Test collection", + "handle": null, + "created_at": "2021-03-16T21:24:13.603Z", + "updated_at": "2021-03-16T21:24:13.603Z", + "deleted_at": null, + "metadata": null + }, + "type_id": "test-type", + "type": { + "id": "test-type", + "value": "test-type", + "created_at": "2021-03-16T21:24:13.613Z", + "updated_at": "2021-03-16T21:24:13.613Z", + "deleted_at": null, + "metadata": null + }, + "tags": [ + { + "id": "tag1", + "value": "123", + "created_at": "2021-03-16T21:24:13.609Z", + "updated_at": "2021-03-16T21:24:13.609Z", + "deleted_at": null, + "metadata": null + }, + { + "id": "ptag_01F0YESHPZYY3H4SJ3A5918SBN", + "value": "456", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "deleted_at": null, + "metadata": null + } + ], + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", + "metadata": null + }, "product_variant": { - "id": "variant_01F0K1815DA13R050ETD3QE8CG", + "id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", "title": "Test variant", - "product_id": "prod_01F0K1814DVJA4WW8SQA4C2S21", + "product_id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", "product": { - "id": "prod_01F0K1814DVJA4WW8SQA4C2S21", + "id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", "title": "Test product", "subtitle": null, "description": "test-product-description", "handle": "test-product", "is_giftcard": false, "thumbnail": null, - "profile_id": "sp_01F0K1810TK56G1RQFJJTN3ZCN", + "profile_id": "sp_01F0YESHMKRB4V3B7F6MVQHGNN", "weight": null, "length": null, "height": null, @@ -509,21 +358,21 @@ "material": null, "collection_id": "test-collection", "type_id": "test-type", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null }, "prices": [ { - "id": "ma_01F0K1815N7BMYYVP6Z63VS49A", + "id": "ma_01F0YESHRFQNH5S8Q0PK84YYZN", "currency_code": "usd", "amount": 100, "sale_amount": null, - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", "region_id": null, - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null } ], @@ -544,196 +393,566 @@ "width": null, "options": [ { - "id": "optval_01F0K1815D5D7KMHJ4EF9HFMH2", + "id": "optval_01F0YESHR7S6ECD03RF6W12DSJ", "value": "large", - "option_id": "opt_01F0K1814KYQSBS6ESDGGV703V", - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "option_id": "opt_01F0YESHQBZVKCEXJ24BS6PCX3", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null }, { - "id": "optval_01F0K1815EZ5KV8N3QB5AAAEED", + "id": "optval_01F0YESHR7N2GHM1RN3GKYPN6P", "value": "green", - "option_id": "opt_01F0K1814MV2PBHXFVTHAD8KA8", - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "option_id": "opt_01F0YESHQBV8MMNN4V7WSDMH6G", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null } ], - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null }, "product_option": { - "id": "opt_01F0K1814KYQSBS6ESDGGV703V", + "id": "opt_01F0YESHQBZVKCEXJ24BS6PCX3", "title": "size", - "product_id": "prod_01F0K1814DVJA4WW8SQA4C2S21", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "product_id": "prod_01F0YESHQ27Y31CAMD0NV6W9YP", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null }, "product_option_value": { - "id": "optval_01F0K1815D5D7KMHJ4EF9HFMH2", + "id": "optval_01F0YESHR7S6ECD03RF6W12DSJ", "value": "large", - "option_id": "opt_01F0K1814KYQSBS6ESDGGV703V", - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "option_id": "opt_01F0YESHQBZVKCEXJ24BS6PCX3", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null, "metadata": null }, "money_amount": { - "id": "ma_01F0K1815N7BMYYVP6Z63VS49A", + "id": "ma_01F0YESHRFQNH5S8Q0PK84YYZN", "currency_code": "usd", "amount": 100, "sale_amount": null, - "variant_id": "variant_01F0K1815DA13R050ETD3QE8CG", + "variant_id": "variant_01F0YESHR7P2YAYBDBY5B6X3PK", "region_id": null, - "created_at": "2021-03-12T10:55:49.379Z", - "updated_at": "2021-03-12T10:55:49.379Z", + "created_at": "2021-03-16T21:24:13.657Z", + "updated_at": "2021-03-16T21:24:13.657Z", "deleted_at": null }, - "gift_card": { - "id": "gift_01F0K18FQFN944SHCBRRK0844M", - "code": "O6UW-SZPS-GB62-Y3Q8", - "value": 1000, - "balance": 1000, - "region_id": "reg_01F0K18FP7NA54BTMGDB75ABA7", + "discount": { + "id": "disc_01F0YESMW10MGHWJKZSDDMN0VN", + "code": "10DISC", + "is_dynamic": false, + "rule_id": "dru_01F0YESMVK96HVX7N419E3CJ7C", + "rule": { + "id": "dru_01F0YESMVK96HVX7N419E3CJ7C", + "description": "10 Percent", + "type": "percentage", + "value": 10, + "allocation": "total", + "usage_limit": null, + "created_at": "2021-03-16T21:24:16.872Z", + "updated_at": "2021-03-16T21:24:16.872Z", + "deleted_at": null, + "metadata": null + }, + "is_disabled": false, + "parent_discount_id": null, + "starts_at": "2021-03-16T21:24:16.872Z", + "ends_at": null, + "created_at": "2021-03-16T21:24:16.872Z", + "updated_at": "2021-03-16T21:24:16.872Z", + "deleted_at": null, + "metadata": null + }, + "discount_rule": { + "id": "dru_01F0YESMVK96HVX7N419E3CJ7C", + "description": "10 Percent", + "type": "percentage", + "value": 10, + "allocation": "total", + "usage_limit": null, + "created_at": "2021-03-16T21:24:16.872Z", + "updated_at": "2021-03-16T21:24:16.872Z", + "deleted_at": null, + "metadata": null + }, + "customer": { + "id": "cus_01F0YESQXFZ5WKMHTXJ4JDPBDZ", + "email": "test1@email.com", + "first_name": null, + "last_name": null, + "billing_address_id": null, + "password_hash": null, + "phone": null, + "has_account": false, + "orders": [], + "created_at": "2021-03-16T21:24:20.015Z", + "updated_at": "2021-03-16T21:24:20.015Z", + "deleted_at": null, + "metadata": null + }, + "shipping_profile": { + "id": "sp_01F0YESTZQFW15SFEZSS29EZ5R", + "name": "Default Shipping Profile", + "type": "default", + "created_at": "2021-03-16T21:24:23.116Z", + "updated_at": "2021-03-16T21:24:23.116Z", + "deleted_at": null, + "metadata": null + }, + "store": { + "id": "store_01F0YESXYNJNTJJY5G5Z26KHKJ", + "name": "Medusa Store", + "default_currency_code": "usd", + "default_currency": { + "code": "usd", + "symbol": "$", + "symbol_native": "$", + "name": "US Dollar" + }, + "currencies": [], + "swap_link_template": null, + "created_at": "2021-03-16T21:24:26.191Z", + "updated_at": "2021-03-16T21:24:26.191Z", + "metadata": null, + "payment_providers": [ + { + "id": "test-pay", + "is_installed": true + } + ], + "fulfillment_providers": [ + { + "id": "test-ful", + "is_installed": true + } + ] + }, + "user": { + "id": "admin_user", + "email": "admin@medusa.js", + "first_name": null, + "last_name": null, + "api_token": "test_token", + "created_at": "2021-03-16T21:24:29.411Z", + "updated_at": "2021-03-16T21:24:29.411Z", + "deleted_at": null, + "metadata": null + }, + "notification": { + "id": "noti_01F0YET45G9NHP08Z66CE4QKBS", + "resource_type": "order", + "resource_id": "order_01F0BF66ZBXNJ98WDQ9SCWH8Y7", + "event_name": "order.placed", + "to": "test@email.com", + "provider_id": "test-not", + "created_at": "2021-03-16T21:24:32.560Z", + "updated_at": "2021-03-16T21:24:32.560Z", + "resends": [] + }, + "order": { + "id": "order_01F0YET7CZ741ECWG1J3N34RXF", + "status": "pending", + "fulfillment_status": "not_fulfilled", + "payment_status": "not_paid", + "display_id": 1, + "cart_id": null, + "customer_id": "cus_01F0YET7C3H3D5M8QPNPP5CDAX", + "customer": { + "id": "cus_01F0YET7C3H3D5M8QPNPP5CDAX", + "email": "test@email.com", + "first_name": null, + "last_name": null, + "billing_address_id": null, + "password_hash": null, + "phone": null, + "has_account": false, + "created_at": "2021-03-16T21:24:35.843Z", + "updated_at": "2021-03-16T21:24:35.843Z", + "deleted_at": null, + "metadata": null + }, + "email": "test@email.com", + "billing_address": { + "id": "addr_01F0YET7CZZX0842X5AHQYAZ80", + "customer_id": null, + "company": null, + "first_name": "lebron", + "last_name": null, + "address_1": null, + "address_2": null, + "city": null, + "country_code": null, + "province": null, + "postal_code": null, + "phone": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "deleted_at": null, + "metadata": null + }, + "shipping_address": { + "id": "addr_01F0YET7CZDHXHXYJ3JTXPH4T7", + "customer_id": null, + "company": null, + "first_name": "lebron", + "last_name": null, + "address_1": null, + "address_2": null, + "city": null, + "country_code": "us", + "province": null, + "postal_code": null, + "phone": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "deleted_at": null, + "metadata": null + }, + "region_id": "reg_01F0YET7BZTARY9MKN1SJ7AAXF", "region": { - "id": "reg_01F0K18FP7NA54BTMGDB75ABA7", + "id": "reg_01F0YET7BZTARY9MKN1SJ7AAXF", "name": "Test Region", "currency_code": "usd", "tax_rate": "0", "tax_code": null, "payment_providers": [], "fulfillment_providers": [], - "created_at": "2021-03-12T10:56:04.295Z", - "updated_at": "2021-03-12T10:56:04.295Z", + "created_at": "2021-03-16T21:24:35.839Z", + "updated_at": "2021-03-16T21:24:35.839Z", "deleted_at": null, "metadata": null }, - "is_disabled": false, - "ends_at": null, - "created_at": "2021-03-12T10:56:04.324Z", - "updated_at": "2021-03-12T10:56:04.324Z", - "deleted_at": null, - "metadata": null - }, - "shipping_option": { - "id": "so_01F0K184VDZ5AXZXS05RCCNSJH", - "name": "Free Shipping", - "region_id": "reg_01F0K184SWFZH676GN3E59EHMN", - "region": { - "id": "reg_01F0K184SWFZH676GN3E59EHMN", - "name": "Test Region", - "currency_code": "usd", - "tax_rate": "0", - "tax_code": null, - "payment_providers": [], - "fulfillment_providers": [ - { - "id": "test-ful", - "is_installed": true - } - ], - "created_at": "2021-03-12T10:55:53.148Z", - "updated_at": "2021-03-12T10:55:53.148Z", - "deleted_at": null, - "metadata": null - }, - "profile_id": "sp_01F0K184SAYPYPHCMVENN6V8KH", - "profile": { - "id": "sp_01F0K184SAYPYPHCMVENN6V8KH", - "name": "Default Shipping Profile", - "type": "default", - "created_at": "2021-03-12T10:55:53.081Z", - "updated_at": "2021-03-12T10:55:53.081Z", - "deleted_at": null, - "metadata": null - }, - "provider_id": "test-ful", - "price_type": "flat_rate", - "amount": 100, - "is_return": false, - "requirements": [], - "data": {}, - "created_at": "2021-03-12T10:55:53.184Z", - "updated_at": "2021-03-12T10:55:53.184Z", - "deleted_at": null, - "metadata": null - }, - "region": { - "id": "reg_01F0K184SWFZH676GN3E59EHMN", - "name": "Test Region", "currency_code": "usd", - "tax_rate": "0", - "tax_code": null, - "payment_providers": [], - "fulfillment_providers": [ + "tax_rate": 0, + "discounts": [ { - "id": "test-ful", - "is_installed": true + "id": "test-discount", + "code": "TEST134", + "is_dynamic": false, + "rule_id": "dru_01F0YET7CZQDGWTFQYY8T4KYRZ", + "rule": { + "id": "dru_01F0YET7CZQDGWTFQYY8T4KYRZ", + "description": "Test Discount", + "type": "percentage", + "value": 10, + "allocation": "total", + "usage_limit": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "deleted_at": null, + "metadata": null + }, + "is_disabled": false, + "parent_discount_id": null, + "starts_at": "2021-03-16T21:24:35.871Z", + "ends_at": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "deleted_at": null, + "metadata": null } ], - "created_at": "2021-03-12T10:55:53.148Z", - "updated_at": "2021-03-12T10:55:53.148Z", - "deleted_at": null, - "metadata": null + "gift_cards": [], + "shipping_methods": [ + { + "id": "sm_01F0YET7DR2E7CYVSDHM593QG2", + "shipping_option_id": "so_01F0YET7C758MMXF1WNVCPGKZJ", + "order_id": "order_01F0YET7CZ741ECWG1J3N34RXF", + "claim_order_id": null, + "cart_id": null, + "swap_id": null, + "return_id": null, + "shipping_option": { + "id": "so_01F0YET7C758MMXF1WNVCPGKZJ", + "name": "test-option", + "region_id": "reg_01F0YET7BZTARY9MKN1SJ7AAXF", + "profile_id": "sp_01F0YET7AF62TCC9CMWK5TXXAQ", + "provider_id": "test-ful", + "price_type": "flat_rate", + "amount": 1000, + "is_return": false, + "data": {}, + "created_at": "2021-03-16T21:24:35.846Z", + "updated_at": "2021-03-16T21:24:35.846Z", + "deleted_at": null, + "metadata": null + }, + "price": 1000, + "data": {} + } + ], + "payments": [ + { + "id": "test-payment", + "swap_id": null, + "cart_id": null, + "order_id": "order_01F0YET7CZ741ECWG1J3N34RXF", + "amount": 10000, + "currency_code": "usd", + "amount_refunded": 0, + "provider_id": "test", + "data": {}, + "captured_at": null, + "canceled_at": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "metadata": null, + "idempotency_key": null + } + ], + "fulfillments": [], + "returns": [], + "claims": [], + "refunds": [], + "swaps": [], + "items": [ + { + "id": "test-item", + "cart_id": null, + "order_id": "order_01F0YET7CZ741ECWG1J3N34RXF", + "swap_id": null, + "claim_order_id": null, + "title": "Line Item", + "description": "Line Item Desc", + "thumbnail": "https://test.js/1234", + "is_giftcard": false, + "should_merge": true, + "allow_discounts": true, + "has_shipping": null, + "unit_price": 8000, + "variant_id": "variant_01F0YET7BMD9FGWA5NTPBWT2SS", + "variant": { + "id": "variant_01F0YET7BMD9FGWA5NTPBWT2SS", + "title": "test variant", + "product_id": "prod_01F0YET7BA4AQ8WEK687BNWP3N", + "product": { + "id": "prod_01F0YET7BA4AQ8WEK687BNWP3N", + "title": "test product", + "subtitle": null, + "description": null, + "handle": "test-product", + "is_giftcard": false, + "thumbnail": null, + "profile_id": "sp_01F0YET7AF62TCC9CMWK5TXXAQ", + "weight": null, + "length": null, + "height": null, + "width": null, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "collection_id": null, + "type_id": null, + "created_at": "2021-03-16T21:24:35.818Z", + "updated_at": "2021-03-16T21:24:35.818Z", + "deleted_at": null, + "metadata": null + }, + "sku": null, + "barcode": null, + "ean": null, + "upc": null, + "inventory_quantity": 1, + "allow_backorder": false, + "manage_inventory": true, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "weight": null, + "length": null, + "height": null, + "width": null, + "created_at": "2021-03-16T21:24:35.828Z", + "updated_at": "2021-03-16T21:24:35.828Z", + "deleted_at": null, + "metadata": null + }, + "quantity": 1, + "fulfilled_quantity": 1, + "returned_quantity": null, + "shipped_quantity": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "metadata": null, + "refundable": 7200 + } + ], + "gift_card_transactions": [], + "canceled_at": null, + "created_at": "2021-03-16T21:24:35.871Z", + "updated_at": "2021-03-16T21:24:35.871Z", + "metadata": null, + "shipping_total": 1000, + "gift_card_total": 0, + "discount_total": 800, + "tax_total": 0, + "subtotal": 8000, + "total": 8200, + "refunded_total": 0, + "refundable_amount": 8200 }, "return": { - "id": "ret_01F0K17WQFXJ8R8HS0NFQGRWT2", + "id": "ret_01F0YET7XPCMF8RZ0Y151NZV2V", "status": "requested", "items": [ { - "return_id": "ret_01F0K17WQFXJ8R8HS0NFQGRWT2", + "return_id": "ret_01F0YET7XPCMF8RZ0Y151NZV2V", "item_id": "test-item", "quantity": 1, "is_requested": true, "requested_quantity": 1, "received_quantity": null, + "reason_id": null, + "reason": null, + "note": null, "metadata": null } ], "swap_id": null, "claim_order_id": null, - "order_id": "order_01F0K17WJC0F5K5G111Y53E641", + "order_id": "order_01F0YET7RD6NWQTEM0ZN5DRRVD", "shipping_method": null, "shipping_data": null, "refund_amount": 7200, "received_at": null, - "created_at": "2021-03-12T10:55:44.853Z", - "updated_at": "2021-03-12T10:55:44.853Z", + "created_at": "2021-03-16T21:24:36.381Z", + "updated_at": "2021-03-16T21:24:36.381Z", "metadata": null, - "idempotency_key": "21d6d548-fd78-4ad7-831f-309930b69455" + "idempotency_key": "f3dee891-7a24-4e34-9071-62606035563d" }, - "notification": { - "id": "noti_01F0K18CB6ZS9N2NZYSCFMRY44", - "resource_type": "order", - "resource_id": "order_01F0BF66ZBXNJ98WDQ9SCWH8Y7", - "event_name": "order.placed", - "to": "test@email.com", - "provider_id": "test-not", - "created_at": "2021-03-12T10:56:00.869Z", - "updated_at": "2021-03-12T10:56:00.869Z", - "resends": [] - }, - "discount_rule": { - "id": "dru_01F0K188JR04H4Z843MRMRC6SS", - "description": "10 Percent", - "type": "percentage", - "value": 10, - "allocation": "total", - "usage_limit": null, - "created_at": "2021-03-12T10:55:57.004Z", - "updated_at": "2021-03-12T10:55:57.004Z", + "swap": { + "id": "swap_01F0YET86Y9G92D3YDR9Y6V676", + "fulfillment_status": "not_fulfilled", + "payment_status": "not_paid", + "order_id": "order_01F0YET82SR6NB8K61TNRN36FW", + "additional_items": [ + { + "id": "item_01F0YET86YR1J3GX155E9R81A3", + "cart_id": "cart_01F0YET896KVZ17Y2QDVT28QFE", + "order_id": null, + "swap_id": "swap_01F0YET86Y9G92D3YDR9Y6V676", + "claim_order_id": null, + "title": "test product", + "description": "test variant", + "thumbnail": null, + "is_giftcard": false, + "should_merge": true, + "allow_discounts": true, + "has_shipping": null, + "unit_price": 8000, + "variant_id": "variant_01F0YET825M92TKN1ZGAVBPX1B", + "variant": { + "id": "variant_01F0YET825M92TKN1ZGAVBPX1B", + "title": "test variant", + "product_id": "prod_01F0YET8213X0J501ZZHZ56Y7Y", + "product": { + "id": "prod_01F0YET8213X0J501ZZHZ56Y7Y", + "title": "test product", + "subtitle": null, + "description": null, + "handle": "test-product", + "is_giftcard": false, + "thumbnail": null, + "profile_id": "sp_01F0YET7AF62TCC9CMWK5TXXAQ", + "weight": null, + "length": null, + "height": null, + "width": null, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "collection_id": null, + "type_id": null, + "created_at": "2021-03-16T21:24:36.545Z", + "updated_at": "2021-03-16T21:24:36.545Z", + "deleted_at": null, + "metadata": null + }, + "sku": null, + "barcode": null, + "ean": null, + "upc": null, + "inventory_quantity": 1, + "allow_backorder": false, + "manage_inventory": true, + "hs_code": null, + "origin_country": null, + "mid_code": null, + "material": null, + "weight": null, + "length": null, + "height": null, + "width": null, + "created_at": "2021-03-16T21:24:36.549Z", + "updated_at": "2021-03-16T21:24:36.549Z", + "deleted_at": null, + "metadata": null + }, + "quantity": 2, + "fulfilled_quantity": null, + "returned_quantity": null, + "shipped_quantity": null, + "created_at": "2021-03-16T21:24:36.659Z", + "updated_at": "2021-03-16T21:24:36.659Z", + "metadata": {} + } + ], + "return_order": { + "id": "ret_01F0YET873ZAXQ7PYVKVFMT9FP", + "status": "requested", + "items": [ + { + "return_id": "ret_01F0YET873ZAXQ7PYVKVFMT9FP", + "item_id": "test-item", + "quantity": 1, + "is_requested": true, + "requested_quantity": 1, + "received_quantity": null, + "reason_id": null, + "reason": null, + "note": null, + "metadata": null + } + ], + "swap_id": "swap_01F0YET86Y9G92D3YDR9Y6V676", + "claim_order_id": null, + "order_id": null, + "shipping_method": null, + "shipping_data": null, + "refund_amount": 7200, + "received_at": null, + "created_at": "2021-03-16T21:24:36.659Z", + "updated_at": "2021-03-16T21:24:36.659Z", + "metadata": null, + "idempotency_key": null + }, + "fulfillments": [], + "payment": null, + "difference_due": null, + "shipping_address_id": null, + "shipping_address": null, + "shipping_methods": [], + "cart_id": "cart_01F0YET896KVZ17Y2QDVT28QFE", + "confirmed_at": null, + "created_at": "2021-03-16T21:24:36.659Z", + "updated_at": "2021-03-16T21:24:36.659Z", "deleted_at": null, - "metadata": null + "metadata": null, + "idempotency_key": "10804103-2f4f-41ef-b44e-7049459f157d" } } } \ No newline at end of file diff --git a/docs/api/store-spec3.json b/docs/api/store-spec3.json index f198bdb762..5727ac1234 100644 --- a/docs/api/store-spec3.json +++ b/docs/api/store-spec3.json @@ -75,6 +75,130 @@ } ], "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", @@ -1357,135 +1481,22 @@ } } }, - "/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" ], @@ -1519,6 +1530,228 @@ } } }, + "/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", @@ -1639,162 +1872,6 @@ } } }, - "/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", @@ -4199,6 +4276,60 @@ "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" diff --git a/docs/api/store-spec3.yaml b/docs/api/store-spec3.yaml index 1a0e348ed8..43e7a49d17 100644 --- a/docs/api/store-spec3.yaml +++ b/docs/api/store-spec3.yaml @@ -121,338 +121,6 @@ paths: properties: exists: type: boolean - '/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 @@ -986,11 +654,350 @@ paths: 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: @@ -1140,6 +1147,47 @@ 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 @@ -3183,6 +3231,47 @@ components: 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 diff --git a/e2e/prod-project/yarn.lock b/e2e/prod-project/yarn.lock index 7ab01a5daa..141d5e196b 100644 --- a/e2e/prod-project/yarn.lock +++ b/e2e/prod-project/yarn.lock @@ -2282,9 +2282,9 @@ domexception@^1.0.1: webidl-conversions "^4.0.2" dot-prop@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== + version "4.2.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" + integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== dependencies: is-obj "^1.0.0" @@ -3213,9 +3213,9 @@ inherits@2.0.3: integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= ini@^1.3.4, ini@~1.3.0: - version "1.3.5" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" - integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + version "1.3.8" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" + integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== inquirer@^7.0.0: version "7.1.0" diff --git a/package.json b/package.json index 9ba069bd82..d44803d4e7 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "test:fixtures": "jest --config=docs-util/jest.config.js --runInBand" }, "dependencies": { + "import-from": "^3.0.0", "oas-normalize": "^2.3.1", "swagger-inline": "^3.2.2" } diff --git a/packages/medusa/jest.config.js b/packages/medusa/jest.config.js deleted file mode 100644 index 82513aa071..0000000000 --- a/packages/medusa/jest.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - testEnvironment: "node", -} diff --git a/packages/medusa/src/api/routes/admin/auth/create-session.js b/packages/medusa/src/api/routes/admin/auth/create-session.js index 2643974152..7cb77ced09 100644 --- a/packages/medusa/src/api/routes/admin/auth/create-session.js +++ b/packages/medusa/src/api/routes/admin/auth/create-session.js @@ -1,3 +1,4 @@ +import _ from "lodash" import jwt from "jsonwebtoken" import { Validator } from "medusa-core-utils" import config from "../../../../config" @@ -19,7 +20,7 @@ import config from "../../../../config" * application/json: * schema: * properties: - * customer: + * user: * $ref: "#/components/schemas/user" */ export default async (req, res) => { @@ -46,5 +47,7 @@ export default async (req, res) => { expiresIn: "24h", }) - res.json({ user: result.user }) + const cleanRes = _.omit(result.user, ["password_hash"]) + + res.json({ user: cleanRes }) } diff --git a/packages/medusa/src/api/routes/admin/auth/get-session.js b/packages/medusa/src/api/routes/admin/auth/get-session.js index 59bdc5fa61..b4073059d9 100644 --- a/packages/medusa/src/api/routes/admin/auth/get-session.js +++ b/packages/medusa/src/api/routes/admin/auth/get-session.js @@ -1,4 +1,4 @@ -import passport from "passport" +import _ from "lodash" /** * @oas [get] /auth @@ -14,11 +14,13 @@ import passport from "passport" * application/json: * schema: * properties: - * customer: + * user: * $ref: "#/components/schemas/user" */ export default async (req, res) => { const userService = req.scope.resolve("userService") const user = await userService.retrieve(req.user.userId) - res.status(200).json({ user }) + + const cleanRes = _.omit(user, ["password_hash"]) + res.status(200).json({ user: cleanRes }) } 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 4b78d0ca09..120b2419cb 100644 --- a/packages/medusa/src/api/routes/admin/orders/create-swap.js +++ b/packages/medusa/src/api/routes/admin/orders/create-swap.js @@ -7,7 +7,7 @@ import { defaultFields, defaultRelations } from "./" * summary: "Create a Swap" * description: "Creates a Swap. Swaps are used to handle Return of previously purchased goods and Fulfillment of replacements simultaneously." * parameters: - * - (path) id=* {string} The id of the Swap. + * - (path) id=* {string} The id of the Order. * requestBody: * content: * application/json: diff --git a/packages/medusa/src/api/routes/admin/orders/list-orders.js b/packages/medusa/src/api/routes/admin/orders/list-orders.js index 8a0b3439f3..650be1c1d7 100644 --- a/packages/medusa/src/api/routes/admin/orders/list-orders.js +++ b/packages/medusa/src/api/routes/admin/orders/list-orders.js @@ -6,7 +6,7 @@ import { MedusaError, Validator } from "medusa-core-utils" * @oas [get] /orders * operationId: "GetOrders" * summary: "List Orders" - * description: "Retrieves an list of Orders" + * description: "Retrieves a list of Orders" * tags: * - Order * responses: @@ -16,8 +16,10 @@ import { MedusaError, Validator } from "medusa-core-utils" * application/json: * schema: * properties: - * order: - * $ref: "#/components/schemas/order" + * orders: + * type: array + * items: + * $ref: "#/components/schemas/order" */ export default async (req, res) => { const schema = Validator.orderFilter() diff --git a/packages/medusa/src/api/routes/admin/return-reasons/update-reason.js b/packages/medusa/src/api/routes/admin/return-reasons/update-reason.js index e756533dda..82d933c406 100644 --- a/packages/medusa/src/api/routes/admin/return-reasons/update-reason.js +++ b/packages/medusa/src/api/routes/admin/return-reasons/update-reason.js @@ -2,7 +2,7 @@ import { MedusaError, Validator } from "medusa-core-utils" import { defaultRelations, defaultFields } from "./" /** - * @oas [post] /return-reasons/:id + * @oas [post] /return-reasons/{id} * operationId: "PostReturnReasonsReason" * summary: "Update a Return Reason" * description: "Updates a Return Reason" diff --git a/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.js b/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.js index bd10ad1887..05a6ac1ea0 100644 --- a/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.js +++ b/packages/medusa/src/api/routes/store/gift-cards/get-gift-card.js @@ -5,6 +5,8 @@ import { defaultRelations, defaultFields } from "./" * operationId: "GetGiftCardsCode" * summary: "Retrieve Gift Card by Code" * description: "Retrieves a Gift Card by its associated unqiue code." + * parameters: + * - (path) code=* {string} The unique Gift Card code. * tags: * - Gift Card * responses: diff --git a/packages/medusa/yarn.lock b/packages/medusa/yarn.lock index b95dbbaa6d..dd3d7bc7d6 100644 --- a/packages/medusa/yarn.lock +++ b/packages/medusa/yarn.lock @@ -2724,9 +2724,9 @@ domexception@^1.0.1: webidl-conversions "^4.0.2" dot-prop@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== + version "4.2.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" + integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== dependencies: is-obj "^1.0.0" @@ -3594,9 +3594,9 @@ has@^1.0.1, has@^1.0.3: function-bind "^1.1.1" highlight.js@^10.0.0: - version "10.4.0" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.4.0.tgz#ef3ce475e5dfa7a48484260b49ea242ddab823a0" - integrity sha512-EfrUGcQ63oLJbj0J0RI9ebX6TAITbsDBLbsjr881L/X5fMO9+oadKzEF21C7R3ULKG6Gv3uoab2HiqVJa/4+oA== + version "10.5.0" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.5.0.tgz#3f09fede6a865757378f2d9ebdcbc15ba268f98f" + integrity sha512-xTmvd9HiIHR6L53TMC7TKolEj65zG1XU+Onr8oi86mYa+nLcIbxTTWkpW7CsEwv/vK7u1zb8alZIMLDqqN6KTw== homedir-polyfill@^1.0.1: version "1.0.3" diff --git a/www/LICENSE b/www/LICENSE index 7e964c1ee5..8ad47e209d 100644 --- a/www/LICENSE +++ b/www/LICENSE @@ -1,6 +1,6 @@ The BSD Zero Clause License (0BSD) -Copyright (c) 2020 Gatsby Inc. +Copyright (c) 2020 Medusa Commerce Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. diff --git a/www/src/components/json-box.js b/www/src/components/json-box.js index 6823f02536..30f43fce68 100644 --- a/www/src/components/json-box.js +++ b/www/src/components/json-box.js @@ -49,8 +49,19 @@ const JsonBox = ({ text, resourceId, endpoint, spec }) => { cleanDets["x-resourceId"] in fixtures.resources ) { toSet[name] = fixtures.resources[cleanDets["x-resourceId"]] - } else { + } else if (cleanDets.type === "array") { toSet[name] = cleanDets + if (cleanDets.items.$ref) { + const [, ...path] = cleanDets.items.$ref.split("/") + let cleanObj = deref(path, spec) + if ( + cleanObj["x-resourceId"] && + cleanObj["x-resourceId"] in fixtures.resources + ) { + cleanObj = fixtures.resources[cleanObj["x-resourceId"]] + } + toSet[name] = [cleanObj] + } } } }