-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from konduto/events-field-support
Events field support
- Loading branch information
Showing
14 changed files
with
688 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.konduto.sdk.models; | ||
|
||
import com.konduto.sdk.annotations.Required; | ||
import com.konduto.sdk.annotations.ValidateFormat; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Model that represents an event. | ||
* | ||
* @see <a href="http://docs.konduto.com">Konduto API Spec</a> | ||
*/ | ||
public class KondutoEvent extends KondutoModel { | ||
|
||
@Required | ||
private String name; | ||
|
||
@Required | ||
@ValidateFormat( | ||
format = "\\d{4}-(10|11|12|0\\d)-(30|31|[0-2]\\d)T(20|21|22|23|24|[0-1]?\\d):[0-5]?\\d(:[0-5]?\\d)?Z" | ||
) | ||
private String date; | ||
|
||
private KondutoEventType type; | ||
|
||
private String subtype; | ||
|
||
private KondutoEventVenue venue; | ||
|
||
private List<KondutoEventTicket> tickets; | ||
|
||
/** | ||
* Fluent constructor | ||
* @param attributeName the attribute name (e.g totalAmount) | ||
* @param attributeValue the attribute value (e.g 123.2) | ||
* @return a new instance | ||
*/ | ||
@Override | ||
public KondutoEvent with(String attributeName, Object attributeValue) { | ||
return (KondutoEvent) super.with(attributeName, attributeValue); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
KondutoEvent that = (KondutoEvent) o; | ||
|
||
if (!name.equals(that.name)) return false; | ||
return date.equals(that.date); | ||
} | ||
|
||
@Override | ||
public boolean isValid() { | ||
boolean isValid = true; | ||
if (tickets != null) { | ||
for (KondutoEventTicket ticket : tickets) { | ||
isValid &= ticket.isValid(); | ||
} | ||
} | ||
|
||
return isValid && super.isValid(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(String date) { | ||
this.date = date; | ||
} | ||
|
||
public KondutoEventType getType() { | ||
return type; | ||
} | ||
|
||
public void setType(KondutoEventType type) { | ||
this.type = type; | ||
} | ||
|
||
public String getSubtype() { | ||
return subtype; | ||
} | ||
|
||
public void setSubtype(String subtype) { | ||
this.subtype = subtype; | ||
} | ||
|
||
public KondutoEventVenue getVenue() { | ||
return venue; | ||
} | ||
|
||
public void setVenue(KondutoEventVenue venue) { | ||
this.venue = venue; | ||
} | ||
|
||
public List<KondutoEventTicket> getTickets() { | ||
return tickets; | ||
} | ||
|
||
public void setTickets(List<KondutoEventTicket> tickets) { | ||
this.tickets = tickets; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/main/java/com/konduto/sdk/models/KondutoEventTicket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.konduto.sdk.models; | ||
|
||
import com.konduto.sdk.annotations.Required; | ||
|
||
/** | ||
* Model that represents an event ticket. | ||
* | ||
* @see <a href="http://docs.konduto.com">Konduto API Spec</a> | ||
*/ | ||
public class KondutoEventTicket extends KondutoModel { | ||
|
||
private String id; | ||
|
||
@Required | ||
private KondutoEventTicketCategory category; | ||
|
||
@Required | ||
private Boolean premium; | ||
|
||
private String section; | ||
|
||
private KondutoEventTicketAttendee attendee; | ||
|
||
/** | ||
* Fluent constructor | ||
* @param attributeName the attribute name (e.g totalAmount) | ||
* @param attributeValue the attribute value (e.g 123.2) | ||
* @return a new instance | ||
*/ | ||
@Override | ||
public KondutoEventTicket with(String attributeName, Object attributeValue) { | ||
return (KondutoEventTicket) super.with(attributeName, attributeValue); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(!(obj instanceof KondutoEventTicket)) { return false; } | ||
KondutoEventTicket that = (KondutoEventTicket) obj; | ||
|
||
if (id == null || !id.equals(that.id)) return false; | ||
if (section == null || !section.equals(that.section)) return false; | ||
if (category == null || !category.equals(that.category)) return false; | ||
return attendee != null && attendee.equals(that.attendee); | ||
} | ||
|
||
@Override | ||
public boolean isValid() { | ||
if (attendee != null) return attendee.isValid() && super.isValid(); | ||
return super.isValid(); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public KondutoEventTicketCategory getCategory() { | ||
return category; | ||
} | ||
|
||
public void setCategory(KondutoEventTicketCategory category) { | ||
this.category = category; | ||
} | ||
|
||
public String getSection() { | ||
return section; | ||
} | ||
|
||
public void setSection(String section) { | ||
this.section = section; | ||
} | ||
|
||
public Boolean getPremium() { | ||
return premium; | ||
} | ||
|
||
public void setPremium(Boolean premium) { | ||
this.premium = premium; | ||
} | ||
|
||
public KondutoEventTicketAttendee getAttendee() { | ||
return attendee; | ||
} | ||
|
||
public void setAttendee(KondutoEventTicketAttendee attendee) { | ||
this.attendee = attendee; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/com/konduto/sdk/models/KondutoEventTicketAttendee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.konduto.sdk.models; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import com.konduto.sdk.annotations.Required; | ||
import com.konduto.sdk.annotations.ValidateFormat; | ||
|
||
/** | ||
* Model representing an attendee to an event. | ||
* | ||
* @see <a href="http://docs.konduto.com">Konduto API Spec</a> | ||
* | ||
*/ | ||
public class KondutoEventTicketAttendee extends KondutoModel { | ||
|
||
@Required | ||
private String document; | ||
|
||
private KondutoEventTicketAttendeeDocumentType documentType; | ||
|
||
@SerializedName("dob") | ||
@ValidateFormat(format = "\\d{4}-(10|11|12|0\\d)-(30|31|[0-2]\\d)") | ||
private String dateOfBirth; | ||
|
||
private String name; | ||
|
||
/** | ||
* Fluent constructor | ||
* @param attributeName the attribute name (e.g totalAmount) | ||
* @param attributeValue the attribute value (e.g 123.2) | ||
* @return a new instance | ||
*/ | ||
@Override | ||
public KondutoEventTicketAttendee with(String attributeName, Object attributeValue) { | ||
return (KondutoEventTicketAttendee) super.with(attributeName, attributeValue); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if(!(obj instanceof KondutoEventTicketAttendee)) { return false; } | ||
KondutoEventTicketAttendee that = (KondutoEventTicketAttendee) obj; | ||
return this.document != null && this.document.equals(that.document); | ||
} | ||
|
||
public KondutoEventTicketAttendeeDocumentType getDocumentType() { | ||
return documentType; | ||
} | ||
|
||
public void setDocumentType(KondutoEventTicketAttendeeDocumentType documentType) { | ||
this.documentType = documentType; | ||
} | ||
|
||
public String getDateOfBirth() { | ||
return dateOfBirth; | ||
} | ||
|
||
public void setDateOfBirth(String dateOfBirth) { | ||
this.dateOfBirth = dateOfBirth; | ||
} | ||
|
||
public String getDocument() { | ||
return document; | ||
} | ||
|
||
public void setDocument(String document) { | ||
this.document = document; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/konduto/sdk/models/KondutoEventTicketAttendeeDocumentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.konduto.sdk.models; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* Enum representing the types of documents Konduto's API accepts when handling event tickets attendee's | ||
* | ||
* @see <a href="http://docs.konduto.com">Konduto API Spec</a> | ||
*/ | ||
public enum KondutoEventTicketAttendeeDocumentType { | ||
@SerializedName("cpf") | ||
CPF, | ||
@SerializedName("cnpj") | ||
CNPJ, | ||
@SerializedName("rg") | ||
RG, | ||
@SerializedName("passport") | ||
PASSPORT, | ||
@SerializedName("other") | ||
OTHER | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/konduto/sdk/models/KondutoEventTicketCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.konduto.sdk.models; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* Enum representing a event ticket category. | ||
* For instance, if the ticket was bought by a student it will probably have a discount. The same applies to | ||
* senior citizens. | ||
* | ||
* @see <a href="http://docs.konduto.com">Konduto API Spec</a> | ||
*/ | ||
public enum KondutoEventTicketCategory { | ||
@SerializedName("student") | ||
STUDENT, | ||
@SerializedName("senior") | ||
SENIOR, | ||
@SerializedName("government") | ||
GOVERNMENT, | ||
@SerializedName("social") | ||
SOCIAL, | ||
@SerializedName("regular") | ||
REGULAR | ||
} |
Oops, something went wrong.