@polar-sh/sdk 0.40.3 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +1 -1
  2. package/dist/commonjs/funcs/eventsList.js +1 -0
  3. package/dist/commonjs/funcs/eventsList.js.map +1 -1
  4. package/dist/commonjs/lib/config.d.ts +3 -3
  5. package/dist/commonjs/lib/config.js +3 -3
  6. package/dist/commonjs/models/components/benefitcycledevent.d.ts +5 -0
  7. package/dist/commonjs/models/components/benefitcycledevent.d.ts.map +1 -1
  8. package/dist/commonjs/models/components/benefitcycledevent.js +4 -0
  9. package/dist/commonjs/models/components/benefitcycledevent.js.map +1 -1
  10. package/dist/commonjs/models/components/benefitgrantedevent.d.ts +5 -0
  11. package/dist/commonjs/models/components/benefitgrantedevent.d.ts.map +1 -1
  12. package/dist/commonjs/models/components/benefitgrantedevent.js +4 -0
  13. package/dist/commonjs/models/components/benefitgrantedevent.js.map +1 -1
  14. package/dist/commonjs/models/components/benefitrevokedevent.d.ts +5 -0
  15. package/dist/commonjs/models/components/benefitrevokedevent.d.ts.map +1 -1
  16. package/dist/commonjs/models/components/benefitrevokedevent.js +4 -0
  17. package/dist/commonjs/models/components/benefitrevokedevent.js.map +1 -1
  18. package/dist/commonjs/models/components/benefitupdatedevent.d.ts +5 -0
  19. package/dist/commonjs/models/components/benefitupdatedevent.d.ts.map +1 -1
  20. package/dist/commonjs/models/components/benefitupdatedevent.js +4 -0
  21. package/dist/commonjs/models/components/benefitupdatedevent.js.map +1 -1
  22. package/dist/commonjs/models/components/customercreate.d.ts +0 -3
  23. package/dist/commonjs/models/components/customercreate.d.ts.map +1 -1
  24. package/dist/commonjs/models/components/customercreate.js.map +1 -1
  25. package/dist/commonjs/models/components/customercreatedevent.d.ts +5 -0
  26. package/dist/commonjs/models/components/customercreatedevent.d.ts.map +1 -1
  27. package/dist/commonjs/models/components/customercreatedevent.js +4 -0
  28. package/dist/commonjs/models/components/customercreatedevent.js.map +1 -1
  29. package/dist/commonjs/models/components/customerdeletedevent.d.ts +5 -0
  30. package/dist/commonjs/models/components/customerdeletedevent.d.ts.map +1 -1
  31. package/dist/commonjs/models/components/customerdeletedevent.js +4 -0
  32. package/dist/commonjs/models/components/customerdeletedevent.js.map +1 -1
  33. package/dist/commonjs/models/components/customerupdate.d.ts +0 -3
  34. package/dist/commonjs/models/components/customerupdate.d.ts.map +1 -1
  35. package/dist/commonjs/models/components/customerupdate.js.map +1 -1
  36. package/dist/commonjs/models/components/customerupdatedevent.d.ts +5 -0
  37. package/dist/commonjs/models/components/customerupdatedevent.d.ts.map +1 -1
  38. package/dist/commonjs/models/components/customerupdatedevent.js +4 -0
  39. package/dist/commonjs/models/components/customerupdatedevent.js.map +1 -1
  40. package/dist/commonjs/models/components/customerupdateexternalid.d.ts +0 -3
  41. package/dist/commonjs/models/components/customerupdateexternalid.d.ts.map +1 -1
  42. package/dist/commonjs/models/components/customerupdateexternalid.js.map +1 -1
  43. package/dist/commonjs/models/components/eventcreatecustomer.d.ts +10 -0
  44. package/dist/commonjs/models/components/eventcreatecustomer.d.ts.map +1 -1
  45. package/dist/commonjs/models/components/eventcreatecustomer.js +8 -0
  46. package/dist/commonjs/models/components/eventcreatecustomer.js.map +1 -1
  47. package/dist/commonjs/models/components/eventcreateexternalcustomer.d.ts +10 -0
  48. package/dist/commonjs/models/components/eventcreateexternalcustomer.d.ts.map +1 -1
  49. package/dist/commonjs/models/components/eventcreateexternalcustomer.js +8 -0
  50. package/dist/commonjs/models/components/eventcreateexternalcustomer.js.map +1 -1
  51. package/dist/commonjs/models/components/eventsingestresponse.d.ts +5 -0
  52. package/dist/commonjs/models/components/eventsingestresponse.d.ts.map +1 -1
  53. package/dist/commonjs/models/components/eventsingestresponse.js +2 -0
  54. package/dist/commonjs/models/components/eventsingestresponse.js.map +1 -1
  55. package/dist/commonjs/models/components/metercreditevent.d.ts +5 -0
  56. package/dist/commonjs/models/components/metercreditevent.d.ts.map +1 -1
  57. package/dist/commonjs/models/components/metercreditevent.js +4 -0
  58. package/dist/commonjs/models/components/metercreditevent.js.map +1 -1
  59. package/dist/commonjs/models/components/meterresetevent.d.ts +5 -0
  60. package/dist/commonjs/models/components/meterresetevent.d.ts.map +1 -1
  61. package/dist/commonjs/models/components/meterresetevent.js +4 -0
  62. package/dist/commonjs/models/components/meterresetevent.js.map +1 -1
  63. package/dist/commonjs/models/components/orderpaidevent.d.ts +5 -0
  64. package/dist/commonjs/models/components/orderpaidevent.d.ts.map +1 -1
  65. package/dist/commonjs/models/components/orderpaidevent.js +4 -0
  66. package/dist/commonjs/models/components/orderpaidevent.js.map +1 -1
  67. package/dist/commonjs/models/components/orderrefundedevent.d.ts +5 -0
  68. package/dist/commonjs/models/components/orderrefundedevent.d.ts.map +1 -1
  69. package/dist/commonjs/models/components/orderrefundedevent.js +4 -0
  70. package/dist/commonjs/models/components/orderrefundedevent.js.map +1 -1
  71. package/dist/commonjs/models/components/subscriptioncycledevent.d.ts +5 -0
  72. package/dist/commonjs/models/components/subscriptioncycledevent.d.ts.map +1 -1
  73. package/dist/commonjs/models/components/subscriptioncycledevent.js +4 -0
  74. package/dist/commonjs/models/components/subscriptioncycledevent.js.map +1 -1
  75. package/dist/commonjs/models/components/subscriptionproductupdatedevent.d.ts +5 -0
  76. package/dist/commonjs/models/components/subscriptionproductupdatedevent.d.ts.map +1 -1
  77. package/dist/commonjs/models/components/subscriptionproductupdatedevent.js +4 -0
  78. package/dist/commonjs/models/components/subscriptionproductupdatedevent.js.map +1 -1
  79. package/dist/commonjs/models/components/subscriptionrevokedevent.d.ts +5 -0
  80. package/dist/commonjs/models/components/subscriptionrevokedevent.d.ts.map +1 -1
  81. package/dist/commonjs/models/components/subscriptionrevokedevent.js +4 -0
  82. package/dist/commonjs/models/components/subscriptionrevokedevent.js.map +1 -1
  83. package/dist/commonjs/models/components/userevent.d.ts +5 -0
  84. package/dist/commonjs/models/components/userevent.d.ts.map +1 -1
  85. package/dist/commonjs/models/components/userevent.js +4 -0
  86. package/dist/commonjs/models/components/userevent.js.map +1 -1
  87. package/dist/commonjs/models/operations/eventslist.d.ts +5 -0
  88. package/dist/commonjs/models/operations/eventslist.d.ts.map +1 -1
  89. package/dist/commonjs/models/operations/eventslist.js +4 -0
  90. package/dist/commonjs/models/operations/eventslist.js.map +1 -1
  91. package/dist/esm/funcs/eventsList.js +1 -0
  92. package/dist/esm/funcs/eventsList.js.map +1 -1
  93. package/dist/esm/lib/config.d.ts +3 -3
  94. package/dist/esm/lib/config.js +3 -3
  95. package/dist/esm/models/components/benefitcycledevent.d.ts +5 -0
  96. package/dist/esm/models/components/benefitcycledevent.d.ts.map +1 -1
  97. package/dist/esm/models/components/benefitcycledevent.js +4 -0
  98. package/dist/esm/models/components/benefitcycledevent.js.map +1 -1
  99. package/dist/esm/models/components/benefitgrantedevent.d.ts +5 -0
  100. package/dist/esm/models/components/benefitgrantedevent.d.ts.map +1 -1
  101. package/dist/esm/models/components/benefitgrantedevent.js +4 -0
  102. package/dist/esm/models/components/benefitgrantedevent.js.map +1 -1
  103. package/dist/esm/models/components/benefitrevokedevent.d.ts +5 -0
  104. package/dist/esm/models/components/benefitrevokedevent.d.ts.map +1 -1
  105. package/dist/esm/models/components/benefitrevokedevent.js +4 -0
  106. package/dist/esm/models/components/benefitrevokedevent.js.map +1 -1
  107. package/dist/esm/models/components/benefitupdatedevent.d.ts +5 -0
  108. package/dist/esm/models/components/benefitupdatedevent.d.ts.map +1 -1
  109. package/dist/esm/models/components/benefitupdatedevent.js +4 -0
  110. package/dist/esm/models/components/benefitupdatedevent.js.map +1 -1
  111. package/dist/esm/models/components/customercreate.d.ts +0 -3
  112. package/dist/esm/models/components/customercreate.d.ts.map +1 -1
  113. package/dist/esm/models/components/customercreate.js.map +1 -1
  114. package/dist/esm/models/components/customercreatedevent.d.ts +5 -0
  115. package/dist/esm/models/components/customercreatedevent.d.ts.map +1 -1
  116. package/dist/esm/models/components/customercreatedevent.js +4 -0
  117. package/dist/esm/models/components/customercreatedevent.js.map +1 -1
  118. package/dist/esm/models/components/customerdeletedevent.d.ts +5 -0
  119. package/dist/esm/models/components/customerdeletedevent.d.ts.map +1 -1
  120. package/dist/esm/models/components/customerdeletedevent.js +4 -0
  121. package/dist/esm/models/components/customerdeletedevent.js.map +1 -1
  122. package/dist/esm/models/components/customerupdate.d.ts +0 -3
  123. package/dist/esm/models/components/customerupdate.d.ts.map +1 -1
  124. package/dist/esm/models/components/customerupdate.js.map +1 -1
  125. package/dist/esm/models/components/customerupdatedevent.d.ts +5 -0
  126. package/dist/esm/models/components/customerupdatedevent.d.ts.map +1 -1
  127. package/dist/esm/models/components/customerupdatedevent.js +4 -0
  128. package/dist/esm/models/components/customerupdatedevent.js.map +1 -1
  129. package/dist/esm/models/components/customerupdateexternalid.d.ts +0 -3
  130. package/dist/esm/models/components/customerupdateexternalid.d.ts.map +1 -1
  131. package/dist/esm/models/components/customerupdateexternalid.js.map +1 -1
  132. package/dist/esm/models/components/eventcreatecustomer.d.ts +10 -0
  133. package/dist/esm/models/components/eventcreatecustomer.d.ts.map +1 -1
  134. package/dist/esm/models/components/eventcreatecustomer.js +8 -0
  135. package/dist/esm/models/components/eventcreatecustomer.js.map +1 -1
  136. package/dist/esm/models/components/eventcreateexternalcustomer.d.ts +10 -0
  137. package/dist/esm/models/components/eventcreateexternalcustomer.d.ts.map +1 -1
  138. package/dist/esm/models/components/eventcreateexternalcustomer.js +8 -0
  139. package/dist/esm/models/components/eventcreateexternalcustomer.js.map +1 -1
  140. package/dist/esm/models/components/eventsingestresponse.d.ts +5 -0
  141. package/dist/esm/models/components/eventsingestresponse.d.ts.map +1 -1
  142. package/dist/esm/models/components/eventsingestresponse.js +2 -0
  143. package/dist/esm/models/components/eventsingestresponse.js.map +1 -1
  144. package/dist/esm/models/components/metercreditevent.d.ts +5 -0
  145. package/dist/esm/models/components/metercreditevent.d.ts.map +1 -1
  146. package/dist/esm/models/components/metercreditevent.js +4 -0
  147. package/dist/esm/models/components/metercreditevent.js.map +1 -1
  148. package/dist/esm/models/components/meterresetevent.d.ts +5 -0
  149. package/dist/esm/models/components/meterresetevent.d.ts.map +1 -1
  150. package/dist/esm/models/components/meterresetevent.js +4 -0
  151. package/dist/esm/models/components/meterresetevent.js.map +1 -1
  152. package/dist/esm/models/components/orderpaidevent.d.ts +5 -0
  153. package/dist/esm/models/components/orderpaidevent.d.ts.map +1 -1
  154. package/dist/esm/models/components/orderpaidevent.js +4 -0
  155. package/dist/esm/models/components/orderpaidevent.js.map +1 -1
  156. package/dist/esm/models/components/orderrefundedevent.d.ts +5 -0
  157. package/dist/esm/models/components/orderrefundedevent.d.ts.map +1 -1
  158. package/dist/esm/models/components/orderrefundedevent.js +4 -0
  159. package/dist/esm/models/components/orderrefundedevent.js.map +1 -1
  160. package/dist/esm/models/components/subscriptioncycledevent.d.ts +5 -0
  161. package/dist/esm/models/components/subscriptioncycledevent.d.ts.map +1 -1
  162. package/dist/esm/models/components/subscriptioncycledevent.js +4 -0
  163. package/dist/esm/models/components/subscriptioncycledevent.js.map +1 -1
  164. package/dist/esm/models/components/subscriptionproductupdatedevent.d.ts +5 -0
  165. package/dist/esm/models/components/subscriptionproductupdatedevent.d.ts.map +1 -1
  166. package/dist/esm/models/components/subscriptionproductupdatedevent.js +4 -0
  167. package/dist/esm/models/components/subscriptionproductupdatedevent.js.map +1 -1
  168. package/dist/esm/models/components/subscriptionrevokedevent.d.ts +5 -0
  169. package/dist/esm/models/components/subscriptionrevokedevent.d.ts.map +1 -1
  170. package/dist/esm/models/components/subscriptionrevokedevent.js +4 -0
  171. package/dist/esm/models/components/subscriptionrevokedevent.js.map +1 -1
  172. package/dist/esm/models/components/userevent.d.ts +5 -0
  173. package/dist/esm/models/components/userevent.d.ts.map +1 -1
  174. package/dist/esm/models/components/userevent.js +4 -0
  175. package/dist/esm/models/components/userevent.js.map +1 -1
  176. package/dist/esm/models/operations/eventslist.d.ts +5 -0
  177. package/dist/esm/models/operations/eventslist.d.ts.map +1 -1
  178. package/dist/esm/models/operations/eventslist.js +4 -0
  179. package/dist/esm/models/operations/eventslist.js.map +1 -1
  180. package/examples/package-lock.json +1 -1
  181. package/jsr.json +1 -1
  182. package/package.json +1 -1
  183. package/src/funcs/eventsList.ts +1 -0
  184. package/src/lib/config.ts +3 -3
  185. package/src/models/components/benefitcycledevent.ts +9 -0
  186. package/src/models/components/benefitgrantedevent.ts +9 -0
  187. package/src/models/components/benefitrevokedevent.ts +9 -0
  188. package/src/models/components/benefitupdatedevent.ts +9 -0
  189. package/src/models/components/customercreate.ts +0 -3
  190. package/src/models/components/customercreatedevent.ts +9 -0
  191. package/src/models/components/customerdeletedevent.ts +9 -0
  192. package/src/models/components/customerupdate.ts +0 -3
  193. package/src/models/components/customerupdatedevent.ts +9 -0
  194. package/src/models/components/customerupdateexternalid.ts +0 -3
  195. package/src/models/components/eventcreatecustomer.ts +18 -0
  196. package/src/models/components/eventcreateexternalcustomer.ts +18 -0
  197. package/src/models/components/eventsingestresponse.ts +7 -0
  198. package/src/models/components/metercreditevent.ts +9 -0
  199. package/src/models/components/meterresetevent.ts +9 -0
  200. package/src/models/components/orderpaidevent.ts +9 -0
  201. package/src/models/components/orderrefundedevent.ts +9 -0
  202. package/src/models/components/subscriptioncycledevent.ts +9 -0
  203. package/src/models/components/subscriptionproductupdatedevent.ts +9 -0
  204. package/src/models/components/subscriptionrevokedevent.ts +9 -0
  205. package/src/models/components/userevent.ts +9 -0
  206. package/src/models/operations/eventslist.ts +9 -0
  207. package/.devcontainer/README.md +0 -35
  208. package/docs/sdks/benefitgrants/README.md +0 -88
  209. package/docs/sdks/benefits/README.md +0 -500
  210. package/docs/sdks/checkoutlinks/README.md +0 -407
  211. package/docs/sdks/checkouts/README.md +0 -600
  212. package/docs/sdks/clients/README.md +0 -331
  213. package/docs/sdks/customermeters/README.md +0 -166
  214. package/docs/sdks/customers/README.md +0 -1036
  215. package/docs/sdks/customerseats/README.md +0 -441
  216. package/docs/sdks/customersession/README.md +0 -79
  217. package/docs/sdks/customersessions/README.md +0 -84
  218. package/docs/sdks/customfields/README.md +0 -417
  219. package/docs/sdks/discounts/README.md +0 -409
  220. package/docs/sdks/downloadables/README.md +0 -83
  221. package/docs/sdks/events/README.md +0 -324
  222. package/docs/sdks/files/README.md +0 -460
  223. package/docs/sdks/licensekeys/README.md +0 -576
  224. package/docs/sdks/meters/README.md +0 -437
  225. package/docs/sdks/metrics/README.md +0 -165
  226. package/docs/sdks/oauth2/README.md +0 -371
  227. package/docs/sdks/orders/README.md +0 -489
  228. package/docs/sdks/organizations/README.md +0 -322
  229. package/docs/sdks/payments/README.md +0 -166
  230. package/docs/sdks/polarbenefitgrants/README.md +0 -250
  231. package/docs/sdks/polarcustomermeters/README.md +0 -164
  232. package/docs/sdks/polarcustomers/README.md +0 -482
  233. package/docs/sdks/polarlicensekeys/README.md +0 -406
  234. package/docs/sdks/polarorders/README.md +0 -574
  235. package/docs/sdks/polarorganizations/README.md +0 -79
  236. package/docs/sdks/polarsubscriptions/README.md +0 -326
  237. package/docs/sdks/polarwallets/README.md +0 -164
  238. package/docs/sdks/products/README.md +0 -441
  239. package/docs/sdks/refunds/README.md +0 -171
  240. package/docs/sdks/seats/README.md +0 -379
  241. package/docs/sdks/subscriptions/README.md +0 -493
  242. package/docs/sdks/wallets/README.md +0 -256
  243. package/docs/sdks/webhooks/README.md +0 -650
  244. package/examples/README.md +0 -31
@@ -1,1036 +0,0 @@
1
- # Customers
2
- (*customers*)
3
-
4
- ## Overview
5
-
6
- ### Available Operations
7
-
8
- * [list](#list) - List Customers
9
- * [create](#create) - Create Customer
10
- * [export](#export) - Export Customers
11
- * [get](#get) - Get Customer
12
- * [update](#update) - Update Customer
13
- * [delete](#delete) - Delete Customer
14
- * [getExternal](#getexternal) - Get Customer by External ID
15
- * [updateExternal](#updateexternal) - Update Customer by External ID
16
- * [deleteExternal](#deleteexternal) - Delete Customer by External ID
17
- * [getState](#getstate) - Get Customer State
18
- * [getStateExternal](#getstateexternal) - Get Customer State by External ID
19
- * [getBalance](#getbalance) - Get Customer Balance
20
-
21
- ## list
22
-
23
- List customers.
24
-
25
- **Scopes**: `customers:read` `customers:write`
26
-
27
- ### Example Usage
28
-
29
- <!-- UsageSnippet language="typescript" operationID="customers:list" method="get" path="/v1/customers/" -->
30
- ```typescript
31
- import { Polar } from "@polar-sh/sdk";
32
-
33
- const polar = new Polar({
34
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
35
- });
36
-
37
- async function run() {
38
- const result = await polar.customers.list({
39
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
40
- });
41
-
42
- for await (const page of result) {
43
- console.log(page);
44
- }
45
- }
46
-
47
- run();
48
- ```
49
-
50
- ### Standalone function
51
-
52
- The standalone function version of this method:
53
-
54
- ```typescript
55
- import { PolarCore } from "@polar-sh/sdk/core.js";
56
- import { customersList } from "@polar-sh/sdk/funcs/customersList.js";
57
-
58
- // Use `PolarCore` for best tree-shaking performance.
59
- // You can create one instance of it to use across an application.
60
- const polar = new PolarCore({
61
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
62
- });
63
-
64
- async function run() {
65
- const res = await customersList(polar, {
66
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
67
- });
68
- if (res.ok) {
69
- const { value: result } = res;
70
- for await (const page of result) {
71
- console.log(page);
72
- }
73
- } else {
74
- console.log("customersList failed:", res.error);
75
- }
76
- }
77
-
78
- run();
79
- ```
80
-
81
- ### Parameters
82
-
83
- | Parameter | Type | Required | Description |
84
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
85
- | `request` | [operations.CustomersListRequest](../../models/operations/customerslistrequest.md) | :heavy_check_mark: | The request object to use for the request. |
86
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
87
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
88
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
89
-
90
- ### Response
91
-
92
- **Promise\<[operations.CustomersListResponse](../../models/operations/customerslistresponse.md)\>**
93
-
94
- ### Errors
95
-
96
- | Error Type | Status Code | Content Type |
97
- | -------------------------- | -------------------------- | -------------------------- |
98
- | errors.HTTPValidationError | 422 | application/json |
99
- | errors.SDKError | 4XX, 5XX | \*/\* |
100
-
101
- ## create
102
-
103
- Create a customer.
104
-
105
- **Scopes**: `customers:write`
106
-
107
- ### Example Usage
108
-
109
- <!-- UsageSnippet language="typescript" operationID="customers:create" method="post" path="/v1/customers/" -->
110
- ```typescript
111
- import { Polar } from "@polar-sh/sdk";
112
-
113
- const polar = new Polar({
114
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
115
- });
116
-
117
- async function run() {
118
- const result = await polar.customers.create({
119
- externalId: "usr_1337",
120
- email: "customer@example.com",
121
- name: "John Doe",
122
- billingAddress: {
123
- country: "US",
124
- },
125
- taxId: [
126
- "911144442",
127
- "us_ein",
128
- ],
129
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
130
- });
131
-
132
- console.log(result);
133
- }
134
-
135
- run();
136
- ```
137
-
138
- ### Standalone function
139
-
140
- The standalone function version of this method:
141
-
142
- ```typescript
143
- import { PolarCore } from "@polar-sh/sdk/core.js";
144
- import { customersCreate } from "@polar-sh/sdk/funcs/customersCreate.js";
145
-
146
- // Use `PolarCore` for best tree-shaking performance.
147
- // You can create one instance of it to use across an application.
148
- const polar = new PolarCore({
149
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
150
- });
151
-
152
- async function run() {
153
- const res = await customersCreate(polar, {
154
- externalId: "usr_1337",
155
- email: "customer@example.com",
156
- name: "John Doe",
157
- billingAddress: {
158
- country: "US",
159
- },
160
- taxId: [
161
- "911144442",
162
- "us_ein",
163
- ],
164
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
165
- });
166
- if (res.ok) {
167
- const { value: result } = res;
168
- console.log(result);
169
- } else {
170
- console.log("customersCreate failed:", res.error);
171
- }
172
- }
173
-
174
- run();
175
- ```
176
-
177
- ### Parameters
178
-
179
- | Parameter | Type | Required | Description |
180
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
181
- | `request` | [components.CustomerCreate](../../models/components/customercreate.md) | :heavy_check_mark: | The request object to use for the request. |
182
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
183
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
184
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
185
-
186
- ### Response
187
-
188
- **Promise\<[components.Customer](../../models/components/customer.md)\>**
189
-
190
- ### Errors
191
-
192
- | Error Type | Status Code | Content Type |
193
- | -------------------------- | -------------------------- | -------------------------- |
194
- | errors.HTTPValidationError | 422 | application/json |
195
- | errors.SDKError | 4XX, 5XX | \*/\* |
196
-
197
- ## export
198
-
199
- Export customers as a CSV file.
200
-
201
- **Scopes**: `customers:read` `customers:write`
202
-
203
- ### Example Usage
204
-
205
- <!-- UsageSnippet language="typescript" operationID="customers:export" method="get" path="/v1/customers/export" -->
206
- ```typescript
207
- import { Polar } from "@polar-sh/sdk";
208
-
209
- const polar = new Polar({
210
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
211
- });
212
-
213
- async function run() {
214
- const result = await polar.customers.export({
215
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
216
- });
217
-
218
- console.log(result);
219
- }
220
-
221
- run();
222
- ```
223
-
224
- ### Standalone function
225
-
226
- The standalone function version of this method:
227
-
228
- ```typescript
229
- import { PolarCore } from "@polar-sh/sdk/core.js";
230
- import { customersExport } from "@polar-sh/sdk/funcs/customersExport.js";
231
-
232
- // Use `PolarCore` for best tree-shaking performance.
233
- // You can create one instance of it to use across an application.
234
- const polar = new PolarCore({
235
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
236
- });
237
-
238
- async function run() {
239
- const res = await customersExport(polar, {
240
- organizationId: "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
241
- });
242
- if (res.ok) {
243
- const { value: result } = res;
244
- console.log(result);
245
- } else {
246
- console.log("customersExport failed:", res.error);
247
- }
248
- }
249
-
250
- run();
251
- ```
252
-
253
- ### Parameters
254
-
255
- | Parameter | Type | Required | Description |
256
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
257
- | `request` | [operations.CustomersExportRequest](../../models/operations/customersexportrequest.md) | :heavy_check_mark: | The request object to use for the request. |
258
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
259
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
260
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
261
-
262
- ### Response
263
-
264
- **Promise\<[any](../../models/.md)\>**
265
-
266
- ### Errors
267
-
268
- | Error Type | Status Code | Content Type |
269
- | -------------------------- | -------------------------- | -------------------------- |
270
- | errors.HTTPValidationError | 422 | application/json |
271
- | errors.SDKError | 4XX, 5XX | \*/\* |
272
-
273
- ## get
274
-
275
- Get a customer by ID.
276
-
277
- **Scopes**: `customers:read` `customers:write`
278
-
279
- ### Example Usage
280
-
281
- <!-- UsageSnippet language="typescript" operationID="customers:get" method="get" path="/v1/customers/{id}" -->
282
- ```typescript
283
- import { Polar } from "@polar-sh/sdk";
284
-
285
- const polar = new Polar({
286
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
287
- });
288
-
289
- async function run() {
290
- const result = await polar.customers.get({
291
- id: "<value>",
292
- });
293
-
294
- console.log(result);
295
- }
296
-
297
- run();
298
- ```
299
-
300
- ### Standalone function
301
-
302
- The standalone function version of this method:
303
-
304
- ```typescript
305
- import { PolarCore } from "@polar-sh/sdk/core.js";
306
- import { customersGet } from "@polar-sh/sdk/funcs/customersGet.js";
307
-
308
- // Use `PolarCore` for best tree-shaking performance.
309
- // You can create one instance of it to use across an application.
310
- const polar = new PolarCore({
311
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
312
- });
313
-
314
- async function run() {
315
- const res = await customersGet(polar, {
316
- id: "<value>",
317
- });
318
- if (res.ok) {
319
- const { value: result } = res;
320
- console.log(result);
321
- } else {
322
- console.log("customersGet failed:", res.error);
323
- }
324
- }
325
-
326
- run();
327
- ```
328
-
329
- ### Parameters
330
-
331
- | Parameter | Type | Required | Description |
332
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
333
- | `request` | [operations.CustomersGetRequest](../../models/operations/customersgetrequest.md) | :heavy_check_mark: | The request object to use for the request. |
334
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
335
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
336
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
337
-
338
- ### Response
339
-
340
- **Promise\<[components.Customer](../../models/components/customer.md)\>**
341
-
342
- ### Errors
343
-
344
- | Error Type | Status Code | Content Type |
345
- | -------------------------- | -------------------------- | -------------------------- |
346
- | errors.ResourceNotFound | 404 | application/json |
347
- | errors.HTTPValidationError | 422 | application/json |
348
- | errors.SDKError | 4XX, 5XX | \*/\* |
349
-
350
- ## update
351
-
352
- Update a customer.
353
-
354
- **Scopes**: `customers:write`
355
-
356
- ### Example Usage
357
-
358
- <!-- UsageSnippet language="typescript" operationID="customers:update" method="patch" path="/v1/customers/{id}" -->
359
- ```typescript
360
- import { Polar } from "@polar-sh/sdk";
361
-
362
- const polar = new Polar({
363
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
364
- });
365
-
366
- async function run() {
367
- const result = await polar.customers.update({
368
- id: "<value>",
369
- customerUpdate: {
370
- email: "customer@example.com",
371
- name: "John Doe",
372
- billingAddress: {
373
- country: "US",
374
- },
375
- taxId: [
376
- "911144442",
377
- "us_ein",
378
- ],
379
- externalId: "usr_1337",
380
- },
381
- });
382
-
383
- console.log(result);
384
- }
385
-
386
- run();
387
- ```
388
-
389
- ### Standalone function
390
-
391
- The standalone function version of this method:
392
-
393
- ```typescript
394
- import { PolarCore } from "@polar-sh/sdk/core.js";
395
- import { customersUpdate } from "@polar-sh/sdk/funcs/customersUpdate.js";
396
-
397
- // Use `PolarCore` for best tree-shaking performance.
398
- // You can create one instance of it to use across an application.
399
- const polar = new PolarCore({
400
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
401
- });
402
-
403
- async function run() {
404
- const res = await customersUpdate(polar, {
405
- id: "<value>",
406
- customerUpdate: {
407
- email: "customer@example.com",
408
- name: "John Doe",
409
- billingAddress: {
410
- country: "US",
411
- },
412
- taxId: [
413
- "911144442",
414
- "us_ein",
415
- ],
416
- externalId: "usr_1337",
417
- },
418
- });
419
- if (res.ok) {
420
- const { value: result } = res;
421
- console.log(result);
422
- } else {
423
- console.log("customersUpdate failed:", res.error);
424
- }
425
- }
426
-
427
- run();
428
- ```
429
-
430
- ### Parameters
431
-
432
- | Parameter | Type | Required | Description |
433
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
434
- | `request` | [operations.CustomersUpdateRequest](../../models/operations/customersupdaterequest.md) | :heavy_check_mark: | The request object to use for the request. |
435
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
436
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
437
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
438
-
439
- ### Response
440
-
441
- **Promise\<[components.Customer](../../models/components/customer.md)\>**
442
-
443
- ### Errors
444
-
445
- | Error Type | Status Code | Content Type |
446
- | -------------------------- | -------------------------- | -------------------------- |
447
- | errors.ResourceNotFound | 404 | application/json |
448
- | errors.HTTPValidationError | 422 | application/json |
449
- | errors.SDKError | 4XX, 5XX | \*/\* |
450
-
451
- ## delete
452
-
453
- Delete a customer.
454
-
455
- This action cannot be undone and will immediately:
456
- - Cancel any active subscriptions for the customer
457
- - Revoke all their benefits
458
- - Clear any `external_id`
459
-
460
- Use it only in the context of deleting a user within your
461
- own service. Otherwise, use more granular API endpoints to cancel
462
- a specific subscription or revoke certain benefits.
463
-
464
- Note: The customers information will nonetheless be retained for historic
465
- orders and subscriptions.
466
-
467
- **Scopes**: `customers:write`
468
-
469
- ### Example Usage
470
-
471
- <!-- UsageSnippet language="typescript" operationID="customers:delete" method="delete" path="/v1/customers/{id}" -->
472
- ```typescript
473
- import { Polar } from "@polar-sh/sdk";
474
-
475
- const polar = new Polar({
476
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
477
- });
478
-
479
- async function run() {
480
- await polar.customers.delete({
481
- id: "<value>",
482
- });
483
-
484
-
485
- }
486
-
487
- run();
488
- ```
489
-
490
- ### Standalone function
491
-
492
- The standalone function version of this method:
493
-
494
- ```typescript
495
- import { PolarCore } from "@polar-sh/sdk/core.js";
496
- import { customersDelete } from "@polar-sh/sdk/funcs/customersDelete.js";
497
-
498
- // Use `PolarCore` for best tree-shaking performance.
499
- // You can create one instance of it to use across an application.
500
- const polar = new PolarCore({
501
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
502
- });
503
-
504
- async function run() {
505
- const res = await customersDelete(polar, {
506
- id: "<value>",
507
- });
508
- if (res.ok) {
509
- const { value: result } = res;
510
-
511
- } else {
512
- console.log("customersDelete failed:", res.error);
513
- }
514
- }
515
-
516
- run();
517
- ```
518
-
519
- ### Parameters
520
-
521
- | Parameter | Type | Required | Description |
522
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
523
- | `request` | [operations.CustomersDeleteRequest](../../models/operations/customersdeleterequest.md) | :heavy_check_mark: | The request object to use for the request. |
524
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
525
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
526
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
527
-
528
- ### Response
529
-
530
- **Promise\<void\>**
531
-
532
- ### Errors
533
-
534
- | Error Type | Status Code | Content Type |
535
- | -------------------------- | -------------------------- | -------------------------- |
536
- | errors.ResourceNotFound | 404 | application/json |
537
- | errors.HTTPValidationError | 422 | application/json |
538
- | errors.SDKError | 4XX, 5XX | \*/\* |
539
-
540
- ## getExternal
541
-
542
- Get a customer by external ID.
543
-
544
- **Scopes**: `customers:read` `customers:write`
545
-
546
- ### Example Usage
547
-
548
- <!-- UsageSnippet language="typescript" operationID="customers:get_external" method="get" path="/v1/customers/external/{external_id}" -->
549
- ```typescript
550
- import { Polar } from "@polar-sh/sdk";
551
-
552
- const polar = new Polar({
553
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
554
- });
555
-
556
- async function run() {
557
- const result = await polar.customers.getExternal({
558
- externalId: "<id>",
559
- });
560
-
561
- console.log(result);
562
- }
563
-
564
- run();
565
- ```
566
-
567
- ### Standalone function
568
-
569
- The standalone function version of this method:
570
-
571
- ```typescript
572
- import { PolarCore } from "@polar-sh/sdk/core.js";
573
- import { customersGetExternal } from "@polar-sh/sdk/funcs/customersGetExternal.js";
574
-
575
- // Use `PolarCore` for best tree-shaking performance.
576
- // You can create one instance of it to use across an application.
577
- const polar = new PolarCore({
578
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
579
- });
580
-
581
- async function run() {
582
- const res = await customersGetExternal(polar, {
583
- externalId: "<id>",
584
- });
585
- if (res.ok) {
586
- const { value: result } = res;
587
- console.log(result);
588
- } else {
589
- console.log("customersGetExternal failed:", res.error);
590
- }
591
- }
592
-
593
- run();
594
- ```
595
-
596
- ### Parameters
597
-
598
- | Parameter | Type | Required | Description |
599
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
600
- | `request` | [operations.CustomersGetExternalRequest](../../models/operations/customersgetexternalrequest.md) | :heavy_check_mark: | The request object to use for the request. |
601
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
602
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
603
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
604
-
605
- ### Response
606
-
607
- **Promise\<[components.Customer](../../models/components/customer.md)\>**
608
-
609
- ### Errors
610
-
611
- | Error Type | Status Code | Content Type |
612
- | -------------------------- | -------------------------- | -------------------------- |
613
- | errors.ResourceNotFound | 404 | application/json |
614
- | errors.HTTPValidationError | 422 | application/json |
615
- | errors.SDKError | 4XX, 5XX | \*/\* |
616
-
617
- ## updateExternal
618
-
619
- Update a customer by external ID.
620
-
621
- **Scopes**: `customers:write`
622
-
623
- ### Example Usage
624
-
625
- <!-- UsageSnippet language="typescript" operationID="customers:update_external" method="patch" path="/v1/customers/external/{external_id}" -->
626
- ```typescript
627
- import { Polar } from "@polar-sh/sdk";
628
-
629
- const polar = new Polar({
630
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
631
- });
632
-
633
- async function run() {
634
- const result = await polar.customers.updateExternal({
635
- externalId: "<id>",
636
- customerUpdateExternalID: {
637
- email: "customer@example.com",
638
- name: "John Doe",
639
- billingAddress: {
640
- country: "US",
641
- },
642
- taxId: [
643
- "911144442",
644
- "us_ein",
645
- ],
646
- },
647
- });
648
-
649
- console.log(result);
650
- }
651
-
652
- run();
653
- ```
654
-
655
- ### Standalone function
656
-
657
- The standalone function version of this method:
658
-
659
- ```typescript
660
- import { PolarCore } from "@polar-sh/sdk/core.js";
661
- import { customersUpdateExternal } from "@polar-sh/sdk/funcs/customersUpdateExternal.js";
662
-
663
- // Use `PolarCore` for best tree-shaking performance.
664
- // You can create one instance of it to use across an application.
665
- const polar = new PolarCore({
666
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
667
- });
668
-
669
- async function run() {
670
- const res = await customersUpdateExternal(polar, {
671
- externalId: "<id>",
672
- customerUpdateExternalID: {
673
- email: "customer@example.com",
674
- name: "John Doe",
675
- billingAddress: {
676
- country: "US",
677
- },
678
- taxId: [
679
- "911144442",
680
- "us_ein",
681
- ],
682
- },
683
- });
684
- if (res.ok) {
685
- const { value: result } = res;
686
- console.log(result);
687
- } else {
688
- console.log("customersUpdateExternal failed:", res.error);
689
- }
690
- }
691
-
692
- run();
693
- ```
694
-
695
- ### Parameters
696
-
697
- | Parameter | Type | Required | Description |
698
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
699
- | `request` | [operations.CustomersUpdateExternalRequest](../../models/operations/customersupdateexternalrequest.md) | :heavy_check_mark: | The request object to use for the request. |
700
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
701
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
702
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
703
-
704
- ### Response
705
-
706
- **Promise\<[components.Customer](../../models/components/customer.md)\>**
707
-
708
- ### Errors
709
-
710
- | Error Type | Status Code | Content Type |
711
- | -------------------------- | -------------------------- | -------------------------- |
712
- | errors.ResourceNotFound | 404 | application/json |
713
- | errors.HTTPValidationError | 422 | application/json |
714
- | errors.SDKError | 4XX, 5XX | \*/\* |
715
-
716
- ## deleteExternal
717
-
718
- Delete a customer by external ID.
719
-
720
- Immediately cancels any active subscriptions and revokes any active benefits.
721
-
722
- **Scopes**: `customers:write`
723
-
724
- ### Example Usage
725
-
726
- <!-- UsageSnippet language="typescript" operationID="customers:delete_external" method="delete" path="/v1/customers/external/{external_id}" -->
727
- ```typescript
728
- import { Polar } from "@polar-sh/sdk";
729
-
730
- const polar = new Polar({
731
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
732
- });
733
-
734
- async function run() {
735
- await polar.customers.deleteExternal({
736
- externalId: "<id>",
737
- });
738
-
739
-
740
- }
741
-
742
- run();
743
- ```
744
-
745
- ### Standalone function
746
-
747
- The standalone function version of this method:
748
-
749
- ```typescript
750
- import { PolarCore } from "@polar-sh/sdk/core.js";
751
- import { customersDeleteExternal } from "@polar-sh/sdk/funcs/customersDeleteExternal.js";
752
-
753
- // Use `PolarCore` for best tree-shaking performance.
754
- // You can create one instance of it to use across an application.
755
- const polar = new PolarCore({
756
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
757
- });
758
-
759
- async function run() {
760
- const res = await customersDeleteExternal(polar, {
761
- externalId: "<id>",
762
- });
763
- if (res.ok) {
764
- const { value: result } = res;
765
-
766
- } else {
767
- console.log("customersDeleteExternal failed:", res.error);
768
- }
769
- }
770
-
771
- run();
772
- ```
773
-
774
- ### Parameters
775
-
776
- | Parameter | Type | Required | Description |
777
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
778
- | `request` | [operations.CustomersDeleteExternalRequest](../../models/operations/customersdeleteexternalrequest.md) | :heavy_check_mark: | The request object to use for the request. |
779
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
780
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
781
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
782
-
783
- ### Response
784
-
785
- **Promise\<void\>**
786
-
787
- ### Errors
788
-
789
- | Error Type | Status Code | Content Type |
790
- | -------------------------- | -------------------------- | -------------------------- |
791
- | errors.ResourceNotFound | 404 | application/json |
792
- | errors.HTTPValidationError | 422 | application/json |
793
- | errors.SDKError | 4XX, 5XX | \*/\* |
794
-
795
- ## getState
796
-
797
- Get a customer state by ID.
798
-
799
- The customer state includes information about
800
- the customer's active subscriptions and benefits.
801
-
802
- It's the ideal endpoint to use when you need to get a full overview
803
- of a customer's status.
804
-
805
- **Scopes**: `customers:read` `customers:write`
806
-
807
- ### Example Usage
808
-
809
- <!-- UsageSnippet language="typescript" operationID="customers:get_state" method="get" path="/v1/customers/{id}/state" -->
810
- ```typescript
811
- import { Polar } from "@polar-sh/sdk";
812
-
813
- const polar = new Polar({
814
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
815
- });
816
-
817
- async function run() {
818
- const result = await polar.customers.getState({
819
- id: "<value>",
820
- });
821
-
822
- console.log(result);
823
- }
824
-
825
- run();
826
- ```
827
-
828
- ### Standalone function
829
-
830
- The standalone function version of this method:
831
-
832
- ```typescript
833
- import { PolarCore } from "@polar-sh/sdk/core.js";
834
- import { customersGetState } from "@polar-sh/sdk/funcs/customersGetState.js";
835
-
836
- // Use `PolarCore` for best tree-shaking performance.
837
- // You can create one instance of it to use across an application.
838
- const polar = new PolarCore({
839
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
840
- });
841
-
842
- async function run() {
843
- const res = await customersGetState(polar, {
844
- id: "<value>",
845
- });
846
- if (res.ok) {
847
- const { value: result } = res;
848
- console.log(result);
849
- } else {
850
- console.log("customersGetState failed:", res.error);
851
- }
852
- }
853
-
854
- run();
855
- ```
856
-
857
- ### Parameters
858
-
859
- | Parameter | Type | Required | Description |
860
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
861
- | `request` | [operations.CustomersGetStateRequest](../../models/operations/customersgetstaterequest.md) | :heavy_check_mark: | The request object to use for the request. |
862
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
863
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
864
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
865
-
866
- ### Response
867
-
868
- **Promise\<[components.CustomerState](../../models/components/customerstate.md)\>**
869
-
870
- ### Errors
871
-
872
- | Error Type | Status Code | Content Type |
873
- | -------------------------- | -------------------------- | -------------------------- |
874
- | errors.ResourceNotFound | 404 | application/json |
875
- | errors.HTTPValidationError | 422 | application/json |
876
- | errors.SDKError | 4XX, 5XX | \*/\* |
877
-
878
- ## getStateExternal
879
-
880
- Get a customer state by external ID.
881
-
882
- The customer state includes information about
883
- the customer's active subscriptions and benefits.
884
-
885
- It's the ideal endpoint to use when you need to get a full overview
886
- of a customer's status.
887
-
888
- **Scopes**: `customers:read` `customers:write`
889
-
890
- ### Example Usage
891
-
892
- <!-- UsageSnippet language="typescript" operationID="customers:get_state_external" method="get" path="/v1/customers/external/{external_id}/state" -->
893
- ```typescript
894
- import { Polar } from "@polar-sh/sdk";
895
-
896
- const polar = new Polar({
897
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
898
- });
899
-
900
- async function run() {
901
- const result = await polar.customers.getStateExternal({
902
- externalId: "<id>",
903
- });
904
-
905
- console.log(result);
906
- }
907
-
908
- run();
909
- ```
910
-
911
- ### Standalone function
912
-
913
- The standalone function version of this method:
914
-
915
- ```typescript
916
- import { PolarCore } from "@polar-sh/sdk/core.js";
917
- import { customersGetStateExternal } from "@polar-sh/sdk/funcs/customersGetStateExternal.js";
918
-
919
- // Use `PolarCore` for best tree-shaking performance.
920
- // You can create one instance of it to use across an application.
921
- const polar = new PolarCore({
922
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
923
- });
924
-
925
- async function run() {
926
- const res = await customersGetStateExternal(polar, {
927
- externalId: "<id>",
928
- });
929
- if (res.ok) {
930
- const { value: result } = res;
931
- console.log(result);
932
- } else {
933
- console.log("customersGetStateExternal failed:", res.error);
934
- }
935
- }
936
-
937
- run();
938
- ```
939
-
940
- ### Parameters
941
-
942
- | Parameter | Type | Required | Description |
943
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
944
- | `request` | [operations.CustomersGetStateExternalRequest](../../models/operations/customersgetstateexternalrequest.md) | :heavy_check_mark: | The request object to use for the request. |
945
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
946
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
947
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
948
-
949
- ### Response
950
-
951
- **Promise\<[components.CustomerState](../../models/components/customerstate.md)\>**
952
-
953
- ### Errors
954
-
955
- | Error Type | Status Code | Content Type |
956
- | -------------------------- | -------------------------- | -------------------------- |
957
- | errors.ResourceNotFound | 404 | application/json |
958
- | errors.HTTPValidationError | 422 | application/json |
959
- | errors.SDKError | 4XX, 5XX | \*/\* |
960
-
961
- ## getBalance
962
-
963
- Get customer balance information.
964
-
965
- **Scopes**: `customers:read` `customers:write`
966
-
967
- ### Example Usage
968
-
969
- <!-- UsageSnippet language="typescript" operationID="customers:get_balance" method="get" path="/v1/customers/{id}/balance" -->
970
- ```typescript
971
- import { Polar } from "@polar-sh/sdk";
972
-
973
- const polar = new Polar({
974
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
975
- });
976
-
977
- async function run() {
978
- const result = await polar.customers.getBalance({
979
- id: "<value>",
980
- });
981
-
982
- console.log(result);
983
- }
984
-
985
- run();
986
- ```
987
-
988
- ### Standalone function
989
-
990
- The standalone function version of this method:
991
-
992
- ```typescript
993
- import { PolarCore } from "@polar-sh/sdk/core.js";
994
- import { customersGetBalance } from "@polar-sh/sdk/funcs/customersGetBalance.js";
995
-
996
- // Use `PolarCore` for best tree-shaking performance.
997
- // You can create one instance of it to use across an application.
998
- const polar = new PolarCore({
999
- accessToken: process.env["POLAR_ACCESS_TOKEN"] ?? "",
1000
- });
1001
-
1002
- async function run() {
1003
- const res = await customersGetBalance(polar, {
1004
- id: "<value>",
1005
- });
1006
- if (res.ok) {
1007
- const { value: result } = res;
1008
- console.log(result);
1009
- } else {
1010
- console.log("customersGetBalance failed:", res.error);
1011
- }
1012
- }
1013
-
1014
- run();
1015
- ```
1016
-
1017
- ### Parameters
1018
-
1019
- | Parameter | Type | Required | Description |
1020
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1021
- | `request` | [operations.CustomersGetBalanceRequest](../../models/operations/customersgetbalancerequest.md) | :heavy_check_mark: | The request object to use for the request. |
1022
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
1023
- | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
1024
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
1025
-
1026
- ### Response
1027
-
1028
- **Promise\<[components.CustomerBalance](../../models/components/customerbalance.md)\>**
1029
-
1030
- ### Errors
1031
-
1032
- | Error Type | Status Code | Content Type |
1033
- | -------------------------- | -------------------------- | -------------------------- |
1034
- | errors.ResourceNotFound | 404 | application/json |
1035
- | errors.HTTPValidationError | 422 | application/json |
1036
- | errors.SDKError | 4XX, 5XX | \*/\* |