-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added usageCutoffDate to summary report for all months
- Loading branch information
Showing
13 changed files
with
176 additions
and
34 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
22 changes: 16 additions & 6 deletions
22
src/main/java/seatsio/reports/usage/detailsForEventInMonth/UsageForObjectV1.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 |
---|---|---|
@@ -1,12 +1,22 @@ | ||
package seatsio.reports.usage.detailsForEventInMonth; | ||
|
||
import seatsio.util.ValueObject; | ||
|
||
import java.time.Instant; | ||
|
||
public class UsageForObjectV1 { | ||
public class UsageForObjectV1 extends ValueObject { | ||
|
||
public final String object; | ||
public final int numFirstBookings; | ||
public final Instant firstBookingDate; | ||
public final int numFirstSelections; | ||
public final int numFirstBookingsOrSelections; | ||
|
||
public String object; | ||
public int numFirstBookings; | ||
public Instant firstBookingDate; | ||
public int numFirstSelections; | ||
public int numFirstBookingsOrSelections; | ||
public UsageForObjectV1(String object, int numFirstBookings, Instant firstBookingDate, int numFirstSelections, int numFirstBookingsOrSelections) { | ||
this.object = object; | ||
this.numFirstBookings = numFirstBookings; | ||
this.firstBookingDate = firstBookingDate; | ||
this.numFirstSelections = numFirstSelections; | ||
this.numFirstBookingsOrSelections = numFirstBookingsOrSelections; | ||
} | ||
} |
15 changes: 11 additions & 4 deletions
15
src/main/java/seatsio/reports/usage/detailsForEventInMonth/UsageForObjectV2.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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
package seatsio.reports.usage.detailsForEventInMonth; | ||
|
||
import seatsio.reports.usage.UsageReason; | ||
import seatsio.util.ValueObject; | ||
|
||
import java.util.Map; | ||
|
||
public class UsageForObjectV2 { | ||
public class UsageForObjectV2 extends ValueObject { | ||
|
||
public String object; | ||
public int numUsedObjects; | ||
public Map<UsageReason, Integer> usageByReason; | ||
public final String object; | ||
public final int numUsedObjects; | ||
public final Map<UsageReason, Integer> usageByReason; | ||
|
||
public UsageForObjectV2(String object, int numUsedObjects, Map<UsageReason, Integer> usageByReason) { | ||
this.object = object; | ||
this.numUsedObjects = numUsedObjects; | ||
this.usageByReason = usageByReason; | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
src/main/java/seatsio/reports/usage/detailsForMonth/UsageByChart.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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package seatsio.reports.usage.detailsForMonth; | ||
|
||
import seatsio.util.ValueObject; | ||
|
||
import java.util.List; | ||
|
||
public class UsageByChart { | ||
public class UsageByChart extends ValueObject { | ||
|
||
public final UsageChart chart; | ||
public final List<UsageByEvent> usageByEvent; | ||
|
||
public UsageChart chart; | ||
public List<UsageByEvent> usageByEvent; | ||
public UsageByChart(UsageChart chart, List<UsageByEvent> usageByEvent) { | ||
this.chart = chart; | ||
this.usageByEvent = usageByEvent; | ||
} | ||
} |
12 changes: 9 additions & 3 deletions
12
src/main/java/seatsio/reports/usage/detailsForMonth/UsageByEvent.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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package seatsio.reports.usage.detailsForMonth; | ||
|
||
public class UsageByEvent { | ||
import seatsio.util.ValueObject; | ||
|
||
public UsageEvent event; | ||
public int numUsedObjects; | ||
public class UsageByEvent extends ValueObject { | ||
|
||
public final UsageEvent event; | ||
public final int numUsedObjects; | ||
|
||
public UsageByEvent(UsageEvent event, int numUsedObjects) { | ||
this.event = event; | ||
this.numUsedObjects = numUsedObjects; | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
src/main/java/seatsio/reports/usage/detailsForMonth/UsageChart.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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package seatsio.reports.usage.detailsForMonth; | ||
|
||
public class UsageChart { | ||
import seatsio.util.ValueObject; | ||
|
||
public String name; | ||
public String key; | ||
public class UsageChart extends ValueObject { | ||
|
||
public final String name; | ||
public final String key; | ||
|
||
public UsageChart(String name, String key) { | ||
this.name = name; | ||
this.key = key; | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
src/main/java/seatsio/reports/usage/detailsForMonth/UsageDetails.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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package seatsio.reports.usage.detailsForMonth; | ||
|
||
import seatsio.util.ValueObject; | ||
|
||
import java.util.List; | ||
|
||
public class UsageDetails { | ||
public class UsageDetails extends ValueObject { | ||
|
||
public final Long workspace; | ||
public final List<UsageByChart> usageByChart; | ||
|
||
public Long workspace; | ||
public List<UsageByChart> usageByChart; | ||
public UsageDetails(Long workspace, List<UsageByChart> usageByChart) { | ||
this.workspace = workspace; | ||
this.usageByChart = usageByChart; | ||
} | ||
} |
15 changes: 12 additions & 3 deletions
15
src/main/java/seatsio/reports/usage/detailsForMonth/UsageEvent.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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
package seatsio.reports.usage.detailsForMonth; | ||
|
||
public class UsageEvent { | ||
import seatsio.util.ValueObject; | ||
|
||
public long id; | ||
public String key; | ||
public class UsageEvent extends ValueObject { | ||
|
||
public final long id; | ||
public final String key; | ||
public final boolean deleted; | ||
|
||
public UsageEvent(long id, String key, boolean deleted) { | ||
this.id = id; | ||
this.key = key; | ||
this.deleted = deleted; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/seatsio/reports/usage/summaryForMonths/UsageSummaryForAllMonths.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,17 @@ | ||
package seatsio.reports.usage.summaryForMonths; | ||
|
||
import seatsio.util.ValueObject; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
public class UsageSummaryForAllMonths extends ValueObject { | ||
|
||
public final Instant usageCutoffDate; | ||
public final List<UsageSummaryForMonth> usage; | ||
|
||
public UsageSummaryForAllMonths(Instant usageCutoffDate, List<UsageSummaryForMonth> usage) { | ||
this.usageCutoffDate = usageCutoffDate; | ||
this.usage = usage; | ||
} | ||
} |
11 changes: 8 additions & 3 deletions
11
src/main/java/seatsio/reports/usage/summaryForMonths/UsageSummaryForMonth.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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package seatsio.reports.usage.summaryForMonths; | ||
|
||
import seatsio.reports.usage.Month; | ||
import seatsio.util.ValueObject; | ||
|
||
public class UsageSummaryForMonth { | ||
public class UsageSummaryForMonth extends ValueObject { | ||
|
||
public Month month; | ||
public int numUsedObjects; | ||
public final Month month; | ||
public final int numUsedObjects; | ||
|
||
public UsageSummaryForMonth(Month month, int numUsedObjects) { | ||
this.month = month; | ||
this.numUsedObjects = numUsedObjects; | ||
} | ||
} |
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,58 @@ | ||
package seatsio.reports.usage; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import seatsio.SeatsioClient; | ||
import seatsio.SeatsioClientTest; | ||
import seatsio.reports.usage.detailsForEventInMonth.UsageForObjectV1; | ||
import seatsio.reports.usage.detailsForMonth.UsageByEvent; | ||
import seatsio.reports.usage.detailsForMonth.UsageDetails; | ||
import seatsio.reports.usage.detailsForMonth.UsageEvent; | ||
import seatsio.reports.usage.summaryForMonths.UsageSummaryForAllMonths; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
public class UsageReportTest extends SeatsioClientTest { | ||
|
||
@Test | ||
public void usageReportForAllMonths() { | ||
assumeTrue(isDemoCompanySecretKeySet()); | ||
|
||
SeatsioClient client = seatsioClient(demoCompanySecretKey()); | ||
|
||
UsageSummaryForAllMonths report = client.usageReports.summaryForAllMonths(); | ||
|
||
assertThat(report.usageCutoffDate).isNotNull(); | ||
assertThat(report.usage.size()).isGreaterThan(0); | ||
assertThat(report.usage.get(0).month).isEqualTo(new Month(2014, 2)); | ||
} | ||
|
||
@Test | ||
public void usageReportForMonth() { | ||
assumeTrue(isDemoCompanySecretKeySet()); | ||
|
||
SeatsioClient client = seatsioClient(demoCompanySecretKey()); | ||
|
||
List<UsageDetails> report = client.usageReports.detailsForMonth(new Month(2021, 11)); | ||
|
||
assertThat(report.size()).isGreaterThan(0); | ||
assertThat(report.get(0).usageByChart.size()).isGreaterThan(0); | ||
assertThat(report.get(0).usageByChart.get(0).usageByEvent).containsExactly(new UsageByEvent( | ||
new UsageEvent(580293, "largeStadiumEvent", false), 143 | ||
)); | ||
} | ||
|
||
@Test | ||
public void usageReportForEventInMonth() { | ||
assumeTrue(isDemoCompanySecretKeySet()); | ||
|
||
SeatsioClient client = seatsioClient(demoCompanySecretKey()); | ||
|
||
List<?> report = client.usageReports.detailsForEventInMonth(580293, new Month(2021, 11)); | ||
|
||
assertThat(report.size()).isGreaterThan(0); | ||
assertThat((UsageForObjectV1) report.get(0)).isEqualTo(new UsageForObjectV1("102-9-14", 0, null, 1, 1)); | ||
} | ||
} |