예제 #1
0
  public CGSubscription(Element elem) {
    this.id = elem.getAttribute("id");
    this.gatewayToken = XmlUtils.getNamedElemValue(elem, "gatewayToken");
    this.ccFirstName = XmlUtils.getNamedElemValue(elem, "ccFirstName");
    this.ccLastName = XmlUtils.getNamedElemValue(elem, "ccLastName");
    this.ccType = XmlUtils.getNamedElemValue(elem, "ccType");
    this.ccLastFour = XmlUtils.getNamedElemValue(elem, "ccLastFour");

    this.ccExpirationDate =
        CGService.parseCgDate(XmlUtils.getNamedElemValue(elem, "ccExpirationDate"));
    this.canceledDatetime =
        CGService.parseCgDate(XmlUtils.getNamedElemValue(elem, "canceledDatetime"));
    this.createdDatetime =
        CGService.parseCgDate(XmlUtils.getNamedElemValue(elem, "createdDatetime"));

    Element plansParent = XmlUtils.getFirstChildByTagName(elem, "plans");
    if (plansParent != null) {
      this.plans = new ArrayList<CGPlan>();
      List<Element> planList = XmlUtils.getChildrenByTagName(plansParent, "plan");
      for (Element plan : planList) {
        this.plans.add(new CGPlan(plan));
      }
    }

    Element itemsParent = XmlUtils.getFirstChildByTagName(elem, "items");
    if (itemsParent != null) {
      this.items = new ArrayList<CGItem>();
      List<Element> itemList = XmlUtils.getChildrenByTagName(itemsParent, "item");
      for (Element item : itemList) {
        this.items.add(new CGItem(item));
      }
    }

    Element invoicesParent = XmlUtils.getFirstChildByTagName(elem, "invoices");
    if (invoicesParent != null) {
      this.invoices = new ArrayList<CGInvoice>();
      List<Element> invoiceList = XmlUtils.getChildrenByTagName(invoicesParent, "invoice");
      for (Element invoice : invoiceList) {
        this.invoices.add(new CGInvoice(invoice));
      }

      // Sort invoices by billing date (most recent first)
      Collections.sort(
          this.invoices,
          new Comparator<CGInvoice>() {
            public int compare(CGInvoice inv1, CGInvoice inv2) {
              return inv2.getBillingDatetime().compareTo(inv1.getBillingDatetime());
            }
          });
    }
  }
 public RegistrationData GetRegistrationDetail(String registrationId) throws Exception {
   ServiceRequest sr = new ServiceRequest(configuration);
   sr.getParameters().add("regid", registrationId);
   Document xmlDoc = sr.callService("rustici.registration.getRegistrationDetail");
   return RegistrationData.parseFromXmlElement(
       XmlUtils.getFirstChildByTagName(xmlDoc.getDocumentElement(), "registration"));
 }