@@ -206,6 +206,153 @@ export class Domains {
206206 ) ;
207207 }
208208
209+ /**
210+ * Create a domain purchase with registrant information.
211+ *
212+ * @param {string } params.domain - Fully qualified domain name to purchase (for example, example.com).
213+ * @param {string } params.teamId - Team ID that will own the domain.
214+ * @param {string } params.firstName - Registrant first name used for domain registration.
215+ * @param {string } params.lastName - Registrant last name used for domain registration.
216+ * @param {string } params.email - Registrant email address for registration and notices.
217+ * @param {string } params.phone - Registrant phone number in E.164 format (for example, +15555551234).
218+ * @param {string } params.billingAddressId - Billing address ID used for registration contact details.
219+ * @param {string } params.paymentMethodId - Payment method ID to authorize and capture the purchase.
220+ * @param {string } params.addressLine3 - Additional address line for the registrant (line 3).
221+ * @param {string } params.companyName - Company or organization name for the registrant.
222+ * @param {number } params.periodYears - Registration term in years (1-10).
223+ * @throws {AppwriteException }
224+ * @returns {Promise<Models.Domain> }
225+ */
226+ createPurchase ( params : { domain : string , teamId : string , firstName : string , lastName : string , email : string , phone : string , billingAddressId : string , paymentMethodId : string , addressLine3 ?: string , companyName ?: string , periodYears ?: number } ) : Promise < Models . Domain > ;
227+ /**
228+ * Create a domain purchase with registrant information.
229+ *
230+ * @param {string } domain - Fully qualified domain name to purchase (for example, example.com).
231+ * @param {string } teamId - Team ID that will own the domain.
232+ * @param {string } firstName - Registrant first name used for domain registration.
233+ * @param {string } lastName - Registrant last name used for domain registration.
234+ * @param {string } email - Registrant email address for registration and notices.
235+ * @param {string } phone - Registrant phone number in E.164 format (for example, +15555551234).
236+ * @param {string } billingAddressId - Billing address ID used for registration contact details.
237+ * @param {string } paymentMethodId - Payment method ID to authorize and capture the purchase.
238+ * @param {string } addressLine3 - Additional address line for the registrant (line 3).
239+ * @param {string } companyName - Company or organization name for the registrant.
240+ * @param {number } periodYears - Registration term in years (1-10).
241+ * @throws {AppwriteException }
242+ * @returns {Promise<Models.Domain> }
243+ * @deprecated Use the object parameter style method for a better developer experience.
244+ */
245+ createPurchase ( domain : string , teamId : string , firstName : string , lastName : string , email : string , phone : string , billingAddressId : string , paymentMethodId : string , addressLine3 ?: string , companyName ?: string , periodYears ?: number ) : Promise < Models . Domain > ;
246+ createPurchase (
247+ paramsOrFirst : { domain : string , teamId : string , firstName : string , lastName : string , email : string , phone : string , billingAddressId : string , paymentMethodId : string , addressLine3 ?: string , companyName ?: string , periodYears ?: number } | string ,
248+ ...rest : [ ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( string ) ?, ( number ) ?]
249+ ) : Promise < Models . Domain > {
250+ let params : { domain : string , teamId : string , firstName : string , lastName : string , email : string , phone : string , billingAddressId : string , paymentMethodId : string , addressLine3 ?: string , companyName ?: string , periodYears ?: number } ;
251+
252+ if ( ( paramsOrFirst && typeof paramsOrFirst === 'object' && ! Array . isArray ( paramsOrFirst ) ) ) {
253+ params = ( paramsOrFirst || { } ) as { domain : string , teamId : string , firstName : string , lastName : string , email : string , phone : string , billingAddressId : string , paymentMethodId : string , addressLine3 ?: string , companyName ?: string , periodYears ?: number } ;
254+ } else {
255+ params = {
256+ domain : paramsOrFirst as string ,
257+ teamId : rest [ 0 ] as string ,
258+ firstName : rest [ 1 ] as string ,
259+ lastName : rest [ 2 ] as string ,
260+ email : rest [ 3 ] as string ,
261+ phone : rest [ 4 ] as string ,
262+ billingAddressId : rest [ 5 ] as string ,
263+ paymentMethodId : rest [ 6 ] as string ,
264+ addressLine3 : rest [ 7 ] as string ,
265+ companyName : rest [ 8 ] as string ,
266+ periodYears : rest [ 9 ] as number
267+ } ;
268+ }
269+
270+ const domain = params . domain ;
271+ const teamId = params . teamId ;
272+ const firstName = params . firstName ;
273+ const lastName = params . lastName ;
274+ const email = params . email ;
275+ const phone = params . phone ;
276+ const billingAddressId = params . billingAddressId ;
277+ const paymentMethodId = params . paymentMethodId ;
278+ const addressLine3 = params . addressLine3 ;
279+ const companyName = params . companyName ;
280+ const periodYears = params . periodYears ;
281+
282+ if ( typeof domain === 'undefined' ) {
283+ throw new AppwriteException ( 'Missing required parameter: "domain"' ) ;
284+ }
285+ if ( typeof teamId === 'undefined' ) {
286+ throw new AppwriteException ( 'Missing required parameter: "teamId"' ) ;
287+ }
288+ if ( typeof firstName === 'undefined' ) {
289+ throw new AppwriteException ( 'Missing required parameter: "firstName"' ) ;
290+ }
291+ if ( typeof lastName === 'undefined' ) {
292+ throw new AppwriteException ( 'Missing required parameter: "lastName"' ) ;
293+ }
294+ if ( typeof email === 'undefined' ) {
295+ throw new AppwriteException ( 'Missing required parameter: "email"' ) ;
296+ }
297+ if ( typeof phone === 'undefined' ) {
298+ throw new AppwriteException ( 'Missing required parameter: "phone"' ) ;
299+ }
300+ if ( typeof billingAddressId === 'undefined' ) {
301+ throw new AppwriteException ( 'Missing required parameter: "billingAddressId"' ) ;
302+ }
303+ if ( typeof paymentMethodId === 'undefined' ) {
304+ throw new AppwriteException ( 'Missing required parameter: "paymentMethodId"' ) ;
305+ }
306+
307+ const apiPath = '/domains/purchases' ;
308+ const payload : Payload = { } ;
309+ if ( typeof domain !== 'undefined' ) {
310+ payload [ 'domain' ] = domain ;
311+ }
312+ if ( typeof teamId !== 'undefined' ) {
313+ payload [ 'teamId' ] = teamId ;
314+ }
315+ if ( typeof firstName !== 'undefined' ) {
316+ payload [ 'firstName' ] = firstName ;
317+ }
318+ if ( typeof lastName !== 'undefined' ) {
319+ payload [ 'lastName' ] = lastName ;
320+ }
321+ if ( typeof email !== 'undefined' ) {
322+ payload [ 'email' ] = email ;
323+ }
324+ if ( typeof phone !== 'undefined' ) {
325+ payload [ 'phone' ] = phone ;
326+ }
327+ if ( typeof billingAddressId !== 'undefined' ) {
328+ payload [ 'billingAddressId' ] = billingAddressId ;
329+ }
330+ if ( typeof addressLine3 !== 'undefined' ) {
331+ payload [ 'addressLine3' ] = addressLine3 ;
332+ }
333+ if ( typeof companyName !== 'undefined' ) {
334+ payload [ 'companyName' ] = companyName ;
335+ }
336+ if ( typeof periodYears !== 'undefined' ) {
337+ payload [ 'periodYears' ] = periodYears ;
338+ }
339+ if ( typeof paymentMethodId !== 'undefined' ) {
340+ payload [ 'paymentMethodId' ] = paymentMethodId ;
341+ }
342+ const uri = new URL ( this . client . config . endpoint + apiPath ) ;
343+
344+ const apiHeaders : { [ header : string ] : string } = {
345+ 'content-type' : 'application/json' ,
346+ }
347+
348+ return this . client . call (
349+ 'post' ,
350+ uri ,
351+ apiHeaders ,
352+ payload
353+ ) ;
354+ }
355+
209356 /**
210357 * List domain suggestions.
211358 *
0 commit comments