// Metro module 6219 (f6220). import Record from "../../../lib/Record"; import { BaseInvoiceRecord } from "../../../records/InvoiceRecord"; import CheckoutContextRecord from "./CheckoutContextRecord"; import SubscriptionFacetRecord from "./SubscriptionFacetRecord"; import { $callWithNewTarget } from "../../../_hermes/prelude"; class BillingFacetRecord extends Record { constructor(a0) { super(); this.paymentGateway = a0.paymentGateway; let paymentSourceId = a0.paymentSourceId; if (paymentSourceId == null) { paymentSourceId = null; } this.paymentSourceId = paymentSourceId; let invoicePreview = a0.invoicePreview; if (invoicePreview == null) { invoicePreview = null; } this.invoicePreview = invoicePreview; } static createFromOrder(a0) { const billing_facet = a0.billing_facet; const r1 = billing_facet == null; let r2 = null; if (!r1) { const payment_gateway = billing_facet.payment_gateway; let payment_source_id = billing_facet.payment_source_id; if (payment_source_id == null) { payment_source_id = null; } let invoicePreview = BaseInvoiceRecord.createInvoiceFromOrder(a0); const prototypeOf = Object.getPrototypeOf(BillingFacetRecord); const r18 = Object.create(BillingFacetRecord.prototype); const r19 = $callWithNewTarget(prototypeOf, r18, BillingFacetRecord); const r20 = r19 instanceof Object ? r19 : r18; r20.paymentGateway = payment_gateway; if (payment_source_id == null) { payment_source_id = null; } r20.paymentSourceId = payment_source_id; if (invoicePreview == null) { invoicePreview = null; } r20.invoicePreview = invoicePreview; r2 = r20; } return r2; } } class OrderRecord extends Record { constructor(a0) { super(); this.id = a0.id; this.status = a0.status; this.revision = a0.revision; let orderLineItems = a0.orderLineItems; if (orderLineItems == null) { orderLineItems = []; } this.orderLineItems = orderLineItems; let billingFacetRecord = a0.billingFacetRecord; if (billingFacetRecord == null) { billingFacetRecord = null; } this.billingFacetRecord = billingFacetRecord; let externalGatewayFacet = a0.externalGatewayFacet; if (externalGatewayFacet == null) { externalGatewayFacet = null; } this.externalGatewayFacet = externalGatewayFacet; let giftingFacet = a0.giftingFacet; if (giftingFacet == null) { giftingFacet = null; } this.giftingFacet = giftingFacet; let subscriptionFacet = a0.subscriptionFacet; if (subscriptionFacet == null) { subscriptionFacet = null; } this.subscriptionFacet = subscriptionFacet; let checkoutContextRecord = a0.checkoutContextRecord; if (checkoutContextRecord == null) { checkoutContextRecord = null; } this.checkoutContextRecord = checkoutContextRecord; this.createdAt = a0.createdAt; let unsatisfiedConstraints = a0.unsatisfiedConstraints; if (unsatisfiedConstraints == null) { unsatisfiedConstraints = []; } this.unsatisfiedConstraints = unsatisfiedConstraints; } static createFromServer(a0) { const r1 = { id: a0.id, status: a0.status, revision: a0.revision, orderLineItems: a0.order_line_items, billingFacetRecord: BillingFacetRecord.createFromOrder(a0), externalGatewayFacet: null, giftingFacet: null, checkoutContextRecord: null, createdAt: null, unsatisfiedConstraints: null, subscriptionFacet: null }; let external_gateway_facet = a0.external_gateway_facet; if (external_gateway_facet == null) { external_gateway_facet = null; } r1.externalGatewayFacet = external_gateway_facet; let gifting_facet = a0.gifting_facet; if (gifting_facet == null) { gifting_facet = null; } r1.giftingFacet = gifting_facet; r1.checkoutContextRecord = CheckoutContextRecord.createFromOrder(a0); r1.createdAt = a0.created_at; let unsatisfied_constraints = a0.unsatisfied_constraints; if (unsatisfied_constraints == null) { unsatisfied_constraints = []; } r1.unsatisfiedConstraints = unsatisfied_constraints; r1.subscriptionFacet = SubscriptionFacetRecord.createFromServer(a0.subscription_facet); return new OrderRecord(r1); } getInvoicePreview() { return this.billingFacetRecord != null ? this.billingFacetRecord.invoicePreview : null; } firstUnsatisfiedConstraintReasonCode() { return this.unsatisfiedConstraints.length > 0 ? this.unsatisfiedConstraints[0].reason_code : null; } } export default OrderRecord; export { BillingFacetRecord };