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; 025import javax.xml.bind.annotation.XmlTransient; 026 027@XmlRootElement(name = "account_acquisition") 028public class AccountAcquisition extends RecurlyObject { 029 030 @XmlTransient 031 public static final String ACCOUNT_ACQUISITION_RESOURCE = "/acquisition"; 032 033 @XmlElement(name = "cost_in_cents") 034 private Integer costInCents; 035 036 @XmlElement(name = "currency") 037 private String currency; 038 039 @XmlElement(name = "channel") 040 private AcquisitionChannel channel; 041 042 @XmlElement(name = "subchannel") 043 private String subchannel; 044 045 @XmlElement(name = "campaign") 046 private String campaign; 047 048 @XmlElement(name = "created_at") 049 private DateTime createdAt; 050 051 @XmlElement(name = "updated_at") 052 private DateTime updatedAt; 053 054 public Integer getCostInCents() { 055 return costInCents; 056 } 057 058 public void setCostInCents(final Object costInCents) { 059 this.costInCents = integerOrNull(costInCents); 060 } 061 062 public String getCurrency() { 063 return currency; 064 } 065 066 public void setCurrency(final Object currency) { 067 this.currency = stringOrNull(currency); 068 } 069 070 public AcquisitionChannel getChannel() { 071 return channel; 072 } 073 074 public void setChannel(final AcquisitionChannel channel) { 075 this.channel = channel; 076 } 077 078 public String getSubchannel() { 079 return subchannel; 080 } 081 082 public void setSubchannel(final Object subchannel) { 083 this.subchannel = stringOrNull(subchannel); 084 } 085 086 public String getCampaign() { 087 return campaign; 088 } 089 090 public void setCampaign(final Object campaign) { 091 this.campaign = stringOrNull(campaign); 092 } 093 094 public DateTime getCreatedAt() { 095 return createdAt; 096 } 097 098 protected void setCreatedAt(final Object createdAt) { 099 this.createdAt = dateTimeOrNull(createdAt); 100 } 101 102 public DateTime getUpdatedAt() { 103 return updatedAt; 104 } 105 106 protected void setUpdatedAt(final Object updatedAt) { 107 this.updatedAt = dateTimeOrNull(updatedAt); 108 } 109 110 @Override 111 public String toString() { 112 final StringBuilder sb = new StringBuilder("Account{"); 113 sb.append("href=").append(href); 114 sb.append(", costInCents=").append(costInCents); 115 sb.append(", currency=").append(currency); 116 sb.append(", channel=").append(channel); 117 sb.append(", subchannel=").append(subchannel); 118 sb.append(", campaign=").append(campaign); 119 sb.append(", createdAt=").append(createdAt); 120 sb.append(", updatedAt=").append(updatedAt); 121 sb.append('}'); 122 return sb.toString(); 123 } 124 125 @Override 126 public boolean equals(final Object o) { 127 if (this == o) return true; 128 if (o == null || getClass() != o.getClass()) return false; 129 130 final AccountAcquisition accountAcquisition = (AccountAcquisition) o; 131 132 if (campaign!= null ? !campaign.equals(accountAcquisition.campaign) : accountAcquisition.campaign!= null) { 133 return false; 134 } 135 if (channel != null ? !channel.equals(accountAcquisition.channel) : accountAcquisition.channel!= null) { 136 return false; 137 } 138 if (costInCents != null ? !costInCents.equals(accountAcquisition.costInCents) : accountAcquisition.costInCents != null) { 139 return false; 140 } 141 if (createdAt != null ? createdAt.compareTo(accountAcquisition.createdAt) != 0 : accountAcquisition.createdAt != null) { 142 return false; 143 } 144 if (currency != null ? !currency.equals(accountAcquisition.currency) : accountAcquisition.currency != null) { 145 return false; 146 } 147 if (href != null ? !href.equals(accountAcquisition.href) : accountAcquisition.href != null) { 148 return false; 149 } 150 if (subchannel != null ? !subchannel.equals(accountAcquisition.subchannel) : accountAcquisition.subchannel!= null) { 151 return false; 152 } 153 if (updatedAt != null ? updatedAt.compareTo(accountAcquisition.updatedAt) != 0 : accountAcquisition.updatedAt != null) { 154 return false; 155 } 156 157 return true; 158 } 159 160 @Override 161 public int hashCode() { 162 return Objects.hashCode( 163 campaign, 164 channel, 165 costInCents, 166 createdAt, 167 currency, 168 href, 169 subchannel, 170 updatedAt 171 ); 172 } 173}