**
8 | Our source is open to anyone who's interested in making Bot's using the beautiful Java Programming Language and when we say it's open source, it is literally open. You can just download the actual code and use it as per our licensing terms. All we want in addition to our terms is that you give us your feedback. We passionately created this framework and we want to improve it the best way we can - but we can only do that if you help us. If you found any bugs, issues, ideas or even inquiries, raise a ticket [here](https://github.com/BotMill/fb-botmill/issues).
9 |
10 | **Things to note**
11 | - Make sure that you write descriptive issues. If possible, provide stack trace or screenshots. The more information the better.
12 | - Tag it accordingly.
13 |
14 | **
Code Contributor
**
15 | Interested in contributing to our project? We will always be open to your pull requests! Be sure to check our code of conduct first before making any changes. Even it's all open source, we need to make sure that our code is well documented and complies with the standards.
16 |
17 | If you want to contribute, drop us an email at alvin.reyes@botmill.io OR donato.rimenti@botmill.io or you can talk to us directly thru out Gitter Channel [](https://gitter.im/BotMill/fb-botmill?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
18 |
19 | **Basic Steps if you want to contribute code.**
20 | - Forked the master branch to your user repo.
21 | - Introduce/code your task.
22 | - Commit your changes with "Resolved #"
23 | - Submit a pull requests. Make sure that you only have 1 single commit for every pull request.
24 |
25 | **Pull request and commit messages**
26 | - All commits should have a "Resolved #" on the message.
27 | - All pull request should only have one commit. Multiple commits won't be accepted.
28 | - Make sure to put a good message on your commit. This may or may be used as part of the release notes.
29 |
30 | **Important things to note**
31 | - All commits will trigger a CI build using your branch. It should pass that before we begin reviewing your code.
32 | - All commits should have proper documentation.
33 |
34 | **
Bot Examples
**
35 | We would really appreciate it if you can share the bots that you made using our framework, just like the many people who ask us to show case theirs.
36 |
37 | * [TechnoWebhub](https://technowebhub.com/fb_thub.html)
38 | * [TriviaBot](https://technowebhub.com/trivia_bot.html)
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 BotMill.io
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/FbBotApi.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb;
2 |
3 | import co.aurasphere.botmill.core.BotDefinition;
4 | import co.aurasphere.botmill.fb.autoreply.AutoReply;
5 |
6 | /**
7 | * The Class FbBotApi.
8 | */
9 | public class FbBotApi {
10 |
11 | /** The bot definition. */
12 | private static BotDefinition botDefinition;
13 |
14 | /**
15 | * Sets the fb bot.
16 | *
17 | * @param botDefinition the new fb bot
18 | */
19 | public static void setFbBot(BotDefinition botDefinition) {
20 | FbBotApi.botDefinition = botDefinition;
21 | }
22 |
23 | /**
24 | * Reply.
25 | *
26 | * @param reply the reply
27 | */
28 | public static void reply(AutoReply reply) {
29 | if(FbBotApi.botDefinition == null) {
30 | botDefinition = new FbBotApiBot();
31 | }
32 | ((FbBot)FbBotApi.botDefinition).reply(reply);
33 | }
34 |
35 |
36 | }
37 | class FbBotApiBot extends FbBot implements BotDefinition {
38 | public FbBotApiBot() {
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/FbBotConfiguration.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb;
2 |
3 | import co.aurasphere.botmill.core.internal.util.ConfigurationUtils;
4 |
5 | public abstract class FbBotConfiguration {
6 |
7 | /** The Constant FB_BOTMILL_PAGE_TOKEN. */
8 | private static final String FB_BOTMILL_PAGE_TOKEN = "fb.page.token";
9 |
10 | /** The Constant FB_BOTMILL_VALIDATION_TOKEN. */
11 | private static final String FB_BOTMILL_VALIDATION_TOKEN = "fb.validation.token";
12 |
13 | public FbBotConfiguration() {
14 | this.buildFbBotConfig();
15 | }
16 |
17 | /**
18 | * Builds the Fb bot config.
19 | *
20 | * @throws BotMillMissingConfigurationException
21 | * the bot mill missing configuration exception
22 | */
23 | private void buildFbBotConfig() {
24 |
25 | FbBotMillContext.getInstance().setup(
26 | ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_PAGE_TOKEN),
27 | ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_VALIDATION_TOKEN));
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/api/MessagingInsightApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.api;
25 |
26 | import co.aurasphere.botmill.fb.internal.util.network.FbBotMillNetworkController;
27 | import co.aurasphere.botmill.fb.model.api.messaginginsight.DailyUniqueActiveThreadCounts;
28 | import co.aurasphere.botmill.fb.model.api.messaginginsight.DailyUniqueConversationCounts;
29 |
30 | /**
31 | * Base class for handling Messaging Insight API.
32 | *
33 | * @author Donato Rimenti
34 | * @see Facebook's Messaging Insight API Reference.
37 | * @since 2.0.0
38 | */
39 | public class MessagingInsightApi {
40 |
41 | /**
42 | * Instantiates a new MessagingInsightApi.
43 | */
44 | private MessagingInsightApi() {
45 | }
46 |
47 | /**
48 | * Gets the daily unique active thread counts.
49 | *
50 | * @return the daily unique active thread counts.
51 | */
52 | public static DailyUniqueActiveThreadCounts getDailyUniqueActiveThreadCounts() {
53 | return FbBotMillNetworkController.getDailyUniqueActiveThreadCounts();
54 | }
55 |
56 | /**
57 | * Gets the daily unique conversation counts.
58 | *
59 | * @return the daily unique conversation counts.
60 | */
61 | public static DailyUniqueConversationCounts getDailyUniqueConversationCounts() {
62 | return FbBotMillNetworkController.getDailyUniqueConversationCounts();
63 | }
64 |
65 | /*
66 | * (non-Javadoc)
67 | *
68 | * @see java.lang.Object#toString()
69 | */
70 | @Override
71 | public String toString() {
72 | return "MessagingInsightApi []";
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/api/MessengerCodeApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.api;
25 |
26 | import co.aurasphere.botmill.fb.internal.util.network.FbBotMillNetworkController;
27 | import co.aurasphere.botmill.fb.model.api.messengercode.MessengerCode;
28 | import co.aurasphere.botmill.fb.model.api.messengercode.MessengerCodeRequest;
29 |
30 | /**
31 | * Base class for handling Messenger Code API.
32 | *
33 | * @author Donato Rimenti
34 | * @see Facebook's Messenger Code API Reference.
37 | * @since 2.0.0
38 | */
39 | public class MessengerCodeApi {
40 |
41 | /**
42 | * Instantiates a new MessengerCodeApi.
43 | */
44 | private MessengerCodeApi() {
45 | }
46 |
47 | /**
48 | * Gets a messenger code(Facebook's Messenger QR Code).
49 | *
50 | * @param request
51 | * the size of the code to retrieve.
52 | * @return a {@link MessengerCode}.
53 | */
54 | public static MessengerCode getMessengerCode(MessengerCodeRequest request) {
55 | return FbBotMillNetworkController.postMessengerCode(request);
56 | }
57 |
58 | /**
59 | * Gets a messenger code(Facebook's Messenger QR Code).
60 | *
61 | * @param imageSize
62 | * the size of the code to retrieve.
63 | * @return a {@link MessengerCode}.
64 | */
65 | public static MessengerCode getMessengerCode(int imageSize) {
66 | MessengerCodeRequest request = new MessengerCodeRequest(imageSize);
67 | return getMessengerCode(request);
68 | }
69 |
70 | /**
71 | * Gets a messenger code(Facebook's Messenger QR Code) with default size
72 | * (1000 px).
73 | *
74 | * @return a {@link MessengerCode}.
75 | */
76 | public static MessengerCode getMessengerCode() {
77 | MessengerCodeRequest request = new MessengerCodeRequest();
78 | return getMessengerCode(request);
79 | }
80 |
81 | /*
82 | * (non-Javadoc)
83 | *
84 | * @see java.lang.Object#toString()
85 | */
86 | @Override
87 | public String toString() {
88 | return "MessengerCodeApi []";
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/api/UploadApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.api;
25 |
26 | import co.aurasphere.botmill.fb.internal.util.network.FbBotMillNetworkController;
27 | import co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse;
28 | import co.aurasphere.botmill.fb.model.base.Attachment;
29 | import co.aurasphere.botmill.fb.model.base.AttachmentType;
30 | import co.aurasphere.botmill.fb.model.outcoming.message.AttachmentMessage;
31 | import co.aurasphere.botmill.fb.model.outcoming.message.FbBotMillMessageResponse;
32 | import co.aurasphere.botmill.fb.model.outcoming.payload.AttachmentPayload;
33 |
34 |
35 | /**
36 | * Class for handling the Facebook's Messenger Upload API.
37 | *
38 | * @author Donato Rimenti
39 | * @since 2.0.0
40 | */
41 | public class UploadApi {
42 |
43 | /**
44 | * Instantiates a new UploadApi.
45 | */
46 | private UploadApi() {
47 | }
48 |
49 | /**
50 | * Method to upload an attachment to Facebook's server in order to use it
51 | * later. Requires the pages_messaging permission.
52 | *
53 | * @param attachmentType
54 | * the type of attachment to upload to Facebook. Please notice
55 | * that currently Facebook supports only image, audio, video and
56 | * file attachments.
57 | * @param attachmentUrl
58 | * the URL of the attachment to upload to Facebook.
59 | * @return nonexpiring ID for the attachment.
60 | */
61 | public static UploadAttachmentResponse uploadAttachment(
62 | AttachmentType attachmentType, String attachmentUrl) {
63 | AttachmentPayload payload = new AttachmentPayload(attachmentUrl, true);
64 | Attachment attachment = new Attachment(attachmentType, payload);
65 | AttachmentMessage message = new AttachmentMessage(attachment);
66 | FbBotMillMessageResponse toSend = new FbBotMillMessageResponse(null, message);
67 | return FbBotMillNetworkController.postUploadAttachment(toSend);
68 | }
69 |
70 | /*
71 | * (non-Javadoc)
72 | *
73 | * @see java.lang.Object#toString()
74 | */
75 | @Override
76 | public String toString() {
77 | return "FbBotMillUploadApi []";
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/api/UserProfileApi.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.api;
25 |
26 | import co.aurasphere.botmill.fb.internal.util.network.FbBotMillNetworkController;
27 | import co.aurasphere.botmill.fb.model.api.userprofile.FacebookUserProfile;
28 |
29 |
30 | /**
31 | * Class for handling the retrieval of Facebook user info.
32 | *
33 | * @author Donato Rimenti
34 | * @author Alvin Reyes
35 | */
36 | public class UserProfileApi {
37 |
38 | /**
39 | * Instantiates a new UserProfileApi.
40 | */
41 | private UserProfileApi() {
42 | }
43 |
44 | /**
45 | * Retrieves a {@link FacebookUserProfile} object containing the info for
46 | * the user with the ID passed.
47 | *
48 | * @param userId
49 | * the id of the user whose profile to retrieve.
50 | * @return the user profile.
51 | */
52 | public static FacebookUserProfile getUser(String userId) {
53 | return FbBotMillNetworkController.getUserProfile(userId);
54 | }
55 |
56 | /*
57 | * (non-Javadoc)
58 | *
59 | * @see java.lang.Object#toString()
60 | */
61 | @Override
62 | public String toString() {
63 | return "FbBotMillUserProfileRetriever []";
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/autoreply/ActionAutoReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.autoreply;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
28 | import co.aurasphere.botmill.fb.model.outcoming.action.TypingAction;
29 | import co.aurasphere.botmill.fb.model.outcoming.factory.ReplyFactory;
30 |
31 |
32 | /**
33 | * An {@link AutoReply} that replies with a {@link TypingAction}.
34 | *
35 | * @author Donato Rimenti
36 | * @author Alvin Reyes
37 | *
38 | */
39 | public class ActionAutoReply extends AutoReply {
40 |
41 | /**
42 | * The {@link TypingAction} to perform.
43 | */
44 | private TypingAction typingAction;
45 |
46 | /**
47 | * Instantiates a new action auto reply.
48 | *
49 | * @param typingAction
50 | * the {@link #typingAction}.
51 | */
52 | public ActionAutoReply(TypingAction typingAction) {
53 | this.typingAction = typingAction;
54 | }
55 |
56 | /**
57 | * {@inheritDoc} Replies with a {@link TypingAction}.
58 | */
59 | @Override
60 | public FbBotMillResponse createResponse(MessageEnvelope envelope) {
61 | return ReplyFactory.addTypingAction(this.typingAction).build(envelope);
62 | }
63 |
64 | /*
65 | * (non-Javadoc)
66 | *
67 | * @see java.lang.Object#hashCode()
68 | */
69 | @Override
70 | public int hashCode() {
71 | final int prime = 31;
72 | int result = 1;
73 | result = prime * result + ((typingAction == null) ? 0 : typingAction.hashCode());
74 | return result;
75 | }
76 |
77 | /*
78 | * (non-Javadoc)
79 | *
80 | * @see java.lang.Object#equals(java.lang.Object)
81 | */
82 | @Override
83 | public boolean equals(Object obj) {
84 | if (this == obj)
85 | return true;
86 | if (obj == null)
87 | return false;
88 | if (getClass() != obj.getClass())
89 | return false;
90 | ActionAutoReply other = (ActionAutoReply) obj;
91 | if (typingAction != other.typingAction)
92 | return false;
93 | return true;
94 | }
95 |
96 | /*
97 | * (non-Javadoc)
98 | *
99 | * @see java.lang.Object#toString()
100 | */
101 | @Override
102 | public String toString() {
103 | return "ActionAutoReply [action=" + typingAction + "]";
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/autoreply/AutoReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.autoreply;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
28 | import co.aurasphere.botmill.fb.internal.util.network.FbBotMillNetworkController;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
31 |
32 |
33 | /**
34 | * A class that represents an automatic reply to an event. AutoReply are used in
35 | * conjuction with {@link FbBotMillEvent} in order to handle an Facebook's
36 | * Messenger Platform callback automatically, using the delegation design
37 | * pattern.
38 | *
39 | * @author Donato Rimenti
40 | */
41 | public abstract class AutoReply extends FbBotMillBean implements Reply {
42 |
43 | /**
44 | * Method which defines the reply flow.
45 | *
46 | * @param envelope
47 | * the current callback message
48 | */
49 | public void reply(MessageEnvelope envelope) {
50 | FbBotMillResponse response = createResponse(envelope);
51 | if (response != null) {
52 | // If the response is valid, replies to it.
53 | if (validate(response)) {
54 | FbBotMillNetworkController.postJsonMessage(response);
55 | }
56 | }
57 | }
58 |
59 | /* (non-Javadoc)
60 | * @see co.aurasphere.botmill.fb.autoreply.Reply#createResponse(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)
61 | */
62 | public abstract FbBotMillResponse createResponse(MessageEnvelope envelope);
63 |
64 | /*
65 | * (non-Javadoc)
66 | *
67 | * @see java.lang.Object#toString()
68 | */
69 | @Override
70 | public String toString() {
71 | return "AutoReply []";
72 | }
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/autoreply/EchoAutoReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.autoreply;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
28 | import co.aurasphere.botmill.fb.model.outcoming.factory.ReplyFactory;
29 |
30 |
31 | /**
32 | * An {@link AutoReply} that replies with the last received message. Mostly used
33 | * for testing and demo purposes.
34 | *
35 | * @author Donato Rimenti
36 | */
37 | public class EchoAutoReply extends AutoReply {
38 |
39 | /**
40 | * {@inheritDoc} It replies with the last received message.
41 | */
42 | public FbBotMillResponse createResponse(MessageEnvelope envelope) {
43 | String lastMessage = safeGetMessage(envelope);
44 | return ReplyFactory.addTextMessageOnly(lastMessage).build(envelope);
45 | }
46 |
47 | /*
48 | * (non-Javadoc)
49 | *
50 | * @see co.aurasphere.botmill.fb.autoreply.AutoReply#toString()
51 | */
52 | @Override
53 | public String toString() {
54 | return "EchoAutoReply []";
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/autoreply/LambdaAutoReply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.autoreply;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
28 |
29 |
30 | /**
31 | * An {@link AutoReply} whose reply is defined by a Java 8 Lambda function.
32 | *
33 | * @author Donato Rimenti
34 | * @since 1.2.0
35 | */
36 | public class LambdaAutoReply extends AutoReply {
37 |
38 | /**
39 | * A lambda which represents how to reply to this message.
40 | */
41 | private Reply lambda;
42 |
43 | /**
44 | * Instantiates a new LambdaAutoReply.
45 | *
46 | * @param lambda
47 | * the {@link #lambda}.
48 | */
49 | public LambdaAutoReply(Reply lambda) {
50 | this.lambda = lambda;
51 | }
52 |
53 | /*
54 | * (non-Javadoc)
55 | *
56 | * @see
57 | * co.aurasphere.botmill.fb.autoreply.AutoReply#createResponse(co.aurasphere
58 | * .botmill.fb.model.incoming.MessageEnvelope)
59 | */
60 | @Override
61 | public FbBotMillResponse createResponse(MessageEnvelope envelope) {
62 | return lambda.createResponse(envelope);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/autoreply/Reply.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.autoreply;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
28 |
29 |
30 | /**
31 | * Interface which represents every reply from the bot.
32 | *
33 | * @author Donato Rimenti
34 | * @author Alvin Reyes
35 | * @since 1.2.0
36 | */
37 | public interface Reply {
38 |
39 | /**
40 | * Method which defines the response to send back as a response to the
41 | * current message.
42 | *
43 | * @param envelope
44 | * the current message.
45 | * @return a {@link FbBotMillResponse} which contains the response to the
46 | * current message.
47 | */
48 | public FbBotMillResponse createResponse(MessageEnvelope envelope);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/AnyEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 |
28 |
29 | /**
30 | * An {@link FbBotMillEvent} that processes all the incoming callbacks from
31 | * Facebook Messenger Platform.
32 | *
33 | * @author Donato Rimenti
34 | *
35 | */
36 | public class AnyEvent implements FbBotMillEvent {
37 |
38 | /**
39 | * Verify event condition.
40 | *
41 | * @param envelope
42 | * the envelope
43 | * @return always true, in order to process any incoming callback.
44 | */
45 | public boolean verifyEventCondition(MessageEnvelope envelope) {
46 | return true;
47 | }
48 |
49 | /*
50 | * (non-Javadoc)
51 | *
52 | * @see java.lang.Object#toString()
53 | */
54 | @Override
55 | public String toString() {
56 | return "AnyEvent []";
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/FbBotMillEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
27 |
28 |
29 | /**
30 | * An interface that defines an event from Facebook Messenger Platform callback.
31 | *
32 | * @author Donato Rimenti
33 | *
34 | */
35 | public interface FbBotMillEvent {
36 |
37 | /**
38 | * A method which evaluates whether the event is verified or not.
39 | *
40 | * @param envelope
41 | * the callback message.
42 | * @return true if the event is verified, false otherwise.
43 | */
44 | public boolean verifyEventCondition(MessageEnvelope envelope);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/account/AccountLinkingEvent.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.event.account;
2 |
3 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
4 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
5 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
6 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
7 |
8 | public class AccountLinkingEvent extends FbBotMillBean implements FbBotMillEvent {
9 |
10 | /**
11 | * Instantiates a new LocationEvent.
12 | */
13 | public AccountLinkingEvent() {
14 | }
15 |
16 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
17 | return eventKind(envelope) == FbBotMillEventType.ACCOUNT_LINKING;
18 | }
19 |
20 | /*
21 | * (non-Javadoc)
22 | *
23 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
24 | */
25 | @Override
26 | public String toString() {
27 | return "AccountLinking []";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/account/ReferralEvent.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.event.account;
2 |
3 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
4 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
5 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
6 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
7 |
8 | public class ReferralEvent extends FbBotMillBean implements FbBotMillEvent {
9 |
10 | /**
11 | * Instantiates a new LocationEvent.
12 | */
13 | public ReferralEvent() {
14 | }
15 |
16 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
17 | return eventKind(envelope) == FbBotMillEventType.REFERRAL;
18 | }
19 |
20 | /*
21 | * (non-Javadoc)
22 | *
23 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
24 | */
25 | @Override
26 | public String toString() {
27 | return "ReferralEvent []";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/base/BaseMediaEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.base;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 |
30 |
31 | /**
32 | * Base class for a {@link FbBotMillEvent} that triggers when an exact text is
33 | * matched, case sensitive or not.
34 | *
35 | * @author Alvin Reyes
36 | */
37 | public abstract class BaseMediaEvent extends FbBotMillBean implements
38 | FbBotMillEvent {
39 |
40 | protected String safeGetImage(MessageEnvelope envelope) {
41 | if (envelope != null && envelope.getMessage() != null
42 | && envelope.getMessage().getText() != null
43 | && envelope.getMessage().getQuickReply() == null) {
44 | return envelope.getMessage().getText();
45 | }
46 | return "";
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/media/AudioEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.media;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
28 | import co.aurasphere.botmill.fb.event.base.BaseMediaEvent;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
34 | * message that matches an exact String.
35 | *
36 | * @author Alvin Reyes
37 | */
38 | public class AudioEvent extends BaseMediaEvent {
39 |
40 | /**
41 | * This method is called to verify that the message envelope contains the
42 | * payload to verify that we are processing a location input.
43 | *
44 | * @param envelope
45 | * the message envelope that contains the location payload.
46 | * @return true if the text message received from the callback is a
47 | * location.
48 | */
49 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
50 | return eventKind(envelope) == FbBotMillEventType.AUDIO;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/media/FileEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.media;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
28 | import co.aurasphere.botmill.fb.event.base.BaseMediaEvent;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
34 | * message that matches an exact String.
35 | *
36 | * @author Alvin Reyes
37 | */
38 | public class FileEvent extends BaseMediaEvent {
39 |
40 | /**
41 | * This method is called to verify that the message envelope contains the
42 | * payload to verify that we are processing a location input.
43 | *
44 | * @param envelope
45 | * the message envelope that contains the location payload.
46 | * @return true if the text message received from the callback is a
47 | * location.
48 | */
49 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
50 | return eventKind(envelope) == FbBotMillEventType.FILE;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/media/ImageEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.media;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
28 | import co.aurasphere.botmill.fb.event.base.BaseMediaEvent;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
34 | * message that matches an exact String.
35 | *
36 | * @author Alvin Reyes
37 | */
38 | public class ImageEvent extends BaseMediaEvent {
39 |
40 | /**
41 | * This method is called to verify that the message envelope contains the
42 | * payload to verify that we are processing a location input.
43 | *
44 | * @param envelope
45 | * the message envelope that contains the location payload.
46 | * @return true if the text message received from the callback is a
47 | * location.
48 | */
49 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
50 | return eventKind(envelope) == FbBotMillEventType.IMAGE;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/media/VideoEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.media;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
28 | import co.aurasphere.botmill.fb.event.base.BaseMediaEvent;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
34 | * message that matches an exact String.
35 | *
36 | * @author Alvin Reyes
37 | */
38 | public class VideoEvent extends BaseMediaEvent {
39 |
40 | /**
41 | * This method is called to verify that the message envelope contains the
42 | * payload to verify that we are processing a location input.
43 | *
44 | * @param envelope
45 | * the message envelope that contains the location payload.
46 | * @return true if the text message received from the callback is a
47 | * location.
48 | */
49 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
50 | return eventKind(envelope) == FbBotMillEventType.VIDEO;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/AnyMessageEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
28 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * A {@link FbBotMillEvent} that triggers whenever the users sends a text
34 | * message.
35 | *
36 | * @author Donato Rimenti
37 | *
38 | */
39 | public class AnyMessageEvent extends FbBotMillBean implements FbBotMillEvent {
40 |
41 | /**
42 | * Verify event condition.
43 | *
44 | * @param envelope
45 | * the envelope
46 | * @return true if the incoming callback contains a non-empty, non-null text
47 | * message, false otherwise.
48 | */
49 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
50 | return eventKind(envelope) == FbBotMillEventType.MESSAGE;
51 | }
52 |
53 | /*
54 | * (non-Javadoc)
55 | *
56 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
57 | */
58 | @Override
59 | public String toString() {
60 | return "AnyMessageEvent []";
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/LocationEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
28 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 | import co.aurasphere.botmill.fb.model.outcoming.quickreply.QuickReply;
31 |
32 |
33 | /**
34 | * An {@link FbBotMillEvent} that triggers whenever the users sends a location
35 | * using a {@link QuickReply} button.
36 | *
37 | * @author Alvin Reyes
38 | *
39 | */
40 | public class LocationEvent extends FbBotMillBean implements FbBotMillEvent {
41 |
42 | /**
43 | * Instantiates a new LocationEvent.
44 | */
45 | public LocationEvent() {
46 | }
47 |
48 | /**
49 | * This method is called to verify that the message envelope contains the
50 | * payload to verify that we are processing a location input.
51 | *
52 | * @param envelope
53 | * the message envelope that contains the location payload.
54 | * @return true if the text message received from the callback is a
55 | * location.
56 | */
57 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
58 | return eventKind(envelope) == FbBotMillEventType.LOCATION;
59 | }
60 |
61 | /*
62 | * (non-Javadoc)
63 | *
64 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
65 | */
66 | @Override
67 | public String toString() {
68 | return "LocationEvent []";
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/MessageEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.base.BaseStringEvent;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 |
30 |
31 | /**
32 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
33 | * message that matches an exact String.
34 | *
35 | * @author Donato Rimenti
36 | */
37 | public class MessageEvent extends BaseStringEvent {
38 |
39 | /**
40 | * Instantiates a new MessageEvent.
41 | *
42 | * @param expectedMessage
43 | * the {@link BaseStringEvent#expectedString}.
44 | * @param caseSensitive
45 | * the {@link BaseStringEvent#caseSensitive}.
46 | */
47 | public MessageEvent(String expectedMessage, boolean caseSensitive) {
48 | super(expectedMessage, caseSensitive);
49 | }
50 |
51 | /**
52 | * Instantiates a new MessageEvent.
53 | *
54 | * @param expectedMessage
55 | * the {@link BaseStringEvent#expectedString}.
56 | */
57 | public MessageEvent(String expectedMessage) {
58 | super(expectedMessage);
59 | }
60 |
61 | /*
62 | * (non-Javadoc)
63 | *
64 | * @see
65 | * co.aurasphere.botmill.fb.event.FbBotMillEvent#verifyEventCondition(co.
66 | * aurasphere.botmill.fb.model.incoming.MessageEnvelope)
67 | */
68 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
69 | String message = safeGetMessage(envelope);
70 | return verifyStringMatch(message);
71 | }
72 |
73 | /*
74 | * (non-Javadoc)
75 | *
76 | * @see co.aurasphere.botmill.fb.event.base.BaseStringEvent#toString()
77 | */
78 | @Override
79 | public String toString() {
80 | return "MessageEvent [expectedString=" + expectedString
81 | + ", caseSensitive=" + caseSensitive + "]";
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/MessagePatternEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import java.util.regex.Pattern;
27 |
28 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
29 | import co.aurasphere.botmill.fb.event.base.BasePatternEvent;
30 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
31 |
32 |
33 | /**
34 | * An {@link FbBotMillEvent} that triggers whenever the users sends a text
35 | * message that matches a {@link Pattern}.
36 | *
37 | * @author Donato Rimenti
38 | *
39 | */
40 | public class MessagePatternEvent extends BasePatternEvent {
41 |
42 | /**
43 | * Instantiates a new MessagePatternEvent.
44 | *
45 | * @param expectedPattern
46 | * the {@link BasePatternEvent#expectedPattern}.
47 | */
48 | public MessagePatternEvent(Pattern expectedPattern) {
49 | super(expectedPattern);
50 | }
51 |
52 | /**
53 | * Instantiates a new MessagePatternEvent.
54 | *
55 | * @param expectedPattern
56 | * the {@link BasePatternEvent#expectedPattern}.
57 | */
58 | public MessagePatternEvent(String expectedPattern) {
59 | super(expectedPattern);
60 | }
61 |
62 | /*
63 | * (non-Javadoc)
64 | *
65 | * @see
66 | * co.aurasphere.botmill.fb.event.FbBotMillEvent#verifyEventCondition(co.
67 | * aurasphere.botmill.fb.model.incoming.MessageEnvelope)
68 | */
69 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
70 | String message = safeGetMessage(envelope);
71 | return verifyPatternMatch(message);
72 | }
73 |
74 | /*
75 | * (non-Javadoc)
76 | *
77 | * @see co.aurasphere.botmill.fb.event.base.BasePatternEvent#toString()
78 | */
79 | @Override
80 | public String toString() {
81 | return "MessagePatternEvent [expectedPattern=" + expectedPattern + "]";
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/QuickReplyMessageEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.base.BaseStringEvent;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 |
30 |
31 | /**
32 | * An {@link FbBotMillEvent} that processes all the incoming callbacks that
33 | * contains a specific text message from Facebook's Messenger Platform.
34 | *
35 | * @author Alvin Reyes
36 | */
37 | public class QuickReplyMessageEvent extends BaseStringEvent {
38 |
39 | /**
40 | * Instantiates a new quick reply message event.
41 | *
42 | * @param expectedPayload
43 | * the expected payload
44 | * @param caseSensitive
45 | * the case sensitive
46 | */
47 | public QuickReplyMessageEvent(String expectedPayload, boolean caseSensitive) {
48 | super(expectedPayload, caseSensitive);
49 | }
50 |
51 | /**
52 | * Instantiates a new quick reply message event.
53 | *
54 | * @param expectedPayload
55 | * the expected payload
56 | */
57 | public QuickReplyMessageEvent(String expectedPayload) {
58 | super(expectedPayload);
59 | }
60 |
61 | /**
62 | * Verify event condition.
63 | *
64 | * @param envelope
65 | * the envelope
66 | * @return true if the text message received by the callback equals the
67 | * expected message, false otherwise.
68 | */
69 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
70 | String message = safeGetQuickReplyPayload(envelope);
71 | if (caseSensitive) {
72 | expectedString = expectedString.toLowerCase();
73 | message = message.toLowerCase();
74 | }
75 | return message.equals(expectedString);
76 | }
77 |
78 | /*
79 | * (non-Javadoc)
80 | *
81 | * @see co.aurasphere.botmill.fb.event.base.BaseStringEvent#toString()
82 | */
83 | @Override
84 | public String toString() {
85 | return "QuickReplyMessageEvent [expectedString=" + expectedString + "]";
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/message/QuickReplyMessagePatternEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.message;
25 |
26 | import java.util.regex.Pattern;
27 |
28 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
29 | import co.aurasphere.botmill.fb.event.base.BasePatternEvent;
30 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
31 |
32 |
33 | /**
34 | * An {@link FbBotMillEvent} that processes all the incoming callbacks that
35 | * contains a text message which matches against a defined pattern from
36 | * Facebook's Messenger Platform.
37 | *
38 | * @author Alvin Reyes
39 | */
40 | public class QuickReplyMessagePatternEvent extends BasePatternEvent {
41 |
42 | /**
43 | * Instantiates a new quick reply message event pattern.
44 | *
45 | * @param expectedPattern
46 | * the expected pattern
47 | * @see BasePatternEvent#BasePatternEvent(Pattern)
48 | */
49 | public QuickReplyMessagePatternEvent(Pattern expectedPattern) {
50 | super(expectedPattern);
51 | }
52 |
53 | /**
54 | * Instantiates a new quick reply message event pattern.
55 | *
56 | * @param expectedPattern
57 | * the expected pattern
58 | * @see BasePatternEvent#BasePatternEvent(String)
59 | */
60 | public QuickReplyMessagePatternEvent(String expectedPattern) {
61 | super(expectedPattern);
62 | }
63 |
64 | /**
65 | * Verify event condition.
66 | *
67 | * @param envelope
68 | * the envelope
69 | * @return true if the text message received from the callback matches the
70 | * expected pattern, false otherwise.
71 | */
72 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
73 | String message = safeGetQuickReplyPayload(envelope);
74 | return expectedPattern.matcher(message).matches();
75 | }
76 |
77 | /*
78 | * (non-Javadoc)
79 | *
80 | * @see co.aurasphere.botmill.fb.event.base.BasePatternEvent#toString()
81 | */
82 | @Override
83 | public String toString() {
84 | return "QuickReplyMessagePatternEvent [expectedPattern="
85 | + expectedPattern + "]";
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/postback/AnyPostbackEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.postback;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
28 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
29 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
30 |
31 |
32 | /**
33 | * A {@link FbBotMillEvent} that triggers whenever the users sends a payload
34 | * back by pressing a button or similar.
35 | *
36 | * @author Donato Rimenti
37 | * @author Alvin Reyes
38 | */
39 | public class AnyPostbackEvent extends FbBotMillBean implements FbBotMillEvent {
40 |
41 | /*
42 | * (non-Javadoc)
43 | *
44 | * @see
45 | * co.aurasphere.botmill.fb.event.FbBotMillEvent#verifyEventCondition(co.
46 | * aurasphere.botmill.fb.model.incoming.MessageEnvelope)
47 | */
48 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
49 | return eventKind(envelope) == FbBotMillEventType.POSTBACK;
50 | }
51 |
52 | /*
53 | * (non-Javadoc)
54 | *
55 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
56 | */
57 | @Override
58 | public String toString() {
59 | return "AnyPostbackEvent []";
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/postback/PostbackEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.postback;
25 |
26 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
27 | import co.aurasphere.botmill.fb.event.base.BaseStringEvent;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 |
30 |
31 | /**
32 | * An {@link FbBotMillEvent} that triggers whenever the users sends a a payload
33 | * back by pressing a button or similar that matches an exact String.
34 | *
35 | * @author Donato Rimenti
36 | *
37 | */
38 | public class PostbackEvent extends BaseStringEvent {
39 |
40 | /**
41 | * Instantiates a new PostbackEvent.
42 | *
43 | * @param expectedPayload
44 | * the {@link BaseStringEvent#expectedString}.
45 | * @param caseSensitive
46 | * the {@link BaseStringEvent#caseSensitive}.
47 | */
48 | public PostbackEvent(String expectedPayload, boolean caseSensitive) {
49 | super(expectedPayload, caseSensitive);
50 | }
51 |
52 | /**
53 | * Instantiates a new PostbackEvent.
54 | *
55 | * @param expectedPayload
56 | * the {@link BaseStringEvent#expectedString}.
57 | */
58 | public PostbackEvent(String expectedPayload) {
59 | super(expectedPayload);
60 | }
61 |
62 | /*
63 | * (non-Javadoc)
64 | *
65 | * @see
66 | * co.aurasphere.botmill.fb.event.FbBotMillEvent#verifyEventCondition(co.
67 | * aurasphere.botmill.fb.model.incoming.MessageEnvelope)
68 | */
69 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
70 | String payload = safeGetPostbackPayload(envelope);
71 | return verifyStringMatch(payload);
72 | }
73 |
74 | /*
75 | * (non-Javadoc)
76 | *
77 | * @see co.aurasphere.botmill.fb.event.base.BaseStringEvent#toString()
78 | */
79 | @Override
80 | public String toString() {
81 | return "PostbackEvent [expectedString=" + expectedString
82 | + ", caseSensitive=" + caseSensitive + "]";
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/event/postback/PostbackPatternEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.event.postback;
25 |
26 | import java.util.regex.Pattern;
27 |
28 | import co.aurasphere.botmill.fb.event.FbBotMillEvent;
29 | import co.aurasphere.botmill.fb.event.base.BasePatternEvent;
30 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
31 |
32 |
33 | /**
34 | * An {@link FbBotMillEvent} that triggers whenever the users sends a a payload
35 | * back by pressing a button or similar that matches a {@link Pattern}.
36 | *
37 | * @author Donato Rimenti
38 | * @author Alvin Reyes
39 | *
40 | */
41 | public class PostbackPatternEvent extends BasePatternEvent {
42 |
43 | /**
44 | * Instantiates a new PostbackPatternEvent.
45 | *
46 | * @param expectedPattern
47 | * the {@link BasePatternEvent#expectedPattern}.
48 | */
49 | public PostbackPatternEvent(Pattern expectedPattern) {
50 | super(expectedPattern);
51 | }
52 |
53 | /**
54 | * Instantiates a new PostbackPatternEvent.
55 | *
56 | * @param expectedPattern
57 | * the {@link BasePatternEvent#expectedPattern}.
58 | */
59 | public PostbackPatternEvent(String expectedPattern) {
60 | super(expectedPattern);
61 | }
62 |
63 | /*
64 | * (non-Javadoc)
65 | *
66 | * @see
67 | * co.aurasphere.botmill.fb.event.FbBotMillEvent#verifyEventCondition(co.
68 | * aurasphere.botmill.fb.model.incoming.MessageEnvelope)
69 | */
70 | public final boolean verifyEventCondition(MessageEnvelope envelope) {
71 | String payload = safeGetPostbackPayload(envelope);
72 | return verifyPatternMatch(payload);
73 | }
74 |
75 | /*
76 | * (non-Javadoc)
77 | *
78 | * @see co.aurasphere.botmill.fb.event.base.BasePatternEvent#toString()
79 | */
80 | @Override
81 | public String toString() {
82 | return "PostbackPatternEvent [expectedPattern=" + expectedPattern + "]";
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/internal/util/json/CalendarSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.internal.util.json;
25 |
26 | import java.lang.reflect.Type;
27 | import java.text.DecimalFormat;
28 | import java.util.Calendar;
29 |
30 | import com.google.gson.JsonElement;
31 | import com.google.gson.JsonSerializationContext;
32 | import com.google.gson.JsonSerializer;
33 |
34 |
35 | /**
36 | * Class that handles the serialization of a Calendar using the Facebook date
37 | * format (YYYY-MM-DDThh:mm).
38 | *
39 | * @author Donato Rimenti
40 | *
41 | */
42 | public class CalendarSerializer implements JsonSerializer {
43 |
44 | /**
45 | * The formatter for the calendar.
46 | */
47 | private final DecimalFormat formatter;
48 |
49 | /**
50 | * Instantiates a new calendar serializer.
51 | */
52 | public CalendarSerializer() {
53 | this.formatter = new DecimalFormat("00");
54 | }
55 |
56 | /**
57 | * Serializes a Calendar using the Facebook date format (YYYY-MM-DDThh:mm).
58 | *
59 | * @param src
60 | * the src
61 | * @param typeOfSrc
62 | * the type of src
63 | * @param context
64 | * the context
65 | * @return the json element
66 | */
67 | public JsonElement serialize(Calendar src, Type typeOfSrc,
68 | JsonSerializationContext context) {
69 | int year = src.get(Calendar.YEAR);
70 | String month = this.formatter.format(Double.valueOf(src
71 | .get(Calendar.MONTH) + 1));
72 | String day = this.formatter.format(Double.valueOf(src
73 | .get(Calendar.DAY_OF_MONTH)));
74 | String hour = this.formatter.format(Double.valueOf(src
75 | .get(Calendar.HOUR_OF_DAY)));
76 | String minute = this.formatter.format(Double.valueOf(src
77 | .get(Calendar.MINUTE)));
78 | String formattedDate = year + "-" + month + "-" + day + "T" + hour
79 | + ":" + minute;
80 |
81 | return context.serialize(formattedDate);
82 | }
83 |
84 | /*
85 | * (non-Javadoc)
86 | *
87 | * @see java.lang.Object#toString()
88 | */
89 | @Override
90 | public String toString() {
91 | return "CalendarSerializer [formatter=" + formatter + "]";
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/internal/util/json/EnumLowercaseSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.internal.util.json;
25 |
26 | import java.lang.reflect.Type;
27 |
28 | import co.aurasphere.botmill.fb.model.outcoming.template.button.PaymentType;
29 |
30 | import com.google.gson.JsonElement;
31 | import com.google.gson.JsonSerializationContext;
32 | import com.google.gson.JsonSerializer;
33 |
34 |
35 | /**
36 | * Class that serializes an Enum as its lowercase name.
37 | *
38 | * @author Donato Rimenti
39 | */
40 | public class EnumLowercaseSerializer implements JsonSerializer> {
41 |
42 | /**
43 | * Serializes an Enum as its lowercase name.
44 | *
45 | * @param src
46 | * the src.
47 | * @param typeOfSrc
48 | * the type of src.
49 | * @param context
50 | * the context.
51 | * @return the json element.
52 | */
53 | public JsonElement serialize(Enum> src, Type typeOfSrc,
54 | JsonSerializationContext context) {
55 |
56 | // Ignore this serializer for enums of class PaymentType.
57 | if (src.getDeclaringClass().equals(PaymentType.class)) {
58 | return context.serialize(src.name());
59 | }
60 |
61 | return context.serialize(src.name().toLowerCase());
62 | }
63 |
64 | /*
65 | * (non-Javadoc)
66 | *
67 | * @see java.lang.Object#toString()
68 | */
69 | @Override
70 | public String toString() {
71 | return "EnumLowercaseSerializer []";
72 | }
73 | }
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/internal/util/json/IncomingMessageDeserializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.internal.util.json;
25 |
26 | import java.lang.reflect.Type;
27 |
28 | import com.google.gson.JsonDeserializationContext;
29 | import com.google.gson.JsonDeserializer;
30 | import com.google.gson.JsonElement;
31 | import com.google.gson.JsonParseException;
32 |
33 | import co.aurasphere.botmill.fb.model.incoming.callback.EchoMessage;
34 | import co.aurasphere.botmill.fb.model.incoming.callback.IncomingMessage;
35 | import co.aurasphere.botmill.fb.model.incoming.callback.ReceivedMessage;
36 |
37 |
38 | /**
39 | * Custom deserializer for an {@link IncomingMessage}. Instantiates the correct
40 | * message from interface.
41 | *
42 | * @author Donato Rimenti
43 | * @since 1.1.0
44 | */
45 | public class IncomingMessageDeserializer implements
46 | JsonDeserializer {
47 |
48 | /*
49 | * (non-Javadoc)
50 | *
51 | * @see
52 | * com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement,
53 | * java.lang.reflect.Type, com.google.gson.JsonDeserializationContext)
54 | */
55 | public IncomingMessage deserialize(JsonElement json, Type typeOfT,
56 | JsonDeserializationContext context) throws JsonParseException {
57 | JsonElement isEchoElement = json.getAsJsonObject().get("is_echo");
58 | boolean isEcho = isEchoElement != null ? isEchoElement.getAsBoolean() : false;
59 | Class extends IncomingMessage> incomingMessageClass = null;
60 | if (isEcho == true) {
61 | incomingMessageClass = EchoMessage.class;
62 | } else {
63 | incomingMessageClass = ReceivedMessage.class;
64 | }
65 | return context.deserialize(json, incomingMessageClass);
66 | }
67 |
68 | /*
69 | * (non-Javadoc)
70 | *
71 | * @see java.lang.Object#toString()
72 | */
73 | @Override
74 | public String toString() {
75 | return "IncomingMessageDeserializer []";
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/annotation/FbBotMillController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.annotation;
25 |
26 | import java.lang.annotation.Documented;
27 | import java.lang.annotation.ElementType;
28 | import java.lang.annotation.Inherited;
29 | import java.lang.annotation.Retention;
30 | import java.lang.annotation.RetentionPolicy;
31 | import java.lang.annotation.Target;
32 |
33 | import co.aurasphere.botmill.fb.event.FbBotMillEventType;
34 |
35 |
36 | /**
37 | * The Interface FbBotMillController.
38 | *
39 | * @author Alvin P. Reyes
40 | */
41 | @Documented
42 | @Target(ElementType.METHOD)
43 | @Inherited
44 | @Retention(RetentionPolicy.RUNTIME)
45 | public @interface FbBotMillController {
46 |
47 | /**
48 | * Event type.
49 | *
50 | * @return the fb bot mill event type
51 | */
52 | FbBotMillEventType eventType() default FbBotMillEventType.MESSAGE;
53 |
54 | /**
55 | * Text.
56 | *
57 | * @return the string
58 | */
59 | String text() default "";
60 |
61 | /**
62 | * Pattern.
63 | *
64 | * @return the string
65 | */
66 | String pattern() default "";
67 |
68 | /**
69 | * Payload.
70 | *
71 | * @return the string
72 | */
73 | String payload() default "";
74 |
75 | /**
76 | * Quick reply payload.
77 | *
78 | * @return the string
79 | */
80 | String quickReplyPayload() default "";
81 |
82 | /**
83 | * Quick replt payload pattern.
84 | *
85 | * @return the string
86 | */
87 | String quickReplyPayloadPattern() default "";
88 |
89 | /**
90 | * Postback.
91 | *
92 | * @return the string
93 | */
94 | String postback() default "";
95 |
96 | /**
97 | * Postback pattern.
98 | *
99 | * @return the string
100 | */
101 | String postbackPattern() default "";
102 |
103 | /**
104 | * Case sensitive.
105 | *
106 | * @return true, if successful
107 | */
108 | boolean caseSensitive() default false;
109 |
110 | /**
111 | * Meta.
112 | *
113 | * @return the string
114 | */
115 | String meta() default ""; // random text to indicate the purpose.
116 |
117 |
118 | boolean skipAuthorization() default false;
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/annotation/FbBotMillInit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.annotation;
25 |
26 | import java.lang.annotation.Documented;
27 | import java.lang.annotation.ElementType;
28 | import java.lang.annotation.Inherited;
29 | import java.lang.annotation.Retention;
30 | import java.lang.annotation.RetentionPolicy;
31 | import java.lang.annotation.Target;
32 |
33 |
34 | /**
35 | * The Interface FbBotMillInit.
36 | *
37 | * @author Alvin P. Reyes
38 | */
39 | @Documented
40 | @Target(ElementType.METHOD)
41 | @Inherited
42 | @Retention(RetentionPolicy.RUNTIME)
43 | public @interface FbBotMillInit {
44 |
45 | /**
46 | * Meta.
47 | *
48 | * @return the string
49 | */
50 | String meta() default ""; // random text to indicate the purpose.
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messaginginsight/DailyUniqueActiveThreadCounts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messaginginsight;
25 |
26 | import java.io.Serializable;
27 | import java.util.List;
28 |
29 | import co.aurasphere.botmill.fb.api.MessagingInsightApi;
30 |
31 | /**
32 | * Model used by {@link MessagingInsightApi#getDailyUniqueActiveThreadCounts()}.
33 | *
34 | * @author Donato Rimenti
35 | * @since 2.0.0
36 | */
37 | public class DailyUniqueActiveThreadCounts implements Serializable {
38 |
39 | /**
40 | * The serial version UID.
41 | */
42 | private static final long serialVersionUID = 1L;
43 |
44 | /**
45 | * The data.
46 | */
47 | private List data;
48 |
49 | /**
50 | * Gets the {@link #data}.
51 | *
52 | * @return the {@link #data}.
53 | */
54 | public List getData() {
55 | return data;
56 | }
57 |
58 | /**
59 | * Sets the {@link #data}.
60 | *
61 | * @param data
62 | * the {@link #data} to set.
63 | */
64 | public void setData(List data) {
65 | this.data = data;
66 | }
67 |
68 | /*
69 | * (non-Javadoc)
70 | *
71 | * @see java.lang.Object#hashCode()
72 | */
73 | @Override
74 | public int hashCode() {
75 | final int prime = 31;
76 | int result = 1;
77 | result = prime * result + ((data == null) ? 0 : data.hashCode());
78 | return result;
79 | }
80 |
81 | /*
82 | * (non-Javadoc)
83 | *
84 | * @see java.lang.Object#equals(java.lang.Object)
85 | */
86 | @Override
87 | public boolean equals(Object obj) {
88 | if (this == obj)
89 | return true;
90 | if (obj == null)
91 | return false;
92 | if (getClass() != obj.getClass())
93 | return false;
94 | DailyUniqueActiveThreadCounts other = (DailyUniqueActiveThreadCounts) obj;
95 | if (data == null) {
96 | if (other.data != null)
97 | return false;
98 | } else if (!data.equals(other.data))
99 | return false;
100 | return true;
101 | }
102 |
103 | /*
104 | * (non-Javadoc)
105 | *
106 | * @see java.lang.Object#toString()
107 | */
108 | @Override
109 | public String toString() {
110 | return "DailyUniqueActiveThreadCounts [data=" + data + "]";
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messaginginsight/DailyUniqueConversationCounts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messaginginsight;
25 |
26 | import java.io.Serializable;
27 | import java.util.List;
28 |
29 | import co.aurasphere.botmill.fb.api.MessagingInsightApi;
30 |
31 | /**
32 | * Model used by {@link MessagingInsightApi#getDailyUniqueConversationCounts()}.
33 | *
34 | * @author Donato Rimenti
35 | * @since 2.0.0
36 | */
37 | public class DailyUniqueConversationCounts implements Serializable {
38 |
39 | /**
40 | * The serial version UID.
41 | */
42 | private static final long serialVersionUID = 1L;
43 |
44 | /**
45 | * The data.
46 | */
47 | private List data;
48 |
49 | /**
50 | * Gets the {@link #data}.
51 | *
52 | * @return the {@link #data}.
53 | */
54 | public List getData() {
55 | return data;
56 | }
57 |
58 | /**
59 | * Sets the {@link #data}.
60 | *
61 | * @param data
62 | * the {@link #data} to set.
63 | */
64 | public void setData(List data) {
65 | this.data = data;
66 | }
67 |
68 | /*
69 | * (non-Javadoc)
70 | *
71 | * @see java.lang.Object#hashCode()
72 | */
73 | @Override
74 | public int hashCode() {
75 | final int prime = 31;
76 | int result = 1;
77 | result = prime * result + ((data == null) ? 0 : data.hashCode());
78 | return result;
79 | }
80 |
81 | /*
82 | * (non-Javadoc)
83 | *
84 | * @see java.lang.Object#equals(java.lang.Object)
85 | */
86 | @Override
87 | public boolean equals(Object obj) {
88 | if (this == obj)
89 | return true;
90 | if (obj == null)
91 | return false;
92 | if (getClass() != obj.getClass())
93 | return false;
94 | DailyUniqueConversationCounts other = (DailyUniqueConversationCounts) obj;
95 | if (data == null) {
96 | if (other.data != null)
97 | return false;
98 | } else if (!data.equals(other.data))
99 | return false;
100 | return true;
101 | }
102 |
103 | /*
104 | * (non-Javadoc)
105 | *
106 | * @see java.lang.Object#toString()
107 | */
108 | @Override
109 | public String toString() {
110 | return "DailyUniqueConversationCounts [data=" + data + "]";
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messaginginsight/DailyUniqueConversationCountsRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messaginginsight;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * Record used by {@link DailyUniqueConversationCounts}.
30 | *
31 | * @author Donato Rimenti
32 | * @since 2.0.0
33 | */
34 | public class DailyUniqueConversationCountsRecord extends MessagingInsightBaseRecord {
35 |
36 | /**
37 | * The serial version UID.
38 | */
39 | private static final long serialVersionUID = 1L;
40 |
41 | /**
42 | * The values.
43 | */
44 | private List values;
45 |
46 | /**
47 | * Gets the {@link #values}.
48 | *
49 | * @return the {@link #values}.
50 | */
51 | public List getValues() {
52 | return values;
53 | }
54 |
55 | /**
56 | * Sets the {@link #values}.
57 | *
58 | * @param values the {@link #values} to set.
59 | */
60 | public void setValues(List values) {
61 | this.values = values;
62 | }
63 |
64 | /* (non-Javadoc)
65 | * @see co.aurasphere.botmill.fb.model.api.messaginginsight.MessagingInsightBaseRecord#hashCode()
66 | */
67 | @Override
68 | public int hashCode() {
69 | final int prime = 31;
70 | int result = super.hashCode();
71 | result = prime * result + ((values == null) ? 0 : values.hashCode());
72 | return result;
73 | }
74 |
75 | /* (non-Javadoc)
76 | * @see co.aurasphere.botmill.fb.model.api.messaginginsight.MessagingInsightBaseRecord#equals(java.lang.Object)
77 | */
78 | @Override
79 | public boolean equals(Object obj) {
80 | if (this == obj)
81 | return true;
82 | if (!super.equals(obj))
83 | return false;
84 | if (getClass() != obj.getClass())
85 | return false;
86 | DailyUniqueConversationCountsRecord other = (DailyUniqueConversationCountsRecord) obj;
87 | if (values == null) {
88 | if (other.values != null)
89 | return false;
90 | } else if (!values.equals(other.values))
91 | return false;
92 | return true;
93 | }
94 |
95 | /* (non-Javadoc)
96 | * @see co.aurasphere.botmill.fb.model.api.messaginginsight.MessagingInsightBaseRecord#toString()
97 | */
98 | @Override
99 | public String toString() {
100 | return "DailyUniqueConversationCountsRecord [values=" + values + "]";
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messengercode/MessengerCode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messengercode;
25 |
26 | import java.io.Serializable;
27 |
28 | /**
29 | * Base class for a Messenger Code (Messenger's platform QR code).
30 | *
31 | * @author Donato Rimenti
32 | * @since 2.0.0
33 | */
34 | public class MessengerCode implements Serializable {
35 |
36 | /**
37 | * The serial version UID.
38 | */
39 | private static final long serialVersionUID = 1L;
40 |
41 | /**
42 | * The URI that you can download your Messenger Code at. This is not a
43 | * permanent URI; you should download and cache the image as soon as
44 | * possible.
45 | */
46 | private String uri;
47 |
48 | /**
49 | * Gets the {@link #uri}.
50 | *
51 | * @return the {@link #uri}.
52 | */
53 | public String getUri() {
54 | return uri;
55 | }
56 |
57 | /**
58 | * Sets the {@link #uri}.
59 | *
60 | * @param uri
61 | * the {@link #uri} to set.
62 | */
63 | public void setUri(String uri) {
64 | this.uri = uri;
65 | }
66 |
67 | /*
68 | * (non-Javadoc)
69 | *
70 | * @see java.lang.Object#hashCode()
71 | */
72 | @Override
73 | public int hashCode() {
74 | final int prime = 31;
75 | int result = 1;
76 | result = prime * result + ((uri == null) ? 0 : uri.hashCode());
77 | return result;
78 | }
79 |
80 | /*
81 | * (non-Javadoc)
82 | *
83 | * @see java.lang.Object#equals(java.lang.Object)
84 | */
85 | @Override
86 | public boolean equals(Object obj) {
87 | if (this == obj)
88 | return true;
89 | if (obj == null)
90 | return false;
91 | if (getClass() != obj.getClass())
92 | return false;
93 | MessengerCode other = (MessengerCode) obj;
94 | if (uri == null) {
95 | if (other.uri != null)
96 | return false;
97 | } else if (!uri.equals(other.uri))
98 | return false;
99 | return true;
100 | }
101 |
102 | /*
103 | * (non-Javadoc)
104 | *
105 | * @see java.lang.Object#toString()
106 | */
107 | @Override
108 | public String toString() {
109 | return "MessengerCode [uri=" + uri + "]";
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messengercode/MessengerCodeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messengercode;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 | /**
29 | * Type for a {@link MessengerCode}.
30 | *
31 | * @author Donato Rimenti
32 | * @since 2.0.0
33 | */
34 | public enum MessengerCodeType {
35 |
36 | /**
37 | * The standard.
38 | */
39 | @SerializedName("standard")
40 | STANDARD;
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messengerprofile/HomeUrl.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.model.api.messengerprofile;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.google.gson.annotations.SerializedName;
6 |
7 | import co.aurasphere.botmill.fb.model.outcoming.template.button.WebViewHeightRatioType;
8 | import co.aurasphere.botmill.fb.model.outcoming.template.button.WebViewShareButton;
9 |
10 | public class HomeUrl implements Serializable {
11 |
12 | private static final long serialVersionUID = 1L;
13 |
14 | private String url;
15 | @SerializedName("webview_height_ratio")
16 | private WebViewHeightRatioType webviewHeightRatio;
17 | @SerializedName("webview_share_button")
18 | private WebViewShareButton webviewShareButton;
19 | @SerializedName("in_test")
20 | private boolean inTest;
21 |
22 | public String getUrl() {
23 | return url;
24 | }
25 |
26 | public void setUrl(String url) {
27 | this.url = url;
28 | }
29 |
30 | public WebViewHeightRatioType getWebviewHeightRatio() {
31 | return webviewHeightRatio;
32 | }
33 |
34 | public void setWebviewHeightRatio(WebViewHeightRatioType webviewHeightRatio) {
35 | this.webviewHeightRatio = webviewHeightRatio;
36 | }
37 |
38 | public WebViewShareButton getWebviewShareButton() {
39 | return webviewShareButton;
40 | }
41 |
42 | public void setWebviewShareButton(WebViewShareButton webviewShareButton) {
43 | this.webviewShareButton = webviewShareButton;
44 | }
45 |
46 | public boolean isInTest() {
47 | return inTest;
48 | }
49 |
50 | public void setInTest(boolean inTest) {
51 | this.inTest = inTest;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messengerprofile/HomeUrlRequest.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.model.api.messengerprofile;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class HomeUrlRequest {
6 |
7 | @SerializedName("home_url")
8 | private HomeUrl homeUrl;
9 |
10 | public HomeUrl getHomeUrl() {
11 | return homeUrl;
12 | }
13 |
14 | public void setHomeUrl(HomeUrl homeUrl) {
15 | this.homeUrl = homeUrl;
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/messengerprofile/persistentmenu/PersistentMenuRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.messengerprofile.persistentmenu;
25 |
26 | import java.io.Serializable;
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | import com.google.gson.annotations.SerializedName;
31 |
32 |
33 | /**
34 | * The Class PersistentMenuRequest.
35 | *
36 | * The Persistent Menu Request is the main object we sent thru our post request which will
37 | * create the necessary JSON structured data to create the persistent menu of the bots
38 | *
39 | * @author Alvin P. Reyes
40 | *
41 | */
42 | public class PersistentMenuRequest implements Serializable {
43 |
44 | /** The Constant serialVersionUID. */
45 | private static final long serialVersionUID = 1L;
46 |
47 | /** The persistent menu. */
48 | @SerializedName("persistent_menu")
49 | private List persistentMenu;
50 |
51 |
52 | /**
53 | * Instantiates a new persistent menu request.
54 | */
55 | public PersistentMenuRequest() {
56 | this.persistentMenu = new ArrayList();
57 | }
58 |
59 | /**
60 | * Gets the persistent menu.
61 | *
62 | * @return the persistent menu
63 | */
64 | public List getPersistentMenu() {
65 | return persistentMenu;
66 | }
67 |
68 | /**
69 | * Sets the persistent menu.
70 | *
71 | * @param persistentMenu the new persistent menu
72 | */
73 | public void setPersistentMenu(List persistentMenu) {
74 | this.persistentMenu = persistentMenu;
75 | }
76 |
77 | /**
78 | * Adds the persistent menu.
79 | *
80 | * @param persistentMenu the persistent menu
81 | */
82 | public void addPersistentMenu(PersistentMenu persistentMenu) {
83 | this.persistentMenu.add(persistentMenu);
84 | }
85 |
86 | /**
87 | * Adds the all persistent menu.
88 | *
89 | * @param persistentMenus the persistent menus
90 | */
91 | public void addAllPersistentMenu(List persistentMenus) {
92 | this.persistentMenu.addAll(persistentMenus);
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/threadsettings/DomainActionType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.threadsettings;
25 |
26 |
27 | /**
28 | * The Enum DomainActionType.
29 | *
30 | * @author Alvin Reyes
31 | */
32 | public enum DomainActionType {
33 |
34 | /** The add. */
35 | ADD,
36 | /** The remove. */
37 | REMOVE;
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/threadsettings/SettingType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.threadsettings;
25 |
26 |
27 | /**
28 | * Enum for the Thread Setting to modify.
29 | *
30 | * @author Donato Rimenti
31 | * @see Facebook's Messenger Platform Thread Settings Documentation
34 | *
35 | */
36 | public enum SettingType {
37 |
38 | /**
39 | * Setting for the Greeting Text message.
40 | */
41 | GREETING,
42 |
43 | /**
44 | * Setting for the Get Started Button or the Persistent Menu.
45 | */
46 | CALL_TO_ACTIONS,
47 |
48 | /** The domain whitelisting. */
49 | DOMAIN_WHITELISTING,
50 |
51 | /** The payment. */
52 | PAYMENT;
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/threadsettings/ThreadSettingsBaseRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.threadsettings;
25 |
26 | import java.io.Serializable;
27 |
28 | import javax.validation.constraints.NotNull;
29 |
30 | import com.google.gson.annotations.SerializedName;
31 |
32 |
33 | /**
34 | * Base request for a Thread Setting configuration.
35 | *
36 | * @author Donato Rimenti
37 | * @see Facebook's Messenger Platform Thread Settings Documentation
40 | *
41 | */
42 | public abstract class ThreadSettingsBaseRequest implements Serializable {
43 |
44 | /**
45 | * The serial version UID.
46 | */
47 | private static final long serialVersionUID = 1L;
48 |
49 | /**
50 | * The type of setting to change.
51 | */
52 | @NotNull
53 | @SerializedName("setting_type")
54 | protected SettingType type;
55 |
56 | /**
57 | * Gets the {@link #type}.
58 | *
59 | * @return the {@link #type}.
60 | */
61 | public SettingType getType() {
62 | return type;
63 | }
64 |
65 | /**
66 | * Sets the {@link #type}.
67 | *
68 | * @param type
69 | * the {@link #type} to set.
70 | */
71 | public void setType(SettingType type) {
72 | this.type = type;
73 | }
74 |
75 | /*
76 | * (non-Javadoc)
77 | *
78 | * @see java.lang.Object#hashCode()
79 | */
80 | @Override
81 | public int hashCode() {
82 | final int prime = 31;
83 | int result = 1;
84 | result = prime * result + ((type == null) ? 0 : type.hashCode());
85 | return result;
86 | }
87 |
88 | /*
89 | * (non-Javadoc)
90 | *
91 | * @see java.lang.Object#equals(java.lang.Object)
92 | */
93 | @Override
94 | public boolean equals(Object obj) {
95 | if (this == obj)
96 | return true;
97 | if (obj == null)
98 | return false;
99 | if (getClass() != obj.getClass())
100 | return false;
101 | ThreadSettingsBaseRequest other = (ThreadSettingsBaseRequest) obj;
102 | if (type != other.type)
103 | return false;
104 | return true;
105 | }
106 |
107 | /*
108 | * (non-Javadoc)
109 | *
110 | * @see java.lang.Object#toString()
111 | */
112 | @Override
113 | public String toString() {
114 | return "ThreadSettingsBaseRequest [type=" + type + "]";
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/threadsettings/ThreadState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.threadsettings;
25 |
26 |
27 | /**
28 | * Enum that represents the Facebook Thread state.
29 | *
30 | * @author Donato Rimenti
31 | * @see Facebook's Messenger Platform Thread Settings Documentation
34 | *
35 | */
36 | public enum ThreadState {
37 |
38 | /**
39 | * Used for the Get Started Button.
40 | */
41 | NEW_THREAD,
42 |
43 | /**
44 | * Used for the Persistent Menu.
45 | */
46 | EXISTING_THREAD;
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/threadsettings/payment/PaymentDevModeAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | */
25 | package co.aurasphere.botmill.fb.model.api.threadsettings.payment;
26 |
27 |
28 | /**
29 | * The Enum PaymentDevModeAction.
30 | */
31 | public enum PaymentDevModeAction {
32 |
33 | /** The add. */
34 | ADD,
35 | /** The remove. */
36 | REMOVE;
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/api/userprofile/Gender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.api.userprofile;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 |
29 | /**
30 | * Enumeration used for the deserialization of the gender in the user profile.
31 | *
32 | * @author Donato Rimenti
33 | *
34 | */
35 | public enum Gender {
36 |
37 | /**
38 | * The male gender.
39 | */
40 | @SerializedName("male") MALE,
41 |
42 | /**
43 | * The female gender.
44 | */
45 | @SerializedName("female") FEMALE;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/base/AttachmentType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.base;
25 |
26 | import java.io.Serializable;
27 |
28 | import com.google.gson.annotations.SerializedName;
29 |
30 |
31 | /**
32 | * Enum for attachment types.
33 | *
34 | * @author Donato Rimenti
35 | *
36 | */
37 | public enum AttachmentType implements Serializable {
38 |
39 | /**
40 | * Image file attachment.
41 | */
42 | @SerializedName("image") IMAGE,
43 |
44 | /**
45 | * Audio file attachment.
46 | */
47 | @SerializedName("audio") AUDIO,
48 |
49 | /**
50 | * Video file attachment.
51 | */
52 | @SerializedName("video") VIDEO,
53 |
54 | /**
55 | * Generic file attachment.
56 | */
57 | @SerializedName("file") FILE,
58 |
59 | /**
60 | * Location object attachment.
61 | */
62 | @SerializedName("location") LOCATION,
63 |
64 | /**
65 | * Template attachment. Only used in replies.
66 | */
67 | @SerializedName("template") TEMPLATE,
68 |
69 | /**
70 | * Legacy attachment. This attachment type should not be used. Only used in
71 | * incoming messages.
72 | */
73 | @SerializedName("fallback") FALLBACK;
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/base/Payload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.base;
25 |
26 | import java.io.Serializable;
27 |
28 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
29 |
30 | /**
31 | * Interface which represents a {@link FbBotMillResponse} payload.
32 | *
33 | * @author Donato Rimenti
34 | *
35 | */
36 | public interface Payload extends Serializable {
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/base/QuickReplyLocationPayload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.base;
25 |
26 | import co.aurasphere.botmill.fb.model.incoming.callback.LocationCoordinates;
27 |
28 |
29 | /**
30 | * A {@link Payload} which contains a Location sent by a Quick Reply.
31 | *
32 | * @author Alvin Reyes
33 | *
34 | */
35 | public class QuickReplyLocationPayload implements Payload {
36 |
37 | /**
38 | * The serial version UID.
39 | */
40 | private static final long serialVersionUID = 1L;
41 |
42 | /**
43 | * The coordinates.
44 | */
45 | private LocationCoordinates coordinates;
46 |
47 | /**
48 | * Gets the {@link #coordinates}.
49 | *
50 | * @return the {@link #coordinates}.
51 | */
52 | public LocationCoordinates getCoordinates() {
53 | return coordinates;
54 | }
55 |
56 | /**
57 | * Sets the {@link #coordinates}.
58 | *
59 | * @param coordinates
60 | * the {@link #coordinates} to set.
61 | */
62 | public void setCoordinates(LocationCoordinates coordinates) {
63 | this.coordinates = coordinates;
64 | }
65 |
66 | /*
67 | * (non-Javadoc)
68 | *
69 | * @see java.lang.Object#hashCode()
70 | */
71 | @Override
72 | public int hashCode() {
73 | final int prime = 31;
74 | int result = 1;
75 | result = prime * result
76 | + ((coordinates == null) ? 0 : coordinates.hashCode());
77 | return result;
78 | }
79 |
80 | /*
81 | * (non-Javadoc)
82 | *
83 | * @see java.lang.Object#equals(java.lang.Object)
84 | */
85 | @Override
86 | public boolean equals(Object obj) {
87 | if (this == obj)
88 | return true;
89 | if (obj == null)
90 | return false;
91 | if (getClass() != obj.getClass())
92 | return false;
93 | QuickReplyLocationPayload other = (QuickReplyLocationPayload) obj;
94 | if (coordinates == null) {
95 | if (other.coordinates != null)
96 | return false;
97 | } else if (!coordinates.equals(other.coordinates))
98 | return false;
99 | return true;
100 | }
101 |
102 | /*
103 | * (non-Javadoc)
104 | *
105 | * @see java.lang.Object#toString()
106 | */
107 | @Override
108 | public String toString() {
109 | return "QuickReplyLocationPayload [coordinates=" + coordinates + "]";
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/base/User.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.base;
25 |
26 | import java.io.Serializable;
27 |
28 | import org.hibernate.validator.constraints.NotBlank;
29 |
30 |
31 | /**
32 | * An object that contains a Facebook's user ID.
33 | *
34 | * @author Donato Rimenti
35 | *
36 | */
37 | public class User implements Serializable {
38 |
39 | /**
40 | * The serial version UID.
41 | */
42 | private static final long serialVersionUID = 1L;
43 |
44 | /**
45 | * The Facebook's user ID.
46 | */
47 | @NotBlank
48 | private String id;
49 |
50 | /**
51 | * Instantiates a new user.
52 | */
53 | public User() {
54 | }
55 |
56 | /**
57 | * Instantiates a new user.
58 | *
59 | * @param id
60 | * the {@link #id}.
61 | */
62 | public User(String id) {
63 | this.id = id;
64 | }
65 |
66 | /**
67 | * Gets the {@link #id}.
68 | *
69 | * @return the {@link #id}.
70 | */
71 | public String getId() {
72 | return id;
73 | }
74 |
75 | /**
76 | * Sets the {@link #id}.
77 | *
78 | * @param id
79 | * the {@link #id} to set.
80 | */
81 | public void setId(String id) {
82 | this.id = id;
83 | }
84 |
85 | /*
86 | * (non-Javadoc)
87 | *
88 | * @see java.lang.Object#hashCode()
89 | */
90 | @Override
91 | public int hashCode() {
92 | final int prime = 31;
93 | int result = 1;
94 | result = prime * result + ((id == null) ? 0 : id.hashCode());
95 | return result;
96 | }
97 |
98 | /*
99 | * (non-Javadoc)
100 | *
101 | * @see java.lang.Object#equals(java.lang.Object)
102 | */
103 | @Override
104 | public boolean equals(Object obj) {
105 | if (this == obj)
106 | return true;
107 | if (obj == null)
108 | return false;
109 | if (getClass() != obj.getClass())
110 | return false;
111 | User other = (User) obj;
112 | if (id == null) {
113 | if (other.id != null)
114 | return false;
115 | } else if (!id.equals(other.id))
116 | return false;
117 | return true;
118 | }
119 |
120 | /*
121 | * (non-Javadoc)
122 | *
123 | * @see java.lang.Object#toString()
124 | */
125 | @Override
126 | public String toString() {
127 | return "User [id=" + id + "]";
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/FacebookErrorMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming;
25 |
26 | import java.io.Serializable;
27 |
28 |
29 | /**
30 | * Message which contains a {@link FacebookError}.
31 | *
32 | * @author Donato Rimenti
33 | * @author Alvin Reyes
34 | *
35 | */
36 | public class FacebookErrorMessage implements Serializable {
37 |
38 | /**
39 | * The serial version UID.
40 | */
41 | private static final long serialVersionUID = 1L;
42 |
43 | /**
44 | * The error from Facebook.
45 | */
46 | private FacebookError error;
47 |
48 | /**
49 | * Gets the {@link #error}.
50 | *
51 | * @return the {@link #error}.
52 | */
53 | public FacebookError getError() {
54 | return error;
55 | }
56 |
57 | /**
58 | * Sets the {@link #error}.
59 | *
60 | * @param error
61 | * the {@link #error} to set.
62 | */
63 | public void setError(FacebookError error) {
64 | this.error = error;
65 | }
66 |
67 | /*
68 | * (non-Javadoc)
69 | *
70 | * @see java.lang.Object#hashCode()
71 | */
72 | @Override
73 | public int hashCode() {
74 | final int prime = 31;
75 | int result = 1;
76 | result = prime * result + ((error == null) ? 0 : error.hashCode());
77 | return result;
78 | }
79 |
80 | /*
81 | * (non-Javadoc)
82 | *
83 | * @see java.lang.Object#equals(java.lang.Object)
84 | */
85 | @Override
86 | public boolean equals(Object obj) {
87 | if (this == obj)
88 | return true;
89 | if (obj == null)
90 | return false;
91 | if (getClass() != obj.getClass())
92 | return false;
93 | FacebookErrorMessage other = (FacebookErrorMessage) obj;
94 | if (error == null) {
95 | if (other.error != null)
96 | return false;
97 | } else if (!error.equals(other.error))
98 | return false;
99 | return true;
100 | }
101 |
102 | /*
103 | * (non-Javadoc)
104 | *
105 | * @see java.lang.Object#toString()
106 | */
107 | @Override
108 | public String toString() {
109 | return "FacebookErrorMessage [error=" + error + "]";
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/MessengerCallbackObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 |
29 | /**
30 | * Object field for a {@link MessengerCallback}.
31 | *
32 | * @author Donato Rimenti
33 | */
34 | public enum MessengerCallbackObject {
35 |
36 | /**
37 | * The page.
38 | */
39 | @SerializedName("page")
40 | PAGE;
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/callback/AccountLinkingStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming.callback;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 |
29 | /**
30 | * Status for {@link AccountLinking}.
31 | *
32 | * @author Donato Rimenti
33 | */
34 | public enum AccountLinkingStatus {
35 |
36 | /**
37 | * The linked.
38 | */
39 | @SerializedName("linked")
40 | LINKED,
41 |
42 | /**
43 | * The unlinked.
44 | */
45 | @SerializedName("unlinked")
46 | UNLINKED;
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/callback/ReferralSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming.callback;
25 |
26 |
27 | /**
28 | * Source for the {@link Referral} object.
29 | *
30 | * @author Donato Rimenti
31 | */
32 | public enum ReferralSource {
33 |
34 | /**
35 | * The shortlink.
36 | */
37 | SHORTLINK;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/callback/ReferralType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming.callback;
25 |
26 |
27 | /**
28 | * The Enum ReferralType.
29 | */
30 | public enum ReferralType {
31 |
32 | /**
33 | * The open thread.
34 | */
35 | OPEN_THREAD;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/incoming/callback/payment/ProviderType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.incoming.callback.payment;
25 |
26 |
27 | /**
28 | * Provider type for a {@link PaymentCredential} object.
29 | *
30 | * @author Donato Rimenti
31 | */
32 | public enum ProviderType {
33 |
34 | /**
35 | * The stripe.
36 | */
37 | STRIPE,
38 |
39 | /**
40 | * The paypal.
41 | */
42 | PAYPAL,
43 |
44 | /**
45 | * The token.
46 | */
47 | TOKEN;
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/FbBotMillResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming;
25 |
26 | import java.io.Serializable;
27 |
28 | import javax.validation.Valid;
29 | import javax.validation.constraints.NotNull;
30 |
31 | import co.aurasphere.botmill.fb.model.base.User;
32 |
33 |
34 | /**
35 | * Object that represents a FbBotMill response.
36 | *
37 | * @author Donato Rimenti
38 | * @author Alvin Reyes
39 | */
40 | public abstract class FbBotMillResponse implements Serializable {
41 |
42 | /**
43 | * The serial version UID.
44 | */
45 | private static final long serialVersionUID = 1L;
46 |
47 | /**
48 | * The recipient of the message.
49 | */
50 | @Valid
51 | @NotNull
52 | protected User recipient;
53 |
54 | /**
55 | * Gets the {@link #recipient}.
56 | *
57 | * @return the {@link #recipient}.
58 | */
59 | public User getRecipient() {
60 | return recipient;
61 | }
62 |
63 | /**
64 | * Sets the {@link #recipient}.
65 | *
66 | * @param recipient
67 | * the {@link #recipient} to set.
68 | */
69 | public void setRecipient(User recipient) {
70 | this.recipient = recipient;
71 | }
72 |
73 | /*
74 | * (non-Javadoc)
75 | *
76 | * @see java.lang.Object#hashCode()
77 | */
78 | @Override
79 | public int hashCode() {
80 | final int prime = 31;
81 | int result = 1;
82 | result = prime * result
83 | + ((recipient == null) ? 0 : recipient.hashCode());
84 | return result;
85 | }
86 |
87 | /*
88 | * (non-Javadoc)
89 | *
90 | * @see java.lang.Object#equals(java.lang.Object)
91 | */
92 | @Override
93 | public boolean equals(Object obj) {
94 | if (this == obj)
95 | return true;
96 | if (obj == null)
97 | return false;
98 | if (getClass() != obj.getClass())
99 | return false;
100 | FbBotMillResponse other = (FbBotMillResponse) obj;
101 | if (recipient == null) {
102 | if (other.recipient != null)
103 | return false;
104 | } else if (!recipient.equals(other.recipient))
105 | return false;
106 | return true;
107 | }
108 |
109 | /*
110 | * (non-Javadoc)
111 | *
112 | * @see java.lang.Object#toString()
113 | */
114 | @Override
115 | public String toString() {
116 | return "FbBotMillResponse [recipient=" + recipient + "]";
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/action/TypingAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.action;
25 |
26 |
27 | /**
28 | * Enum that represents the non-message actions that a bot can perform. They are
29 | * used in conjunction with {@link FbBotMillActionResponse}.
30 | *
31 | * @author Donato Rimenti
32 | * @author Alvin Reyes
33 | *
34 | */
35 | public enum TypingAction {
36 |
37 | /**
38 | * Marks the message as seen.
39 | */
40 | MARK_SEEN,
41 |
42 | /**
43 | * Brings up the "is writing..." label. This label is turned off
44 | * automatically after 20 seconds or when a {@link #TYPING_OFF} action is
45 | * sent.
46 | */
47 | TYPING_ON,
48 |
49 | /**
50 | * Removes the "is writing..." label if present.
51 | */
52 | TYPING_OFF;
53 |
54 | }
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ActionResponseBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import co.aurasphere.botmill.fb.model.base.User;
27 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
28 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
29 | import co.aurasphere.botmill.fb.model.outcoming.action.FbBotMillActionResponse;
30 | import co.aurasphere.botmill.fb.model.outcoming.action.TypingAction;
31 |
32 |
33 | /**
34 | * A builder for a response which contains and performs a {@link TypingAction}.
35 | *
36 | * @author Donato Rimenti
37 | * @see Facebook's Messenger Platform Sender Actions Documentation
40 | *
41 | */
42 | public class ActionResponseBuilder extends FbBotMillResponseBuilder {
43 |
44 | /**
45 | * The action to perform.
46 | */
47 | private TypingAction action;
48 |
49 | /**
50 | * Instantiates a new action response builder.
51 | *
52 | * @param action
53 | * the {@link #action}.
54 | */
55 | ActionResponseBuilder(TypingAction action) {
56 | this.action = action;
57 | }
58 |
59 | /**
60 | * {@inheritDoc} It returns a {@link FbBotMillActionResponse} with the
61 | * {@link TypingAction} to perform.
62 | */
63 | public FbBotMillResponse build(MessageEnvelope envelope) {
64 | User recipient = getRecipient(envelope);
65 | return new FbBotMillActionResponse(recipient, action);
66 | }
67 |
68 | /*
69 | * (non-Javadoc)
70 | *
71 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
72 | */
73 | @Override
74 | public String toString() {
75 | return "ActionResponseBuilder [action=" + action + "]";
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/AirlineBaseTemplateBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 |
27 | /**
28 | * Base Airline Template builder. It doesn't contain any method nor field.
29 | *
30 | * @author Donato Rimenti
31 | *
32 | */
33 | public abstract class AirlineBaseTemplateBuilder extends TemplateBaseBuilder {
34 |
35 | /*
36 | * (non-Javadoc)
37 | *
38 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
39 | */
40 | @Override
41 | public String toString() {
42 | return "AirlineBaseTemplateBuilder [messageBuilder=" + messageBuilder
43 | + "]";
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/BuyButtonBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import co.aurasphere.botmill.fb.model.outcoming.template.button.BuyButton;
27 | import co.aurasphere.botmill.fb.model.outcoming.template.button.PaymentSummary;
28 | import co.aurasphere.botmill.fb.model.outcoming.template.button.PaymentType;
29 |
30 |
31 | /**
32 | * Builder for a {@link BuyButton}.
33 | *
34 | * @author Donato Rimenti
35 | * @since 1.1.0
36 | */
37 | public class BuyButtonBuilder {
38 |
39 | /**
40 | * The {@link BuyButton} created with this builder.
41 | */
42 | private BuyButton buyButton;
43 |
44 | /**
45 | * Instantiates a new BuyButtonBuilder.
46 | *
47 | * @param payload
48 | * the {@link BuyButton#payload}.
49 | */
50 | BuyButtonBuilder(String payload) {
51 | this.buyButton = new BuyButton(payload);
52 | }
53 |
54 | /**
55 | * Sets the {@link PaymentSummary} for the current {@link BuyButton}.
56 | *
57 | * @param paymentSummary
58 | * the {@link BuyButton#paymentSummary}.
59 | * @return this builder.
60 | */
61 | public BuyButtonBuilder setPaymentSummary(PaymentSummary paymentSummary) {
62 | this.buyButton.setPaymentSummary(paymentSummary);
63 | return this;
64 | }
65 |
66 | /**
67 | * Sets the {@link PaymentSummary} for the current {@link BuyButton}.
68 | *
69 | * @param currency
70 | * the {@link PaymentSummary#currency}.
71 | * @param paymentType
72 | * the {@link PaymentSummary#paymentType}.
73 | * @param merchantName
74 | * the {@link PaymentSummary#merchantName}.
75 | * @return this builder.
76 | */
77 | public PaymentSummaryBuilder setPaymentSummary(String currency,
78 | PaymentType paymentType, String merchantName) {
79 | return new PaymentSummaryBuilder(currency, paymentType, merchantName,
80 | this);
81 | }
82 |
83 | /**
84 | * Builds the {@link BuyButton}.
85 | *
86 | * @return the {@link #buyButton}.
87 | */
88 | public BuyButton build() {
89 | return this.buyButton;
90 | }
91 |
92 | /*
93 | * (non-Javadoc)
94 | *
95 | * @see java.lang.Object#toString()
96 | */
97 | @Override
98 | public String toString() {
99 | return "BuyButtonBuilder [buyButton=" + buyButton + "]";
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/FbBotMillResponseBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import co.aurasphere.botmill.fb.bean.FbBotMillBean;
27 | import co.aurasphere.botmill.fb.model.base.User;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
30 |
31 |
32 | /**
33 | * Abstract class for the response builders. Defines how a bot should build the
34 | * {@link FbBotMillResponse} object representing its response.
35 | *
36 | * @author Donato Rimenti
37 | *
38 | */
39 | public abstract class FbBotMillResponseBuilder extends FbBotMillBean {
40 |
41 | /**
42 | * Builds the {@link FbBotMillResponse} that the bot should return.
43 | *
44 | * @param envelope
45 | * a {@link MessageEnvelope} object representing the incoming
46 | * message.
47 | * @return the {@link FbBotMillResponse} of this bot.
48 | */
49 | abstract FbBotMillResponse build(MessageEnvelope envelope);
50 |
51 | /**
52 | * Returns the recipient of the envelope which is the sender of the previous
53 | * one.
54 | *
55 | * @param envelope
56 | * the incoming envelope.
57 | * @return the recipient.
58 | */
59 | protected User getRecipient(MessageEnvelope envelope) {
60 | return safeGetSender(envelope);
61 | }
62 |
63 | /*
64 | * (non-Javadoc)
65 | *
66 | * @see co.aurasphere.botmill.fb.bean.FbBotMillBean#toString()
67 | */
68 | @Override
69 | public String toString() {
70 | return "FbBotMillResponseBuilder []";
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/FlightInfoBuilderDelegator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import co.aurasphere.botmill.fb.model.outcoming.template.airline.FlightInfo;
27 |
28 |
29 | /**
30 | * An interface that represents a builder which uses a {@link FlightInfoBuilder}
31 | * object to populate its {@link FlightInfo} field.
32 | *
33 | * @author Donato Rimenti
34 | *
35 | */
36 | public abstract class FlightInfoBuilderDelegator extends
37 | AirlineBaseTemplateBuilder {
38 |
39 | /**
40 | * Adds a flight info object to the builder's payload.
41 | *
42 | * @param flightInfo
43 | * the flight info to add.
44 | */
45 | abstract void addFlightInfo(FlightInfo flightInfo);
46 |
47 | /*
48 | * (non-Javadoc)
49 | *
50 | * @see
51 | * co.aurasphere.botmill.fb.model.outcoming.factory.AirlineBaseTemplateBuilder
52 | * #toString()
53 | */
54 | @Override
55 | public String toString() {
56 | return "FlightInfoBuilderDelegator [messageBuilder=" + messageBuilder
57 | + "]";
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/MessageBaseBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import java.util.List;
27 |
28 | import co.aurasphere.botmill.fb.model.outcoming.quickreply.QuickReply;
29 |
30 |
31 | /**
32 | * Base class for a {@link FbBotMillResponseBuilder} that builds a message.
33 | *
34 | * @author Donato Rimenti
35 | *
36 | */
37 | public abstract class MessageBaseBuilder extends FbBotMillResponseBuilder {
38 |
39 | /**
40 | * The quick replies of this message. It's initialized lazily.
41 | */
42 | protected List quickReplies;
43 |
44 | /*
45 | * (non-Javadoc)
46 | *
47 | * @see
48 | * co.aurasphere.botmill.fb.model.outcoming.factory.TemplateBaseBuilder#
49 | * toString()
50 | */
51 | @Override
52 | public String toString() {
53 | return "MessageBaseBuilder [quickReplies=" + quickReplies + "]";
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/QuickReplyFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 | import co.aurasphere.botmill.fb.model.outcoming.quickreply.QuickReply;
27 |
28 |
29 | /**
30 | * Factory class for building {@link QuickReply} objects.
31 | *
32 | * @author Alvin Reyes
33 | */
34 | public class QuickReplyFactory {
35 |
36 | /**
37 | * Instantiates a new QuickReplyFactory.
38 | */
39 | private QuickReplyFactory() {
40 | }
41 |
42 | /**
43 | * Creates a {@link QuickReply}.
44 | *
45 | * @param title
46 | * the {@link QuickReply#title}.
47 | * @param payload
48 | * the {@link QuickReply#payload}.
49 | * @return a {@link QuickReply} object.
50 | */
51 | public static QuickReply createQuickReply(String title, String payload) {
52 | return new QuickReply(title, payload);
53 | }
54 |
55 | /**
56 | * Creates a {@link QuickReply} with a location.
57 | *
58 | * @param location
59 | * the {@link QuickReply#title}.
60 | * @return a {@link QuickReply} object.
61 | */
62 | public static QuickReply createQuickReplyLocation(String location) {
63 | return new QuickReply(location);
64 | }
65 |
66 | /**
67 | * Creates a {@link QuickReply} with a location.
68 | *
69 | * @param title
70 | * the {@link QuickReply#title}.
71 | * @param payload
72 | * the {@link QuickReply#payload}.
73 | * @param imageUrl
74 | * the {@link QuickReply#imageUrl}.
75 | * @return a {@link QuickReply} object.
76 | */
77 | public static QuickReply createQuickReplyLocation(String title,
78 | String payload, String imageUrl) {
79 | return new QuickReply(title, payload, imageUrl);
80 | }
81 |
82 | /*
83 | * (non-Javadoc)
84 | *
85 | * @see java.lang.Object#toString()
86 | */
87 | @Override
88 | public String toString() {
89 | return "QuickReplyFactory []";
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/TemplateBaseBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.factory;
25 |
26 |
27 | /**
28 | * Base class for {@link FbBotMillResponseBuilder} that builds a template.
29 | *
30 | * @author Donato Rimenti
31 | */
32 | public abstract class TemplateBaseBuilder extends FbBotMillResponseBuilder {
33 |
34 | /**
35 | * The delegated builder for a message containing a template.
36 | */
37 | protected AttachmentMessageBuilder messageBuilder;
38 |
39 | /*
40 | * (non-Javadoc)
41 | *
42 | * @see
43 | * co.aurasphere.botmill.fb.model.outcoming.factory.TemplateBaseBuilder#
44 | * toString()
45 | */
46 | @Override
47 | public String toString() {
48 | return "TemplateBaseBuilder [messageBuilder=" + messageBuilder + "]";
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/payload/PayloadType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.payload;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 |
29 | /**
30 | * Enum that represents the all available payloads.
31 | *
32 | * @author Donato Rimenti
33 | *
34 | */
35 | public enum PayloadType {
36 |
37 | /**
38 | * The button.
39 | */
40 | @SerializedName("button")
41 | BUTTON,
42 |
43 | /**
44 | * The generic.
45 | */
46 | @SerializedName("generic")
47 | GENERIC,
48 |
49 | /**
50 | * The list.
51 | */
52 | @SerializedName("list")
53 | LIST,
54 |
55 | /**
56 | * The receipt.
57 | */
58 | @SerializedName("receipt")
59 | RECEIPT,
60 |
61 | /**
62 | * The airline itinerary.
63 | */
64 | @SerializedName("airline_itinerary")
65 | AIRLINE_ITINERARY,
66 |
67 | /**
68 | * The airline boardingpass.
69 | */
70 | @SerializedName("airline_boardingpass")
71 | AIRLINE_BOARDINGPASS,
72 |
73 | /**
74 | * The airline update.
75 | */
76 | @SerializedName("airline_update")
77 | AIRLINE_UPDATE,
78 |
79 | /**
80 | * The airline checkin.
81 | */
82 | @SerializedName("airline_checkin")
83 | AIRLINE_CHECKIN;
84 | }
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/payload/UrlPayload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.payload;
25 |
26 | import org.hibernate.validator.constraints.NotBlank;
27 |
28 | import co.aurasphere.botmill.fb.model.base.Payload;
29 |
30 |
31 | /**
32 | * A {@link Payload} which contains an URL.
33 | *
34 | * @author Donato Rimenti
35 | *
36 | */
37 | public class UrlPayload implements Payload {
38 |
39 | /**
40 | * The serial version UID.
41 | */
42 | private static final long serialVersionUID = 1L;
43 |
44 | /**
45 | * The URL associated with this payload.
46 | */
47 | private String url;
48 |
49 | /**
50 | * Instantiates a new UrlPayload.
51 | */
52 | public UrlPayload() {
53 | }
54 |
55 | /**
56 | * Instantiates a new UrlPayload.
57 | *
58 | * @param url
59 | * the {@link #url}.
60 | */
61 | public UrlPayload(String url) {
62 | this.url = url;
63 | }
64 |
65 | /**
66 | * Gets the {@link #url}.
67 | *
68 | * @return the {@link #url}.
69 | */
70 | public String getUrl() {
71 | return url;
72 | }
73 |
74 | /**
75 | * Sets the {@link #url}.
76 | *
77 | * @param url
78 | * the {@link #url} to set.
79 | */
80 | public void setUrl(String url) {
81 | this.url = url;
82 | }
83 |
84 | /*
85 | * (non-Javadoc)
86 | *
87 | * @see java.lang.Object#hashCode()
88 | */
89 | @Override
90 | public int hashCode() {
91 | final int prime = 31;
92 | int result = 1;
93 | result = prime * result + ((url == null) ? 0 : url.hashCode());
94 | return result;
95 | }
96 |
97 | /*
98 | * (non-Javadoc)
99 | *
100 | * @see java.lang.Object#equals(java.lang.Object)
101 | */
102 | @Override
103 | public boolean equals(Object obj) {
104 | if (this == obj)
105 | return true;
106 | if (obj == null)
107 | return false;
108 | if (getClass() != obj.getClass())
109 | return false;
110 | UrlPayload other = (UrlPayload) obj;
111 | if (url == null) {
112 | if (other.url != null)
113 | return false;
114 | } else if (!url.equals(other.url))
115 | return false;
116 | return true;
117 | }
118 |
119 | /*
120 | * (non-Javadoc)
121 | *
122 | * @see java.lang.Object#toString()
123 | */
124 | @Override
125 | public String toString() {
126 | return "UrlPayload [url=" + url + "]";
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/quickreply/QuickReplyType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.quickreply;
25 |
26 |
27 | /**
28 | * The Enum QuickReplyType.
29 | */
30 | public enum QuickReplyType {
31 |
32 | /** The text. */
33 | TEXT,
34 | /** The location. */
35 | LOCATION;
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/airline/TravelClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.airline;
25 |
26 |
27 | /**
28 | * The Enum TravelClass.
29 | */
30 | public enum TravelClass {
31 |
32 | /** The economy. */
33 | ECONOMY,
34 | /** The business. */
35 | BUSINESS,
36 | /** The first class. */
37 | FIRST_CLASS;
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/airline/UpdateType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.airline;
25 |
26 |
27 | /**
28 | * Enum that represents the kinds of updates of a flight.
29 | *
30 | * @author Donato Rimenti
31 | *
32 | */
33 | public enum UpdateType {
34 |
35 | /**
36 | * Flight delay update.
37 | */
38 | DELAY,
39 |
40 | /**
41 | * Flight gate change update.
42 | */
43 | GATE_CHANGE,
44 |
45 | /**
46 | * Flight cancellation update.
47 | */
48 | CANCELLATION;
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/Button.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 | import java.io.Serializable;
27 |
28 | import javax.validation.constraints.NotNull;
29 |
30 |
31 | /**
32 | * The Class Button.
33 | */
34 | public abstract class Button implements Serializable {
35 |
36 | /** The Constant serialVersionUID. */
37 | private static final long serialVersionUID = 1L;
38 |
39 | /**
40 | * The button type.
41 | */
42 | @NotNull
43 | protected ButtonType type;
44 |
45 | /**
46 | * Gets the type.
47 | *
48 | * @return the type
49 | */
50 | public ButtonType getType() {
51 | return type;
52 | }
53 |
54 | /**
55 | * Sets the type.
56 | *
57 | * @param type
58 | * the new type
59 | */
60 | public void setType(ButtonType type) {
61 | this.type = type;
62 | }
63 |
64 | /*
65 | * (non-Javadoc)
66 | *
67 | * @see java.lang.Object#hashCode()
68 | */
69 | @Override
70 | public int hashCode() {
71 | final int prime = 31;
72 | int result = 1;
73 | result = prime * result + ((type == null) ? 0 : type.hashCode());
74 | return result;
75 | }
76 |
77 | /*
78 | * (non-Javadoc)
79 | *
80 | * @see java.lang.Object#equals(java.lang.Object)
81 | */
82 | @Override
83 | public boolean equals(Object obj) {
84 | if (this == obj)
85 | return true;
86 | if (obj == null)
87 | return false;
88 | if (getClass() != obj.getClass())
89 | return false;
90 | Button other = (Button) obj;
91 | if (type != other.type)
92 | return false;
93 | return true;
94 | }
95 |
96 | /*
97 | * (non-Javadoc)
98 | *
99 | * @see java.lang.Object#toString()
100 | */
101 | @Override
102 | public String toString() {
103 | return "Button [type=" + type + "]";
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/ButtonType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 | import com.google.gson.annotations.SerializedName;
27 |
28 |
29 | /**
30 | * The Enum for WebViewHeightRatioType.
31 | *
32 | * @author Alvin Reyes
33 | *
34 | */
35 | public enum ButtonType {
36 |
37 | /** The web url. */
38 | @SerializedName("web_url")
39 | WEB_URL,
40 |
41 | /** The postback. */
42 | @SerializedName("postback")
43 | POSTBACK,
44 |
45 | /** The phone number. */
46 | @SerializedName("phone_number")
47 | PHONE_NUMBER,
48 |
49 | /** The element share. */
50 | @SerializedName("element_share")
51 | ELEMENT_SHARE,
52 |
53 | /** The account link. */
54 | @SerializedName("account_link")
55 | ACCOUNT_LINK,
56 |
57 | /** The account unlink. */
58 | @SerializedName("account_unlink")
59 | ACCOUNT_UNLINK,
60 |
61 | /** The payment. */
62 | @SerializedName("payment")
63 | PAYMENT,
64 |
65 | /** The nested. */
66 | @SerializedName("nested")
67 | NESTED;
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/LogoutButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 |
27 | /**
28 | * The Logout Button Class/Object.
29 | *
30 | * @author Alvin Reyes
31 | *
32 | */
33 | public class LogoutButton extends Button {
34 |
35 | /** The Constant serialVersionUID. */
36 | private static final long serialVersionUID = 1L;
37 |
38 | /**
39 | * Instantiates a new logout button.
40 | */
41 | public LogoutButton() {
42 | this.type = ButtonType.ACCOUNT_UNLINK;
43 | }
44 |
45 | /*
46 | * (non-Javadoc)
47 | *
48 | * @see
49 | * co.aurasphere.botmill.fb.model.outcoming.template.button.Button#toString
50 | * ()
51 | */
52 | @Override
53 | public String toString() {
54 | return "LogoutButton [type=" + type + "]";
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/PaymentType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 |
27 | /**
28 | * The Enum PaymentType.
29 | */
30 | public enum PaymentType {
31 |
32 | /** The fixed amount. */
33 | FIXED_AMOUNT,
34 |
35 | /** The flexible amount. */
36 | FLEXIBLE_AMOUNT;
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/RequestedUserInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 |
27 |
28 | /**
29 | * The RequestedUserInfo Class/Object.
30 | *
31 | * @author Alvin Reyes
32 | *
33 | */
34 | public enum RequestedUserInfo {
35 |
36 | /** The shipping address. */
37 | SHIPPING_ADDRESS,
38 |
39 | /** The contact name. */
40 | CONTACT_NAME,
41 |
42 | /** The contact phone. */
43 | CONTACT_PHONE,
44 |
45 | /** The contact email. */
46 | CONTACT_EMAIL;
47 |
48 | }
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/ShareButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 |
27 | /**
28 | * The Share Button Class/Object.
29 | *
30 | * @author Alvin Reyes
31 | *
32 | */
33 | public class ShareButton extends Button {
34 |
35 | /** The Constant serialVersionUID. */
36 | private static final long serialVersionUID = 1L;
37 |
38 | /**
39 | * Instantiates a new share button.
40 | */
41 | public ShareButton() {
42 | this.type = ButtonType.ELEMENT_SHARE;
43 | }
44 |
45 | /*
46 | * (non-Javadoc)
47 | *
48 | * @see
49 | * co.aurasphere.botmill.fb.model.outcoming.template.button.Button#toString
50 | * ()
51 | */
52 | @Override
53 | public String toString() {
54 | return "ShareButton [type=" + type + "]";
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/WebViewHeightRatioType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
25 |
26 |
27 | /**
28 | * The Enum for WebViewHeightRatioType.
29 | *
30 | * @author Alvin Reyes
31 | *
32 | */
33 | public enum WebViewHeightRatioType {
34 |
35 | /** The compact. */
36 | COMPACT,
37 | /** The tall. */
38 | TALL,
39 | /** The full. */
40 | FULL;
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/button/WebViewShareButton.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.model.outcoming.template.button;
2 |
3 | public enum WebViewShareButton {
4 |
5 | SHOW,
6 | HIDE
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/model/outcoming/template/list/TopElementStyle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.model.outcoming.template.list;
25 |
26 |
27 | /**
28 | * The TopElementStyle Enum.
29 | *
30 | * @author Alvin Reyes
31 | *
32 | */
33 | public enum TopElementStyle {
34 |
35 | /** The large. */
36 | LARGE,
37 | /** The compact. */
38 | COMPACT
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/co/aurasphere/botmill/fb/support/FbBotMillSubscriptionHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.support;
25 |
26 | /**
27 | * Helper class for registering and validating a page against Facebook.
28 | *
29 | * @author Donato Rimenti
30 | * @since 1.2.0
31 | */
32 | public class FbBotMillSubscriptionHelper {
33 |
34 | // TODO
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/resources/ValidationMessages.properties:
--------------------------------------------------------------------------------
1 | javax.validation.constraints.NotNull.message=Field can't be null
2 | org.hibernate.validator.constraints.NotEmpty.message=Field can't be empty
3 | org.hibernate.validator.constraints.NotBlank.message=Field can't be blank
4 | javax.validation.constraints.Size.message=Field size must be between {min} and {max}
5 |
6 | currency.pattern.message=Currency [${validatedValue}] must be a three digit ISO-4217-3 code in format [A-Z]{3}. See this document for more information about Facebook's currency support: https://developers.facebook.com/docs/payments/reference/supportedcurrencies
7 | theme.color.pattern.message=Theme Color must be a valid RGB color in the format #RRGGBB
8 | locale.pattern.message=Locale must be in format [a-z]{2}_[A-Z]{2}. See this document for more infos on supported locale: https://developers.facebook.com/docs/internationalization#locales
9 | country.pattern.message=Country must be in format [A-Za-z]{2}.
--------------------------------------------------------------------------------
/src/main/resources/botmill.properties:
--------------------------------------------------------------------------------
1 | # Fb-BotMill
2 | # Make sure to put the proper page and validation token in this property file before
3 | # running.
4 | #Put your page token here
5 | fb.page.token=
6 | #Put your webhook token here
7 | fb.validation.token=
8 |
9 | # Put the mocked recipient id (for testing only) here
10 | fb.mock.id=
11 |
12 | data.adapter.type=map
13 |
14 | # can be drop-create|create-once
15 | data.strategy=drop-create
16 |
17 | # mongodb (our preferred nosql database)
18 | mongodb.username=
19 | mongodb.password=
20 | mongodb.database=
21 | mongodb.server=
22 | mongodb.port=
23 |
24 | #hsql
25 | hsql.driver=org.hsqldb.jdbc.JDBCDriver
26 | hsql.conn.url=
27 | hsql.username=
28 | hsql.password=
29 | hsql.table.prefix=botmill
30 |
31 | #rdbms
32 | rdbms.driver=
33 | rbdms.conn.url=
34 | rdbms.username=
35 | rdbms.password=
36 | rdbms.table.prefix=botmill
--------------------------------------------------------------------------------
/src/test/java/co/aurasphere/botmill/fb/test/TestDeserialization.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.test;
25 |
26 | import co.aurasphere.botmill.fb.internal.util.json.FbBotMillJsonUtils;
27 | import co.aurasphere.botmill.fb.model.base.Payload;
28 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
29 | import co.aurasphere.botmill.fb.model.outcoming.payload.UrlPayload;
30 |
31 |
32 | /**
33 | * The Class TestDeserialization.
34 | *
35 | * @author Donato Rimenti
36 | */
37 | public class TestDeserialization {
38 |
39 | /**
40 | * The main method.
41 | *
42 | * @param args the arguments
43 | */
44 | public static void main(String[] args) {
45 | String json = "{\"sender\":{\"id\":\"USER_ID\"},\"recipient\":{\"id\":\"PAGE_ID\"},\"timestamp\":1458692752478,\"message\":{\"mid\":\"mid.1458696618141:b4ef9d19ec21086067\",\"seq\":51,\"attachments\":[{\"type\":\"image\",\"payload\":{\"url\":\"IMAGE_URL\"}}]}}";
46 | String json2 = "{\"sender\":{\"id\":\"1152902104831488\"},\"recipient\":{\"id\":\"1209810882431614\"},\"timestamp\":1482953812997,\"message\":{\"mid\":\"mid.1482953812997:6c6e910961\",\"seq\":778909,\"attachments\":[{\"title\":\"Alvin's Location\",\"url\":\"https:\\/\\/www.facebook.com\\/l.php?u=https\u00253A\u00252F\u00252Fwww.bing.com\u00252Fmaps\u00252Fdefault.aspx\u00253Fv\u00253D2\u002526pc\u00253DFACEBK\u002526mid\u00253D8100\u002526where1\u00253D43.899746\u0025252C\u00252B-79.269825\u002526FORM\u00253DFBKPL1\u002526mkt\u00253Den-US&h=ATNzUb8qaIa5x61TRftUfE7RxWJE_E-5XeshoVeDOeGprLWnutTFxlENgC7vFhYuD3pB02N6PpzsEgcOiofJShlqT7a-lesSHScIzrLQVGPg-_22e6CETCbNhXeo57KTKsXLQU8&s=1&enc=AZNukLEVHCKFse_g9I7aBKSSgHbB3odYCw_9Do4rhrUXbJvjz_okfOP0gGwjSJ9Cd5PRpkxhT9kiCBrGBbXQCqPejz98NXzD6V6WVIEB4ZaDqA\",\"type\":\"location\",\"payload\":{\"coordinates\":{\"lat\":43.899746,\"long\":-79.269825}}}]}}";
47 | MessageEnvelope envelope = FbBotMillJsonUtils.fromJson(json, MessageEnvelope.class);
48 | Payload payload = envelope.getMessage().getAttachments().get(0).getPayload();
49 |
50 | UrlPayload actualPayload = (UrlPayload) payload;
51 |
52 | System.out.println(actualPayload.getUrl());
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/co/aurasphere/botmill/fb/test/api/MessengerCodeApiTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.test.api;
25 |
26 | import org.junit.Assert;
27 | import org.junit.Assume;
28 | import org.junit.Before;
29 | import org.junit.Test;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 | import co.aurasphere.botmill.fb.FbBotMillContext;
33 | import co.aurasphere.botmill.fb.api.MessengerCodeApi;
34 | import co.aurasphere.botmill.fb.model.api.messengercode.MessengerCode;
35 | import co.aurasphere.botmill.fb.model.api.messengercode.MessengerCodeRequest;
36 |
37 | /**
38 | * Test for the {@link MessengerCodeApi} class.
39 | *
40 | * @author Donato Rimenti
41 | * @since 2.0.0
42 | */
43 | public class MessengerCodeApiTest {
44 |
45 | private final static Logger logger = LoggerFactory.getLogger(MessengerCodeApiTest.class);
46 |
47 | @Before
48 | public void setup() {
49 | Assume.assumeTrue(isConfigurationExist());
50 | FbBotMillContext.getInstance().setup(System.getenv("fb.page.token"), System.getenv("fb.validation.token"));
51 | }
52 |
53 | @Test
54 | public void testMessengerCodeApi() {
55 |
56 | MessengerCode response = MessengerCodeApi.getMessengerCode();
57 | checkResponse(response);
58 |
59 | // Tests different cases.
60 | response = MessengerCodeApi.getMessengerCode(100);
61 | checkResponse(response);
62 |
63 | response = MessengerCodeApi.getMessengerCode(1000);
64 | checkResponse(response);
65 |
66 | response = MessengerCodeApi.getMessengerCode(new MessengerCodeRequest(2000));
67 | checkResponse(response);
68 |
69 | }
70 |
71 | private boolean isConfigurationExist() {
72 | if(System.getenv("fb.page.token") != null && System.getenv("fb.validation.token") != null) {
73 | return true;
74 | }
75 | return false;
76 | }
77 |
78 | /**
79 | * Checks if the response is valid.
80 | *
81 | * @param response
82 | * the MessengerCode to check.
83 | */
84 | private void checkResponse(MessengerCode response) {
85 | Assert.assertNotNull(response);
86 | String uri = response.getUri();
87 | Assert.assertNotNull(uri);
88 | Assert.assertNotEquals("", uri);
89 | logger.info(
90 | "Succesfully got a Messenger code from Facebook (uri: [{}])",
91 | uri);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/test/java/co/aurasphere/botmill/fb/test/api/UploadApiTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.test.api;
25 |
26 | import org.junit.Assume;
27 | import org.junit.Before;
28 | import org.junit.Test;
29 | import org.slf4j.Logger;
30 | import org.slf4j.LoggerFactory;
31 | import org.springframework.util.Assert;
32 |
33 | import co.aurasphere.botmill.core.internal.util.ConfigurationUtils;
34 | import co.aurasphere.botmill.fb.FbBotMillContext;
35 | import co.aurasphere.botmill.fb.api.UploadApi;
36 | import co.aurasphere.botmill.fb.model.api.upload.UploadAttachmentResponse;
37 | import co.aurasphere.botmill.fb.model.base.AttachmentType;
38 |
39 |
40 | /**
41 | * Test for the {@link UploadApi} class.
42 | *
43 | * @author Donato Rimenti
44 | * @since 2.0.0
45 | */
46 | public class UploadApiTest {
47 |
48 | private final static Logger logger = LoggerFactory.getLogger(UploadApiTest.class);
49 |
50 | @Before
51 | public void setup() {
52 | Assume.assumeTrue(isConfigurationExist());
53 | FbBotMillContext.getInstance().setup(System.getenv("fb.page.token"), System.getenv("fb.validation.token"));
54 | }
55 |
56 | @Test
57 | public void test() {
58 | UploadAttachmentResponse response = UploadApi
59 | .uploadAttachment(
60 | AttachmentType.IMAGE,
61 | "http://vignette2.wikia.nocookie.net/nickelodeon/images/2/27/Spongebob_PNG.png/revision/latest?cb=20120702055752");
62 | String attachmentId = response.getAttachmentId();
63 | Assert.notNull(attachmentId);
64 | logger.info("Succesfully posted attachment with Upload Api (ID: [{}])", attachmentId);
65 | }
66 |
67 | private boolean isConfigurationExist() {
68 | if(System.getenv("fb.page.token") != null && System.getenv("fb.validation.token") != null) {
69 | return true;
70 | }
71 | return false;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/java/co/aurasphere/botmill/fb/test/autoreply/LambdaAutoReplyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * MIT License
3 | *
4 | * Copyright (c) 2016 BotMill.io
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | */
24 | package co.aurasphere.botmill.fb.test.autoreply;
25 |
26 | import co.aurasphere.botmill.core.annotation.Bot;
27 | import co.aurasphere.botmill.fb.FbBot;
28 | import co.aurasphere.botmill.fb.autoreply.LambdaAutoReply;
29 | import co.aurasphere.botmill.fb.autoreply.Reply;
30 | import co.aurasphere.botmill.fb.event.message.MessageEvent;
31 | import co.aurasphere.botmill.fb.model.incoming.MessageEnvelope;
32 | import co.aurasphere.botmill.fb.model.outcoming.FbBotMillResponse;
33 | import co.aurasphere.botmill.fb.model.outcoming.factory.ReplyFactory;
34 |
35 |
36 | /**
37 | * Test for a {@link LambdaAutoReply}.
38 | *
39 | * @author Donato Rimenti
40 | * @author Alvin Reyes
41 | */
42 | @Bot
43 | public class LambdaAutoReplyTest extends FbBot {
44 |
45 | /**
46 | * The message to send in order to test this component.
47 | */
48 | private static final String MESSAGE_TO_SEND = "test_lambda_auto_reply";
49 |
50 | /*
51 | * (non-Javadoc)
52 | *
53 | * @see co.aurasphere.botmill.fb.FbBotDefinition#defineBehaviour()
54 | */
55 | @Override
56 | public void defineBehaviour() {
57 |
58 | // This cannot be tested with a real lambda since the project is
59 | // compiled in 1.5, but this test is equivalent.
60 | addActionFrame(new MessageEvent(MESSAGE_TO_SEND), new LambdaAutoReply(
61 | new Reply() {
62 | public FbBotMillResponse createResponse(
63 | MessageEnvelope envelope) {
64 | return ReplyFactory.addTextMessageOnly(MESSAGE_TO_SEND).build(
65 | envelope);
66 | }
67 | }));
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/java/co/aurasphere/botmill/fb/test/autoreply/template/AnnotatedTemplatedBehaviourConigTest.java:
--------------------------------------------------------------------------------
1 | package co.aurasphere.botmill.fb.test.autoreply.template;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import co.aurasphere.botmill.core.annotation.BotConfiguration;
7 | import co.aurasphere.botmill.fb.FbBotConfiguration;
8 | import co.aurasphere.botmill.fb.api.MessengerProfileApi;
9 | import co.aurasphere.botmill.fb.model.outcoming.factory.ButtonFactory;
10 | import co.aurasphere.botmill.fb.model.outcoming.template.button.Button;
11 |
12 | @BotConfiguration
13 | public class AnnotatedTemplatedBehaviourConigTest extends FbBotConfiguration {
14 |
15 | public AnnotatedTemplatedBehaviourConigTest() {
16 | List