Subversion Repositories SmartDukaan

Rev

Rev 420 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.payments;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.thrift.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.protocol.*;

public class PaymentService {

  public interface Iface {

    public Payment createPayment(long user_id, long cart_id, double amount, PaymentGateway gateway) throws PaymentException, TException;

    public PaymentRequest createPaymentRequest(long cart_id, long application_id, long merchant_tx_id, List<Param> params) throws PaymentException, TException;

    public void addCallbackUrl(long application_id, String callback_url, boolean updateIfExisting) throws PaymentException, TException;

    public void getCallbackUrl(long application_id) throws PaymentException, TException;

    public List<Payment> getPaymentsForUser(long userId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException;

    public List<Payment> getPaymentsForCart(long cartId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException;

    public List<Payment> getPayments(long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException;

    public Payment getPaymentForMerchantId(long merchant_tx_id) throws PaymentException, TException;

    public void changePaymentStatus(long merchant_tx_id, PaymentStatus newStatus) throws PaymentException, TException;

    public void changePaymentRequestStatus(long request_id, RequestStatus requestStatus) throws PaymentException, TException;

  }

  public static class Client implements Iface {
    public Client(TProtocol prot)
    {
      this(prot, prot);
    }

    public Client(TProtocol iprot, TProtocol oprot)
    {
      iprot_ = iprot;
      oprot_ = oprot;
    }

    protected TProtocol iprot_;
    protected TProtocol oprot_;

    protected int seqid_;

    public TProtocol getInputProtocol()
    {
      return this.iprot_;
    }

    public TProtocol getOutputProtocol()
    {
      return this.oprot_;
    }

    public Payment createPayment(long user_id, long cart_id, double amount, PaymentGateway gateway) throws PaymentException, TException
    {
      send_createPayment(user_id, cart_id, amount, gateway);
      return recv_createPayment();
    }

    public void send_createPayment(long user_id, long cart_id, double amount, PaymentGateway gateway) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("createPayment", TMessageType.CALL, seqid_));
      createPayment_args args = new createPayment_args();
      args.user_id = user_id;
      args.cart_id = cart_id;
      args.amount = amount;
      args.gateway = gateway;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public Payment recv_createPayment() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      createPayment_result result = new createPayment_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "createPayment failed: unknown result");
    }

    public PaymentRequest createPaymentRequest(long cart_id, long application_id, long merchant_tx_id, List<Param> params) throws PaymentException, TException
    {
      send_createPaymentRequest(cart_id, application_id, merchant_tx_id, params);
      return recv_createPaymentRequest();
    }

    public void send_createPaymentRequest(long cart_id, long application_id, long merchant_tx_id, List<Param> params) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("createPaymentRequest", TMessageType.CALL, seqid_));
      createPaymentRequest_args args = new createPaymentRequest_args();
      args.cart_id = cart_id;
      args.application_id = application_id;
      args.merchant_tx_id = merchant_tx_id;
      args.params = params;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public PaymentRequest recv_createPaymentRequest() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      createPaymentRequest_result result = new createPaymentRequest_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "createPaymentRequest failed: unknown result");
    }

    public void addCallbackUrl(long application_id, String callback_url, boolean updateIfExisting) throws PaymentException, TException
    {
      send_addCallbackUrl(application_id, callback_url, updateIfExisting);
      recv_addCallbackUrl();
    }

    public void send_addCallbackUrl(long application_id, String callback_url, boolean updateIfExisting) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("addCallbackUrl", TMessageType.CALL, seqid_));
      addCallbackUrl_args args = new addCallbackUrl_args();
      args.application_id = application_id;
      args.callback_url = callback_url;
      args.updateIfExisting = updateIfExisting;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_addCallbackUrl() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      addCallbackUrl_result result = new addCallbackUrl_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pe != null) {
        throw result.pe;
      }
      return;
    }

    public void getCallbackUrl(long application_id) throws PaymentException, TException
    {
      send_getCallbackUrl(application_id);
      recv_getCallbackUrl();
    }

    public void send_getCallbackUrl(long application_id) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getCallbackUrl", TMessageType.CALL, seqid_));
      getCallbackUrl_args args = new getCallbackUrl_args();
      args.application_id = application_id;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_getCallbackUrl() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getCallbackUrl_result result = new getCallbackUrl_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pe != null) {
        throw result.pe;
      }
      return;
    }

    public List<Payment> getPaymentsForUser(long userId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException
    {
      send_getPaymentsForUser(userId, from_time, to_time, status, gateway);
      return recv_getPaymentsForUser();
    }

    public void send_getPaymentsForUser(long userId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPaymentsForUser", TMessageType.CALL, seqid_));
      getPaymentsForUser_args args = new getPaymentsForUser_args();
      args.userId = userId;
      args.from_time = from_time;
      args.to_time = to_time;
      args.status = status;
      args.gateway = gateway;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<Payment> recv_getPaymentsForUser() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPaymentsForUser_result result = new getPaymentsForUser_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPaymentsForUser failed: unknown result");
    }

    public List<Payment> getPaymentsForCart(long cartId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException
    {
      send_getPaymentsForCart(cartId, from_time, to_time, status, gateway);
      return recv_getPaymentsForCart();
    }

    public void send_getPaymentsForCart(long cartId, long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPaymentsForCart", TMessageType.CALL, seqid_));
      getPaymentsForCart_args args = new getPaymentsForCart_args();
      args.cartId = cartId;
      args.from_time = from_time;
      args.to_time = to_time;
      args.status = status;
      args.gateway = gateway;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<Payment> recv_getPaymentsForCart() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPaymentsForCart_result result = new getPaymentsForCart_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPaymentsForCart failed: unknown result");
    }

    public List<Payment> getPayments(long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws PaymentException, TException
    {
      send_getPayments(from_time, to_time, status, gateway);
      return recv_getPayments();
    }

    public void send_getPayments(long from_time, long to_time, PaymentStatus status, PaymentGateway gateway) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPayments", TMessageType.CALL, seqid_));
      getPayments_args args = new getPayments_args();
      args.from_time = from_time;
      args.to_time = to_time;
      args.status = status;
      args.gateway = gateway;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<Payment> recv_getPayments() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPayments_result result = new getPayments_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPayments failed: unknown result");
    }

    public Payment getPaymentForMerchantId(long merchant_tx_id) throws PaymentException, TException
    {
      send_getPaymentForMerchantId(merchant_tx_id);
      return recv_getPaymentForMerchantId();
    }

    public void send_getPaymentForMerchantId(long merchant_tx_id) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPaymentForMerchantId", TMessageType.CALL, seqid_));
      getPaymentForMerchantId_args args = new getPaymentForMerchantId_args();
      args.merchant_tx_id = merchant_tx_id;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public Payment recv_getPaymentForMerchantId() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPaymentForMerchantId_result result = new getPaymentForMerchantId_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pe != null) {
        throw result.pe;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPaymentForMerchantId failed: unknown result");
    }

    public void changePaymentStatus(long merchant_tx_id, PaymentStatus newStatus) throws PaymentException, TException
    {
      send_changePaymentStatus(merchant_tx_id, newStatus);
      recv_changePaymentStatus();
    }

    public void send_changePaymentStatus(long merchant_tx_id, PaymentStatus newStatus) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("changePaymentStatus", TMessageType.CALL, seqid_));
      changePaymentStatus_args args = new changePaymentStatus_args();
      args.merchant_tx_id = merchant_tx_id;
      args.newStatus = newStatus;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_changePaymentStatus() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      changePaymentStatus_result result = new changePaymentStatus_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pe != null) {
        throw result.pe;
      }
      return;
    }

    public void changePaymentRequestStatus(long request_id, RequestStatus requestStatus) throws PaymentException, TException
    {
      send_changePaymentRequestStatus(request_id, requestStatus);
      recv_changePaymentRequestStatus();
    }

    public void send_changePaymentRequestStatus(long request_id, RequestStatus requestStatus) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("changePaymentRequestStatus", TMessageType.CALL, seqid_));
      changePaymentRequestStatus_args args = new changePaymentRequestStatus_args();
      args.request_id = request_id;
      args.requestStatus = requestStatus;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_changePaymentRequestStatus() throws PaymentException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      changePaymentRequestStatus_result result = new changePaymentRequestStatus_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pe != null) {
        throw result.pe;
      }
      return;
    }

  }
  public static class Processor implements TProcessor {
    private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
    public Processor(Iface iface)
    {
      iface_ = iface;
      processMap_.put("createPayment", new createPayment());
      processMap_.put("createPaymentRequest", new createPaymentRequest());
      processMap_.put("addCallbackUrl", new addCallbackUrl());
      processMap_.put("getCallbackUrl", new getCallbackUrl());
      processMap_.put("getPaymentsForUser", new getPaymentsForUser());
      processMap_.put("getPaymentsForCart", new getPaymentsForCart());
      processMap_.put("getPayments", new getPayments());
      processMap_.put("getPaymentForMerchantId", new getPaymentForMerchantId());
      processMap_.put("changePaymentStatus", new changePaymentStatus());
      processMap_.put("changePaymentRequestStatus", new changePaymentRequestStatus());
    }

    protected static interface ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
    }

    private Iface iface_;
    protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();

    public boolean process(TProtocol iprot, TProtocol oprot) throws TException
    {
      TMessage msg = iprot.readMessageBegin();
      ProcessFunction fn = processMap_.get(msg.name);
      if (fn == null) {
        TProtocolUtil.skip(iprot, TType.STRUCT);
        iprot.readMessageEnd();
        TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
        oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
        x.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
        return true;
      }
      fn.process(msg.seqid, iprot, oprot);
      return true;
    }

    private class createPayment implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        createPayment_args args = new createPayment_args();
        args.read(iprot);
        iprot.readMessageEnd();
        createPayment_result result = new createPayment_result();
        try {
          result.success = iface_.createPayment(args.user_id, args.cart_id, args.amount, args.gateway);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing createPayment", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing createPayment");
          oprot.writeMessageBegin(new TMessage("createPayment", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("createPayment", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class createPaymentRequest implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        createPaymentRequest_args args = new createPaymentRequest_args();
        args.read(iprot);
        iprot.readMessageEnd();
        createPaymentRequest_result result = new createPaymentRequest_result();
        try {
          result.success = iface_.createPaymentRequest(args.cart_id, args.application_id, args.merchant_tx_id, args.params);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing createPaymentRequest", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing createPaymentRequest");
          oprot.writeMessageBegin(new TMessage("createPaymentRequest", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("createPaymentRequest", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class addCallbackUrl implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        addCallbackUrl_args args = new addCallbackUrl_args();
        args.read(iprot);
        iprot.readMessageEnd();
        addCallbackUrl_result result = new addCallbackUrl_result();
        try {
          iface_.addCallbackUrl(args.application_id, args.callback_url, args.updateIfExisting);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing addCallbackUrl", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing addCallbackUrl");
          oprot.writeMessageBegin(new TMessage("addCallbackUrl", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("addCallbackUrl", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getCallbackUrl implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getCallbackUrl_args args = new getCallbackUrl_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getCallbackUrl_result result = new getCallbackUrl_result();
        try {
          iface_.getCallbackUrl(args.application_id);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getCallbackUrl", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getCallbackUrl");
          oprot.writeMessageBegin(new TMessage("getCallbackUrl", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getCallbackUrl", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPaymentsForUser implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPaymentsForUser_args args = new getPaymentsForUser_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPaymentsForUser_result result = new getPaymentsForUser_result();
        try {
          result.success = iface_.getPaymentsForUser(args.userId, args.from_time, args.to_time, args.status, args.gateway);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPaymentsForUser", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPaymentsForUser");
          oprot.writeMessageBegin(new TMessage("getPaymentsForUser", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPaymentsForUser", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPaymentsForCart implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPaymentsForCart_args args = new getPaymentsForCart_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPaymentsForCart_result result = new getPaymentsForCart_result();
        try {
          result.success = iface_.getPaymentsForCart(args.cartId, args.from_time, args.to_time, args.status, args.gateway);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPaymentsForCart", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPaymentsForCart");
          oprot.writeMessageBegin(new TMessage("getPaymentsForCart", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPaymentsForCart", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPayments implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPayments_args args = new getPayments_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPayments_result result = new getPayments_result();
        try {
          result.success = iface_.getPayments(args.from_time, args.to_time, args.status, args.gateway);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPayments", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPayments");
          oprot.writeMessageBegin(new TMessage("getPayments", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPayments", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPaymentForMerchantId implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPaymentForMerchantId_args args = new getPaymentForMerchantId_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPaymentForMerchantId_result result = new getPaymentForMerchantId_result();
        try {
          result.success = iface_.getPaymentForMerchantId(args.merchant_tx_id);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPaymentForMerchantId", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPaymentForMerchantId");
          oprot.writeMessageBegin(new TMessage("getPaymentForMerchantId", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPaymentForMerchantId", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class changePaymentStatus implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        changePaymentStatus_args args = new changePaymentStatus_args();
        args.read(iprot);
        iprot.readMessageEnd();
        changePaymentStatus_result result = new changePaymentStatus_result();
        try {
          iface_.changePaymentStatus(args.merchant_tx_id, args.newStatus);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing changePaymentStatus", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing changePaymentStatus");
          oprot.writeMessageBegin(new TMessage("changePaymentStatus", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("changePaymentStatus", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class changePaymentRequestStatus implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        changePaymentRequestStatus_args args = new changePaymentRequestStatus_args();
        args.read(iprot);
        iprot.readMessageEnd();
        changePaymentRequestStatus_result result = new changePaymentRequestStatus_result();
        try {
          iface_.changePaymentRequestStatus(args.request_id, args.requestStatus);
        } catch (PaymentException pe) {
          result.pe = pe;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing changePaymentRequestStatus", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing changePaymentRequestStatus");
          oprot.writeMessageBegin(new TMessage("changePaymentRequestStatus", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("changePaymentRequestStatus", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

  }

  public static class createPayment_args implements TBase<createPayment_args._Fields>, java.io.Serializable, Cloneable, Comparable<createPayment_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("createPayment_args");

    private static final TField USER_ID_FIELD_DESC = new TField("user_id", TType.I64, (short)1);
    private static final TField CART_ID_FIELD_DESC = new TField("cart_id", TType.I64, (short)2);
    private static final TField AMOUNT_FIELD_DESC = new TField("amount", TType.DOUBLE, (short)3);
    private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)4);

    private long user_id;
    private long cart_id;
    private double amount;
    private PaymentGateway gateway;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      USER_ID((short)1, "user_id"),
      CART_ID((short)2, "cart_id"),
      AMOUNT((short)3, "amount"),
      /**
       * 
       * @see PaymentGateway
       */
      GATEWAY((short)4, "gateway");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __USER_ID_ISSET_ID = 0;
    private static final int __CART_ID_ISSET_ID = 1;
    private static final int __AMOUNT_ISSET_ID = 2;
    private BitSet __isset_bit_vector = new BitSet(3);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.USER_ID, new FieldMetaData("user_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.CART_ID, new FieldMetaData("cart_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.AMOUNT, new FieldMetaData("amount", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.DOUBLE)));
      put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentGateway.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(createPayment_args.class, metaDataMap);
    }

    public createPayment_args() {
    }

    public createPayment_args(
      long user_id,
      long cart_id,
      double amount,
      PaymentGateway gateway)
    {
      this();
      this.user_id = user_id;
      setUser_idIsSet(true);
      this.cart_id = cart_id;
      setCart_idIsSet(true);
      this.amount = amount;
      setAmountIsSet(true);
      this.gateway = gateway;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPayment_args(createPayment_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.user_id = other.user_id;
      this.cart_id = other.cart_id;
      this.amount = other.amount;
      if (other.isSetGateway()) {
        this.gateway = other.gateway;
      }
    }

    public createPayment_args deepCopy() {
      return new createPayment_args(this);
    }

    @Deprecated
    public createPayment_args clone() {
      return new createPayment_args(this);
    }

    public long getUser_id() {
      return this.user_id;
    }

    public createPayment_args setUser_id(long user_id) {
      this.user_id = user_id;
      setUser_idIsSet(true);
      return this;
    }

    public void unsetUser_id() {
      __isset_bit_vector.clear(__USER_ID_ISSET_ID);
    }

    /** Returns true if field user_id is set (has been asigned a value) and false otherwise */
    public boolean isSetUser_id() {
      return __isset_bit_vector.get(__USER_ID_ISSET_ID);
    }

    public void setUser_idIsSet(boolean value) {
      __isset_bit_vector.set(__USER_ID_ISSET_ID, value);
    }

    public long getCart_id() {
      return this.cart_id;
    }

    public createPayment_args setCart_id(long cart_id) {
      this.cart_id = cart_id;
      setCart_idIsSet(true);
      return this;
    }

    public void unsetCart_id() {
      __isset_bit_vector.clear(__CART_ID_ISSET_ID);
    }

    /** Returns true if field cart_id is set (has been asigned a value) and false otherwise */
    public boolean isSetCart_id() {
      return __isset_bit_vector.get(__CART_ID_ISSET_ID);
    }

    public void setCart_idIsSet(boolean value) {
      __isset_bit_vector.set(__CART_ID_ISSET_ID, value);
    }

    public double getAmount() {
      return this.amount;
    }

    public createPayment_args setAmount(double amount) {
      this.amount = amount;
      setAmountIsSet(true);
      return this;
    }

    public void unsetAmount() {
      __isset_bit_vector.clear(__AMOUNT_ISSET_ID);
    }

    /** Returns true if field amount is set (has been asigned a value) and false otherwise */
    public boolean isSetAmount() {
      return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
    }

    public void setAmountIsSet(boolean value) {
      __isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
    }

    /**
     * 
     * @see PaymentGateway
     */
    public PaymentGateway getGateway() {
      return this.gateway;
    }

    /**
     * 
     * @see PaymentGateway
     */
    public createPayment_args setGateway(PaymentGateway gateway) {
      this.gateway = gateway;
      return this;
    }

    public void unsetGateway() {
      this.gateway = null;
    }

    /** Returns true if field gateway is set (has been asigned a value) and false otherwise */
    public boolean isSetGateway() {
      return this.gateway != null;
    }

    public void setGatewayIsSet(boolean value) {
      if (!value) {
        this.gateway = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case USER_ID:
        if (value == null) {
          unsetUser_id();
        } else {
          setUser_id((Long)value);
        }
        break;

      case CART_ID:
        if (value == null) {
          unsetCart_id();
        } else {
          setCart_id((Long)value);
        }
        break;

      case AMOUNT:
        if (value == null) {
          unsetAmount();
        } else {
          setAmount((Double)value);
        }
        break;

      case GATEWAY:
        if (value == null) {
          unsetGateway();
        } else {
          setGateway((PaymentGateway)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case USER_ID:
        return new Long(getUser_id());

      case CART_ID:
        return new Long(getCart_id());

      case AMOUNT:
        return new Double(getAmount());

      case GATEWAY:
        return getGateway();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case USER_ID:
        return isSetUser_id();
      case CART_ID:
        return isSetCart_id();
      case AMOUNT:
        return isSetAmount();
      case GATEWAY:
        return isSetGateway();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof createPayment_args)
        return this.equals((createPayment_args)that);
      return false;
    }

    public boolean equals(createPayment_args that) {
      if (that == null)
        return false;

      boolean this_present_user_id = true;
      boolean that_present_user_id = true;
      if (this_present_user_id || that_present_user_id) {
        if (!(this_present_user_id && that_present_user_id))
          return false;
        if (this.user_id != that.user_id)
          return false;
      }

      boolean this_present_cart_id = true;
      boolean that_present_cart_id = true;
      if (this_present_cart_id || that_present_cart_id) {
        if (!(this_present_cart_id && that_present_cart_id))
          return false;
        if (this.cart_id != that.cart_id)
          return false;
      }

      boolean this_present_amount = true;
      boolean that_present_amount = true;
      if (this_present_amount || that_present_amount) {
        if (!(this_present_amount && that_present_amount))
          return false;
        if (this.amount != that.amount)
          return false;
      }

      boolean this_present_gateway = true && this.isSetGateway();
      boolean that_present_gateway = true && that.isSetGateway();
      if (this_present_gateway || that_present_gateway) {
        if (!(this_present_gateway && that_present_gateway))
          return false;
        if (!this.gateway.equals(that.gateway))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(createPayment_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      createPayment_args typedOther = (createPayment_args)other;

      lastComparison = Boolean.valueOf(isSetUser_id()).compareTo(isSetUser_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(user_id, typedOther.user_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetCart_id()).compareTo(isSetCart_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(cart_id, typedOther.cart_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetAmount()).compareTo(isSetAmount());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(amount, typedOther.amount);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(isSetGateway());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(gateway, typedOther.gateway);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case USER_ID:
              if (field.type == TType.I64) {
                this.user_id = iprot.readI64();
                setUser_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case CART_ID:
              if (field.type == TType.I64) {
                this.cart_id = iprot.readI64();
                setCart_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case AMOUNT:
              if (field.type == TType.DOUBLE) {
                this.amount = iprot.readDouble();
                setAmountIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case GATEWAY:
              if (field.type == TType.I32) {
                this.gateway = PaymentGateway.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(USER_ID_FIELD_DESC);
      oprot.writeI64(this.user_id);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
      oprot.writeI64(this.cart_id);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
      oprot.writeDouble(this.amount);
      oprot.writeFieldEnd();
      if (this.gateway != null) {
        oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
        oprot.writeI32(this.gateway.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("createPayment_args(");
      boolean first = true;

      sb.append("user_id:");
      sb.append(this.user_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("cart_id:");
      sb.append(this.cart_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("amount:");
      sb.append(this.amount);
      first = false;
      if (!first) sb.append(", ");
      sb.append("gateway:");
      if (this.gateway == null) {
        sb.append("null");
      } else {
        String gateway_name = gateway.name();
        if (gateway_name != null) {
          sb.append(gateway_name);
          sb.append(" (");
        }
        sb.append(this.gateway);
        if (gateway_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class createPayment_result implements TBase<createPayment_result._Fields>, java.io.Serializable, Cloneable   {
    private static final TStruct STRUCT_DESC = new TStruct("createPayment_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private Payment success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, Payment.class)));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(createPayment_result.class, metaDataMap);
    }

    public createPayment_result() {
    }

    public createPayment_result(
      Payment success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPayment_result(createPayment_result other) {
      if (other.isSetSuccess()) {
        this.success = new Payment(other.success);
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public createPayment_result deepCopy() {
      return new createPayment_result(this);
    }

    @Deprecated
    public createPayment_result clone() {
      return new createPayment_result(this);
    }

    public Payment getSuccess() {
      return this.success;
    }

    public createPayment_result setSuccess(Payment success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public createPayment_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Payment)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof createPayment_result)
        return this.equals((createPayment_result)that);
      return false;
    }

    public boolean equals(createPayment_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new Payment();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("createPayment_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class createPaymentRequest_args implements TBase<createPaymentRequest_args._Fields>, java.io.Serializable, Cloneable, Comparable<createPaymentRequest_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("createPaymentRequest_args");

    private static final TField CART_ID_FIELD_DESC = new TField("cart_id", TType.I64, (short)1);
    private static final TField APPLICATION_ID_FIELD_DESC = new TField("application_id", TType.I64, (short)2);
    private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.I64, (short)3);
    private static final TField PARAMS_FIELD_DESC = new TField("params", TType.LIST, (short)5);

    private long cart_id;
    private long application_id;
    private long merchant_tx_id;
    private List<Param> params;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      CART_ID((short)1, "cart_id"),
      APPLICATION_ID((short)2, "application_id"),
      MERCHANT_TX_ID((short)3, "merchant_tx_id"),
      PARAMS((short)5, "params");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __CART_ID_ISSET_ID = 0;
    private static final int __APPLICATION_ID_ISSET_ID = 1;
    private static final int __MERCHANT_TX_ID_ISSET_ID = 2;
    private BitSet __isset_bit_vector = new BitSet(3);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.CART_ID, new FieldMetaData("cart_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.APPLICATION_ID, new FieldMetaData("application_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.PARAMS, new FieldMetaData("params", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Param.class))));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(createPaymentRequest_args.class, metaDataMap);
    }

    public createPaymentRequest_args() {
    }

    public createPaymentRequest_args(
      long cart_id,
      long application_id,
      long merchant_tx_id,
      List<Param> params)
    {
      this();
      this.cart_id = cart_id;
      setCart_idIsSet(true);
      this.application_id = application_id;
      setApplication_idIsSet(true);
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
      this.params = params;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPaymentRequest_args(createPaymentRequest_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.cart_id = other.cart_id;
      this.application_id = other.application_id;
      this.merchant_tx_id = other.merchant_tx_id;
      if (other.isSetParams()) {
        List<Param> __this__params = new ArrayList<Param>();
        for (Param other_element : other.params) {
          __this__params.add(new Param(other_element));
        }
        this.params = __this__params;
      }
    }

    public createPaymentRequest_args deepCopy() {
      return new createPaymentRequest_args(this);
    }

    @Deprecated
    public createPaymentRequest_args clone() {
      return new createPaymentRequest_args(this);
    }

    public long getCart_id() {
      return this.cart_id;
    }

    public createPaymentRequest_args setCart_id(long cart_id) {
      this.cart_id = cart_id;
      setCart_idIsSet(true);
      return this;
    }

    public void unsetCart_id() {
      __isset_bit_vector.clear(__CART_ID_ISSET_ID);
    }

    /** Returns true if field cart_id is set (has been asigned a value) and false otherwise */
    public boolean isSetCart_id() {
      return __isset_bit_vector.get(__CART_ID_ISSET_ID);
    }

    public void setCart_idIsSet(boolean value) {
      __isset_bit_vector.set(__CART_ID_ISSET_ID, value);
    }

    public long getApplication_id() {
      return this.application_id;
    }

    public createPaymentRequest_args setApplication_id(long application_id) {
      this.application_id = application_id;
      setApplication_idIsSet(true);
      return this;
    }

    public void unsetApplication_id() {
      __isset_bit_vector.clear(__APPLICATION_ID_ISSET_ID);
    }

    /** Returns true if field application_id is set (has been asigned a value) and false otherwise */
    public boolean isSetApplication_id() {
      return __isset_bit_vector.get(__APPLICATION_ID_ISSET_ID);
    }

    public void setApplication_idIsSet(boolean value) {
      __isset_bit_vector.set(__APPLICATION_ID_ISSET_ID, value);
    }

    public long getMerchant_tx_id() {
      return this.merchant_tx_id;
    }

    public createPaymentRequest_args setMerchant_tx_id(long merchant_tx_id) {
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
      return this;
    }

    public void unsetMerchant_tx_id() {
      __isset_bit_vector.clear(__MERCHANT_TX_ID_ISSET_ID);
    }

    /** Returns true if field merchant_tx_id is set (has been asigned a value) and false otherwise */
    public boolean isSetMerchant_tx_id() {
      return __isset_bit_vector.get(__MERCHANT_TX_ID_ISSET_ID);
    }

    public void setMerchant_tx_idIsSet(boolean value) {
      __isset_bit_vector.set(__MERCHANT_TX_ID_ISSET_ID, value);
    }

    public int getParamsSize() {
      return (this.params == null) ? 0 : this.params.size();
    }

    public java.util.Iterator<Param> getParamsIterator() {
      return (this.params == null) ? null : this.params.iterator();
    }

    public void addToParams(Param elem) {
      if (this.params == null) {
        this.params = new ArrayList<Param>();
      }
      this.params.add(elem);
    }

    public List<Param> getParams() {
      return this.params;
    }

    public createPaymentRequest_args setParams(List<Param> params) {
      this.params = params;
      return this;
    }

    public void unsetParams() {
      this.params = null;
    }

    /** Returns true if field params is set (has been asigned a value) and false otherwise */
    public boolean isSetParams() {
      return this.params != null;
    }

    public void setParamsIsSet(boolean value) {
      if (!value) {
        this.params = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case CART_ID:
        if (value == null) {
          unsetCart_id();
        } else {
          setCart_id((Long)value);
        }
        break;

      case APPLICATION_ID:
        if (value == null) {
          unsetApplication_id();
        } else {
          setApplication_id((Long)value);
        }
        break;

      case MERCHANT_TX_ID:
        if (value == null) {
          unsetMerchant_tx_id();
        } else {
          setMerchant_tx_id((Long)value);
        }
        break;

      case PARAMS:
        if (value == null) {
          unsetParams();
        } else {
          setParams((List<Param>)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case CART_ID:
        return new Long(getCart_id());

      case APPLICATION_ID:
        return new Long(getApplication_id());

      case MERCHANT_TX_ID:
        return new Long(getMerchant_tx_id());

      case PARAMS:
        return getParams();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case CART_ID:
        return isSetCart_id();
      case APPLICATION_ID:
        return isSetApplication_id();
      case MERCHANT_TX_ID:
        return isSetMerchant_tx_id();
      case PARAMS:
        return isSetParams();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof createPaymentRequest_args)
        return this.equals((createPaymentRequest_args)that);
      return false;
    }

    public boolean equals(createPaymentRequest_args that) {
      if (that == null)
        return false;

      boolean this_present_cart_id = true;
      boolean that_present_cart_id = true;
      if (this_present_cart_id || that_present_cart_id) {
        if (!(this_present_cart_id && that_present_cart_id))
          return false;
        if (this.cart_id != that.cart_id)
          return false;
      }

      boolean this_present_application_id = true;
      boolean that_present_application_id = true;
      if (this_present_application_id || that_present_application_id) {
        if (!(this_present_application_id && that_present_application_id))
          return false;
        if (this.application_id != that.application_id)
          return false;
      }

      boolean this_present_merchant_tx_id = true;
      boolean that_present_merchant_tx_id = true;
      if (this_present_merchant_tx_id || that_present_merchant_tx_id) {
        if (!(this_present_merchant_tx_id && that_present_merchant_tx_id))
          return false;
        if (this.merchant_tx_id != that.merchant_tx_id)
          return false;
      }

      boolean this_present_params = true && this.isSetParams();
      boolean that_present_params = true && that.isSetParams();
      if (this_present_params || that_present_params) {
        if (!(this_present_params && that_present_params))
          return false;
        if (!this.params.equals(that.params))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(createPaymentRequest_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      createPaymentRequest_args typedOther = (createPaymentRequest_args)other;

      lastComparison = Boolean.valueOf(isSetCart_id()).compareTo(isSetCart_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(cart_id, typedOther.cart_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetApplication_id()).compareTo(isSetApplication_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(application_id, typedOther.application_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetMerchant_tx_id()).compareTo(isSetMerchant_tx_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(merchant_tx_id, typedOther.merchant_tx_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetParams()).compareTo(isSetParams());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(params, typedOther.params);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case CART_ID:
              if (field.type == TType.I64) {
                this.cart_id = iprot.readI64();
                setCart_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case APPLICATION_ID:
              if (field.type == TType.I64) {
                this.application_id = iprot.readI64();
                setApplication_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case MERCHANT_TX_ID:
              if (field.type == TType.I64) {
                this.merchant_tx_id = iprot.readI64();
                setMerchant_tx_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PARAMS:
              if (field.type == TType.LIST) {
                {
                  TList _list9 = iprot.readListBegin();
                  this.params = new ArrayList<Param>(_list9.size);
                  for (int _i10 = 0; _i10 < _list9.size; ++_i10)
                  {
                    Param _elem11;
                    _elem11 = new Param();
                    _elem11.read(iprot);
                    this.params.add(_elem11);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
      oprot.writeI64(this.cart_id);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(APPLICATION_ID_FIELD_DESC);
      oprot.writeI64(this.application_id);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(MERCHANT_TX_ID_FIELD_DESC);
      oprot.writeI64(this.merchant_tx_id);
      oprot.writeFieldEnd();
      if (this.params != null) {
        oprot.writeFieldBegin(PARAMS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.params.size()));
          for (Param _iter12 : this.params)
          {
            _iter12.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("createPaymentRequest_args(");
      boolean first = true;

      sb.append("cart_id:");
      sb.append(this.cart_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("application_id:");
      sb.append(this.application_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("merchant_tx_id:");
      sb.append(this.merchant_tx_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("params:");
      if (this.params == null) {
        sb.append("null");
      } else {
        sb.append(this.params);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class createPaymentRequest_result implements TBase<createPaymentRequest_result._Fields>, java.io.Serializable, Cloneable, Comparable<createPaymentRequest_result>   {
    private static final TStruct STRUCT_DESC = new TStruct("createPaymentRequest_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private PaymentRequest success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, PaymentRequest.class)));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(createPaymentRequest_result.class, metaDataMap);
    }

    public createPaymentRequest_result() {
    }

    public createPaymentRequest_result(
      PaymentRequest success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPaymentRequest_result(createPaymentRequest_result other) {
      if (other.isSetSuccess()) {
        this.success = new PaymentRequest(other.success);
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public createPaymentRequest_result deepCopy() {
      return new createPaymentRequest_result(this);
    }

    @Deprecated
    public createPaymentRequest_result clone() {
      return new createPaymentRequest_result(this);
    }

    public PaymentRequest getSuccess() {
      return this.success;
    }

    public createPaymentRequest_result setSuccess(PaymentRequest success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public createPaymentRequest_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((PaymentRequest)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof createPaymentRequest_result)
        return this.equals((createPaymentRequest_result)that);
      return false;
    }

    public boolean equals(createPaymentRequest_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(createPaymentRequest_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      createPaymentRequest_result typedOther = (createPaymentRequest_result)other;

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetPe()).compareTo(isSetPe());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pe, typedOther.pe);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new PaymentRequest();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("createPaymentRequest_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class addCallbackUrl_args implements TBase<addCallbackUrl_args._Fields>, java.io.Serializable, Cloneable, Comparable<addCallbackUrl_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("addCallbackUrl_args");

    private static final TField APPLICATION_ID_FIELD_DESC = new TField("application_id", TType.I64, (short)1);
    private static final TField CALLBACK_URL_FIELD_DESC = new TField("callback_url", TType.STRING, (short)2);
    private static final TField UPDATE_IF_EXISTING_FIELD_DESC = new TField("updateIfExisting", TType.BOOL, (short)3);

    private long application_id;
    private String callback_url;
    private boolean updateIfExisting;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      APPLICATION_ID((short)1, "application_id"),
      CALLBACK_URL((short)2, "callback_url"),
      UPDATE_IF_EXISTING((short)3, "updateIfExisting");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __APPLICATION_ID_ISSET_ID = 0;
    private static final int __UPDATEIFEXISTING_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.APPLICATION_ID, new FieldMetaData("application_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.CALLBACK_URL, new FieldMetaData("callback_url", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.UPDATE_IF_EXISTING, new FieldMetaData("updateIfExisting", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.BOOL)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(addCallbackUrl_args.class, metaDataMap);
    }

    public addCallbackUrl_args() {
    }

    public addCallbackUrl_args(
      long application_id,
      String callback_url,
      boolean updateIfExisting)
    {
      this();
      this.application_id = application_id;
      setApplication_idIsSet(true);
      this.callback_url = callback_url;
      this.updateIfExisting = updateIfExisting;
      setUpdateIfExistingIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public addCallbackUrl_args(addCallbackUrl_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.application_id = other.application_id;
      if (other.isSetCallback_url()) {
        this.callback_url = other.callback_url;
      }
      this.updateIfExisting = other.updateIfExisting;
    }

    public addCallbackUrl_args deepCopy() {
      return new addCallbackUrl_args(this);
    }

    @Deprecated
    public addCallbackUrl_args clone() {
      return new addCallbackUrl_args(this);
    }

    public long getApplication_id() {
      return this.application_id;
    }

    public addCallbackUrl_args setApplication_id(long application_id) {
      this.application_id = application_id;
      setApplication_idIsSet(true);
      return this;
    }

    public void unsetApplication_id() {
      __isset_bit_vector.clear(__APPLICATION_ID_ISSET_ID);
    }

    /** Returns true if field application_id is set (has been asigned a value) and false otherwise */
    public boolean isSetApplication_id() {
      return __isset_bit_vector.get(__APPLICATION_ID_ISSET_ID);
    }

    public void setApplication_idIsSet(boolean value) {
      __isset_bit_vector.set(__APPLICATION_ID_ISSET_ID, value);
    }

    public String getCallback_url() {
      return this.callback_url;
    }

    public addCallbackUrl_args setCallback_url(String callback_url) {
      this.callback_url = callback_url;
      return this;
    }

    public void unsetCallback_url() {
      this.callback_url = null;
    }

    /** Returns true if field callback_url is set (has been asigned a value) and false otherwise */
    public boolean isSetCallback_url() {
      return this.callback_url != null;
    }

    public void setCallback_urlIsSet(boolean value) {
      if (!value) {
        this.callback_url = null;
      }
    }

    public boolean isUpdateIfExisting() {
      return this.updateIfExisting;
    }

    public addCallbackUrl_args setUpdateIfExisting(boolean updateIfExisting) {
      this.updateIfExisting = updateIfExisting;
      setUpdateIfExistingIsSet(true);
      return this;
    }

    public void unsetUpdateIfExisting() {
      __isset_bit_vector.clear(__UPDATEIFEXISTING_ISSET_ID);
    }

    /** Returns true if field updateIfExisting is set (has been asigned a value) and false otherwise */
    public boolean isSetUpdateIfExisting() {
      return __isset_bit_vector.get(__UPDATEIFEXISTING_ISSET_ID);
    }

    public void setUpdateIfExistingIsSet(boolean value) {
      __isset_bit_vector.set(__UPDATEIFEXISTING_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case APPLICATION_ID:
        if (value == null) {
          unsetApplication_id();
        } else {
          setApplication_id((Long)value);
        }
        break;

      case CALLBACK_URL:
        if (value == null) {
          unsetCallback_url();
        } else {
          setCallback_url((String)value);
        }
        break;

      case UPDATE_IF_EXISTING:
        if (value == null) {
          unsetUpdateIfExisting();
        } else {
          setUpdateIfExisting((Boolean)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case APPLICATION_ID:
        return new Long(getApplication_id());

      case CALLBACK_URL:
        return getCallback_url();

      case UPDATE_IF_EXISTING:
        return new Boolean(isUpdateIfExisting());

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case APPLICATION_ID:
        return isSetApplication_id();
      case CALLBACK_URL:
        return isSetCallback_url();
      case UPDATE_IF_EXISTING:
        return isSetUpdateIfExisting();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof addCallbackUrl_args)
        return this.equals((addCallbackUrl_args)that);
      return false;
    }

    public boolean equals(addCallbackUrl_args that) {
      if (that == null)
        return false;

      boolean this_present_application_id = true;
      boolean that_present_application_id = true;
      if (this_present_application_id || that_present_application_id) {
        if (!(this_present_application_id && that_present_application_id))
          return false;
        if (this.application_id != that.application_id)
          return false;
      }

      boolean this_present_callback_url = true && this.isSetCallback_url();
      boolean that_present_callback_url = true && that.isSetCallback_url();
      if (this_present_callback_url || that_present_callback_url) {
        if (!(this_present_callback_url && that_present_callback_url))
          return false;
        if (!this.callback_url.equals(that.callback_url))
          return false;
      }

      boolean this_present_updateIfExisting = true;
      boolean that_present_updateIfExisting = true;
      if (this_present_updateIfExisting || that_present_updateIfExisting) {
        if (!(this_present_updateIfExisting && that_present_updateIfExisting))
          return false;
        if (this.updateIfExisting != that.updateIfExisting)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(addCallbackUrl_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      addCallbackUrl_args typedOther = (addCallbackUrl_args)other;

      lastComparison = Boolean.valueOf(isSetApplication_id()).compareTo(isSetApplication_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(application_id, typedOther.application_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetCallback_url()).compareTo(isSetCallback_url());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(callback_url, typedOther.callback_url);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetUpdateIfExisting()).compareTo(isSetUpdateIfExisting());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(updateIfExisting, typedOther.updateIfExisting);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case APPLICATION_ID:
              if (field.type == TType.I64) {
                this.application_id = iprot.readI64();
                setApplication_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case CALLBACK_URL:
              if (field.type == TType.STRING) {
                this.callback_url = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case UPDATE_IF_EXISTING:
              if (field.type == TType.BOOL) {
                this.updateIfExisting = iprot.readBool();
                setUpdateIfExistingIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(APPLICATION_ID_FIELD_DESC);
      oprot.writeI64(this.application_id);
      oprot.writeFieldEnd();
      if (this.callback_url != null) {
        oprot.writeFieldBegin(CALLBACK_URL_FIELD_DESC);
        oprot.writeString(this.callback_url);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(UPDATE_IF_EXISTING_FIELD_DESC);
      oprot.writeBool(this.updateIfExisting);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("addCallbackUrl_args(");
      boolean first = true;

      sb.append("application_id:");
      sb.append(this.application_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("callback_url:");
      if (this.callback_url == null) {
        sb.append("null");
      } else {
        sb.append(this.callback_url);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("updateIfExisting:");
      sb.append(this.updateIfExisting);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class addCallbackUrl_result implements TBase<addCallbackUrl_result._Fields>, java.io.Serializable, Cloneable, Comparable<addCallbackUrl_result>   {
    private static final TStruct STRUCT_DESC = new TStruct("addCallbackUrl_result");

    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(addCallbackUrl_result.class, metaDataMap);
    }

    public addCallbackUrl_result() {
    }

    public addCallbackUrl_result(
      PaymentException pe)
    {
      this();
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public addCallbackUrl_result(addCallbackUrl_result other) {
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public addCallbackUrl_result deepCopy() {
      return new addCallbackUrl_result(this);
    }

    @Deprecated
    public addCallbackUrl_result clone() {
      return new addCallbackUrl_result(this);
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public addCallbackUrl_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof addCallbackUrl_result)
        return this.equals((addCallbackUrl_result)that);
      return false;
    }

    public boolean equals(addCallbackUrl_result that) {
      if (that == null)
        return false;

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(addCallbackUrl_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      addCallbackUrl_result typedOther = (addCallbackUrl_result)other;

      lastComparison = Boolean.valueOf(isSetPe()).compareTo(isSetPe());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pe, typedOther.pe);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("addCallbackUrl_result(");
      boolean first = true;

      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getCallbackUrl_args implements TBase<getCallbackUrl_args._Fields>, java.io.Serializable, Cloneable, Comparable<getCallbackUrl_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("getCallbackUrl_args");

    private static final TField APPLICATION_ID_FIELD_DESC = new TField("application_id", TType.I64, (short)1);

    private long application_id;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      APPLICATION_ID((short)1, "application_id");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __APPLICATION_ID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.APPLICATION_ID, new FieldMetaData("application_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getCallbackUrl_args.class, metaDataMap);
    }

    public getCallbackUrl_args() {
    }

    public getCallbackUrl_args(
      long application_id)
    {
      this();
      this.application_id = application_id;
      setApplication_idIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getCallbackUrl_args(getCallbackUrl_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.application_id = other.application_id;
    }

    public getCallbackUrl_args deepCopy() {
      return new getCallbackUrl_args(this);
    }

    @Deprecated
    public getCallbackUrl_args clone() {
      return new getCallbackUrl_args(this);
    }

    public long getApplication_id() {
      return this.application_id;
    }

    public getCallbackUrl_args setApplication_id(long application_id) {
      this.application_id = application_id;
      setApplication_idIsSet(true);
      return this;
    }

    public void unsetApplication_id() {
      __isset_bit_vector.clear(__APPLICATION_ID_ISSET_ID);
    }

    /** Returns true if field application_id is set (has been asigned a value) and false otherwise */
    public boolean isSetApplication_id() {
      return __isset_bit_vector.get(__APPLICATION_ID_ISSET_ID);
    }

    public void setApplication_idIsSet(boolean value) {
      __isset_bit_vector.set(__APPLICATION_ID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case APPLICATION_ID:
        if (value == null) {
          unsetApplication_id();
        } else {
          setApplication_id((Long)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case APPLICATION_ID:
        return new Long(getApplication_id());

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case APPLICATION_ID:
        return isSetApplication_id();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getCallbackUrl_args)
        return this.equals((getCallbackUrl_args)that);
      return false;
    }

    public boolean equals(getCallbackUrl_args that) {
      if (that == null)
        return false;

      boolean this_present_application_id = true;
      boolean that_present_application_id = true;
      if (this_present_application_id || that_present_application_id) {
        if (!(this_present_application_id && that_present_application_id))
          return false;
        if (this.application_id != that.application_id)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getCallbackUrl_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getCallbackUrl_args typedOther = (getCallbackUrl_args)other;

      lastComparison = Boolean.valueOf(isSetApplication_id()).compareTo(isSetApplication_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(application_id, typedOther.application_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case APPLICATION_ID:
              if (field.type == TType.I64) {
                this.application_id = iprot.readI64();
                setApplication_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(APPLICATION_ID_FIELD_DESC);
      oprot.writeI64(this.application_id);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getCallbackUrl_args(");
      boolean first = true;

      sb.append("application_id:");
      sb.append(this.application_id);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getCallbackUrl_result implements TBase<getCallbackUrl_result._Fields>, java.io.Serializable, Cloneable, Comparable<getCallbackUrl_result>   {
    private static final TStruct STRUCT_DESC = new TStruct("getCallbackUrl_result");

    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getCallbackUrl_result.class, metaDataMap);
    }

    public getCallbackUrl_result() {
    }

    public getCallbackUrl_result(
      PaymentException pe)
    {
      this();
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getCallbackUrl_result(getCallbackUrl_result other) {
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public getCallbackUrl_result deepCopy() {
      return new getCallbackUrl_result(this);
    }

    @Deprecated
    public getCallbackUrl_result clone() {
      return new getCallbackUrl_result(this);
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public getCallbackUrl_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getCallbackUrl_result)
        return this.equals((getCallbackUrl_result)that);
      return false;
    }

    public boolean equals(getCallbackUrl_result that) {
      if (that == null)
        return false;

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getCallbackUrl_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getCallbackUrl_result typedOther = (getCallbackUrl_result)other;

      lastComparison = Boolean.valueOf(isSetPe()).compareTo(isSetPe());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pe, typedOther.pe);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getCallbackUrl_result(");
      boolean first = true;

      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentsForUser_args implements TBase<getPaymentsForUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<getPaymentsForUser_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentsForUser_args");

    private static final TField USER_ID_FIELD_DESC = new TField("userId", TType.I64, (short)1);
    private static final TField FROM_TIME_FIELD_DESC = new TField("from_time", TType.I64, (short)2);
    private static final TField TO_TIME_FIELD_DESC = new TField("to_time", TType.I64, (short)3);
    private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)4);
    private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)5);

    private long userId;
    private long from_time;
    private long to_time;
    private PaymentStatus status;
    private PaymentGateway gateway;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      USER_ID((short)1, "userId"),
      FROM_TIME((short)2, "from_time"),
      TO_TIME((short)3, "to_time"),
      /**
       * 
       * @see PaymentStatus
       */
      STATUS((short)4, "status"),
      /**
       * 
       * @see PaymentGateway
       */
      GATEWAY((short)5, "gateway");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __USERID_ISSET_ID = 0;
    private static final int __FROM_TIME_ISSET_ID = 1;
    private static final int __TO_TIME_ISSET_ID = 2;
    private BitSet __isset_bit_vector = new BitSet(3);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.USER_ID, new FieldMetaData("userId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.FROM_TIME, new FieldMetaData("from_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.TO_TIME, new FieldMetaData("to_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentStatus.class)));
      put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentGateway.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentsForUser_args.class, metaDataMap);
    }

    public getPaymentsForUser_args() {
    }

    public getPaymentsForUser_args(
      long userId,
      long from_time,
      long to_time,
      PaymentStatus status,
      PaymentGateway gateway)
    {
      this();
      this.userId = userId;
      setUserIdIsSet(true);
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      this.to_time = to_time;
      setTo_timeIsSet(true);
      this.status = status;
      this.gateway = gateway;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentsForUser_args(getPaymentsForUser_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.userId = other.userId;
      this.from_time = other.from_time;
      this.to_time = other.to_time;
      if (other.isSetStatus()) {
        this.status = other.status;
      }
      if (other.isSetGateway()) {
        this.gateway = other.gateway;
      }
    }

    public getPaymentsForUser_args deepCopy() {
      return new getPaymentsForUser_args(this);
    }

    @Deprecated
    public getPaymentsForUser_args clone() {
      return new getPaymentsForUser_args(this);
    }

    public long getUserId() {
      return this.userId;
    }

    public getPaymentsForUser_args setUserId(long userId) {
      this.userId = userId;
      setUserIdIsSet(true);
      return this;
    }

    public void unsetUserId() {
      __isset_bit_vector.clear(__USERID_ISSET_ID);
    }

    /** Returns true if field userId is set (has been asigned a value) and false otherwise */
    public boolean isSetUserId() {
      return __isset_bit_vector.get(__USERID_ISSET_ID);
    }

    public void setUserIdIsSet(boolean value) {
      __isset_bit_vector.set(__USERID_ISSET_ID, value);
    }

    public long getFrom_time() {
      return this.from_time;
    }

    public getPaymentsForUser_args setFrom_time(long from_time) {
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      return this;
    }

    public void unsetFrom_time() {
      __isset_bit_vector.clear(__FROM_TIME_ISSET_ID);
    }

    /** Returns true if field from_time is set (has been asigned a value) and false otherwise */
    public boolean isSetFrom_time() {
      return __isset_bit_vector.get(__FROM_TIME_ISSET_ID);
    }

    public void setFrom_timeIsSet(boolean value) {
      __isset_bit_vector.set(__FROM_TIME_ISSET_ID, value);
    }

    public long getTo_time() {
      return this.to_time;
    }

    public getPaymentsForUser_args setTo_time(long to_time) {
      this.to_time = to_time;
      setTo_timeIsSet(true);
      return this;
    }

    public void unsetTo_time() {
      __isset_bit_vector.clear(__TO_TIME_ISSET_ID);
    }

    /** Returns true if field to_time is set (has been asigned a value) and false otherwise */
    public boolean isSetTo_time() {
      return __isset_bit_vector.get(__TO_TIME_ISSET_ID);
    }

    public void setTo_timeIsSet(boolean value) {
      __isset_bit_vector.set(__TO_TIME_ISSET_ID, value);
    }

    /**
     * 
     * @see PaymentStatus
     */
    public PaymentStatus getStatus() {
      return this.status;
    }

    /**
     * 
     * @see PaymentStatus
     */
    public getPaymentsForUser_args setStatus(PaymentStatus status) {
      this.status = status;
      return this;
    }

    public void unsetStatus() {
      this.status = null;
    }

    /** Returns true if field status is set (has been asigned a value) and false otherwise */
    public boolean isSetStatus() {
      return this.status != null;
    }

    public void setStatusIsSet(boolean value) {
      if (!value) {
        this.status = null;
      }
    }

    /**
     * 
     * @see PaymentGateway
     */
    public PaymentGateway getGateway() {
      return this.gateway;
    }

    /**
     * 
     * @see PaymentGateway
     */
    public getPaymentsForUser_args setGateway(PaymentGateway gateway) {
      this.gateway = gateway;
      return this;
    }

    public void unsetGateway() {
      this.gateway = null;
    }

    /** Returns true if field gateway is set (has been asigned a value) and false otherwise */
    public boolean isSetGateway() {
      return this.gateway != null;
    }

    public void setGatewayIsSet(boolean value) {
      if (!value) {
        this.gateway = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case USER_ID:
        if (value == null) {
          unsetUserId();
        } else {
          setUserId((Long)value);
        }
        break;

      case FROM_TIME:
        if (value == null) {
          unsetFrom_time();
        } else {
          setFrom_time((Long)value);
        }
        break;

      case TO_TIME:
        if (value == null) {
          unsetTo_time();
        } else {
          setTo_time((Long)value);
        }
        break;

      case STATUS:
        if (value == null) {
          unsetStatus();
        } else {
          setStatus((PaymentStatus)value);
        }
        break;

      case GATEWAY:
        if (value == null) {
          unsetGateway();
        } else {
          setGateway((PaymentGateway)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case USER_ID:
        return new Long(getUserId());

      case FROM_TIME:
        return new Long(getFrom_time());

      case TO_TIME:
        return new Long(getTo_time());

      case STATUS:
        return getStatus();

      case GATEWAY:
        return getGateway();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case USER_ID:
        return isSetUserId();
      case FROM_TIME:
        return isSetFrom_time();
      case TO_TIME:
        return isSetTo_time();
      case STATUS:
        return isSetStatus();
      case GATEWAY:
        return isSetGateway();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentsForUser_args)
        return this.equals((getPaymentsForUser_args)that);
      return false;
    }

    public boolean equals(getPaymentsForUser_args that) {
      if (that == null)
        return false;

      boolean this_present_userId = true;
      boolean that_present_userId = true;
      if (this_present_userId || that_present_userId) {
        if (!(this_present_userId && that_present_userId))
          return false;
        if (this.userId != that.userId)
          return false;
      }

      boolean this_present_from_time = true;
      boolean that_present_from_time = true;
      if (this_present_from_time || that_present_from_time) {
        if (!(this_present_from_time && that_present_from_time))
          return false;
        if (this.from_time != that.from_time)
          return false;
      }

      boolean this_present_to_time = true;
      boolean that_present_to_time = true;
      if (this_present_to_time || that_present_to_time) {
        if (!(this_present_to_time && that_present_to_time))
          return false;
        if (this.to_time != that.to_time)
          return false;
      }

      boolean this_present_status = true && this.isSetStatus();
      boolean that_present_status = true && that.isSetStatus();
      if (this_present_status || that_present_status) {
        if (!(this_present_status && that_present_status))
          return false;
        if (!this.status.equals(that.status))
          return false;
      }

      boolean this_present_gateway = true && this.isSetGateway();
      boolean that_present_gateway = true && that.isSetGateway();
      if (this_present_gateway || that_present_gateway) {
        if (!(this_present_gateway && that_present_gateway))
          return false;
        if (!this.gateway.equals(that.gateway))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getPaymentsForUser_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getPaymentsForUser_args typedOther = (getPaymentsForUser_args)other;

      lastComparison = Boolean.valueOf(isSetUserId()).compareTo(isSetUserId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(userId, typedOther.userId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetFrom_time()).compareTo(isSetFrom_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(from_time, typedOther.from_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetTo_time()).compareTo(isSetTo_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(to_time, typedOther.to_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(status, typedOther.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(isSetGateway());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(gateway, typedOther.gateway);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case USER_ID:
              if (field.type == TType.I64) {
                this.userId = iprot.readI64();
                setUserIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case FROM_TIME:
              if (field.type == TType.I64) {
                this.from_time = iprot.readI64();
                setFrom_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TO_TIME:
              if (field.type == TType.I64) {
                this.to_time = iprot.readI64();
                setTo_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case STATUS:
              if (field.type == TType.I32) {
                this.status = PaymentStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case GATEWAY:
              if (field.type == TType.I32) {
                this.gateway = PaymentGateway.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(USER_ID_FIELD_DESC);
      oprot.writeI64(this.userId);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(FROM_TIME_FIELD_DESC);
      oprot.writeI64(this.from_time);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(TO_TIME_FIELD_DESC);
      oprot.writeI64(this.to_time);
      oprot.writeFieldEnd();
      if (this.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeI32(this.status.getValue());
        oprot.writeFieldEnd();
      }
      if (this.gateway != null) {
        oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
        oprot.writeI32(this.gateway.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentsForUser_args(");
      boolean first = true;

      sb.append("userId:");
      sb.append(this.userId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("from_time:");
      sb.append(this.from_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("to_time:");
      sb.append(this.to_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("status:");
      if (this.status == null) {
        sb.append("null");
      } else {
        String status_name = status.name();
        if (status_name != null) {
          sb.append(status_name);
          sb.append(" (");
        }
        sb.append(this.status);
        if (status_name != null) {
          sb.append(")");
        }
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("gateway:");
      if (this.gateway == null) {
        sb.append("null");
      } else {
        String gateway_name = gateway.name();
        if (gateway_name != null) {
          sb.append(gateway_name);
          sb.append(" (");
        }
        sb.append(this.gateway);
        if (gateway_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentsForUser_result implements TBase<getPaymentsForUser_result._Fields>, java.io.Serializable, Cloneable   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentsForUser_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private List<Payment> success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Payment.class))));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentsForUser_result.class, metaDataMap);
    }

    public getPaymentsForUser_result() {
    }

    public getPaymentsForUser_result(
      List<Payment> success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentsForUser_result(getPaymentsForUser_result other) {
      if (other.isSetSuccess()) {
        List<Payment> __this__success = new ArrayList<Payment>();
        for (Payment other_element : other.success) {
          __this__success.add(new Payment(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public getPaymentsForUser_result deepCopy() {
      return new getPaymentsForUser_result(this);
    }

    @Deprecated
    public getPaymentsForUser_result clone() {
      return new getPaymentsForUser_result(this);
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<Payment> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(Payment elem) {
      if (this.success == null) {
        this.success = new ArrayList<Payment>();
      }
      this.success.add(elem);
    }

    public List<Payment> getSuccess() {
      return this.success;
    }

    public getPaymentsForUser_result setSuccess(List<Payment> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public getPaymentsForUser_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<Payment>)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentsForUser_result)
        return this.equals((getPaymentsForUser_result)that);
      return false;
    }

    public boolean equals(getPaymentsForUser_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list13 = iprot.readListBegin();
                  this.success = new ArrayList<Payment>(_list13.size);
                  for (int _i14 = 0; _i14 < _list13.size; ++_i14)
                  {
                    Payment _elem15;
                    _elem15 = new Payment();
                    _elem15.read(iprot);
                    this.success.add(_elem15);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (Payment _iter16 : this.success)
          {
            _iter16.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentsForUser_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentsForCart_args implements TBase<getPaymentsForCart_args._Fields>, java.io.Serializable, Cloneable, Comparable<getPaymentsForCart_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentsForCart_args");

    private static final TField CART_ID_FIELD_DESC = new TField("cartId", TType.I64, (short)1);
    private static final TField FROM_TIME_FIELD_DESC = new TField("from_time", TType.I64, (short)2);
    private static final TField TO_TIME_FIELD_DESC = new TField("to_time", TType.I64, (short)3);
    private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)4);
    private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)5);

    private long cartId;
    private long from_time;
    private long to_time;
    private PaymentStatus status;
    private PaymentGateway gateway;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      CART_ID((short)1, "cartId"),
      FROM_TIME((short)2, "from_time"),
      TO_TIME((short)3, "to_time"),
      /**
       * 
       * @see PaymentStatus
       */
      STATUS((short)4, "status"),
      /**
       * 
       * @see PaymentGateway
       */
      GATEWAY((short)5, "gateway");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __CARTID_ISSET_ID = 0;
    private static final int __FROM_TIME_ISSET_ID = 1;
    private static final int __TO_TIME_ISSET_ID = 2;
    private BitSet __isset_bit_vector = new BitSet(3);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.CART_ID, new FieldMetaData("cartId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.FROM_TIME, new FieldMetaData("from_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.TO_TIME, new FieldMetaData("to_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentStatus.class)));
      put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentGateway.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentsForCart_args.class, metaDataMap);
    }

    public getPaymentsForCart_args() {
    }

    public getPaymentsForCart_args(
      long cartId,
      long from_time,
      long to_time,
      PaymentStatus status,
      PaymentGateway gateway)
    {
      this();
      this.cartId = cartId;
      setCartIdIsSet(true);
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      this.to_time = to_time;
      setTo_timeIsSet(true);
      this.status = status;
      this.gateway = gateway;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentsForCart_args(getPaymentsForCart_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.cartId = other.cartId;
      this.from_time = other.from_time;
      this.to_time = other.to_time;
      if (other.isSetStatus()) {
        this.status = other.status;
      }
      if (other.isSetGateway()) {
        this.gateway = other.gateway;
      }
    }

    public getPaymentsForCart_args deepCopy() {
      return new getPaymentsForCart_args(this);
    }

    @Deprecated
    public getPaymentsForCart_args clone() {
      return new getPaymentsForCart_args(this);
    }

    public long getCartId() {
      return this.cartId;
    }

    public getPaymentsForCart_args setCartId(long cartId) {
      this.cartId = cartId;
      setCartIdIsSet(true);
      return this;
    }

    public void unsetCartId() {
      __isset_bit_vector.clear(__CARTID_ISSET_ID);
    }

    /** Returns true if field cartId is set (has been asigned a value) and false otherwise */
    public boolean isSetCartId() {
      return __isset_bit_vector.get(__CARTID_ISSET_ID);
    }

    public void setCartIdIsSet(boolean value) {
      __isset_bit_vector.set(__CARTID_ISSET_ID, value);
    }

    public long getFrom_time() {
      return this.from_time;
    }

    public getPaymentsForCart_args setFrom_time(long from_time) {
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      return this;
    }

    public void unsetFrom_time() {
      __isset_bit_vector.clear(__FROM_TIME_ISSET_ID);
    }

    /** Returns true if field from_time is set (has been asigned a value) and false otherwise */
    public boolean isSetFrom_time() {
      return __isset_bit_vector.get(__FROM_TIME_ISSET_ID);
    }

    public void setFrom_timeIsSet(boolean value) {
      __isset_bit_vector.set(__FROM_TIME_ISSET_ID, value);
    }

    public long getTo_time() {
      return this.to_time;
    }

    public getPaymentsForCart_args setTo_time(long to_time) {
      this.to_time = to_time;
      setTo_timeIsSet(true);
      return this;
    }

    public void unsetTo_time() {
      __isset_bit_vector.clear(__TO_TIME_ISSET_ID);
    }

    /** Returns true if field to_time is set (has been asigned a value) and false otherwise */
    public boolean isSetTo_time() {
      return __isset_bit_vector.get(__TO_TIME_ISSET_ID);
    }

    public void setTo_timeIsSet(boolean value) {
      __isset_bit_vector.set(__TO_TIME_ISSET_ID, value);
    }

    /**
     * 
     * @see PaymentStatus
     */
    public PaymentStatus getStatus() {
      return this.status;
    }

    /**
     * 
     * @see PaymentStatus
     */
    public getPaymentsForCart_args setStatus(PaymentStatus status) {
      this.status = status;
      return this;
    }

    public void unsetStatus() {
      this.status = null;
    }

    /** Returns true if field status is set (has been asigned a value) and false otherwise */
    public boolean isSetStatus() {
      return this.status != null;
    }

    public void setStatusIsSet(boolean value) {
      if (!value) {
        this.status = null;
      }
    }

    /**
     * 
     * @see PaymentGateway
     */
    public PaymentGateway getGateway() {
      return this.gateway;
    }

    /**
     * 
     * @see PaymentGateway
     */
    public getPaymentsForCart_args setGateway(PaymentGateway gateway) {
      this.gateway = gateway;
      return this;
    }

    public void unsetGateway() {
      this.gateway = null;
    }

    /** Returns true if field gateway is set (has been asigned a value) and false otherwise */
    public boolean isSetGateway() {
      return this.gateway != null;
    }

    public void setGatewayIsSet(boolean value) {
      if (!value) {
        this.gateway = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case CART_ID:
        if (value == null) {
          unsetCartId();
        } else {
          setCartId((Long)value);
        }
        break;

      case FROM_TIME:
        if (value == null) {
          unsetFrom_time();
        } else {
          setFrom_time((Long)value);
        }
        break;

      case TO_TIME:
        if (value == null) {
          unsetTo_time();
        } else {
          setTo_time((Long)value);
        }
        break;

      case STATUS:
        if (value == null) {
          unsetStatus();
        } else {
          setStatus((PaymentStatus)value);
        }
        break;

      case GATEWAY:
        if (value == null) {
          unsetGateway();
        } else {
          setGateway((PaymentGateway)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case CART_ID:
        return new Long(getCartId());

      case FROM_TIME:
        return new Long(getFrom_time());

      case TO_TIME:
        return new Long(getTo_time());

      case STATUS:
        return getStatus();

      case GATEWAY:
        return getGateway();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case CART_ID:
        return isSetCartId();
      case FROM_TIME:
        return isSetFrom_time();
      case TO_TIME:
        return isSetTo_time();
      case STATUS:
        return isSetStatus();
      case GATEWAY:
        return isSetGateway();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentsForCart_args)
        return this.equals((getPaymentsForCart_args)that);
      return false;
    }

    public boolean equals(getPaymentsForCart_args that) {
      if (that == null)
        return false;

      boolean this_present_cartId = true;
      boolean that_present_cartId = true;
      if (this_present_cartId || that_present_cartId) {
        if (!(this_present_cartId && that_present_cartId))
          return false;
        if (this.cartId != that.cartId)
          return false;
      }

      boolean this_present_from_time = true;
      boolean that_present_from_time = true;
      if (this_present_from_time || that_present_from_time) {
        if (!(this_present_from_time && that_present_from_time))
          return false;
        if (this.from_time != that.from_time)
          return false;
      }

      boolean this_present_to_time = true;
      boolean that_present_to_time = true;
      if (this_present_to_time || that_present_to_time) {
        if (!(this_present_to_time && that_present_to_time))
          return false;
        if (this.to_time != that.to_time)
          return false;
      }

      boolean this_present_status = true && this.isSetStatus();
      boolean that_present_status = true && that.isSetStatus();
      if (this_present_status || that_present_status) {
        if (!(this_present_status && that_present_status))
          return false;
        if (!this.status.equals(that.status))
          return false;
      }

      boolean this_present_gateway = true && this.isSetGateway();
      boolean that_present_gateway = true && that.isSetGateway();
      if (this_present_gateway || that_present_gateway) {
        if (!(this_present_gateway && that_present_gateway))
          return false;
        if (!this.gateway.equals(that.gateway))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getPaymentsForCart_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getPaymentsForCart_args typedOther = (getPaymentsForCart_args)other;

      lastComparison = Boolean.valueOf(isSetCartId()).compareTo(isSetCartId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(cartId, typedOther.cartId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetFrom_time()).compareTo(isSetFrom_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(from_time, typedOther.from_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetTo_time()).compareTo(isSetTo_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(to_time, typedOther.to_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(status, typedOther.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(isSetGateway());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(gateway, typedOther.gateway);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case CART_ID:
              if (field.type == TType.I64) {
                this.cartId = iprot.readI64();
                setCartIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case FROM_TIME:
              if (field.type == TType.I64) {
                this.from_time = iprot.readI64();
                setFrom_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TO_TIME:
              if (field.type == TType.I64) {
                this.to_time = iprot.readI64();
                setTo_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case STATUS:
              if (field.type == TType.I32) {
                this.status = PaymentStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case GATEWAY:
              if (field.type == TType.I32) {
                this.gateway = PaymentGateway.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
      oprot.writeI64(this.cartId);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(FROM_TIME_FIELD_DESC);
      oprot.writeI64(this.from_time);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(TO_TIME_FIELD_DESC);
      oprot.writeI64(this.to_time);
      oprot.writeFieldEnd();
      if (this.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeI32(this.status.getValue());
        oprot.writeFieldEnd();
      }
      if (this.gateway != null) {
        oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
        oprot.writeI32(this.gateway.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentsForCart_args(");
      boolean first = true;

      sb.append("cartId:");
      sb.append(this.cartId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("from_time:");
      sb.append(this.from_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("to_time:");
      sb.append(this.to_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("status:");
      if (this.status == null) {
        sb.append("null");
      } else {
        String status_name = status.name();
        if (status_name != null) {
          sb.append(status_name);
          sb.append(" (");
        }
        sb.append(this.status);
        if (status_name != null) {
          sb.append(")");
        }
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("gateway:");
      if (this.gateway == null) {
        sb.append("null");
      } else {
        String gateway_name = gateway.name();
        if (gateway_name != null) {
          sb.append(gateway_name);
          sb.append(" (");
        }
        sb.append(this.gateway);
        if (gateway_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentsForCart_result implements TBase<getPaymentsForCart_result._Fields>, java.io.Serializable, Cloneable   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentsForCart_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private List<Payment> success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Payment.class))));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentsForCart_result.class, metaDataMap);
    }

    public getPaymentsForCart_result() {
    }

    public getPaymentsForCart_result(
      List<Payment> success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentsForCart_result(getPaymentsForCart_result other) {
      if (other.isSetSuccess()) {
        List<Payment> __this__success = new ArrayList<Payment>();
        for (Payment other_element : other.success) {
          __this__success.add(new Payment(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public getPaymentsForCart_result deepCopy() {
      return new getPaymentsForCart_result(this);
    }

    @Deprecated
    public getPaymentsForCart_result clone() {
      return new getPaymentsForCart_result(this);
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<Payment> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(Payment elem) {
      if (this.success == null) {
        this.success = new ArrayList<Payment>();
      }
      this.success.add(elem);
    }

    public List<Payment> getSuccess() {
      return this.success;
    }

    public getPaymentsForCart_result setSuccess(List<Payment> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public getPaymentsForCart_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<Payment>)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentsForCart_result)
        return this.equals((getPaymentsForCart_result)that);
      return false;
    }

    public boolean equals(getPaymentsForCart_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list17 = iprot.readListBegin();
                  this.success = new ArrayList<Payment>(_list17.size);
                  for (int _i18 = 0; _i18 < _list17.size; ++_i18)
                  {
                    Payment _elem19;
                    _elem19 = new Payment();
                    _elem19.read(iprot);
                    this.success.add(_elem19);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (Payment _iter20 : this.success)
          {
            _iter20.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentsForCart_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPayments_args implements TBase<getPayments_args._Fields>, java.io.Serializable, Cloneable, Comparable<getPayments_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("getPayments_args");

    private static final TField FROM_TIME_FIELD_DESC = new TField("from_time", TType.I64, (short)1);
    private static final TField TO_TIME_FIELD_DESC = new TField("to_time", TType.I64, (short)2);
    private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)3);
    private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)4);

    private long from_time;
    private long to_time;
    private PaymentStatus status;
    private PaymentGateway gateway;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      FROM_TIME((short)1, "from_time"),
      TO_TIME((short)2, "to_time"),
      /**
       * 
       * @see PaymentStatus
       */
      STATUS((short)3, "status"),
      /**
       * 
       * @see PaymentGateway
       */
      GATEWAY((short)4, "gateway");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __FROM_TIME_ISSET_ID = 0;
    private static final int __TO_TIME_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.FROM_TIME, new FieldMetaData("from_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.TO_TIME, new FieldMetaData("to_time", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentStatus.class)));
      put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentGateway.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPayments_args.class, metaDataMap);
    }

    public getPayments_args() {
    }

    public getPayments_args(
      long from_time,
      long to_time,
      PaymentStatus status,
      PaymentGateway gateway)
    {
      this();
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      this.to_time = to_time;
      setTo_timeIsSet(true);
      this.status = status;
      this.gateway = gateway;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPayments_args(getPayments_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.from_time = other.from_time;
      this.to_time = other.to_time;
      if (other.isSetStatus()) {
        this.status = other.status;
      }
      if (other.isSetGateway()) {
        this.gateway = other.gateway;
      }
    }

    public getPayments_args deepCopy() {
      return new getPayments_args(this);
    }

    @Deprecated
    public getPayments_args clone() {
      return new getPayments_args(this);
    }

    public long getFrom_time() {
      return this.from_time;
    }

    public getPayments_args setFrom_time(long from_time) {
      this.from_time = from_time;
      setFrom_timeIsSet(true);
      return this;
    }

    public void unsetFrom_time() {
      __isset_bit_vector.clear(__FROM_TIME_ISSET_ID);
    }

    /** Returns true if field from_time is set (has been asigned a value) and false otherwise */
    public boolean isSetFrom_time() {
      return __isset_bit_vector.get(__FROM_TIME_ISSET_ID);
    }

    public void setFrom_timeIsSet(boolean value) {
      __isset_bit_vector.set(__FROM_TIME_ISSET_ID, value);
    }

    public long getTo_time() {
      return this.to_time;
    }

    public getPayments_args setTo_time(long to_time) {
      this.to_time = to_time;
      setTo_timeIsSet(true);
      return this;
    }

    public void unsetTo_time() {
      __isset_bit_vector.clear(__TO_TIME_ISSET_ID);
    }

    /** Returns true if field to_time is set (has been asigned a value) and false otherwise */
    public boolean isSetTo_time() {
      return __isset_bit_vector.get(__TO_TIME_ISSET_ID);
    }

    public void setTo_timeIsSet(boolean value) {
      __isset_bit_vector.set(__TO_TIME_ISSET_ID, value);
    }

    /**
     * 
     * @see PaymentStatus
     */
    public PaymentStatus getStatus() {
      return this.status;
    }

    /**
     * 
     * @see PaymentStatus
     */
    public getPayments_args setStatus(PaymentStatus status) {
      this.status = status;
      return this;
    }

    public void unsetStatus() {
      this.status = null;
    }

    /** Returns true if field status is set (has been asigned a value) and false otherwise */
    public boolean isSetStatus() {
      return this.status != null;
    }

    public void setStatusIsSet(boolean value) {
      if (!value) {
        this.status = null;
      }
    }

    /**
     * 
     * @see PaymentGateway
     */
    public PaymentGateway getGateway() {
      return this.gateway;
    }

    /**
     * 
     * @see PaymentGateway
     */
    public getPayments_args setGateway(PaymentGateway gateway) {
      this.gateway = gateway;
      return this;
    }

    public void unsetGateway() {
      this.gateway = null;
    }

    /** Returns true if field gateway is set (has been asigned a value) and false otherwise */
    public boolean isSetGateway() {
      return this.gateway != null;
    }

    public void setGatewayIsSet(boolean value) {
      if (!value) {
        this.gateway = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case FROM_TIME:
        if (value == null) {
          unsetFrom_time();
        } else {
          setFrom_time((Long)value);
        }
        break;

      case TO_TIME:
        if (value == null) {
          unsetTo_time();
        } else {
          setTo_time((Long)value);
        }
        break;

      case STATUS:
        if (value == null) {
          unsetStatus();
        } else {
          setStatus((PaymentStatus)value);
        }
        break;

      case GATEWAY:
        if (value == null) {
          unsetGateway();
        } else {
          setGateway((PaymentGateway)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case FROM_TIME:
        return new Long(getFrom_time());

      case TO_TIME:
        return new Long(getTo_time());

      case STATUS:
        return getStatus();

      case GATEWAY:
        return getGateway();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case FROM_TIME:
        return isSetFrom_time();
      case TO_TIME:
        return isSetTo_time();
      case STATUS:
        return isSetStatus();
      case GATEWAY:
        return isSetGateway();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPayments_args)
        return this.equals((getPayments_args)that);
      return false;
    }

    public boolean equals(getPayments_args that) {
      if (that == null)
        return false;

      boolean this_present_from_time = true;
      boolean that_present_from_time = true;
      if (this_present_from_time || that_present_from_time) {
        if (!(this_present_from_time && that_present_from_time))
          return false;
        if (this.from_time != that.from_time)
          return false;
      }

      boolean this_present_to_time = true;
      boolean that_present_to_time = true;
      if (this_present_to_time || that_present_to_time) {
        if (!(this_present_to_time && that_present_to_time))
          return false;
        if (this.to_time != that.to_time)
          return false;
      }

      boolean this_present_status = true && this.isSetStatus();
      boolean that_present_status = true && that.isSetStatus();
      if (this_present_status || that_present_status) {
        if (!(this_present_status && that_present_status))
          return false;
        if (!this.status.equals(that.status))
          return false;
      }

      boolean this_present_gateway = true && this.isSetGateway();
      boolean that_present_gateway = true && that.isSetGateway();
      if (this_present_gateway || that_present_gateway) {
        if (!(this_present_gateway && that_present_gateway))
          return false;
        if (!this.gateway.equals(that.gateway))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getPayments_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getPayments_args typedOther = (getPayments_args)other;

      lastComparison = Boolean.valueOf(isSetFrom_time()).compareTo(isSetFrom_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(from_time, typedOther.from_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetTo_time()).compareTo(isSetTo_time());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(to_time, typedOther.to_time);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(status, typedOther.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(isSetGateway());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(gateway, typedOther.gateway);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case FROM_TIME:
              if (field.type == TType.I64) {
                this.from_time = iprot.readI64();
                setFrom_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TO_TIME:
              if (field.type == TType.I64) {
                this.to_time = iprot.readI64();
                setTo_timeIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case STATUS:
              if (field.type == TType.I32) {
                this.status = PaymentStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case GATEWAY:
              if (field.type == TType.I32) {
                this.gateway = PaymentGateway.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(FROM_TIME_FIELD_DESC);
      oprot.writeI64(this.from_time);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(TO_TIME_FIELD_DESC);
      oprot.writeI64(this.to_time);
      oprot.writeFieldEnd();
      if (this.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeI32(this.status.getValue());
        oprot.writeFieldEnd();
      }
      if (this.gateway != null) {
        oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
        oprot.writeI32(this.gateway.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPayments_args(");
      boolean first = true;

      sb.append("from_time:");
      sb.append(this.from_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("to_time:");
      sb.append(this.to_time);
      first = false;
      if (!first) sb.append(", ");
      sb.append("status:");
      if (this.status == null) {
        sb.append("null");
      } else {
        String status_name = status.name();
        if (status_name != null) {
          sb.append(status_name);
          sb.append(" (");
        }
        sb.append(this.status);
        if (status_name != null) {
          sb.append(")");
        }
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("gateway:");
      if (this.gateway == null) {
        sb.append("null");
      } else {
        String gateway_name = gateway.name();
        if (gateway_name != null) {
          sb.append(gateway_name);
          sb.append(" (");
        }
        sb.append(this.gateway);
        if (gateway_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPayments_result implements TBase<getPayments_result._Fields>, java.io.Serializable, Cloneable   {
    private static final TStruct STRUCT_DESC = new TStruct("getPayments_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private List<Payment> success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Payment.class))));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPayments_result.class, metaDataMap);
    }

    public getPayments_result() {
    }

    public getPayments_result(
      List<Payment> success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPayments_result(getPayments_result other) {
      if (other.isSetSuccess()) {
        List<Payment> __this__success = new ArrayList<Payment>();
        for (Payment other_element : other.success) {
          __this__success.add(new Payment(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public getPayments_result deepCopy() {
      return new getPayments_result(this);
    }

    @Deprecated
    public getPayments_result clone() {
      return new getPayments_result(this);
    }

    public int getSuccessSize() {
      return (this.success == null) ? 0 : this.success.size();
    }

    public java.util.Iterator<Payment> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(Payment elem) {
      if (this.success == null) {
        this.success = new ArrayList<Payment>();
      }
      this.success.add(elem);
    }

    public List<Payment> getSuccess() {
      return this.success;
    }

    public getPayments_result setSuccess(List<Payment> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public getPayments_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<Payment>)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPayments_result)
        return this.equals((getPayments_result)that);
      return false;
    }

    public boolean equals(getPayments_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list21 = iprot.readListBegin();
                  this.success = new ArrayList<Payment>(_list21.size);
                  for (int _i22 = 0; _i22 < _list21.size; ++_i22)
                  {
                    Payment _elem23;
                    _elem23 = new Payment();
                    _elem23.read(iprot);
                    this.success.add(_elem23);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (Payment _iter24 : this.success)
          {
            _iter24.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPayments_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentForMerchantId_args implements TBase<getPaymentForMerchantId_args._Fields>, java.io.Serializable, Cloneable, Comparable<getPaymentForMerchantId_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentForMerchantId_args");

    private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.I64, (short)1);

    private long merchant_tx_id;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      MERCHANT_TX_ID((short)1, "merchant_tx_id");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __MERCHANT_TX_ID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentForMerchantId_args.class, metaDataMap);
    }

    public getPaymentForMerchantId_args() {
    }

    public getPaymentForMerchantId_args(
      long merchant_tx_id)
    {
      this();
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentForMerchantId_args(getPaymentForMerchantId_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.merchant_tx_id = other.merchant_tx_id;
    }

    public getPaymentForMerchantId_args deepCopy() {
      return new getPaymentForMerchantId_args(this);
    }

    @Deprecated
    public getPaymentForMerchantId_args clone() {
      return new getPaymentForMerchantId_args(this);
    }

    public long getMerchant_tx_id() {
      return this.merchant_tx_id;
    }

    public getPaymentForMerchantId_args setMerchant_tx_id(long merchant_tx_id) {
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
      return this;
    }

    public void unsetMerchant_tx_id() {
      __isset_bit_vector.clear(__MERCHANT_TX_ID_ISSET_ID);
    }

    /** Returns true if field merchant_tx_id is set (has been asigned a value) and false otherwise */
    public boolean isSetMerchant_tx_id() {
      return __isset_bit_vector.get(__MERCHANT_TX_ID_ISSET_ID);
    }

    public void setMerchant_tx_idIsSet(boolean value) {
      __isset_bit_vector.set(__MERCHANT_TX_ID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case MERCHANT_TX_ID:
        if (value == null) {
          unsetMerchant_tx_id();
        } else {
          setMerchant_tx_id((Long)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case MERCHANT_TX_ID:
        return new Long(getMerchant_tx_id());

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case MERCHANT_TX_ID:
        return isSetMerchant_tx_id();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentForMerchantId_args)
        return this.equals((getPaymentForMerchantId_args)that);
      return false;
    }

    public boolean equals(getPaymentForMerchantId_args that) {
      if (that == null)
        return false;

      boolean this_present_merchant_tx_id = true;
      boolean that_present_merchant_tx_id = true;
      if (this_present_merchant_tx_id || that_present_merchant_tx_id) {
        if (!(this_present_merchant_tx_id && that_present_merchant_tx_id))
          return false;
        if (this.merchant_tx_id != that.merchant_tx_id)
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getPaymentForMerchantId_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getPaymentForMerchantId_args typedOther = (getPaymentForMerchantId_args)other;

      lastComparison = Boolean.valueOf(isSetMerchant_tx_id()).compareTo(isSetMerchant_tx_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(merchant_tx_id, typedOther.merchant_tx_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case MERCHANT_TX_ID:
              if (field.type == TType.I64) {
                this.merchant_tx_id = iprot.readI64();
                setMerchant_tx_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(MERCHANT_TX_ID_FIELD_DESC);
      oprot.writeI64(this.merchant_tx_id);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentForMerchantId_args(");
      boolean first = true;

      sb.append("merchant_tx_id:");
      sb.append(this.merchant_tx_id);
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class getPaymentForMerchantId_result implements TBase<getPaymentForMerchantId_result._Fields>, java.io.Serializable, Cloneable   {
    private static final TStruct STRUCT_DESC = new TStruct("getPaymentForMerchantId_result");

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private Payment success;
    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, Payment.class)));
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(getPaymentForMerchantId_result.class, metaDataMap);
    }

    public getPaymentForMerchantId_result() {
    }

    public getPaymentForMerchantId_result(
      Payment success,
      PaymentException pe)
    {
      this();
      this.success = success;
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPaymentForMerchantId_result(getPaymentForMerchantId_result other) {
      if (other.isSetSuccess()) {
        this.success = new Payment(other.success);
      }
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public getPaymentForMerchantId_result deepCopy() {
      return new getPaymentForMerchantId_result(this);
    }

    @Deprecated
    public getPaymentForMerchantId_result clone() {
      return new getPaymentForMerchantId_result(this);
    }

    public Payment getSuccess() {
      return this.success;
    }

    public getPaymentForMerchantId_result setSuccess(Payment success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been asigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public getPaymentForMerchantId_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Payment)value);
        }
        break;

      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getPaymentForMerchantId_result)
        return this.equals((getPaymentForMerchantId_result)that);
      return false;
    }

    public boolean equals(getPaymentForMerchantId_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new Payment();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getPaymentForMerchantId_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class changePaymentStatus_args implements TBase<changePaymentStatus_args._Fields>, java.io.Serializable, Cloneable, Comparable<changePaymentStatus_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("changePaymentStatus_args");

    private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.I64, (short)1);
    private static final TField NEW_STATUS_FIELD_DESC = new TField("newStatus", TType.I32, (short)2);

    private long merchant_tx_id;
    private PaymentStatus newStatus;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      MERCHANT_TX_ID((short)1, "merchant_tx_id"),
      /**
       * 
       * @see PaymentStatus
       */
      NEW_STATUS((short)2, "newStatus");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __MERCHANT_TX_ID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.NEW_STATUS, new FieldMetaData("newStatus", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, PaymentStatus.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(changePaymentStatus_args.class, metaDataMap);
    }

    public changePaymentStatus_args() {
    }

    public changePaymentStatus_args(
      long merchant_tx_id,
      PaymentStatus newStatus)
    {
      this();
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
      this.newStatus = newStatus;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public changePaymentStatus_args(changePaymentStatus_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.merchant_tx_id = other.merchant_tx_id;
      if (other.isSetNewStatus()) {
        this.newStatus = other.newStatus;
      }
    }

    public changePaymentStatus_args deepCopy() {
      return new changePaymentStatus_args(this);
    }

    @Deprecated
    public changePaymentStatus_args clone() {
      return new changePaymentStatus_args(this);
    }

    public long getMerchant_tx_id() {
      return this.merchant_tx_id;
    }

    public changePaymentStatus_args setMerchant_tx_id(long merchant_tx_id) {
      this.merchant_tx_id = merchant_tx_id;
      setMerchant_tx_idIsSet(true);
      return this;
    }

    public void unsetMerchant_tx_id() {
      __isset_bit_vector.clear(__MERCHANT_TX_ID_ISSET_ID);
    }

    /** Returns true if field merchant_tx_id is set (has been asigned a value) and false otherwise */
    public boolean isSetMerchant_tx_id() {
      return __isset_bit_vector.get(__MERCHANT_TX_ID_ISSET_ID);
    }

    public void setMerchant_tx_idIsSet(boolean value) {
      __isset_bit_vector.set(__MERCHANT_TX_ID_ISSET_ID, value);
    }

    /**
     * 
     * @see PaymentStatus
     */
    public PaymentStatus getNewStatus() {
      return this.newStatus;
    }

    /**
     * 
     * @see PaymentStatus
     */
    public changePaymentStatus_args setNewStatus(PaymentStatus newStatus) {
      this.newStatus = newStatus;
      return this;
    }

    public void unsetNewStatus() {
      this.newStatus = null;
    }

    /** Returns true if field newStatus is set (has been asigned a value) and false otherwise */
    public boolean isSetNewStatus() {
      return this.newStatus != null;
    }

    public void setNewStatusIsSet(boolean value) {
      if (!value) {
        this.newStatus = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case MERCHANT_TX_ID:
        if (value == null) {
          unsetMerchant_tx_id();
        } else {
          setMerchant_tx_id((Long)value);
        }
        break;

      case NEW_STATUS:
        if (value == null) {
          unsetNewStatus();
        } else {
          setNewStatus((PaymentStatus)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case MERCHANT_TX_ID:
        return new Long(getMerchant_tx_id());

      case NEW_STATUS:
        return getNewStatus();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case MERCHANT_TX_ID:
        return isSetMerchant_tx_id();
      case NEW_STATUS:
        return isSetNewStatus();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof changePaymentStatus_args)
        return this.equals((changePaymentStatus_args)that);
      return false;
    }

    public boolean equals(changePaymentStatus_args that) {
      if (that == null)
        return false;

      boolean this_present_merchant_tx_id = true;
      boolean that_present_merchant_tx_id = true;
      if (this_present_merchant_tx_id || that_present_merchant_tx_id) {
        if (!(this_present_merchant_tx_id && that_present_merchant_tx_id))
          return false;
        if (this.merchant_tx_id != that.merchant_tx_id)
          return false;
      }

      boolean this_present_newStatus = true && this.isSetNewStatus();
      boolean that_present_newStatus = true && that.isSetNewStatus();
      if (this_present_newStatus || that_present_newStatus) {
        if (!(this_present_newStatus && that_present_newStatus))
          return false;
        if (!this.newStatus.equals(that.newStatus))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(changePaymentStatus_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      changePaymentStatus_args typedOther = (changePaymentStatus_args)other;

      lastComparison = Boolean.valueOf(isSetMerchant_tx_id()).compareTo(isSetMerchant_tx_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(merchant_tx_id, typedOther.merchant_tx_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetNewStatus()).compareTo(isSetNewStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(newStatus, typedOther.newStatus);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case MERCHANT_TX_ID:
              if (field.type == TType.I64) {
                this.merchant_tx_id = iprot.readI64();
                setMerchant_tx_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case NEW_STATUS:
              if (field.type == TType.I32) {
                this.newStatus = PaymentStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(MERCHANT_TX_ID_FIELD_DESC);
      oprot.writeI64(this.merchant_tx_id);
      oprot.writeFieldEnd();
      if (this.newStatus != null) {
        oprot.writeFieldBegin(NEW_STATUS_FIELD_DESC);
        oprot.writeI32(this.newStatus.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("changePaymentStatus_args(");
      boolean first = true;

      sb.append("merchant_tx_id:");
      sb.append(this.merchant_tx_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("newStatus:");
      if (this.newStatus == null) {
        sb.append("null");
      } else {
        String newStatus_name = newStatus.name();
        if (newStatus_name != null) {
          sb.append(newStatus_name);
          sb.append(" (");
        }
        sb.append(this.newStatus);
        if (newStatus_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class changePaymentStatus_result implements TBase<changePaymentStatus_result._Fields>, java.io.Serializable, Cloneable, Comparable<changePaymentStatus_result>   {
    private static final TStruct STRUCT_DESC = new TStruct("changePaymentStatus_result");

    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(changePaymentStatus_result.class, metaDataMap);
    }

    public changePaymentStatus_result() {
    }

    public changePaymentStatus_result(
      PaymentException pe)
    {
      this();
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public changePaymentStatus_result(changePaymentStatus_result other) {
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public changePaymentStatus_result deepCopy() {
      return new changePaymentStatus_result(this);
    }

    @Deprecated
    public changePaymentStatus_result clone() {
      return new changePaymentStatus_result(this);
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public changePaymentStatus_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof changePaymentStatus_result)
        return this.equals((changePaymentStatus_result)that);
      return false;
    }

    public boolean equals(changePaymentStatus_result that) {
      if (that == null)
        return false;

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(changePaymentStatus_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      changePaymentStatus_result typedOther = (changePaymentStatus_result)other;

      lastComparison = Boolean.valueOf(isSetPe()).compareTo(isSetPe());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pe, typedOther.pe);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("changePaymentStatus_result(");
      boolean first = true;

      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class changePaymentRequestStatus_args implements TBase<changePaymentRequestStatus_args._Fields>, java.io.Serializable, Cloneable, Comparable<changePaymentRequestStatus_args>   {
    private static final TStruct STRUCT_DESC = new TStruct("changePaymentRequestStatus_args");

    private static final TField REQUEST_ID_FIELD_DESC = new TField("request_id", TType.I64, (short)1);
    private static final TField REQUEST_STATUS_FIELD_DESC = new TField("requestStatus", TType.I32, (short)2);

    private long request_id;
    private RequestStatus requestStatus;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      REQUEST_ID((short)1, "request_id"),
      /**
       * 
       * @see RequestStatus
       */
      REQUEST_STATUS((short)2, "requestStatus");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    private static final int __REQUEST_ID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.REQUEST_ID, new FieldMetaData("request_id", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.REQUEST_STATUS, new FieldMetaData("requestStatus", TFieldRequirementType.DEFAULT, 
          new EnumMetaData(TType.ENUM, RequestStatus.class)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(changePaymentRequestStatus_args.class, metaDataMap);
    }

    public changePaymentRequestStatus_args() {
    }

    public changePaymentRequestStatus_args(
      long request_id,
      RequestStatus requestStatus)
    {
      this();
      this.request_id = request_id;
      setRequest_idIsSet(true);
      this.requestStatus = requestStatus;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public changePaymentRequestStatus_args(changePaymentRequestStatus_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.request_id = other.request_id;
      if (other.isSetRequestStatus()) {
        this.requestStatus = other.requestStatus;
      }
    }

    public changePaymentRequestStatus_args deepCopy() {
      return new changePaymentRequestStatus_args(this);
    }

    @Deprecated
    public changePaymentRequestStatus_args clone() {
      return new changePaymentRequestStatus_args(this);
    }

    public long getRequest_id() {
      return this.request_id;
    }

    public changePaymentRequestStatus_args setRequest_id(long request_id) {
      this.request_id = request_id;
      setRequest_idIsSet(true);
      return this;
    }

    public void unsetRequest_id() {
      __isset_bit_vector.clear(__REQUEST_ID_ISSET_ID);
    }

    /** Returns true if field request_id is set (has been asigned a value) and false otherwise */
    public boolean isSetRequest_id() {
      return __isset_bit_vector.get(__REQUEST_ID_ISSET_ID);
    }

    public void setRequest_idIsSet(boolean value) {
      __isset_bit_vector.set(__REQUEST_ID_ISSET_ID, value);
    }

    /**
     * 
     * @see RequestStatus
     */
    public RequestStatus getRequestStatus() {
      return this.requestStatus;
    }

    /**
     * 
     * @see RequestStatus
     */
    public changePaymentRequestStatus_args setRequestStatus(RequestStatus requestStatus) {
      this.requestStatus = requestStatus;
      return this;
    }

    public void unsetRequestStatus() {
      this.requestStatus = null;
    }

    /** Returns true if field requestStatus is set (has been asigned a value) and false otherwise */
    public boolean isSetRequestStatus() {
      return this.requestStatus != null;
    }

    public void setRequestStatusIsSet(boolean value) {
      if (!value) {
        this.requestStatus = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case REQUEST_ID:
        if (value == null) {
          unsetRequest_id();
        } else {
          setRequest_id((Long)value);
        }
        break;

      case REQUEST_STATUS:
        if (value == null) {
          unsetRequestStatus();
        } else {
          setRequestStatus((RequestStatus)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case REQUEST_ID:
        return new Long(getRequest_id());

      case REQUEST_STATUS:
        return getRequestStatus();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case REQUEST_ID:
        return isSetRequest_id();
      case REQUEST_STATUS:
        return isSetRequestStatus();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof changePaymentRequestStatus_args)
        return this.equals((changePaymentRequestStatus_args)that);
      return false;
    }

    public boolean equals(changePaymentRequestStatus_args that) {
      if (that == null)
        return false;

      boolean this_present_request_id = true;
      boolean that_present_request_id = true;
      if (this_present_request_id || that_present_request_id) {
        if (!(this_present_request_id && that_present_request_id))
          return false;
        if (this.request_id != that.request_id)
          return false;
      }

      boolean this_present_requestStatus = true && this.isSetRequestStatus();
      boolean that_present_requestStatus = true && that.isSetRequestStatus();
      if (this_present_requestStatus || that_present_requestStatus) {
        if (!(this_present_requestStatus && that_present_requestStatus))
          return false;
        if (!this.requestStatus.equals(that.requestStatus))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(changePaymentRequestStatus_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      changePaymentRequestStatus_args typedOther = (changePaymentRequestStatus_args)other;

      lastComparison = Boolean.valueOf(isSetRequest_id()).compareTo(isSetRequest_id());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(request_id, typedOther.request_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetRequestStatus()).compareTo(isSetRequestStatus());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(requestStatus, typedOther.requestStatus);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case REQUEST_ID:
              if (field.type == TType.I64) {
                this.request_id = iprot.readI64();
                setRequest_idIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case REQUEST_STATUS:
              if (field.type == TType.I32) {
                this.requestStatus = RequestStatus.findByValue(iprot.readI32());
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(REQUEST_ID_FIELD_DESC);
      oprot.writeI64(this.request_id);
      oprot.writeFieldEnd();
      if (this.requestStatus != null) {
        oprot.writeFieldBegin(REQUEST_STATUS_FIELD_DESC);
        oprot.writeI32(this.requestStatus.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("changePaymentRequestStatus_args(");
      boolean first = true;

      sb.append("request_id:");
      sb.append(this.request_id);
      first = false;
      if (!first) sb.append(", ");
      sb.append("requestStatus:");
      if (this.requestStatus == null) {
        sb.append("null");
      } else {
        String requestStatus_name = requestStatus.name();
        if (requestStatus_name != null) {
          sb.append(requestStatus_name);
          sb.append(" (");
        }
        sb.append(this.requestStatus);
        if (requestStatus_name != null) {
          sb.append(")");
        }
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

  public static class changePaymentRequestStatus_result implements TBase<changePaymentRequestStatus_result._Fields>, java.io.Serializable, Cloneable, Comparable<changePaymentRequestStatus_result>   {
    private static final TStruct STRUCT_DESC = new TStruct("changePaymentRequestStatus_result");

    private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short)1);

    private PaymentException pe;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PE((short)1, "pe");

      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byId.put((int)field._thriftId, field);
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        return byId.get(fieldId);
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

    static {
      FieldMetaData.addStructMetaDataMap(changePaymentRequestStatus_result.class, metaDataMap);
    }

    public changePaymentRequestStatus_result() {
    }

    public changePaymentRequestStatus_result(
      PaymentException pe)
    {
      this();
      this.pe = pe;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public changePaymentRequestStatus_result(changePaymentRequestStatus_result other) {
      if (other.isSetPe()) {
        this.pe = new PaymentException(other.pe);
      }
    }

    public changePaymentRequestStatus_result deepCopy() {
      return new changePaymentRequestStatus_result(this);
    }

    @Deprecated
    public changePaymentRequestStatus_result clone() {
      return new changePaymentRequestStatus_result(this);
    }

    public PaymentException getPe() {
      return this.pe;
    }

    public changePaymentRequestStatus_result setPe(PaymentException pe) {
      this.pe = pe;
      return this;
    }

    public void unsetPe() {
      this.pe = null;
    }

    /** Returns true if field pe is set (has been asigned a value) and false otherwise */
    public boolean isSetPe() {
      return this.pe != null;
    }

    public void setPeIsSet(boolean value) {
      if (!value) {
        this.pe = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PE:
        if (value == null) {
          unsetPe();
        } else {
          setPe((PaymentException)value);
        }
        break;

      }
    }

    public void setFieldValue(int fieldID, Object value) {
      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PE:
        return getPe();

      }
      throw new IllegalStateException();
    }

    public Object getFieldValue(int fieldId) {
      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
    }

    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      switch (field) {
      case PE:
        return isSetPe();
      }
      throw new IllegalStateException();
    }

    public boolean isSet(int fieldID) {
      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof changePaymentRequestStatus_result)
        return this.equals((changePaymentRequestStatus_result)that);
      return false;
    }

    public boolean equals(changePaymentRequestStatus_result that) {
      if (that == null)
        return false;

      boolean this_present_pe = true && this.isSetPe();
      boolean that_present_pe = true && that.isSetPe();
      if (this_present_pe || that_present_pe) {
        if (!(this_present_pe && that_present_pe))
          return false;
        if (!this.pe.equals(that.pe))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(changePaymentRequestStatus_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      changePaymentRequestStatus_result typedOther = (changePaymentRequestStatus_result)other;

      lastComparison = Boolean.valueOf(isSetPe()).compareTo(isSetPe());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pe, typedOther.pe);
      if (lastComparison != 0) {
        return lastComparison;
      }
      return 0;
    }

    public void read(TProtocol iprot) throws TException {
      TField field;
      iprot.readStructBegin();
      while (true)
      {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) { 
          break;
        }
        _Fields fieldId = _Fields.findByThriftId(field.id);
        if (fieldId == null) {
          TProtocolUtil.skip(iprot, field.type);
        } else {
          switch (fieldId) {
            case PE:
              if (field.type == TType.STRUCT) {
                this.pe = new PaymentException();
                this.pe.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPe()) {
        oprot.writeFieldBegin(PE_FIELD_DESC);
        this.pe.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("changePaymentRequestStatus_result(");
      boolean first = true;

      sb.append("pe:");
      if (this.pe == null) {
        sb.append("null");
      } else {
        sb.append(this.pe);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws TException {
      // check for required fields
    }

  }

}