private WriteXml ( |
||
xmlWriter | ||
Результат | void |
protected void WriteSubscriptionXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("subscription"); // Start: subscription xmlWriter.WriteElementString("plan_code", _planCode); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteIfCollectionHasAny("subscription_add_ons", AddOns); xmlWriter.WriteStringIfValid("coupon_code", _couponCode); if (UnitAmountInCents.HasValue) { xmlWriter.WriteElementString("unit_amount_in_cents", UnitAmountInCents.Value.AsString()); } xmlWriter.WriteElementString("quantity", Quantity.AsString()); if (TrialPeriodEndsAt.HasValue) { xmlWriter.WriteElementString("trial_ends_at", TrialPeriodEndsAt.Value.ToString("s")); } if (StartsAt.HasValue) { xmlWriter.WriteElementString("starts_at", StartsAt.Value.ToString("s")); } if (TotalBillingCycles.HasValue) { xmlWriter.WriteElementString("total_billing_cycles", TotalBillingCycles.Value.AsString()); } if (FirstRenewalDate.HasValue) { xmlWriter.WriteElementString("first_renewal_date", FirstRenewalDate.Value.ToString("s")); } if (CollectionMethod.Like("manual")) { xmlWriter.WriteElementString("collection_method", "manual"); xmlWriter.WriteElementString("net_terms", NetTerms.Value.AsString()); xmlWriter.WriteElementString("po_number", PoNumber); } else if (CollectionMethod.Like("automatic")) { xmlWriter.WriteElementString("collection_method", "automatic"); } // <account> and billing info Account.WriteXml(xmlWriter); xmlWriter.WriteEndElement(); // End: subscription }
internal override void WriteXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("transaction"); xmlWriter.WriteElementString("amount_in_cents", AmountInCents.AsString()); xmlWriter.WriteElementString("currency", Currency); if (Account != null) { Account.WriteXml(xmlWriter); } xmlWriter.WriteEndElement(); }
public async Task <Account> CreateAsync(Account account) { var memoryStream = new MemoryStream(); var xmlWriter = XmlWriter.Create(memoryStream); account.WriteXml(xmlWriter, "account"); var requestUri = _requestFactory.MakeRequestUri(URL_PREFIX); var result = await _requestFactory.SendXmlPostRequestAsync(requestUri, memoryStream).ConfigureAwait(false); if (result.StatusCode == HttpStatusCode.OK) { return(await Account.CreateFromReaderAsync(result.ResponseReader, requestUri).ConfigureAwait(false)); } throw result.Exception ?? new Exception("Not sure what happened!"); }
internal override void WriteXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("transaction"); xmlWriter.WriteElementString("amount_in_cents", AmountInCents.AsString()); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteStringIfValid("description", Description); xmlWriter.WriteElementString("tax_exempt", TaxExempt.AsString().ToLower()); xmlWriter.WriteStringIfValid("tax_code", TaxCode); xmlWriter.WriteStringIfValid("accounting_code", AccountingCode); if (Account != null) { Account.WriteXml(xmlWriter); } xmlWriter.WriteEndElement(); }
internal override void WriteXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("purchase"); // Start: purchase xmlWriter.WriteElementString("collection_method", CollectionMethod.ToString().EnumNameToTransportCase()); if (NetTerms.HasValue) { xmlWriter.WriteElementString("net_terms", NetTerms.Value.ToString()); } if (PoNumber != null) { xmlWriter.WriteElementString("po_number", PoNumber); } xmlWriter.WriteElementString("currency", Currency); if (ShippingAddressId.HasValue) { xmlWriter.WriteElementString("shipping_address_id", ShippingAddressId.Value.ToString()); } Account.WriteXml(xmlWriter); if (Adjustments.HasAny()) { xmlWriter.WriteStartElement("adjustments"); // Start: adjustments foreach (var adjustment in Adjustments) { adjustment.WriteEmbeddedXml(xmlWriter); } xmlWriter.WriteEndElement(); // End: adjustments } if (Subscriptions.HasAny()) { xmlWriter.WriteStartElement("subscriptions"); // Start: subscriptions foreach (var subscription in Subscriptions) { subscription.WriteEmbeddedSubscriptionXml(xmlWriter); } xmlWriter.WriteEndElement(); // End: subscriptions } if (CouponCodes.HasAny()) { xmlWriter.WriteStartElement("coupon_codes"); // Start: coupon_codes foreach (var code in CouponCodes) { xmlWriter.WriteElementString("coupon_code", code); } xmlWriter.WriteEndElement(); // End: coupon_codes } if (GiftCardRedemptionCode != null) { var gc = new GiftCard(GiftCardRedemptionCode); gc.WriteRedemptionXml(xmlWriter); } if (CustomerNotes != null) { xmlWriter.WriteElementString("customer_notes", CustomerNotes); } if (TermsAndConditions != null) { xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); } if (VatReverseChargeNotes != null) { xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); } if (GatewayCode != null) { xmlWriter.WriteElementString("gateway_code", GatewayCode); } xmlWriter.WriteEndElement(); // End: purchase }
protected void WriteSubscriptionXml(XmlTextWriter xmlWriter) { xmlWriter.WriteStartElement("subscription"); // Start: subscription xmlWriter.WriteElementString("plan_code", PlanCode); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteIfCollectionHasAny("subscription_add_ons", AddOns); xmlWriter.WriteStringIfValid("coupon_code", _couponCode); if (_couponCodes != null && _couponCodes.Length != 0) { xmlWriter.WriteStartElement("coupon_codes"); foreach (var _coupon_code in _couponCodes) { xmlWriter.WriteElementString("coupon_code", _coupon_code); } xmlWriter.WriteEndElement(); } xmlWriter.WriteElementString("customer_notes", CustomerNotes); xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); if (UnitAmountInCents.HasValue) { xmlWriter.WriteElementString("unit_amount_in_cents", UnitAmountInCents.Value.AsString()); } xmlWriter.WriteElementString("quantity", Quantity.AsString()); if (TrialPeriodEndsAt.HasValue) { xmlWriter.WriteElementString("trial_ends_at", TrialPeriodEndsAt.Value.ToString("s")); } if (BankAccountAuthorizedAt.HasValue) { xmlWriter.WriteElementString("bank_account_authorized_at", BankAccountAuthorizedAt.Value.ToString("s")); } if (StartsAt.HasValue) { xmlWriter.WriteElementString("starts_at", StartsAt.Value.ToString("s")); } if (TotalBillingCycles.HasValue) { xmlWriter.WriteElementString("total_billing_cycles", TotalBillingCycles.Value.AsString()); } if (FirstRenewalDate.HasValue) { xmlWriter.WriteElementString("first_renewal_date", FirstRenewalDate.Value.ToString("s")); } if (Bulk.HasValue) { xmlWriter.WriteElementString("bulk", Bulk.ToString().ToLower()); } if (CollectionMethod.Like("manual")) { xmlWriter.WriteElementString("collection_method", "manual"); xmlWriter.WriteElementString("net_terms", NetTerms.Value.AsString()); xmlWriter.WriteElementString("po_number", PoNumber); } else if (CollectionMethod.Like("automatic")) { xmlWriter.WriteElementString("collection_method", "automatic"); } // <account> and billing info Account.WriteXml(xmlWriter); xmlWriter.WriteEndElement(); // End: subscription }
internal void WriteSubscriptionXml(XmlTextWriter xmlWriter, bool embedded) { xmlWriter.WriteStartElement("subscription"); // Start: subscription xmlWriter.WriteElementString("plan_code", PlanCode); if (!embedded) { // <account> and billing info Account.WriteXml(xmlWriter); xmlWriter.WriteElementString("currency", Currency); xmlWriter.WriteElementString("customer_notes", CustomerNotes); xmlWriter.WriteElementString("terms_and_conditions", TermsAndConditions); xmlWriter.WriteElementString("vat_reverse_charge_notes", VatReverseChargeNotes); xmlWriter.WriteElementString("po_number", PoNumber); } xmlWriter.WriteIfCollectionHasAny("subscription_add_ons", AddOns); xmlWriter.WriteStringIfValid("coupon_code", _couponCode); if (_couponCodes != null && _couponCodes.Length != 0) { xmlWriter.WriteStartElement("coupon_codes"); foreach (var _coupon_code in _couponCodes) { xmlWriter.WriteElementString("coupon_code", _coupon_code); } xmlWriter.WriteEndElement(); } if (UnitAmountInCents.HasValue) { xmlWriter.WriteElementString("unit_amount_in_cents", UnitAmountInCents.Value.AsString()); } xmlWriter.WriteElementString("quantity", Quantity.AsString()); if (TrialPeriodEndsAt.HasValue) { xmlWriter.WriteElementString("trial_ends_at", TrialPeriodEndsAt.Value.ToString("s")); } if (BankAccountAuthorizedAt.HasValue) { xmlWriter.WriteElementString("bank_account_authorized_at", BankAccountAuthorizedAt.Value.ToString("s")); } if (StartsAt.HasValue) { xmlWriter.WriteElementString("starts_at", StartsAt.Value.ToString("s")); } if (TotalBillingCycles.HasValue) { xmlWriter.WriteElementString("total_billing_cycles", TotalBillingCycles.Value.AsString()); } if (FirstRenewalDate.HasValue) { xmlWriter.WriteElementString("first_renewal_date", FirstRenewalDate.Value.ToString("s")); } if (Bulk.HasValue) { xmlWriter.WriteElementString("bulk", Bulk.ToString().ToLower()); } if (CollectionMethod.Like("manual")) { xmlWriter.WriteElementString("collection_method", "manual"); if (NetTerms.HasValue) { xmlWriter.WriteElementString("net_terms", NetTerms.Value.AsString()); } } else if (CollectionMethod.Like("automatic")) { xmlWriter.WriteElementString("collection_method", "automatic"); } if (ShippingAddressId.HasValue) { xmlWriter.WriteElementString("shipping_address_id", ShippingAddressId.Value.ToString()); } if (ImportedTrial.HasValue) { xmlWriter.WriteElementString("imported_trial", ImportedTrial.Value.ToString().ToLower()); } if (RevenueScheduleType.HasValue) { xmlWriter.WriteElementString("revenue_schedule_type", RevenueScheduleType.Value.ToString().EnumNameToTransportCase()); } if (RemainingBillingCycles.HasValue) { xmlWriter.WriteElementString("remaining_billing_cycles", RemainingBillingCycles.Value.AsString()); } if (AutoRenew.HasValue) { xmlWriter.WriteElementString("auto_renew", AutoRenew.Value.AsString()); } if (RenewalBillingCycles.HasValue) { xmlWriter.WriteElementString("renewal_billing_cycles", RenewalBillingCycles.Value.AsString()); } xmlWriter.WriteIfCollectionHasAny("custom_fields", CustomFields); if (!ShippingMethodCode.IsNullOrEmpty()) { xmlWriter.WriteElementString("shipping_method_code", ShippingMethodCode); } if (ShippingAmountInCents.HasValue) { xmlWriter.WriteElementString("shipping_amount_in_cents", ShippingAmountInCents.Value.AsString()); } xmlWriter.WriteEndElement(); // End: subscription }