fix: merge

This commit is contained in:
Sebastian Rindom
2021-03-16 22:39:29 +01:00
26 changed files with 2401 additions and 1255 deletions

View File

@@ -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);
});
});
});

View File

@@ -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]);
});
});
});

View File

@@ -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
);
});
});
});

View File

@@ -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]
);
});
});
});

View File

@@ -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);
});
});
});

View File

@@ -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,

View File

@@ -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"
}
}

View File

@@ -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:

View File

@@ -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()),

View File

@@ -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"

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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"

View File

@@ -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

View File

@@ -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"

View File

@@ -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"
}

View File

@@ -1,3 +0,0 @@
module.exports = {
testEnvironment: "node",
}

View File

@@ -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 })
}

View File

@@ -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 })
}

View File

@@ -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:

View File

@@ -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()

View File

@@ -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"

View File

@@ -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:

View File

@@ -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"

View File

@@ -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.

View File

@@ -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]
}
}
}
}