@getopenpay/client
Version:
OpenPay API TypeScript SDK
96 lines (95 loc) • 5.67 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.instanceOfCreateSubscriptionRequest = instanceOfCreateSubscriptionRequest;
exports.CreateSubscriptionRequestFromJSON = CreateSubscriptionRequestFromJSON;
exports.CreateSubscriptionRequestFromJSONTyped = CreateSubscriptionRequestFromJSONTyped;
exports.CreateSubscriptionRequestToJSON = CreateSubscriptionRequestToJSON;
exports.CreateSubscriptionRequestToJSONTyped = CreateSubscriptionRequestToJSONTyped;
const runtime_1 = require("../runtime");
const CollectionMethodEnum_1 = require("./CollectionMethodEnum");
const SubscriptionItemDetails_1 = require("./SubscriptionItemDetails");
const SelectedPriceQuantity_1 = require("./SelectedPriceQuantity");
const CheckoutPreferences_1 = require("./CheckoutPreferences");
/**
* Check if a given object implements the CreateSubscriptionRequest interface.
*/
function instanceOfCreateSubscriptionRequest(value) {
if (!('customerId' in value) || value['customerId'] === undefined)
return false;
if (!('selectedProductPriceQuantity' in value) || value['selectedProductPriceQuantity'] === undefined)
return false;
return true;
}
function CreateSubscriptionRequestFromJSON(json) {
return CreateSubscriptionRequestFromJSONTyped(json, false);
}
function CreateSubscriptionRequestFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
'attachToCheckoutAttemptId': json['attach_to_checkout_attempt_id'] == null ? undefined : json['attach_to_checkout_attempt_id'],
'cancelAtEnd': json['cancel_at_end'] == null ? undefined : json['cancel_at_end'],
'checkoutPreferences': json['checkout_preferences'] == null ? undefined : (0, CheckoutPreferences_1.CheckoutPreferencesFromJSON)(json['checkout_preferences']),
'collectionMethod': json['collection_method'] == null ? undefined : (0, CollectionMethodEnum_1.CollectionMethodEnumFromJSON)(json['collection_method']),
'couponId': json['coupon_id'] == null ? undefined : json['coupon_id'],
'customFields': json['custom_fields'] == null ? undefined : json['custom_fields'],
'customerId': json['customer_id'],
'description': json['description'] == null ? undefined : json['description'],
'isPreview': json['is_preview'] == null ? undefined : json['is_preview'],
'netD': json['net_d'] == null ? undefined : json['net_d'],
'paymentMethodId': json['payment_method_id'] == null ? undefined : json['payment_method_id'],
'promotionCode': json['promotion_code'] == null ? undefined : json['promotion_code'],
'selectedProductPriceQuantity': (json['selected_product_price_quantity'].map(SelectedPriceQuantity_1.SelectedPriceQuantityFromJSON)),
'skipInvoicePayment': json['skip_invoice_payment'] == null ? undefined : json['skip_invoice_payment'],
'startsAt': json['starts_at'] == null ? undefined : (new Date(json['starts_at'])),
'subscriptionItemDetails': json['subscription_item_details'] == null ? undefined : ((0, runtime_1.mapValues)(json['subscription_item_details'], SubscriptionItemDetails_1.SubscriptionItemDetailsFromJSON)),
'totalAmountAtom': json['total_amount_atom'] == null ? undefined : json['total_amount_atom'],
'trialEnd': json['trial_end'] == null ? undefined : (new Date(json['trial_end'])),
'trialFromPrice': json['trial_from_price'] == null ? undefined : json['trial_from_price'],
'trialPeriodDays': json['trial_period_days'] == null ? undefined : json['trial_period_days'],
};
}
function CreateSubscriptionRequestToJSON(json) {
return CreateSubscriptionRequestToJSONTyped(json, false);
}
function CreateSubscriptionRequestToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
'attach_to_checkout_attempt_id': value['attachToCheckoutAttemptId'],
'cancel_at_end': value['cancelAtEnd'],
'checkout_preferences': (0, CheckoutPreferences_1.CheckoutPreferencesToJSON)(value['checkoutPreferences']),
'collection_method': (0, CollectionMethodEnum_1.CollectionMethodEnumToJSON)(value['collectionMethod']),
'coupon_id': value['couponId'],
'custom_fields': value['customFields'],
'customer_id': value['customerId'],
'description': value['description'],
'is_preview': value['isPreview'],
'net_d': value['netD'],
'payment_method_id': value['paymentMethodId'],
'promotion_code': value['promotionCode'],
'selected_product_price_quantity': (value['selectedProductPriceQuantity'].map(SelectedPriceQuantity_1.SelectedPriceQuantityToJSON)),
'skip_invoice_payment': value['skipInvoicePayment'],
'starts_at': value['startsAt'] == null ? undefined : (value['startsAt'].toISOString()),
'subscription_item_details': value['subscriptionItemDetails'] == null ? undefined : ((0, runtime_1.mapValues)(value['subscriptionItemDetails'], SubscriptionItemDetails_1.SubscriptionItemDetailsToJSON)),
'total_amount_atom': value['totalAmountAtom'],
'trial_end': value['trialEnd'] == null ? undefined : (value['trialEnd'].toISOString()),
'trial_from_price': value['trialFromPrice'],
'trial_period_days': value['trialPeriodDays'],
};
}