-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
ChatGPT/src/main/java/cloud/cleo/squareup/functions/SchedulePrivateShopping.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,78 @@ | ||
package cloud.cleo.squareup.functions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import java.time.LocalDate; | ||
import java.time.LocalTime; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Schedule a Private Shopping Event (just testing for now) | ||
* | ||
* @author sjensen | ||
* @param <Request> | ||
*/ | ||
public class SchedulePrivateShopping<Request> extends AbstractFunction { | ||
|
||
@Override | ||
public String getName() { | ||
return "schedule_private_shoping"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Schedule a private Shopping session for 4 of more people at the store"; | ||
} | ||
|
||
@Override | ||
public Class getRequestClass() { | ||
return Request.class; | ||
} | ||
|
||
/** | ||
* | ||
* @return | ||
*/ | ||
@Override | ||
public Function<Request, Object> getExecutor() { | ||
return (var r) -> { | ||
try { | ||
// TODO . call Sqauare API to schedule | ||
return mapper.createObjectNode().put("status", "SUCCESS").put("message", "The event has been scheduled."); | ||
} catch (Exception e) { | ||
log.error("Unhandled Error", e); | ||
return mapper.createObjectNode().put("status", "FAILED").put("message", "An error has occurred, the event could not be scheduled."); | ||
} | ||
}; | ||
} | ||
|
||
private static class Request { | ||
|
||
@JsonPropertyDescription("Name of the customer who would like to schedule the shopping event") | ||
@JsonProperty(required = true) | ||
public String customer_name; | ||
|
||
@JsonPropertyDescription("The date in ISO format for the private shopping event") | ||
@JsonProperty(required = true) | ||
public LocalDate date; | ||
|
||
@JsonPropertyDescription("The time for the private shopping event") | ||
@JsonProperty(required = true) | ||
public LocalTime time; | ||
|
||
@JsonPropertyDescription("Optional name of the employee requested to provide the event, must be a valid employee first name") | ||
@JsonProperty(required = false) | ||
public String employee_first_name; | ||
} | ||
|
||
/** | ||
* Square must be enabled or their won't be a way to get email addresses | ||
* | ||
* @return | ||
*/ | ||
@Override | ||
protected boolean isEnabled() { | ||
return squareEnabled; | ||
} | ||
|
||
} |
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