001/*
002 * Copyright 2010-2014 Ning, Inc.
003 * Copyright 2014-2015 The Billing Project, LLC
004 *
005 * The Billing Project licenses this file to you under the Apache License, version 2.0
006 * (the "License"); you may not use this file except in compliance with the
007 * License.  You may obtain a copy of the License at:
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
014 * License for the specific language governing permissions and limitations
015 * under the License.
016 */
017
018package com.ning.billing.recurly.model;
019
020import com.google.common.base.Objects;
021import org.joda.time.DateTime;
022
023import javax.xml.bind.annotation.XmlElement;
024import javax.xml.bind.annotation.XmlRootElement;
025
026@XmlRootElement(name = "credit_payment")
027public class CreditPayment extends RecurlyObject {
028
029    @XmlElement(name = "action")
030    private String action;
031
032    @XmlElement(name = "amount_in_cents")
033    private Integer amountInCents;
034
035    @XmlElement(name = "applied_to_invoice")
036    private String appliedToInvoice;
037
038    @XmlElement(name = "currency")
039    private String currency;
040
041    @XmlElement(name = "uuid")
042    private String uuid;
043
044    @XmlElement(name = "created_at")
045    private DateTime createdAt;
046
047    @XmlElement(name = "updated_at")
048    private DateTime updatedAt;
049
050    @XmlElement(name = "voided_at")
051    private DateTime voidedAt;
052
053    public String getUuid() {
054        return uuid;
055    }
056
057    public void setUuid(final Object uuid) {
058        this.uuid = stringOrNull(uuid);
059    }
060
061    public String getCurrency() {
062        return currency;
063    }
064
065    public void setCurrency(final Object currency) {
066        this.currency = stringOrNull(currency);
067    }
068
069    public DateTime getCreatedAt() {
070        return createdAt;
071    }
072
073    public void setCreatedAt(final Object createdAt) {
074        this.createdAt = dateTimeOrNull(createdAt);
075    }
076
077    public DateTime getUpdatedAt() {
078        return updatedAt;
079    }
080
081    public void setUpdatedAt(final Object updatedAt) {
082        this.updatedAt = dateTimeOrNull(updatedAt);
083    }
084
085    public DateTime getVoidedAt() {
086        return voidedAt;
087    }
088
089    public void setVoidedAt(final Object voidedAt) {
090        this.voidedAt = dateTimeOrNull(voidedAt);
091    }
092
093    public Integer getAmountInCents() {
094        return amountInCents;
095    }
096
097    public void setAmountInCents(final Object amountInCents) {
098        this.amountInCents = integerOrNull(amountInCents);
099    }
100
101    public String getAppliedToInvoice() {
102        return appliedToInvoice;
103    } 
104
105    public void setAppliedToInvoice(final Object appliedToInvoice) {
106        this.appliedToInvoice = stringOrNull(appliedToInvoice);
107    }
108
109
110    @Override
111    public String toString() {
112        final StringBuilder sb = new StringBuilder();
113        sb.append("CreditPayment");
114        sb.append("{uuid='").append(uuid).append('\'');
115        sb.append(", currency='").append(currency).append('\'');
116        sb.append(", createdAt=").append(createdAt);
117        sb.append(", updatedAt=").append(updatedAt);
118        sb.append(", voidedAt=").append(voidedAt);
119        sb.append(", appliedToInvoice=").append(appliedToInvoice);
120        sb.append('}');
121        return sb.toString();
122    }
123
124    @Override
125    public boolean equals(final Object o) {
126        if (this == o) return true;
127        if (o == null || getClass() != o.getClass()) return false;
128
129        final CreditPayment that = (CreditPayment) o;
130
131        if (action != null ? !action.equals(that.action) : that.action != null) {
132            return false;
133        }
134        if (amountInCents != null ? !amountInCents.equals(that.amountInCents) : that.amountInCents != null) {
135            return false;
136        }
137        if (createdAt != null ? createdAt.compareTo(that.createdAt) != 0 : that.createdAt != null) {
138            return false;
139        }
140        if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
141            return false;
142        }
143        if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) {
144            return false;
145        }
146        if (updatedAt != null ? updatedAt.compareTo(that.updatedAt) != 0 : that.updatedAt != null) {
147            return false;
148        }
149        if (voidedAt != null ? voidedAt.compareTo(that.voidedAt) != 0 : that.voidedAt != null) {
150            return false;
151        }
152        if (appliedToInvoice != null ? appliedToInvoice.equals(that.appliedToInvoice) : that.appliedToInvoice != null) {
153            return false;
154        }
155
156        return true;
157    }
158
159    @Override
160    public int hashCode() {
161        return Objects.hashCode(
162                action,
163                amountInCents,
164                createdAt,
165                currency,
166                updatedAt,
167                uuid,
168                voidedAt,
169                appliedToInvoice
170        );
171    }
172}