Skip to content

Commit

Permalink
Merge pull request #16 from konduto/events-field-support
Browse files Browse the repository at this point in the history
Events field support
  • Loading branch information
Raphael Sampaio authored Mar 16, 2020
2 parents 225ec05 + a9ddae5 commit 6c62ef2
Show file tree
Hide file tree
Showing 14 changed files with 688 additions and 3 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,44 @@ document_type | _(required)_ The passenger's document type (e.g passport). See *
frequent_traveler | _(optional)_ A boolean. Is this passenger a frequent traveler?
special_needs | _(optional)_ A boolean. Does the passenger have special needs?


##### Events
Parameter | Description
--- | ---
name | _(required)_ The name of the event
date | _(required)_ When the event is going to happen
type | _(optional)_ The type of the event (e.g., show, sports, theater, etc). For the complete list, see **KondutoEventType** enum.
subtype | _(optional)_
venue | _(optional)_ The event's location address. See **Event Venue** bellow.
tickets | _(optional)_ A list of tickets for the given event. See **Event Ticket** below.

##### Event Venue
Parameter | Description
--- | ---
name | _(optional)_ The name of the place (e.g. Wembley Stadium, World Trade Center).
capacity | _(optional)_ The total amount of available tickets for sale.
address | _(optional)_ The specific location.
city | _(optional)_
state | _(optional)_
country | _(optional)_ The country abbreviation code (e.g., BR, US, AU, etc)

##### Event Ticket
Parameter | Description
--- | ---
id | _(optional)_ A unique identifier for the ticket.
category | _(required)_ The ticket type, such as senior, student or regular. For the complete list, see **KondutoEventTicketCategory** enum.
section | _(optional)_ The location of the ticket (e.g., lower seats, upper seats, unseated, etc).
premium | _(required)_ Boolean that indicates if the ticket is a premium one.
attendee | _(optional)_ Information about the ticket owner. See **KondutoEventTicketAttendee** bellow.

##### Event Ticket Attendee
Parameter | Description
--- | ---
name | _(optional)_ The attendee's name.
document | _(required)_ The attendee document value.
documentType | _(optional)_ The type of document informed, such as CPF, CNPJ, passport, etc. For the complete list, see **KondutoEventTicketAttendeeDocumentType** enum.
dateOfBirth | _(optional)_ A string with the attendee's date of birth.
=======
##### Vehicle
Parameter | Description
--- | ---
Expand Down
113 changes: 113 additions & 0 deletions src/main/java/com/konduto/sdk/models/KondutoEvent.java
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 src/main/java/com/konduto/sdk/models/KondutoEventTicket.java
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;
}
}
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;
}
}
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
}
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
}
Loading

0 comments on commit 6c62ef2

Please sign in to comment.