public static DomesticPaymentConsentContext ApiProfileId(
            this DomesticPaymentConsentContext context,
            string value)
        {
            context.ArgNotNull(nameof(context));
            value.ArgNotNull(nameof(value));

            context.GetOrCreateDefault(BaseLens)
            .ApiProfileId = value;

            return(context);
        }
        // HACK: need better abstractions
        public static DomesticPaymentConsentContext DeliveryAddress(
            this DomesticPaymentConsentContext context,
            OBRisk1DeliveryAddress value)
        {
            context.ArgNotNull(nameof(context));

            if (value != null)
            {
                context.GetOrCreateDefault(BaseLens)
                .GetOrCreateDefault(DomesticConsentLens)
                .GetOrCreateDefault(RiskLens).DeliveryAddress = value;
            }

            return(context);
        }
        public static DomesticPaymentConsentContext Amount(
            this DomesticPaymentConsentContext context,
            OBWriteDomestic2DataInitiationInstructedAmount value)
        {
            context.ArgNotNull(nameof(context));
            if (value != null)
            {
                context.GetOrCreateDefault(BaseLens)
                .GetOrCreateDefault(DomesticConsentLens)
                .GetOrCreateDefault(DataLens)
                .GetOrCreateDefault(InitiationLens).InstructedAmount = value;
            }

            return(context);
        }
        public static DomesticPaymentConsentContext Remittance(
            this DomesticPaymentConsentContext context,
            OBWriteDomestic2DataInitiationRemittanceInformation value)
        {
            context.ArgNotNull(nameof(context));

            if (value != null)
            {
                context.GetOrCreateDefault(BaseLens)
                .GetOrCreateDefault(DomesticConsentLens)
                .GetOrCreateDefault(DataLens)
                .GetOrCreateDefault(InitiationLens).RemittanceInformation = value;
            }

            return(context);
        }
        public static DomesticPaymentConsentContext EndToEndIdentification(
            this DomesticPaymentConsentContext context,
            string value)
        {
            context.ArgNotNull(nameof(context));

            if (value != null)
            {
                context.GetOrCreateDefault(BaseLens)
                .GetOrCreateDefault(DomesticConsentLens)
                .GetOrCreateDefault(DataLens)
                .GetOrCreateDefault(InitiationLens).EndToEndIdentification = value;
            }

            return(context);
        }
        public static DomesticPaymentConsentContext Amount(
            this DomesticPaymentConsentContext context,
            string currency,
            double value)
        {
            context.ArgNotNull(nameof(context));

            OBWriteDomestic2DataInitiationInstructedAmount amt = context.GetOrCreateDefault(BaseLens)
                                                                 .GetOrCreateDefault(DomesticConsentLens)
                                                                 .GetOrCreateDefault(DataLens)
                                                                 .GetOrCreateDefault(InitiationLens)
                                                                 .GetOrCreateDefault(InstructedAmountLens);

            amt.Currency = currency;
            amt.Amount   = value.ToString(CultureInfo.InvariantCulture);

            return(context);
        }
        public static DomesticPaymentConsentContext Merchant(
            this DomesticPaymentConsentContext context,
            string merchantCategory,
            string merchantCustomerId,
            OBRisk1.PaymentContextCodeEnum?paymentContextCode)
        {
            context.ArgNotNull(nameof(context));

            if (merchantCategory != null || merchantCustomerId != null || paymentContextCode != null)
            {
                OBRisk1 risk = context.GetOrCreateDefault(BaseLens)
                               .GetOrCreateDefault(DomesticConsentLens)
                               .GetOrCreateDefault(RiskLens);

                risk.MerchantCategoryCode           = merchantCategory;
                risk.MerchantCustomerIdentification = merchantCustomerId;
                risk.PaymentContextCode             = paymentContextCode;
            }

            return(context);
        }
        public static DomesticPaymentConsentContext DebtorAccount(
            this DomesticPaymentConsentContext context,
            string identification,
            string schema,
            string name,
            string secondaryId)
        {
            context.ArgNotNull(nameof(context));

            OBWriteDomestic2DataInitiationDebtorAccount acct = context.GetOrCreateDefault(BaseLens)
                                                               .GetOrCreateDefault(DomesticConsentLens)
                                                               .GetOrCreateDefault(DataLens)
                                                               .GetOrCreateDefault(InitiationLens)
                                                               .GetOrCreateDefault(DebtorAccountLens);

            acct.Identification          = identification;
            acct.Name                    = name;
            acct.SchemeName              = schema;
            acct.SecondaryIdentification = secondaryId;

            return(context);
        }