feat: admin api - allow customers to be created and updated with metadata (#824)

* feat: admin api - allow customers to be created and updated with metadata

* feat: add integration test for metadata
This commit is contained in:
Derek Wene
2021-11-18 18:50:36 +01:00
committed by GitHub
parent 373532ecbc
commit 2d9879ea09
4 changed files with 46 additions and 49 deletions
@@ -1,6 +1,7 @@
import { IsEmail, IsOptional, IsString } from "class-validator"
import { IsEmail, IsObject, IsOptional, IsString } from "class-validator"
import { CustomerService } from "../../../../services"
import { validator } from "../../../../utils/validator"
/**
* @oas [post] /customers
* operationId: "PostCustomers"
@@ -12,6 +13,7 @@ import { validator } from "../../../../utils/validator"
* - (body) first_name=* {string} The Customer's first name.
* - (body) last_name=* {string} The Customer's last name.
* - (body) phone {string} The Customer's phone number.
* - (body) metadata {object} Metadata for the customer.
* tags:
* - Customer
* responses:
@@ -48,4 +50,8 @@ export class AdminPostCustomersReq {
@IsString()
@IsOptional()
phone?: string
@IsObject()
@IsOptional()
metadata?: object
}
@@ -1,7 +1,8 @@
import { IsEmail, IsOptional, IsString } from "class-validator"
import CustomerService from "../../../../services/customer"
import { IsEmail, IsObject, IsOptional, IsString } from "class-validator"
import { MedusaError } from "medusa-core-utils"
import CustomerService from "../../../../services/customer"
import { validator } from "../../../../utils/validator"
/**
* @oas [post] /customers/{id}
* operationId: "PostCustomersCustomer"
@@ -30,6 +31,9 @@ import { validator } from "../../../../utils/validator"
* password:
* type: string
* description: The Customer's password.
* metadata:
* type: object
* description: Metadata for the customer.
* tags:
* - Customer
* responses:
@@ -86,4 +90,8 @@ export class AdminPostCustomersCustomerReq {
@IsString()
@IsOptional()
phone?: string
@IsObject()
@IsOptional()
metadata?: object
}