@getopenpay/client
Version:
OpenPay API TypeScript SDK
175 lines (174 loc) • 10.3 kB
JavaScript
;
/* tslint:disable */
/* eslint-disable */
/**
* OpenPay API
* super charge your subscription management.
*
* The version of the OpenAPI document: 1.2.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.instanceOfSubscriptionExternal = instanceOfSubscriptionExternal;
exports.SubscriptionExternalFromJSON = SubscriptionExternalFromJSON;
exports.SubscriptionExternalFromJSONTyped = SubscriptionExternalFromJSONTyped;
exports.SubscriptionExternalToJSON = SubscriptionExternalToJSON;
exports.SubscriptionExternalToJSONTyped = SubscriptionExternalToJSONTyped;
const CollectionMethodEnum_1 = require("./CollectionMethodEnum");
const SubscriptionItemExternal_1 = require("./SubscriptionItemExternal");
const CalendarIntervalEnum_1 = require("./CalendarIntervalEnum");
const DiscountExternal_1 = require("./DiscountExternal");
const SubscriptionCancellationDetails_1 = require("./SubscriptionCancellationDetails");
const CurrencyEnum_1 = require("./CurrencyEnum");
const ObjectName_1 = require("./ObjectName");
const SubscriptionStatusEnum_1 = require("./SubscriptionStatusEnum");
/**
* Check if a given object implements the SubscriptionExternal interface.
*/
function instanceOfSubscriptionExternal(value) {
if (!('accountId' in value) || value['accountId'] === undefined)
return false;
if (!('cancelAt' in value) || value['cancelAt'] === undefined)
return false;
if (!('cancelAtEnd' in value) || value['cancelAtEnd'] === undefined)
return false;
if (!('cancelledAt' in value) || value['cancelledAt'] === undefined)
return false;
if (!('collectionMethod' in value) || value['collectionMethod'] === undefined)
return false;
if (!('createdAt' in value) || value['createdAt'] === undefined)
return false;
if (!('currency' in value) || value['currency'] === undefined)
return false;
if (!('currentPeriodEnd' in value) || value['currentPeriodEnd'] === undefined)
return false;
if (!('currentPeriodStart' in value) || value['currentPeriodStart'] === undefined)
return false;
if (!('customerId' in value) || value['customerId'] === undefined)
return false;
if (!('defaultPaymentMethodId' in value) || value['defaultPaymentMethodId'] === undefined)
return false;
if (!('description' in value) || value['description'] === undefined)
return false;
if (!('id' in value) || value['id'] === undefined)
return false;
if (!('initialStart' in value) || value['initialStart'] === undefined)
return false;
if (!('name' in value) || value['name'] === undefined)
return false;
if (!('netD' in value) || value['netD'] === undefined)
return false;
if (!('status' in value) || value['status'] === undefined)
return false;
if (!('subscriptionItems' in value) || value['subscriptionItems'] === undefined)
return false;
if (!('updatedAt' in value) || value['updatedAt'] === undefined)
return false;
return true;
}
function SubscriptionExternalFromJSON(json) {
return SubscriptionExternalFromJSONTyped(json, false);
}
function SubscriptionExternalFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
'accountId': json['account_id'],
'billingInterval': json['billing_interval'] == null ? undefined : (0, CalendarIntervalEnum_1.CalendarIntervalEnumFromJSON)(json['billing_interval']),
'billingIntervalCount': json['billing_interval_count'] == null ? undefined : json['billing_interval_count'],
'cancelAt': (json['cancel_at'] == null ? null : new Date(json['cancel_at'])),
'cancelAtEnd': json['cancel_at_end'],
'cancellationDetails': json['cancellation_details'] == null ? undefined : (0, SubscriptionCancellationDetails_1.SubscriptionCancellationDetailsFromJSON)(json['cancellation_details']),
'cancelledAt': (json['cancelled_at'] == null ? null : new Date(json['cancelled_at'])),
'checkoutSessionId': json['checkout_session_id'] == null ? undefined : json['checkout_session_id'],
'collectionMethod': (0, CollectionMethodEnum_1.CollectionMethodEnumFromJSON)(json['collection_method']),
'contractAutoRenew': json['contract_auto_renew'] == null ? undefined : json['contract_auto_renew'],
'contractStart': json['contract_start'] == null ? undefined : (new Date(json['contract_start'])),
'createdAt': (new Date(json['created_at'])),
'currency': (0, CurrencyEnum_1.CurrencyEnumFromJSON)(json['currency']),
'currentPeriodEnd': (new Date(json['current_period_end'])),
'currentPeriodStart': (new Date(json['current_period_start'])),
'customFields': json['custom_fields'] == null ? undefined : json['custom_fields'],
'customerId': json['customer_id'],
'defaultPaymentMethodId': json['default_payment_method_id'],
'description': json['description'],
'discount': json['discount'] == null ? undefined : (0, DiscountExternal_1.DiscountExternalFromJSON)(json['discount']),
'id': json['id'],
'initialStart': (new Date(json['initial_start'])),
'isDeleted': json['is_deleted'] == null ? undefined : json['is_deleted'],
'merchantAccountId': json['merchant_account_id'] == null ? undefined : json['merchant_account_id'],
'metadata': json['metadata'] == null ? undefined : json['metadata'],
'name': json['name'],
'netD': json['net_d'],
'object': json['object'] == null ? undefined : (0, ObjectName_1.ObjectNameFromJSON)(json['object']),
'pauseAtEnd': json['pause_at_end'] == null ? undefined : json['pause_at_end'],
'pauseForCycles': json['pause_for_cycles'] == null ? undefined : json['pause_for_cycles'],
'pausedAt': json['paused_at'] == null ? undefined : (new Date(json['paused_at'])),
'paymentRouteId': json['payment_route_id'] == null ? undefined : json['payment_route_id'],
'remainingBillingCycles': json['remaining_billing_cycles'] == null ? undefined : json['remaining_billing_cycles'],
'renewsAt': json['renews_at'] == null ? undefined : (new Date(json['renews_at'])),
'resumesAt': json['resumes_at'] == null ? undefined : (new Date(json['resumes_at'])),
'status': (0, SubscriptionStatusEnum_1.SubscriptionStatusEnumFromJSON)(json['status']),
'subscriptionItems': (json['subscription_items'].map(SubscriptionItemExternal_1.SubscriptionItemExternalFromJSON)),
'totalBillingCycles': json['total_billing_cycles'] == null ? undefined : json['total_billing_cycles'],
'trialEnd': json['trial_end'] == null ? undefined : (new Date(json['trial_end'])),
'trialStart': json['trial_start'] == null ? undefined : (new Date(json['trial_start'])),
'updatedAt': (new Date(json['updated_at'])),
};
}
function SubscriptionExternalToJSON(json) {
return SubscriptionExternalToJSONTyped(json, false);
}
function SubscriptionExternalToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
'account_id': value['accountId'],
'billing_interval': (0, CalendarIntervalEnum_1.CalendarIntervalEnumToJSON)(value['billingInterval']),
'billing_interval_count': value['billingIntervalCount'],
'cancel_at': (value['cancelAt'] == null ? null : value['cancelAt'].toISOString()),
'cancel_at_end': value['cancelAtEnd'],
'cancellation_details': (0, SubscriptionCancellationDetails_1.SubscriptionCancellationDetailsToJSON)(value['cancellationDetails']),
'cancelled_at': (value['cancelledAt'] == null ? null : value['cancelledAt'].toISOString()),
'checkout_session_id': value['checkoutSessionId'],
'collection_method': (0, CollectionMethodEnum_1.CollectionMethodEnumToJSON)(value['collectionMethod']),
'contract_auto_renew': value['contractAutoRenew'],
'contract_start': value['contractStart'] == null ? undefined : (value['contractStart'].toISOString()),
'created_at': ((value['createdAt']).toISOString()),
'currency': (0, CurrencyEnum_1.CurrencyEnumToJSON)(value['currency']),
'current_period_end': ((value['currentPeriodEnd']).toISOString()),
'current_period_start': ((value['currentPeriodStart']).toISOString()),
'custom_fields': value['customFields'],
'customer_id': value['customerId'],
'default_payment_method_id': value['defaultPaymentMethodId'],
'description': value['description'],
'discount': (0, DiscountExternal_1.DiscountExternalToJSON)(value['discount']),
'id': value['id'],
'initial_start': ((value['initialStart']).toISOString()),
'is_deleted': value['isDeleted'],
'merchant_account_id': value['merchantAccountId'],
'metadata': value['metadata'],
'name': value['name'],
'net_d': value['netD'],
'object': (0, ObjectName_1.ObjectNameToJSON)(value['object']),
'pause_at_end': value['pauseAtEnd'],
'pause_for_cycles': value['pauseForCycles'],
'paused_at': value['pausedAt'] == null ? undefined : (value['pausedAt'].toISOString()),
'payment_route_id': value['paymentRouteId'],
'remaining_billing_cycles': value['remainingBillingCycles'],
'renews_at': value['renewsAt'] == null ? undefined : (value['renewsAt'].toISOString()),
'resumes_at': value['resumesAt'] == null ? undefined : (value['resumesAt'].toISOString()),
'status': (0, SubscriptionStatusEnum_1.SubscriptionStatusEnumToJSON)(value['status']),
'subscription_items': (value['subscriptionItems'].map(SubscriptionItemExternal_1.SubscriptionItemExternalToJSON)),
'total_billing_cycles': value['totalBillingCycles'],
'trial_end': value['trialEnd'] == null ? undefined : (value['trialEnd'].toISOString()),
'trial_start': value['trialStart'] == null ? undefined : (value['trialStart'].toISOString()),
'updated_at': ((value['updatedAt']).toISOString()),
};
}