import * as Utils from '@datocms/rest-client-utils'; import BaseResource from '../../BaseResource.js'; import type * as ApiTypes from '../ApiTypes.js'; import type * as RawApiTypes from '../RawApiTypes.js'; export default class PerOwnerPricingSubscription extends BaseResource { static readonly TYPE = 'per_owner_pricing_subscription' as const; /** * Create a new subscription * * @throws {ApiError} * @throws {TimeoutError} */ create(body: ApiTypes.PerOwnerPricingSubscriptionCreateSchema) { return this.rawCreate( Utils.serializeRequestBody( body, { type: 'per_owner_pricing_subscription', attributes: [ 'payment_intent_id', 'recurrence', 'billing_profile', 'downgrade_reason', ], relationships: ['plan'], }, ), ).then((body) => Utils.deserializeResponseBody( body, ), ); } /** * Create a new subscription * * @throws {ApiError} * @throws {TimeoutError} */ rawCreate( body: RawApiTypes.PerOwnerPricingSubscriptionCreateSchema, ): Promise { return this.client.request( { method: 'POST', url: '/per-owner-pricing-subscriptions', body, }, ); } /** * Simulate * * @throws {ApiError} * @throws {TimeoutError} */ simulate(body: ApiTypes.PerOwnerPricingSubscriptionSimulateSchema) { return this.rawSimulate( Utils.serializeRequestBody( body, { type: 'per_owner_pricing_subscription_simulation', attributes: ['recurrence', 'billing_profile'], relationships: ['plan'], }, ), ).then((body) => Utils.deserializeResponseBody( body, ), ); } /** * Simulate * * @throws {ApiError} * @throws {TimeoutError} */ rawSimulate( body: RawApiTypes.PerOwnerPricingSubscriptionSimulateSchema, ): Promise { return this.client.request( { method: 'POST', url: '/per-owner-pricing-subscriptions/simulate', body, }, ); } /** * Validate a new subscription * * @throws {ApiError} * @throws {TimeoutError} */ validate(body: ApiTypes.PerOwnerPricingSubscriptionValidateSchema) { return this.rawValidate( Utils.serializeRequestBody( body, { type: 'per_owner_pricing_subscription_validation', attributes: [], relationships: ['plan'], }, ), ); } /** * Validate a new subscription * * @throws {ApiError} * @throws {TimeoutError} */ rawValidate( body: RawApiTypes.PerOwnerPricingSubscriptionValidateSchema, ): Promise { return this.client.request({ method: 'POST', url: '/per-owner-pricing-subscriptions/validate', body, }); } }