| 2139 | }); |
| 2140 | }, |
| 2141 | async setPurchaseTag(purchaseId, { tagId, tagName } = {}) { |
| 2142 | const body = {}; |
| 2143 | if (tagId !== undefined) { |
| 2144 | body.tag_id = Number(tagId) || 0; |
| 2145 | } |
| 2146 | if (tagName !== undefined) { |
| 2147 | body.tag_name = String(tagName || '').trim(); |
| 2148 | } |
| 2149 | await request('PUT', `/api/v1/openapi/email/purchases/${encodeURIComponent(purchaseId)}/tag`, { |
| 2150 | jsonData: body, |
| 2151 | }); |
| 2152 | }, |
| 2153 | async batchSetPurchaseTag(ids, { tagId, tagName } = {}) { |
| 2154 | const body = { |
| 2155 | ids: (Array.isArray(ids) ? ids : []).map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0), |