chore: Remove last trace of client in dashboard (#8873)
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class Campaign {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetCampaignParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCampaignResponse>(
|
||||
`/admin/campaigns/${id}`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetCampaignsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCampaignListResponse>(
|
||||
`/admin/campaigns`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
payload: HttpTypes.AdminCreateCampaign,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCampaignResponse>(
|
||||
`/admin/campaigns`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
payload: HttpTypes.AdminUpdateCampaign,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCampaignResponse>(
|
||||
`/admin/campaigns/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"campaign">>(
|
||||
`/admin/campaigns/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async batchPromotions(
|
||||
id: string,
|
||||
payload: HttpTypes.AdminBatchLink,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminCampaignResponse>(
|
||||
`/admin/campaigns/${id}/promotions`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Client } from "../client"
|
||||
import { ApiKey } from "./api-key"
|
||||
import { Campaign } from "./campaign"
|
||||
import { Claim } from "./claim"
|
||||
import { Currency } from "./currency"
|
||||
import { Customer } from "./customer"
|
||||
@@ -23,6 +24,7 @@ import { ProductCollection } from "./product-collection"
|
||||
import { ProductTag } from "./product-tag"
|
||||
import { ProductType } from "./product-type"
|
||||
import { ProductVariant } from "./product-variant"
|
||||
import { Promotion } from "./promotion"
|
||||
import { RefundReason } from "./refund-reasons"
|
||||
import { Region } from "./region"
|
||||
import Reservation from "./reservation"
|
||||
@@ -79,6 +81,8 @@ export class Admin {
|
||||
public workflowExecution: WorkflowExecution
|
||||
public reservation: Reservation
|
||||
public customerGroup: CustomerGroup
|
||||
public promotion: Promotion
|
||||
public campaign: Campaign
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -120,5 +124,7 @@ export class Admin {
|
||||
this.workflowExecution = new WorkflowExecution(client)
|
||||
this.reservation = new Reservation(client)
|
||||
this.customerGroup = new CustomerGroup(client)
|
||||
this.promotion = new Promotion(client)
|
||||
this.campaign = new Campaign(client)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
export class Promotion {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminGetPromotionParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions/${id}`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminGetPromotionsParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionListResponse>(
|
||||
`/admin/promotions`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
payload: HttpTypes.AdminCreatePromotion,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
payload: HttpTypes.AdminUpdatePromotion,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: payload,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.DeleteResponse<"promotion">>(
|
||||
`/admin/promotions/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async addRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
payload: HttpTypes.BatchAddPromotionRulesReq,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions/${id}/${ruleType}/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: { create: payload.rules },
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async updateRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
payload: HttpTypes.BatchUpdatePromotionRulesReq,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions/${id}/${ruleType}/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: { update: payload.rules },
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async removeRules(
|
||||
id: string,
|
||||
ruleType: string,
|
||||
payload: HttpTypes.BatchRemovePromotionRulesReq,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPromotionResponse>(
|
||||
`/admin/promotions/${id}/${ruleType}/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body: { delete: payload.rule_ids },
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async listRules(
|
||||
id: string | null,
|
||||
ruleType: string,
|
||||
query?: HttpTypes.AdminGetPromotionRuleParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
// eslint-disable-next-line max-len
|
||||
return await this.client.fetch<HttpTypes.AdminRuleAttributeOptionsListResponse>(
|
||||
`/admin/promotions/${id}/${ruleType}`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async listRuleAttributes(
|
||||
ruleType: string,
|
||||
promotionType?: string,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
// eslint-disable-next-line max-len
|
||||
return await this.client.fetch<HttpTypes.AdminRuleAttributeOptionsListResponse>(
|
||||
`/admin/promotions/rule-attribute-options/${ruleType}`,
|
||||
{
|
||||
headers,
|
||||
query: { promotion_type: promotionType },
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async listRuleValues(
|
||||
ruleType: string,
|
||||
ruleValue: string,
|
||||
query?: HttpTypes.AdminGetPromotionsRuleValueParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminRuleValueOptionsListResponse>(
|
||||
`/admin/promotions/rule-value-options/${ruleType}/${ruleValue}`,
|
||||
{
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { BaseFilterable } from "../../../dal"
|
||||
import { FindParams, SelectParams } from "../../common"
|
||||
|
||||
export interface AdminGetCampaignsParams
|
||||
extends FindParams,
|
||||
BaseFilterable<AdminGetCampaignsParams> {
|
||||
q?: string
|
||||
campaign_identifier?: string
|
||||
budget?: {
|
||||
currency_code?: string
|
||||
}
|
||||
$and?: AdminGetCampaignsParams[]
|
||||
$or?: AdminGetCampaignsParams[]
|
||||
}
|
||||
|
||||
export interface AdminGetCampaignParams extends SelectParams {}
|
||||
@@ -5,7 +5,8 @@ import {
|
||||
} from "../common"
|
||||
|
||||
export interface AdminCustomerFilters extends BaseCustomerFilters {
|
||||
groups: CustomerGroupInCustomerFilters | string[] | string
|
||||
groups?: CustomerGroupInCustomerFilters | string[] | string
|
||||
has_account?: boolean
|
||||
}
|
||||
export interface AdminCustomerAddressFilters
|
||||
extends BaseCustomerAddressFilters {}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./responses"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import {
|
||||
ApplicationMethodAllocationValues,
|
||||
ApplicationMethodTargetTypeValues,
|
||||
ApplicationMethodTypeValues,
|
||||
PromotionRuleOperatorValues,
|
||||
PromotionTypeValues,
|
||||
} from "../../../promotion"
|
||||
import { AdminCreateCampaign } from "../../campaign"
|
||||
|
||||
export interface AdminCreatePromotionRule {
|
||||
operator: PromotionRuleOperatorValues
|
||||
description?: string | null
|
||||
attribute: string
|
||||
values: string | string[]
|
||||
}
|
||||
|
||||
export interface AdminUpdatePromotionRule {
|
||||
id: string
|
||||
operator?: PromotionRuleOperatorValues
|
||||
description?: string | null
|
||||
attribute?: string
|
||||
values: string | string[]
|
||||
}
|
||||
|
||||
export interface AdminCreateApplicationMethod {
|
||||
description?: string | null
|
||||
value: number
|
||||
currency_code?: string | null
|
||||
max_quantity?: number | null
|
||||
type: ApplicationMethodTypeValues
|
||||
target_type: ApplicationMethodTargetTypeValues
|
||||
allocation?: ApplicationMethodAllocationValues
|
||||
target_rules?: AdminCreatePromotionRule[]
|
||||
buy_rules?: AdminCreatePromotionRule[]
|
||||
apply_to_quantity?: number | null
|
||||
buy_rules_min_quantity?: number | null
|
||||
}
|
||||
|
||||
export interface AdminUpdateApplicationMethod {
|
||||
description?: string | null
|
||||
value?: number
|
||||
max_quantity?: number | null
|
||||
currency_code?: string | null
|
||||
type?: ApplicationMethodTypeValues
|
||||
target_type?: ApplicationMethodTargetTypeValues
|
||||
allocation?: ApplicationMethodAllocationValues
|
||||
target_rules?: AdminCreatePromotionRule[]
|
||||
buy_rules?: AdminCreatePromotionRule[]
|
||||
apply_to_quantity?: number | null
|
||||
buy_rules_min_quantity?: number | null
|
||||
}
|
||||
|
||||
export interface AdminCreatePromotion {
|
||||
code: string
|
||||
is_automatic?: boolean
|
||||
type: PromotionTypeValues
|
||||
campaign_id?: string | null
|
||||
campaign?: AdminCreateCampaign
|
||||
application_method: AdminCreateApplicationMethod
|
||||
rules?: AdminCreatePromotionRule[]
|
||||
}
|
||||
|
||||
export interface AdminUpdatePromotion {
|
||||
code?: string
|
||||
is_automatic?: boolean
|
||||
type?: PromotionTypeValues
|
||||
campaign_id?: string | null
|
||||
campaign?: AdminCreateCampaign
|
||||
application_method?: AdminUpdateApplicationMethod
|
||||
rules?: AdminCreatePromotionRule[]
|
||||
}
|
||||
|
||||
export interface BatchAddPromotionRulesReq {
|
||||
rules: AdminCreatePromotionRule[]
|
||||
}
|
||||
|
||||
export interface BatchRemovePromotionRulesReq {
|
||||
rule_ids: string[]
|
||||
}
|
||||
|
||||
export interface BatchUpdatePromotionRulesReq {
|
||||
rules: AdminUpdatePromotionRule[]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { BaseFilterable, OperatorMap } from "../../../dal"
|
||||
import { FindParams, SelectParams } from "../../common"
|
||||
|
||||
export interface AdminGetPromotionParams extends SelectParams {}
|
||||
|
||||
export interface AdminGetPromotionsParams
|
||||
extends FindParams,
|
||||
BaseFilterable<AdminGetPromotionsParams> {
|
||||
q?: string
|
||||
code?: string | string[]
|
||||
campaign_id?: string | string[]
|
||||
application_method?: {
|
||||
currency_code?: string | string[]
|
||||
}
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
$and?: AdminGetPromotionsParams[]
|
||||
$or?: AdminGetPromotionsParams[]
|
||||
}
|
||||
|
||||
export interface AdminGetPromotionRuleParams {
|
||||
promotion_type?: string
|
||||
application_method_type?: string
|
||||
}
|
||||
|
||||
export interface AdminGetPromotionRuleTypeParams extends SelectParams {
|
||||
promotion_type?: string
|
||||
application_method_type?: string
|
||||
}
|
||||
|
||||
export interface AdminGetPromotionsRuleValueParams extends FindParams {
|
||||
q?: string
|
||||
value?: string | string[]
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user