├── api └── src │ ├── main │ └── java │ │ └── com │ │ └── messagebird │ │ ├── objects │ │ ├── GroupList.java │ │ ├── ContactList.java │ │ ├── MessageList.java │ │ ├── VoiceMessageList.java │ │ ├── ChildAccountRequest.java │ │ ├── conversations │ │ │ ├── ConversationList.java │ │ │ ├── ConversationMessageList.java │ │ │ ├── ConversationWebhookList.java │ │ │ ├── Media.java │ │ │ ├── ConversationEmailContent.java │ │ │ ├── ConversationEmailTracking.java │ │ │ ├── HSMCurrency.java │ │ │ ├── ConversationUpdateRequest.java │ │ │ ├── ConversationFallbackOption.java │ │ │ ├── ConversationWebhookCreateRequest.java │ │ │ ├── ConversationContentLocation.java │ │ │ ├── ConversationEmailRecipient.java │ │ │ ├── ConversationWebhookUpdateRequest.java │ │ │ ├── ConversationStatus.java │ │ │ ├── ConversationContentMedia.java │ │ │ ├── ConversationMessageTag.java │ │ │ ├── ConversationWebhookStatus.java │ │ │ ├── ConversationWebhookBaseRequest.java │ │ │ ├── ConversationPlatformConstants.java │ │ │ ├── ConversationMessageDirection.java │ │ │ ├── ConversationContentType.java │ │ │ ├── ConversationChannelStatus.java │ │ │ ├── ConversationHsmLanguagePolicy.java │ │ │ ├── ConversationEmailAttachment.java │ │ │ ├── MessageComponentType.java │ │ │ ├── ConversationHsmLocalizableParameterCurrency.java │ │ │ ├── ConversationHsmLanguage.java │ │ │ ├── ConversationSendResponse.java │ │ │ ├── ConversationWebhookEvent.java │ │ │ ├── TemplateMediaType.java │ │ │ ├── ConversationEmailInlineImage.java │ │ │ └── ConversationMessageStatus.java │ │ ├── integrations │ │ │ ├── TemplateList.java │ │ │ ├── HSMComponentCard.java │ │ │ ├── HSMOTPButtonType.java │ │ │ ├── HSMQualityScore.java │ │ │ ├── HSMCategory.java │ │ │ ├── HSMComponentFormat.java │ │ │ ├── HSMStatus.java │ │ │ ├── HSMComponentButtonType.java │ │ │ ├── HSMExample.java │ │ │ └── HSMComponentType.java │ │ ├── Gender.java │ │ ├── PhoneNumberFeature.java │ │ ├── PhoneNumberType.java │ │ ├── PhoneNumberSearchPattern.java │ │ ├── FileUploadResponse.java │ │ ├── voicecalls │ │ │ ├── VoiceCallStatus.java │ │ │ ├── VoiceLegDirection.java │ │ │ ├── VoiceCallLegResponse.java │ │ │ ├── VoiceCallCondition.java │ │ │ ├── Webhook.java │ │ │ ├── VoiceLegStatus.java │ │ │ ├── VoiceCallResponse.java │ │ │ ├── WebhookResponseData.java │ │ │ ├── VoiceCallFlowResponse.java │ │ │ ├── WebhookList.java │ │ │ ├── VoiceCallResponseList.java │ │ │ ├── Pagination.java │ │ │ ├── RecordingResponse.java │ │ │ ├── VoiceCallFlowList.java │ │ │ ├── TranscriptionResponse.java │ │ │ └── VoiceCallFlowRequest.java │ │ ├── Messages.java │ │ ├── ContactReference.java │ │ ├── VoiceType.java │ │ ├── PagedPaging.java │ │ ├── DataCodingType.java │ │ ├── MsgType.java │ │ ├── GroupRequest.java │ │ ├── LookupHlr.java │ │ ├── VerifyType.java │ │ ├── GroupReference.java │ │ ├── ChildAccountDetailedResponse.java │ │ ├── MessageBase.java │ │ ├── VerifyMessage.java │ │ ├── ChildAccountResponse.java │ │ ├── MessageResponseBase.java │ │ ├── PurchasedNumber.java │ │ ├── MessageReference.java │ │ ├── PhoneNumbersResponse.java │ │ ├── MClassType.java │ │ ├── OutboundSmsPriceResponse.java │ │ ├── Links.java │ │ ├── Language.java │ │ ├── PurchasedNumbersResponse.java │ │ ├── PurchasedNumberCreatedResponse.java │ │ ├── IfMachineType.java │ │ ├── PhoneNumber.java │ │ ├── ListBase.java │ │ ├── Group.java │ │ ├── CustomDetails.java │ │ ├── Balance.java │ │ ├── HlrDetails.java │ │ ├── OutboundSmsPrice.java │ │ └── ChildAccountCreateResponse.java │ │ └── exceptions │ │ ├── RequestSigningException.java │ │ ├── RequestValidationException.java │ │ ├── NotFoundException.java │ │ ├── UnauthorizedException.java │ │ ├── MessageBirdException.java │ │ └── GeneralException.java │ └── test │ ├── java │ └── com │ │ └── messagebird │ │ ├── util │ │ └── Resources.java │ │ └── objects │ │ ├── integrations │ │ ├── HSMComponentTypeTest.java │ │ └── HSMComponentTest.java │ │ └── conversations │ │ ├── TemplateMediaTypeTest.java │ │ ├── MessageComponentTypeTest.java │ │ └── MessageParamTest.java │ └── resources │ └── fixtures │ ├── call_legs_get.json │ ├── call_legs_list.json │ ├── outbound_sms_prices.json │ ├── call_flow_view.json │ ├── call_flows_post.json │ ├── call_flow_update_response.json │ ├── call_flow_view_title.json │ └── call_flows_list.json ├── .travis.yml ├── .gitignore ├── examples └── src │ └── main │ └── java │ ├── ExampleDeleteChildAccount.java │ ├── ExampleUpdateChildAccount.java │ ├── ExampleUpdateNumber.java │ ├── ExampleGetChildAccounts.java │ ├── ExampleGetChildAccountById.java │ ├── ExampleDeleteVoiceCallFlow.java │ ├── ExampleViewPurchasedNumber.java │ ├── ExampleCancelNumber.java │ ├── ExampleDeleteVoiceCall.java │ ├── ExampleGetOutboundSmsPrices.java │ ├── ExampleListTemplates.java │ ├── ExampleListVoiceCallFlow.java │ ├── ExampleViewVoiceCallFlow.java │ ├── ExampleCreateChildAccount.java │ ├── ExampleListPurchasedNumbers.java │ ├── ExampleListVoiceMessages.java │ ├── ExamplePurchaseNumber.java │ ├── ExampleDeleteMessage.java │ ├── ExampleDeleteRecording.java │ ├── ExampleListMessages.java │ ├── ExampleListTemplatesByWABAID.java │ ├── ExampleViewWebhook.java │ ├── ExampleDeleteTemplatesByName.java │ ├── ExampleReadBalance.java │ ├── ExampleListTemplatesForChannelID.java │ ├── ExampleListVoiceCalls.java │ ├── ExampleUpdateConversation.java │ ├── ExampleViewMessage.java │ ├── ExampleSendVerifyToken.java │ ├── ExampleViewVoiceCall.java │ ├── ExampleSendWebhook.java │ ├── ExampleListTemplatesByName.java │ ├── ExampleViewVoiceMessage.java │ ├── ExampleListMessagesFiltered.java │ ├── ExampleCreateVoiceCallFlow.java │ ├── ExampleViewRecording.java │ ├── ExampleListConversationMessagesWithQueryParam.java │ ├── ExampleFetchTemplateByNameAndLanguage.java │ ├── ExampleViewLookup.java │ ├── ExampleReadHlr.java │ ├── ExampleListOfRecording.java │ ├── ExampleDownloadRecording.java │ ├── ExampleSendMessage.java │ ├── ExampleViewLookupHlr.java │ ├── ExampleRequestLookupHlr.java │ ├── ExampleListTemplatesByNameAndWABAID.java │ ├── ExampleViewTranscription.java │ └── ExampleVerifyEmail.java └── LICENSE /api/src/main/java/com/messagebird/objects/GroupList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Represents a listing of Group objects, along with pagination details. 5 | */ 6 | public class GroupList extends ListBase { 7 | 8 | // 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ContactList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Represents a listing of Contact objects, along with pagination details. 5 | */ 6 | public class ContactList extends ListBase { 7 | 8 | // 9 | } 10 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MessageList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Class to retreive a list of Messages 5 | * Created by rvt on 1/8/15. 6 | */ 7 | public class MessageList extends ListBase { 8 | 9 | // 10 | } 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: trusty 3 | before_script: cd api/ 4 | script: mvn test -Ptest -DskipTests=false -Dhttps.protocols=TLSv1.2 -DmessageBirdAccessKey=test_iQpAp0KCs5GCsMpDhIx2leuNB -DmessageBirdMSISDN=31612345678 5 | jdk: 6 | - oraclejdk11 7 | - openjdk11 8 | - openjdk8 9 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/VoiceMessageList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Class to hold a list of stored voice messages 5 | * Created by rvt on 1/8/15. 6 | */ 7 | public class VoiceMessageList extends ListBase { 8 | 9 | // 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Java ### 2 | *.class 3 | 4 | # Mobile Tools for Java (J2ME) 5 | .mtj.tmp/ 6 | 7 | # Package Files # 8 | *.jar 9 | *.war 10 | *.ear 11 | 12 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 13 | hs_err_pid* 14 | 15 | # The various target folders 16 | *target/ 17 | *.iml 18 | .idea 19 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ChildAccountRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class ChildAccountRequest { 4 | private String name; 5 | 6 | public String getName() { 7 | return name; 8 | } 9 | 10 | public void setName(String name) { 11 | this.name = name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.messagebird.objects.ListBase; 4 | 5 | /** 6 | * Response object representing the Conversation list type. 7 | */ 8 | public class ConversationList extends ListBase { 9 | 10 | // 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationMessageList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.messagebird.objects.ListBase; 4 | 5 | /** 6 | * Response object for the message list type. 7 | */ 8 | public class ConversationMessageList extends ListBase { 9 | 10 | // 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.messagebird.objects.ListBase; 4 | 5 | /** 6 | * Response object for the webhook listing. 7 | */ 8 | public class ConversationWebhookList extends ListBase { 9 | 10 | // 11 | } 12 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/TemplateList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.messagebird.objects.ListBase; 4 | 5 | /** 6 | * Response object representing the Template list type. 7 | * 8 | * @author ssk910 9 | */ 10 | public class TemplateList extends ListBase { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/util/Resources.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.util; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Resources { 6 | 7 | public static String readResourceText(String path) { 8 | return new Scanner( 9 | Resources.class.getResourceAsStream(path), "UTF-8" 10 | ) 11 | .useDelimiter("\\A") 12 | .next(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Gender.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Created by faizan on 09/12/15. 5 | */ 6 | public enum Gender { 7 | 8 | MALE("male"), 9 | FEMALE("female"); 10 | 11 | private String code; 12 | 13 | Gender(String code) { 14 | this.code = code; 15 | } 16 | 17 | public String toString() { 18 | return this.code; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PhoneNumberFeature.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public enum PhoneNumberFeature { 4 | 5 | SMS("sms"), 6 | MMS("mms"), 7 | VOICE("voice"); 8 | 9 | private String type; 10 | 11 | PhoneNumberFeature(String type) { 12 | this.type = type; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return this.type; 18 | } 19 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PhoneNumberType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public enum PhoneNumberType { 4 | LANDLINE("landline"), 5 | MOBILE("mobile"), 6 | PREMIUM_RATE("premium_rate"); 7 | 8 | private String type; 9 | 10 | PhoneNumberType(String type) { 11 | this.type = type; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return this.type; 17 | } 18 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PhoneNumberSearchPattern.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public enum PhoneNumberSearchPattern { 4 | START("start"), 5 | ANYWHERE("anywhere"), 6 | END("end"); 7 | 8 | private String type; 9 | 10 | PhoneNumberSearchPattern(String type) { 11 | this.type = type; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return this.type; 17 | } 18 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/FileUploadResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class FileUploadResponse { 4 | 5 | private String id; 6 | 7 | public String getId() { 8 | return id; 9 | } 10 | 11 | public void setId(String id) { 12 | this.id = id; 13 | } 14 | 15 | @Override 16 | public String toString() { 17 | return "FileUploadResponse{" + 18 | "id='" + id + '\'' + 19 | '}'; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | public enum VoiceCallStatus { 4 | 5 | queued("queued"), 6 | starting("starting"), 7 | ongoing("ongoing"), 8 | ended("ended"), 9 | failed("failed"), 10 | busy("busy"), 11 | no_answer("no_answer"); 12 | 13 | final String value; 14 | 15 | VoiceCallStatus(String type) { 16 | this.value = type; 17 | } 18 | 19 | public String getValue() { 20 | return value; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Messages.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by faizan on 09/12/15. 7 | */ 8 | public class Messages implements Serializable { 9 | private String href; 10 | 11 | public String getHref() { 12 | return href; 13 | } 14 | 15 | public void setHref(String href) { 16 | this.href = href; 17 | } 18 | 19 | public String toString() { 20 | return "Messages{" + 21 | "href=" + this.href + 22 | "}"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceLegDirection.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | 5 | public enum VoiceLegDirection { 6 | Incoming, Outgoing; 7 | 8 | @JsonCreator 9 | public static VoiceLegDirection forValue(String value) { 10 | switch (value) { 11 | case "incoming": return Incoming; 12 | case "outgoing": return Outgoing; 13 | default: throw new IllegalArgumentException("Unknown leg direction: " + value); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ContactReference.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class ContactReference { 4 | 5 | private String href; 6 | private int totalCount; 7 | 8 | public String getHref() { 9 | return href; 10 | } 11 | 12 | public int getTotalCount() { 13 | return totalCount; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "ContactReference{" + 19 | "href='" + href + '\'' + 20 | ", totalCount=" + totalCount + 21 | '}'; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallLegResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | 6 | import java.util.List; 7 | 8 | public class VoiceCallLegResponse { 9 | 10 | private List data; 11 | 12 | @JsonCreator 13 | public VoiceCallLegResponse(@JsonProperty("data") List data) { 14 | this.data = data; 15 | } 16 | 17 | public List getData() { 18 | return data; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/VoiceType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Voice message types 5 | *

6 | * Created by rvt on 1/7/15. 7 | */ 8 | public enum VoiceType { 9 | male("male"), 10 | female("female"); 11 | 12 | final String value; 13 | 14 | VoiceType(String type) { 15 | this.value = type; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "Voice{" + 21 | "value='" + value + '\'' + 22 | '}'; 23 | } 24 | 25 | public String getValue() { 26 | return value; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/RequestSigningException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | /** 4 | * Thrown if an error occurs during request signing. 5 | * 6 | * @deprecated This class is being deprecated together with {@link com.messagebird.RequestSigner} 7 | */ 8 | @Deprecated 9 | public class RequestSigningException extends RuntimeException { 10 | 11 | public RequestSigningException() { 12 | } 13 | 14 | public RequestSigningException(String message) { 15 | super(message); 16 | } 17 | 18 | public RequestSigningException(Throwable cause) { 19 | super(cause); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PagedPaging.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.io.Serializable; 4 | 5 | public class PagedPaging implements Serializable { 6 | 7 | private static final long serialVersionUID = 5764858762655505158L; 8 | private Integer page; 9 | private Integer pageSize; 10 | 11 | public PagedPaging(Integer page, Integer pageSize) { 12 | this.page = page; 13 | this.pageSize = pageSize; 14 | } 15 | 16 | public Integer getPage() { 17 | return page; 18 | } 19 | 20 | public Integer getPageSize() { 21 | return pageSize; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMComponentCard.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * HSMComponentCard 7 | * 8 | * @author AlexL-mb 9 | * @see HSMComponentCard 10 | */ 11 | public class HSMComponentCard { 12 | private List components; 13 | 14 | public List getComponents() { 15 | return components; 16 | } 17 | 18 | public void setComponents(List components) { 19 | this.components = components; 20 | } 21 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/RequestValidationException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | /** 4 | * Thrown if an error occurs during request signing. 5 | */ 6 | public class RequestValidationException extends RuntimeException { 7 | 8 | public RequestValidationException() { 9 | } 10 | 11 | public RequestValidationException(String message) { 12 | super(message); 13 | } 14 | 15 | public RequestValidationException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | public RequestValidationException(String message, Throwable cause) { 20 | super(message, cause); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/DataCodingType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * The datacoding used. Specifies plain or unicode 5 | * 6 | * Created by rvt on 1/7/15. 7 | */ 8 | public enum DataCodingType { 9 | plain("plain"), 10 | unicode("unicode"), 11 | auto("auto"); 12 | 13 | final String value; 14 | 15 | DataCodingType(String value) { 16 | this.value = value; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "DataCoding{" + 22 | "value='" + value + '\'' + 23 | '}'; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MsgType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * The type of message. 5 | * 6 | * Created by rvt on 1/7/15. 7 | */ 8 | public enum MsgType { 9 | sms("sms"), 10 | mms("mms"), 11 | binary("binary"), 12 | premium("premium"), 13 | flash("flash"); 14 | 15 | final String value; 16 | 17 | MsgType(String type) { 18 | this.value = type; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "MsgType{" + 24 | "value='" + value + '\'' + 25 | '}'; 26 | } 27 | 28 | public String getValue() { 29 | return value; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/GroupRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Contains writable values for the Groups API. 5 | */ 6 | public class GroupRequest { 7 | 8 | private String name; 9 | 10 | public GroupRequest(String name) { 11 | this.name = name; 12 | } 13 | 14 | public GroupRequest() { 15 | // 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "GroupRequest{" + 29 | "name='" + name + '\'' + 30 | '}'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/LookupHlr.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.math.BigInteger; 4 | 5 | public class LookupHlr extends Hlr { 6 | private String countryCode; 7 | 8 | public String getCountryCode() { 9 | return countryCode; 10 | } 11 | 12 | public void setCountryCode(String countryCode) { 13 | this.countryCode = countryCode; 14 | } 15 | 16 | public BigInteger getPhoneNumber() { 17 | return msisdn; 18 | } 19 | 20 | public void setPhoneNumber(BigInteger phoneNumber) { 21 | this.msisdn = phoneNumber; 22 | } 23 | 24 | public void setReference(String reference) { 25 | this.reference = reference; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_legs_get.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "first-leg-of-unforgiven-call", 5 | "callId": "unforgiven-call", 6 | "source": "TestSource", 7 | "destination": "31612345678", 8 | "status": "hangup", 9 | "direction": "outgoing", 10 | "duration": 7, 11 | "cost": 0.001519, 12 | "currency": "EUR", 13 | "createdAt": "2019-01-10T16:12:54Z", 14 | "updatedAt": "2019-01-10T16:13:54Z", 15 | "answeredAt": "2019-01-10T16:13:24Z", 16 | "endedAt": "2019-01-10T16:13:30Z", 17 | "sipResponseCode": 200 18 | } 19 | ], 20 | "_links": { 21 | "self": "/calls/unforgiven-call/legs/first-leg-of-unforgiven-call" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/VerifyType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | 5 | /** 6 | * Determines which type the message will be. 7 | */ 8 | public enum VerifyType { 9 | 10 | FLASH("flash"), 11 | SMS("sms"), 12 | TTS("tts"), 13 | EMAIL("email"); 14 | 15 | final String value; 16 | 17 | VerifyType(String type) { 18 | this.value = type; 19 | } 20 | 21 | @JsonValue 22 | public String getValue() { 23 | return value; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "VerifyType{" + 29 | "value='" + value + '\'' + 30 | '}'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/Media.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class Media { 4 | 5 | private String url; 6 | private String caption; 7 | 8 | public String getUrl() { 9 | return url; 10 | } 11 | 12 | public void setUrl(String url) { 13 | this.url = url; 14 | } 15 | 16 | public String getCaption() { 17 | return caption; 18 | } 19 | 20 | public void setCaption(String caption) { 21 | this.caption = caption; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "Media{" + 27 | "url='" + url + '\'' + 28 | ", caption='" + caption + '\'' + 29 | '}'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/GroupReference.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class GroupReference { 4 | 5 | private String href; 6 | private int totalCount; 7 | 8 | public String getHREF() { 9 | return href; 10 | } 11 | 12 | public int getTotalCount() { 13 | return totalCount; 14 | } 15 | 16 | public void setHREF(String href) { 17 | this.href = href; 18 | } 19 | 20 | public void setTotalCount(int totalCount) { 21 | this.totalCount = totalCount; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "GroupReference{" + 27 | "href='" + href + '\'' + 28 | ", totalCount=" + totalCount + 29 | '}'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ChildAccountDetailedResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class ChildAccountDetailedResponse extends ChildAccountResponse{ 4 | private String invoiceAggregation; 5 | 6 | public String getInvoiceAggregation() { 7 | return invoiceAggregation; 8 | } 9 | 10 | public void setInvoiceAggregation(String invoiceAggregation) { 11 | this.invoiceAggregation = invoiceAggregation; 12 | } 13 | 14 | @Override 15 | public String toString() { 16 | return "ChildAccountDetailedResponse{" + 17 | "id='" + getId() + '\'' + 18 | ", name='" + getName() + '\'' + 19 | ", invoiceAggregation='" + invoiceAggregation + '\'' + 20 | '}'; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationEmailContent.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationEmailContent { 4 | private String html; 5 | private String text; 6 | 7 | public String getHtml() { 8 | return html; 9 | } 10 | 11 | public void setHtml(String html) { 12 | this.html = html; 13 | } 14 | 15 | public String getText() { 16 | return text; 17 | } 18 | 19 | public void setText(String text) { 20 | this.text = text; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "ConversationEmailContent{" + 26 | "html='" + html + '\'' + 27 | ", text='" + text + '\'' + 28 | '}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationEmailTracking.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationEmailTracking { 4 | private boolean open; 5 | private boolean click; 6 | 7 | public boolean isOpen() { 8 | return open; 9 | } 10 | 11 | public void setOpen(boolean open) { 12 | this.open = open; 13 | } 14 | 15 | public boolean isClick() { 16 | return click; 17 | } 18 | 19 | public void setClick(boolean click) { 20 | this.click = click; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "ConversationEmailTracking{" + 26 | "open=" + open + 27 | ", click=" + click + 28 | '}'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | import com.messagebird.objects.ErrorReport; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by rvt on 1/9/15. 9 | */ 10 | public class NotFoundException extends MessageBirdException { 11 | public NotFoundException(List errors) { 12 | super(errors); 13 | } 14 | 15 | public NotFoundException(String s, List errors) { 16 | super(s, errors); 17 | } 18 | 19 | public NotFoundException(String s, Throwable throwable, List errors) { 20 | super(s, throwable, errors); 21 | } 22 | 23 | public NotFoundException(Throwable throwable, List errors) { 24 | super(throwable, errors); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/objects/integrations/HSMComponentTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import org.junit.Test; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.junit.Assert.assertNull; 6 | 7 | public class HSMComponentTypeTest { 8 | @Test 9 | public void testForValueValid() { 10 | assertEquals(HSMComponentType.BODY, HSMComponentType.forValue("BODY")); 11 | assertEquals(HSMComponentType.BODY, HSMComponentType.forValue("body")); 12 | } 13 | 14 | @Test(expected = NullPointerException.class) 15 | public void testForValueNull() { 16 | HSMComponentType.forValue(null); 17 | } 18 | 19 | @Test 20 | public void testForValueInvalid() { 21 | assertNull(HSMComponentType.forValue("INVALID")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MessageBase.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Created by rvt on 1/7/15. 7 | */ 8 | public interface MessageBase { 9 | /** 10 | * The body of the SMS message. 11 | * @return Message body 12 | */ 13 | String getBody(); 14 | 15 | /** 16 | * The list of recipients msisdn's. 17 | * @return String of comma separated recipients 18 | */ 19 | String getRecipients(); 20 | 21 | /** 22 | * @return your own reference 23 | */ 24 | String getReference(); 25 | 26 | /** 27 | * The scheduled date and time of the message 28 | * @return the configured date/time to send the mesage, this is handled on the message bird platform 29 | */ 30 | Date getScheduledDatetime(); 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/HSMCurrency.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class HSMCurrency { 4 | 5 | private String currencyCode; 6 | private int amount; 7 | 8 | public String getCurrencyCode() { 9 | return currencyCode; 10 | } 11 | 12 | public void setCurrencyCode(String currencyCode) { 13 | this.currencyCode = currencyCode; 14 | } 15 | 16 | public int getAmount() { 17 | return amount; 18 | } 19 | 20 | public void setAmount(int amount) { 21 | this.amount = amount; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "HSMCurrency{" + 27 | "currencyCode='" + currencyCode + '\'' + 28 | ", amount=" + amount + 29 | '}'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallCondition.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | public class VoiceCallCondition { 4 | private String variable; 5 | private String operator; 6 | private String value; 7 | 8 | public VoiceCallCondition() { 9 | } 10 | 11 | public String getVariable() { 12 | return variable; 13 | } 14 | 15 | public void setVariable(String variable) { 16 | this.variable = variable; 17 | } 18 | 19 | public String getOperator() { 20 | return operator; 21 | } 22 | 23 | public void setOperator(String operator) { 24 | this.operator = operator; 25 | } 26 | 27 | public String getValue() { 28 | return value; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/VerifyMessage.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by leandro.pinto on 22/06/15. 7 | */ 8 | public class VerifyMessage implements Serializable { 9 | 10 | private String id; 11 | private String status; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public String getStatus() { 22 | return status; 23 | } 24 | 25 | public void setStatus(String status) { 26 | this.status = status; 27 | } 28 | 29 | public String toString() { 30 | return "VerifyMessage {" + " " + 31 | "id=" + this.id + " " + 32 | "status=" + this.status + " " + 33 | "}"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ChildAccountResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ChildAccountResponse implements Serializable { 6 | private static final long serialVersionUID = -8605510461438669942L; 7 | 8 | private String id; 9 | private String name; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "ChildAccountResponse{" + 30 | "id='" + id + '\'' + 31 | ", name='" + name + '\'' + 32 | '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MessageResponseBase.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Created by rvt on 1/7/15. 5 | */ 6 | public interface MessageResponseBase { 7 | /** 8 | * An unique random ID which is created on the MessageBird platform and is returned upon creation of the object. 9 | * @return 10 | */ 11 | String getId(); 12 | 13 | /** 14 | * The URL of the created object. 15 | * @return 16 | */ 17 | String getHref(); 18 | 19 | /** 20 | * The body of the SMS message. 21 | * @return 22 | */ 23 | String getBody(); 24 | 25 | /** 26 | * The reference that was set for the message 27 | * @return 28 | */ 29 | String getReference(); 30 | 31 | /** 32 | * Recipient information. 33 | * @return 34 | */ 35 | MessageResponse.Recipients getRecipients(); 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import java.util.Objects; 4 | 5 | public class ConversationUpdateRequest { 6 | 7 | private final ConversationStatus status; 8 | 9 | public ConversationUpdateRequest(ConversationStatus status) { 10 | this.status = status; 11 | } 12 | 13 | public ConversationStatus getStatus() { 14 | return status; 15 | } 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | if (this == o) return true; 20 | if (o == null || getClass() != o.getClass()) return false; 21 | ConversationUpdateRequest that = (ConversationUpdateRequest) o; 22 | return status == that.status; 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return Objects.hash(status); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/Webhook.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Webhook implements Serializable { 6 | 7 | private static final long serialVersionUID = 727746356185518354L; 8 | 9 | private String url; 10 | private String token; 11 | 12 | public String getUrl() { 13 | return url; 14 | } 15 | 16 | public void setUrl(String url) { 17 | this.url = url; 18 | } 19 | 20 | public String getToken() { 21 | return token; 22 | } 23 | 24 | public void setToken(String token) { 25 | this.token = token; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "Webhook{" + 31 | "url='" + url + '\'' + 32 | ", token='" + token + '\'' + 33 | '}'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceLegStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | 5 | public enum VoiceLegStatus { 6 | Starting, 7 | Ringing, 8 | Ongoing, 9 | Busy, 10 | NoAnswer, 11 | Failed, 12 | Hangup; 13 | 14 | @JsonCreator 15 | public static VoiceLegStatus forValue(String value) { 16 | switch (value) { 17 | case "starting": return Starting; 18 | case "ringing": return Ringing; 19 | case "ongoing": return Ongoing; 20 | case "busy": return Busy; 21 | case "no_answer": return NoAnswer; 22 | case "failed": return Failed; 23 | case "hangup": return Hangup; 24 | default: throw new IllegalArgumentException("Unknown leg status: " + value); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | import com.messagebird.objects.ErrorReport; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Exception send when you are not authorised to use this service 9 | * 10 | * Created by rvt on 1/5/15. 11 | */ 12 | public class UnauthorizedException extends MessageBirdException { 13 | public UnauthorizedException(List errors) { 14 | super(errors); 15 | } 16 | 17 | public UnauthorizedException(String s, List errors) { 18 | super(s, errors); 19 | } 20 | 21 | public UnauthorizedException(String s, Throwable throwable, List errors) { 22 | super(s, throwable, errors); 23 | } 24 | 25 | public UnauthorizedException(Throwable throwable, List errors) { 26 | super(throwable, errors); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_legs_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "data":[ 3 | { 4 | "id":"first-leg-of-unforgiven-call", 5 | "callId":"unforgiven-call", 6 | "source":"TestSource", 7 | "destination":"31612345678", 8 | "status":"hangup", 9 | "direction":"outgoing", 10 | "cost":0.001519, 11 | "currency":"EUR", 12 | "duration":7, 13 | "createdAt":"2019-01-10T16:12:54Z", 14 | "updatedAt":"2019-01-10T16:13:54Z", 15 | "answeredAt":"2019-01-10T16:13:24Z", 16 | "endedAt":"2019-01-10T16:13:30Z", 17 | "sipResponseCode": 200, 18 | "_links":{ 19 | "self":"/calls/unforgiven-call/legs/first-leg-of-unforgiven-call" 20 | } 21 | } 22 | ], 23 | "_links":{ 24 | "self":"/calls/unforgiven-call/legs?page=1" 25 | }, 26 | "pagination":{ 27 | "totalCount":1, 28 | "pageCount":1, 29 | "currentPage":1, 30 | "perPage":10 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/outbound_sms_prices.json: -------------------------------------------------------------------------------- 1 | { 2 | "gateway": 10, 3 | "currencyCode": "EUR", 4 | "totalCount": 3, 5 | "prices": [ 6 | { 7 | "price": "0.060000", 8 | "currencyCode": "EUR", 9 | "mccmnc": "0", 10 | "mcc": "0", 11 | "mnc": null, 12 | "countryName": "Default Rate", 13 | "countryIsoCode": "XX", 14 | "operatorName": "Default Rate" 15 | }, 16 | { 17 | "price": "0.047000", 18 | "currencyCode": "EUR", 19 | "mccmnc": "202", 20 | "mcc": "202", 21 | "mnc": null, 22 | "countryName": "Greece", 23 | "countryIsoCode": "GR", 24 | "operatorName": null 25 | }, 26 | { 27 | "price": "0.045000", 28 | "currencyCode": "EUR", 29 | "mccmnc": "20205", 30 | "mcc": "202", 31 | "mnc": "05", 32 | "countryName": "Greece", 33 | "countryIsoCode": "GR", 34 | "operatorName": "Vodafone" 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PurchasedNumber.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.List; 4 | 5 | public class PurchasedNumber extends PhoneNumber { 6 | private List tags; 7 | private String status; 8 | 9 | public List getTags() { 10 | return tags; 11 | } 12 | 13 | public String getStatus() { 14 | return status; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "PhoneNumber{" + 20 | "number='" + this.getNumber() + "\'" + 21 | ", country='" + this.getCountry() + "\'" + 22 | ", region='" + this.getRegion() + "\'" + 23 | ", locality='" + this.getLocality() + "\'" + 24 | ", features=" + this.getFeatures() + 25 | ", type='" + this.getType() + "\'" + 26 | ", tags='" + tags + "\'" + 27 | ", status='" + status + "\'" + 28 | "}"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/objects/conversations/TemplateMediaTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import org.junit.Test; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.junit.Assert.assertNull; 6 | 7 | public class TemplateMediaTypeTest { 8 | @Test 9 | public void testTemplateMediaTypeForValueValid() { 10 | assertEquals(TemplateMediaType.VIDEO, TemplateMediaType.forValue("video")); 11 | } 12 | 13 | @Test(expected = IllegalArgumentException.class) 14 | public void testTemplateMediaTypeForValueNull() { 15 | TemplateMediaType.forValue(null); 16 | } 17 | 18 | @Test 19 | public void testTemplateMediaTypeForValueInvalid() { 20 | assertNull(TemplateMediaType.forValue("non_existing_value")); 21 | } 22 | 23 | @Test 24 | public void testTemplateMediaTypeToString() { 25 | assertEquals("video", TemplateMediaType.VIDEO.toString()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MessageReference.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | public class MessageReference { 4 | 5 | private String href; 6 | private int totalCount; 7 | private String lastMessageId; 8 | 9 | public String getHREF() { 10 | return href; 11 | } 12 | 13 | public int getTotalCount() { 14 | return totalCount; 15 | } 16 | 17 | public void setHREF(String href) { 18 | this.href = href; 19 | } 20 | 21 | public void setTotalCount(int totalCount) { 22 | this.totalCount = totalCount; 23 | } 24 | 25 | public String getLastMessageId() { 26 | return lastMessageId; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "MessageReference{" + 32 | "href='" + href + '\'' + 33 | ", totalCount=" + totalCount + 34 | ", lastMessageId='" + lastMessageId + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PhoneNumbersResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.messagebird.objects.PhoneNumber; 4 | 5 | import java.util.List; 6 | 7 | import java.io.Serializable; 8 | 9 | public class PhoneNumbersResponse implements Serializable { 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 6177098534499444839L; 14 | private Number limit; 15 | private Number offset; 16 | private List items; 17 | 18 | public Number getLimit() { 19 | return this.limit; 20 | } 21 | 22 | public Number getOffset() { 23 | return this.offset; 24 | } 25 | 26 | public List getItems() { 27 | return this.items; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "PhoneNumbersResponse{" + 33 | "limit=" + limit + 34 | ", offset=" + offset + 35 | ", items=" + items + 36 | "}"; 37 | } 38 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/MClassType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * MClass type 8 | * 9 | * Created by rvt on 1/7/15. 10 | */ 11 | public enum MClassType { 12 | flash(0), 13 | normal(1); 14 | 15 | final Integer value; 16 | 17 | MClassType(Integer type) { 18 | this.value = type; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "MClass{" + 24 | "value=" + value + 25 | '}'; 26 | } 27 | 28 | @JsonValue 29 | public Integer toJson() { 30 | return getValue(); 31 | } 32 | 33 | public static MClassType forValue(String value) { 34 | if ("0".equals(value)) { 35 | return flash; 36 | } 37 | return normal; 38 | } 39 | 40 | 41 | public Integer getValue() { 42 | return value; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/OutboundSmsPriceResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.List; 4 | 5 | public class OutboundSmsPriceResponse { 6 | private int gateway; 7 | private String currencyCode; 8 | private int totalCount; 9 | private List prices; 10 | 11 | public int getGateway() { 12 | return gateway; 13 | } 14 | 15 | public String getCurrencyCode() { 16 | return currencyCode; 17 | } 18 | 19 | public int getTotalCount() { 20 | return totalCount; 21 | } 22 | 23 | public List getPrices() { 24 | return prices; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "OutboundSmsPriceResponse{" + 30 | "gateway=" + gateway + 31 | ", currencyCode='" + currencyCode + '\'' + 32 | ", totalCount=" + totalCount + 33 | ", prices=" + prices + 34 | '}'; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationFallbackOption.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationFallbackOption { 4 | private String from; 5 | private String after; 6 | 7 | public ConversationFallbackOption() { 8 | } 9 | 10 | public ConversationFallbackOption(String from, String after) { 11 | this.from = from; 12 | this.after = after; 13 | } 14 | 15 | public String getFrom() { 16 | return from; 17 | } 18 | 19 | public void setFrom(String from) { 20 | this.from = from; 21 | } 22 | 23 | public String getAfter() { 24 | return after; 25 | } 26 | 27 | public void setAfter(String after) { 28 | this.after = after; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "ConversationFallbackOption{" + 34 | "from='" + from + '\'' + 35 | ", after='" + after + '\'' + 36 | '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Links.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Link's class used only during List retreival and stored the first/previous etc data 5 | * Created by rvt on 1/8/15. 6 | */ 7 | public class Links { 8 | private String first; 9 | private String previous; 10 | private String next; 11 | private String last; 12 | 13 | public Links() { 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "Links{" + 19 | "first='" + first + '\'' + 20 | ", previous='" + previous + '\'' + 21 | ", next='" + next + '\'' + 22 | ", last='" + last + '\'' + 23 | '}'; 24 | } 25 | 26 | public String getFirst() { 27 | return first; 28 | } 29 | 30 | public String getPrevious() { 31 | return previous; 32 | } 33 | 34 | public String getNext() { 35 | return next; 36 | } 37 | 38 | public String getLast() { 39 | return last; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Request object used to create webhooks. 7 | */ 8 | public class ConversationWebhookCreateRequest extends ConversationWebhookBaseRequest{ 9 | 10 | private String channelId; 11 | 12 | public ConversationWebhookCreateRequest( 13 | final String channelId, 14 | final String url, 15 | final List events 16 | ) { 17 | this.channelId = channelId; 18 | this.url = url; 19 | this.events = events; 20 | } 21 | 22 | @Override 23 | protected String getRequestName() { 24 | return "ConversationWebhookCreateRequest"; 25 | } 26 | 27 | @Override 28 | protected String getStringRepresentationOfExtraParameters() { 29 | return "channelId='" + channelId; 30 | } 31 | 32 | public String getChannelId() { 33 | return channelId; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMOTPButtonType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | public enum HSMOTPButtonType { 7 | ONE_TAP("ONE_TAP"), 8 | COPY_CODE("COPY_CODE"); 9 | 10 | private final String type; 11 | 12 | HSMOTPButtonType(String type) { 13 | this.type = type; 14 | } 15 | @JsonCreator 16 | public static HSMOTPButtonType forValue(String value) { 17 | for (HSMOTPButtonType OTPButtonType : HSMOTPButtonType.values()) { 18 | if (OTPButtonType.getType().equals(value)) { 19 | return OTPButtonType; 20 | } 21 | } 22 | return null; 23 | } 24 | 25 | @JsonValue 26 | public String toJson() { 27 | return getType(); 28 | } 29 | 30 | public String getType() { 31 | return type; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return getType(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMQualityScore.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import java.util.List; 4 | 5 | public class HSMQualityScore { 6 | private String score; 7 | private long date; 8 | private List reasons; 9 | 10 | public String getScore() { 11 | return score; 12 | } 13 | 14 | public void setScore(String score) { 15 | this.score = score; 16 | } 17 | 18 | public long getDate() { 19 | return date; 20 | } 21 | 22 | public void setDate(long date) { 23 | this.date = date; 24 | } 25 | 26 | public List getReasons() { 27 | return reasons; 28 | } 29 | 30 | public void setReasons(List reasons) { 31 | this.reasons = reasons; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "HSMQualityScore{" + 37 | "score='" + score + '\'' + 38 | ", date=" + date + 39 | ", reasons=" + reasons + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Language.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.fasterxml.jackson.annotation.JsonValue; 4 | 5 | /** 6 | * Created by faizan on 09/12/15. 7 | */ 8 | public enum Language { 9 | 10 | NL_NL("nl-nl"), 11 | DE_DE("de-de"), 12 | EN_GB("en-gb"), 13 | EN_US("en-us"), 14 | ES_ES("es-es"), 15 | FR_FR("fr-fr"), 16 | RU_RU("ru-ru"), 17 | ZH_CN("zh-cn"), 18 | EN_AU("en-au"), 19 | ES_MX("es-mx"), 20 | ES_US("es-us"), 21 | FR_CA("fr-ca"), 22 | IS_IS("is-is"), 23 | IT_IT("it-it"), 24 | JA_JP("ja-jp"), 25 | KO_KR("ko-kr"), 26 | PL_PL("pl-pl"), 27 | PT_BR("pt-br"), 28 | RO_RO("ro-ro"); 29 | 30 | final String code; 31 | 32 | Language(String code) { 33 | this.code = code; 34 | } 35 | 36 | @JsonValue 37 | public String getCode() { 38 | return code; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "Language{" + 44 | "code='" + code + '\'' + 45 | '}'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/objects/conversations/MessageComponentTypeTest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import org.junit.Test; 4 | import static org.junit.Assert.assertEquals; 5 | import static org.junit.Assert.assertNull; 6 | 7 | public class MessageComponentTypeTest { 8 | @Test 9 | public void testMessageComponentTypeForValueValid() { 10 | assertEquals(MessageComponentType.HEADER, MessageComponentType.forValue("header")); 11 | assertEquals(MessageComponentType.BUTTON, MessageComponentType.forValue("button")); 12 | } 13 | 14 | @Test(expected = NullPointerException.class) 15 | public void testMessageComponentTypeForValueNull() { 16 | MessageComponentType.forValue(null); 17 | } 18 | 19 | @Test 20 | public void testMessageComponentTypeForValueInvalid() { 21 | assertNull(MessageComponentType.forValue("invalid_type")); 22 | } 23 | 24 | @Test 25 | public void testMessageComponentTypeToString() { 26 | assertEquals("header", MessageComponentType.HEADER.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PurchasedNumbersResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.List; 4 | 5 | public class PurchasedNumbersResponse { 6 | private int offset; 7 | private int limit; 8 | private int count; 9 | private int totalCount; 10 | private List items; 11 | 12 | public int getOffset() { 13 | return offset; 14 | } 15 | 16 | public int getLimit() { 17 | return limit; 18 | } 19 | 20 | public int getCount() { 21 | return count; 22 | } 23 | 24 | public int getTotalCount() { 25 | return totalCount; 26 | } 27 | 28 | public List getItems() { 29 | return items; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "PurchasedNumbersResponse{" + 35 | "offset=" + offset + 36 | ", limit=" + limit + 37 | ", count=" + count + 38 | ", totalCount=" + totalCount + 39 | ", items=" + items + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PurchasedNumberCreatedResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.Date; 4 | 5 | public class PurchasedNumberCreatedResponse extends PurchasedNumber { 6 | private Date createdAt; 7 | private Date renewalAt; 8 | 9 | public Date getCreatedAt() { 10 | return createdAt; 11 | } 12 | 13 | public Date getRenewalAt() { 14 | return renewalAt; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "PhoneNumber{" + 20 | "number='" + this.getNumber() + "\'" + 21 | ", country='" + this.getCountry() + "\'" + 22 | ", region='" + this.getRegion() + "\'" + 23 | ", locality='" + this.getLocality() + "\'" + 24 | ", features=" + this.getFeatures() + 25 | ", type='" + this.getType() + "\'" + 26 | ", tags='" + this.getTags() + "\'" + 27 | ", status='" + this.getStatus() + "\'" + 28 | ", createdAt='" + createdAt + "\'" + 29 | ", renewalAt='" + renewalAt + "\'" + 30 | "}"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/MessageBirdException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | import com.messagebird.objects.ErrorReport; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Base class for MessageBird exceptions that can contain Error codes from the REST service 9 | * 10 | * Created by rvt on 1/6/15. 11 | */ 12 | public class MessageBirdException extends Exception { 13 | private List errors; 14 | 15 | public MessageBirdException(List errors) { 16 | this.errors = errors; 17 | } 18 | 19 | public MessageBirdException(String s, List errors) { 20 | super(s); 21 | this.errors = errors; 22 | } 23 | 24 | public MessageBirdException(String s, Throwable throwable, List errors) { 25 | super(s, throwable); 26 | this.errors = errors; 27 | } 28 | 29 | public MessageBirdException(Throwable throwable, List errors) { 30 | super(throwable); 31 | this.errors = errors; 32 | } 33 | 34 | public List getErrors() { 35 | return errors; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class VoiceCallResponse implements Serializable { 10 | 11 | private static final long serialVersionUID = -3429781513863789117L; 12 | 13 | private List data; 14 | @JsonProperty("_links") 15 | private Map links; 16 | 17 | public List getData() { 18 | return data; 19 | } 20 | 21 | public void setData(List data) { 22 | this.data = data; 23 | } 24 | 25 | public Map getLinks() { 26 | return links; 27 | } 28 | 29 | public void setLinks(Map links) { 30 | this.links = links; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "VoiceCallResponse{" + 36 | "data=" + data + 37 | ", links=" + links + 38 | '}'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/objects/integrations/HSMComponentTest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import org.junit.Test; 4 | import static org.junit.Assert.assertEquals; 5 | 6 | public class HSMComponentTest { 7 | @Test 8 | public void testToString() { 9 | HSMComponent component = new HSMComponent(); 10 | component.setType(HSMComponentType.BODY); 11 | component.setFormat(HSMComponentFormat.TEXT); 12 | component.setText("Test text"); 13 | component.setAddSecurityRecommendation(true); 14 | component.setCodeExpirationMinutes(10); 15 | component.setHasExpiration(true); 16 | 17 | String expected = "HSMComponent{type=BODY, format=TEXT, text='Test text', addSecurityRecommendation=true, codeExpirationMinutes=10, buttons=null, hasExpiration=true, cards=null, example=null}"; 18 | assertEquals(expected, component.toString()); 19 | } 20 | 21 | @Test(expected = IllegalArgumentException.class) 22 | public void testSetTextInvalid() { 23 | HSMComponent component = new HSMComponent(); 24 | component.setText(""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/WebhookResponseData.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class WebhookResponseData implements Serializable { 10 | 11 | private static final long serialVersionUID = 7840085698939378254L; 12 | private List data; 13 | @JsonProperty("_links") 14 | private Map links; 15 | 16 | public List getData() { 17 | return data; 18 | } 19 | 20 | public void setData(List data) { 21 | this.data = data; 22 | } 23 | 24 | public Map getLinks() { 25 | return links; 26 | } 27 | 28 | public void setLinks(Map links) { 29 | this.links = links; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "WebhookResponseData{" + 35 | "data=" + data + 36 | ", links=" + links + 37 | '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallFlowResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class VoiceCallFlowResponse implements Serializable { 10 | 11 | private static final long serialVersionUID = -3429781513863789117L; 12 | 13 | private List data; 14 | @JsonProperty("_links") 15 | private Map links; 16 | 17 | public List getData() { 18 | return data; 19 | } 20 | 21 | public void setData(List data) { 22 | this.data = data; 23 | } 24 | 25 | public Map getLinks() { 26 | return links; 27 | } 28 | 29 | public void setLinks(Map links) { 30 | this.links = links; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "VoiceCallResponse{" + 36 | "data=" + data + 37 | ", links=" + links + 38 | '}'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationContentLocation.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | /** 4 | * Coordinates that point to a location. 5 | */ 6 | public class ConversationContentLocation { 7 | 8 | private double latitude, longitude; 9 | 10 | public ConversationContentLocation(double latitude, double longitude) { 11 | this.latitude = latitude; 12 | this.longitude = longitude; 13 | } 14 | 15 | public ConversationContentLocation() { 16 | // 17 | } 18 | 19 | public double getLatitude() { 20 | return latitude; 21 | } 22 | 23 | public void setLatitude(double latitude) { 24 | this.latitude = latitude; 25 | } 26 | 27 | public double getLongitude() { 28 | return longitude; 29 | } 30 | 31 | public void setLongitude(double longitude) { 32 | this.longitude = longitude; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "ConversationContentLocation{" + 38 | "latitude=" + latitude + 39 | ", longitude=" + longitude + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationEmailRecipient.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import java.util.Map; 4 | 5 | public class ConversationEmailRecipient { 6 | private String address; 7 | private String name; 8 | private Map variables; 9 | 10 | public String getAddress() { 11 | return address; 12 | } 13 | 14 | public void setAddress(String address) { 15 | this.address = address; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public Map getVariables() { 27 | return variables; 28 | } 29 | 30 | public void setVariables(Map variables) { 31 | this.variables = variables; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "ConversationEmailRecipient{" + 37 | "address='" + address + '\'' + 38 | ", name='" + name + '\'' + 39 | ", variables=" + variables + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Request object used to update webhook. 7 | */ 8 | public class ConversationWebhookUpdateRequest extends ConversationWebhookBaseRequest { 9 | private ConversationWebhookStatus status; 10 | 11 | public ConversationWebhookUpdateRequest( 12 | final ConversationWebhookStatus status, 13 | final String url, 14 | final List events 15 | ) { 16 | this.status = status; 17 | this.url = url; 18 | this.events = events; 19 | } 20 | 21 | public ConversationWebhookStatus getStatus() { 22 | return status; 23 | } 24 | 25 | public void setStatus(ConversationWebhookStatus status) { 26 | this.status = status; 27 | } 28 | 29 | @Override 30 | protected String getRequestName() { 31 | return "ConversationWebhookUpdateRequest"; 32 | } 33 | 34 | @Override 35 | protected String getStringRepresentationOfExtraParameters() { 36 | return "status='" + status; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteChildAccount.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | public class ExampleDeleteChildAccount { 9 | public static void main(String[] args) { 10 | if (args.length < 2) { 11 | System.out.println("Please specify your access key and id of child account arguments"); 12 | return; 13 | } 14 | 15 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 16 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 17 | 18 | try { 19 | System.out.println("Deleting a child account of partner accounts"); 20 | messageBirdClient.deleteChildAccount(args[1]); 21 | System.out.println("Child account is deleted"); 22 | 23 | } catch (GeneralException | UnauthorizedException | NotFoundException exception) { 24 | exception.printStackTrace(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/test/java/com/messagebird/objects/conversations/MessageParamTest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import org.junit.Test; 4 | import static org.junit.Assert.assertEquals; 5 | 6 | public class MessageParamTest { 7 | @Test 8 | public void testMessageParamToString() { 9 | MessageParam param = new MessageParam(); 10 | param.setType(TemplateMediaType.IMAGE); 11 | param.setText("Sample text"); 12 | param.setPayload("Sample payload"); 13 | 14 | String expected = "MessageParam{type=image, text='Sample text', payload='Sample payload', currency=null, dateTime='null', document=null, image=null, video=null, expirationTime='null', couponCode='null'}"; 15 | assertEquals(expected, param.toString()); 16 | } 17 | 18 | @Test(expected = IllegalArgumentException.class) 19 | public void testMessageParamSetTextInvalid() { 20 | MessageParam param = new MessageParam(); 21 | param.setText(""); 22 | } 23 | 24 | @Test 25 | public void testMessageParamSetTextValid() { 26 | MessageParam param = new MessageParam(); 27 | param.setText("Valid text"); 28 | assertEquals("Valid text", param.getText()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Indicates whether a conversation is active or if it has been archived. 8 | */ 9 | public enum ConversationStatus { 10 | 11 | ACTIVE("active"), 12 | ARCHIVED("archived"); 13 | 14 | private final String status; 15 | 16 | ConversationStatus(final String status) { 17 | this.status = status; 18 | } 19 | 20 | @JsonCreator 21 | public static ConversationStatus forValue(final String value) { 22 | for (ConversationStatus conversationStatus : ConversationStatus.values()) { 23 | if (conversationStatus.getStatus().equals(value)) { 24 | return conversationStatus; 25 | } 26 | } 27 | 28 | return null; 29 | } 30 | 31 | @JsonValue 32 | public String toJson() { 33 | return getStatus(); 34 | } 35 | 36 | public String getStatus() { 37 | return status; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return getStatus(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleUpdateChildAccount.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.ChildAccountResponse; 7 | 8 | public class ExampleUpdateChildAccount { 9 | public static void main(String[] args) { 10 | if (args.length < 2) { 11 | System.out.println("Please specify your access key, name of child account, id of child account parameters"); 12 | return; 13 | } 14 | 15 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 16 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 17 | 18 | try { 19 | System.out.println("Updating a child account"); 20 | ChildAccountResponse response = messageBirdClient.updateChildAccount(args[1], args[2]); 21 | System.out.println("Child account is updated: " + response.toString()); 22 | } catch (GeneralException | UnauthorizedException exception) { 23 | exception.printStackTrace(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleUpdateNumber.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | 7 | public class ExampleUpdateNumber { 8 | public static void main(String[] args) { 9 | if (args.length < 3) { 10 | System.out.println("Please specify your access key, phone number, and the tags you wish to apply to it."); 11 | return; 12 | } 13 | // First create your service object 14 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 15 | 16 | // Add the service to the client 17 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 18 | try { 19 | System.out.println(messageBirdClient.updateNumber(args[1], args[2], args[3], args[4])); 20 | } catch (UnauthorizedException | GeneralException exception) { 21 | if (exception.getErrors() != null) { 22 | System.out.println(exception.getErrors().toString()); 23 | } 24 | exception.printStackTrace(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/IfMachineType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * IfMachine class for Voice Messages 8 | * Created by rvt on 1/7/15. 9 | */ 10 | public enum IfMachineType { 11 | cont("continue"), 12 | delay("delay"), 13 | hangup("hangup"); 14 | 15 | final String value; 16 | 17 | IfMachineType(String type) { 18 | this.value = type; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "IfMachine{" + 24 | "value='" + value + '\'' + 25 | '}'; 26 | } 27 | 28 | @JsonValue 29 | public String toJson() { 30 | return getValue(); 31 | } 32 | 33 | @JsonCreator 34 | public static IfMachineType forValue(String value) { 35 | if ("continue".equals(value)) { 36 | return cont; 37 | } else if ("delay".equals(value)) { 38 | return delay; 39 | } else if ("hangup".equals(value)) { 40 | return hangup; 41 | } 42 | return null; 43 | } 44 | 45 | public String getValue() { 46 | return value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMCategory.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * An enum for HSMComponentFormat 8 | * 9 | * @see HSMComponentFormat 10 | * @author ssk910 11 | */ 12 | public enum HSMCategory { 13 | 14 | AUTHENTICATION("AUTHENTICATION"), 15 | UTILITY("UTILITY"), 16 | MARKETING("MARKETING"); 17 | 18 | private final String category; 19 | 20 | HSMCategory(String category) { 21 | this.category = category; 22 | } 23 | 24 | @JsonCreator 25 | public static HSMCategory forValue(String value) { 26 | for (HSMCategory hsmCategory : HSMCategory.values()) { 27 | if (hsmCategory.getCategory().equals(value)) { 28 | return hsmCategory; 29 | } 30 | } 31 | 32 | return null; 33 | } 34 | 35 | @JsonValue 36 | public String toJson() { 37 | return getCategory(); 38 | } 39 | 40 | public String getCategory() { 41 | return category; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return getCategory(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleGetChildAccounts.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.ChildAccountResponse; 7 | 8 | import java.util.List; 9 | 10 | public class ExampleGetChildAccounts { 11 | public static void main(String[] args) { 12 | if (args.length < 2) { 13 | System.out.println("Please specify your access key, offset, limit arguments"); 14 | return; 15 | } 16 | 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 19 | 20 | try { 21 | System.out.println("Get a child accounts of partner account"); 22 | List response = messageBirdClient.getChildAccounts(Integer.valueOf(args[1]), Integer.valueOf(args[2])); 23 | System.out.println("response: " + response); 24 | } catch (GeneralException | UnauthorizedException exception) { 25 | exception.printStackTrace(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationContentMedia.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | /** 4 | * Contains media referenced by a URL. Supported types are audio, file, image 5 | * and video. 6 | */ 7 | public class ConversationContentMedia { 8 | 9 | private String url; 10 | private String caption; 11 | 12 | public ConversationContentMedia(final String url, final String caption) { 13 | this.url = url; 14 | this.caption = caption; 15 | } 16 | 17 | public ConversationContentMedia(final String url) { 18 | this.url = url; 19 | } 20 | 21 | public ConversationContentMedia() { 22 | // 23 | } 24 | 25 | public String getUrl() { 26 | return url; 27 | } 28 | 29 | public void setUrl(final String url) { 30 | this.url = url; 31 | } 32 | 33 | public String getCaption() { 34 | return caption; 35 | } 36 | 37 | public void setCaption(String caption) { 38 | this.caption = caption; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "ConversationContentMedia{" + 44 | "url='" + url + '\'' + 45 | ", caption='" + caption + '\'' + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationMessageTag.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * These allow tagging a message based on Facebook tags. 8 | * For more information visit: https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags/ 9 | */ 10 | public enum ConversationMessageTag { 11 | EventUpdate("event.update"), 12 | PurchaseUpdate("purchase.update"), 13 | AccountUpdate("account.update"), 14 | HumanAgent("human_agent"); 15 | 16 | @JsonValue 17 | private final String tag; 18 | 19 | ConversationMessageTag(String tag) { 20 | this.tag = tag; 21 | } 22 | 23 | @JsonCreator 24 | public static ConversationMessageTag forValue(final String value) { 25 | for (ConversationMessageTag tag : ConversationMessageTag.values()) { 26 | if (tag.getTag().equals(value)) { 27 | return tag; 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | public String getTag() { 34 | return tag; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return tag; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleGetChildAccountById.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.ChildAccountDetailedResponse; 8 | 9 | public class ExampleGetChildAccountById { 10 | public static void main(String[] args) { 11 | if (args.length < 2) { 12 | System.out.println("Please specify your access key and id of child account arguments"); 13 | return; 14 | } 15 | 16 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 17 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 18 | 19 | try { 20 | System.out.println("Get a child account by id"); 21 | ChildAccountDetailedResponse response = messageBirdClient.getChildAccountById(args[1]); 22 | System.out.println("Response: " + response.toString()); 23 | } catch (GeneralException | UnauthorizedException | NotFoundException exception) { 24 | exception.printStackTrace(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMComponentFormat.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * An enum for HSMComponentFormat 8 | * 9 | * @see HSMComponentFormat 10 | * @author ssk910 11 | */ 12 | public enum HSMComponentFormat { 13 | 14 | TEXT("TEXT"), 15 | IMAGE("IMAGE"), 16 | DOCUMENT("DOCUMENT"), 17 | VIDEO("VIDEO"); 18 | 19 | private final String format; 20 | 21 | HSMComponentFormat(String format) { 22 | this.format = format; 23 | } 24 | 25 | @JsonCreator 26 | public static HSMComponentFormat forValue(String value) { 27 | for (HSMComponentFormat hsmComponentFormat : HSMComponentFormat.values()) { 28 | if (hsmComponentFormat.getFormat().equals(value)) { 29 | return hsmComponentFormat; 30 | } 31 | } 32 | 33 | return null; 34 | } 35 | 36 | @JsonValue 37 | public String toJson() { 38 | return getFormat(); 39 | } 40 | 41 | public String getFormat() { 42 | return format; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return getFormat(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Indicates whether a conversation webhook is enabled or disabled. 8 | */ 9 | public enum ConversationWebhookStatus { 10 | ENABLED("enabled"), 11 | DISABLED("disabled"); 12 | 13 | private final String status; 14 | 15 | ConversationWebhookStatus(final String status) { 16 | this.status = status; 17 | } 18 | 19 | @JsonCreator 20 | public static ConversationWebhookStatus forValue(final String value) { 21 | for (ConversationWebhookStatus conversationWebhookStatus : ConversationWebhookStatus.values()) { 22 | if (conversationWebhookStatus.getStatus().equals(value)) { 23 | return conversationWebhookStatus; 24 | } 25 | } 26 | 27 | return null; 28 | } 29 | 30 | @JsonValue 31 | public String toJson() { 32 | return getStatus(); 33 | } 34 | 35 | public String getStatus() { 36 | return status; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return getStatus(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteVoiceCallFlow.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.exceptions.NotFoundException; 7 | 8 | public class ExampleDeleteVoiceCallFlow { 9 | 10 | public static void main(String[] args) { 11 | if (args.length < 2) { 12 | System.out.println("Please specify your access key and a voice call flow ID"); 13 | return; 14 | } 15 | 16 | //First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | //Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | //Deleting voice call by id 24 | System.out.println("Deleting a Voice Call Flow"); 25 | messageBirdClient.deleteVoiceCallFlow(args[1]); 26 | System.out.println("Voice call flow deleted "); 27 | 28 | } catch (GeneralException | NotFoundException | UnauthorizedException exception) { 29 | exception.printStackTrace(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookBaseRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | /** 7 | * Contains common fields for webhook requests. 8 | */ 9 | public abstract class ConversationWebhookBaseRequest { 10 | protected String url; 11 | protected List events; 12 | 13 | public String getUrl() { 14 | return url; 15 | } 16 | 17 | public void setUrl(String url) { 18 | this.url = url; 19 | } 20 | 21 | public List getEvents() { 22 | return events; 23 | } 24 | 25 | public void setEvents(List events) { 26 | this.events = events; 27 | } 28 | 29 | protected abstract String getRequestName(); 30 | 31 | protected abstract String getStringRepresentationOfExtraParameters(); 32 | 33 | @Override 34 | public String toString() { 35 | return getRequestName() + "{" + 36 | getStringRepresentationOfExtraParameters() + '\'' + 37 | ", url='" + url + '\'' + 38 | ", events=" + events.stream().map(ConversationWebhookEvent::toString).collect(Collectors.joining(",")) + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewPurchasedNumber.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | public class ExampleViewPurchasedNumber { 9 | public static void main(String[] args) { 10 | if (args.length < 2) { 11 | System.out.println("Please specify your access key and phone number."); 12 | return; 13 | } 14 | // First create your service object 15 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0], "https://numbers.messagebird.com"); 16 | 17 | // Add the service to the client 18 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 19 | 20 | try { 21 | System.out.println(messageBirdClient.viewPurchasedNumber(args[1])); 22 | } catch (UnauthorizedException | NotFoundException | GeneralException exception) { 23 | if (exception.getErrors() != null) { 24 | System.out.println(exception.getErrors().toString()); 25 | } 26 | exception.printStackTrace(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleCancelNumber.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.exceptions.NotFoundException; 7 | 8 | public class ExampleCancelNumber { 9 | public static void main(String[] args) { 10 | if (args.length < 2) { 11 | System.out.println("Please specify your access key & the number you wish to delete."); 12 | return; 13 | } 14 | // First create your service object 15 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 16 | 17 | // Add the service to the client 18 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 19 | 20 | try { 21 | messageBirdClient.cancelNumber(args[1]); 22 | System.out.println("Number Deleted!"); 23 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 24 | if (exception.getErrors() != null) { 25 | System.out.println(exception.getErrors().toString()); 26 | } 27 | exception.printStackTrace(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * An enum for HSMStatus object 8 | * 9 | * @see HSMStatus object 10 | * @author ssk910 11 | */ 12 | public enum HSMStatus { 13 | 14 | NEW("NEW"), 15 | APPROVED("APPROVED"), 16 | PENDING("PENDING"), 17 | REJECTED("REJECTED"), 18 | PENDING_DELETION("PENDING_DELETION"), 19 | DELETED("DELETED"), 20 | DISABLED("DISABLED"), 21 | PAUSED("PAUSED"); 22 | 23 | private final String status; 24 | 25 | HSMStatus(String status) { 26 | this.status = status; 27 | } 28 | 29 | @JsonCreator 30 | public static HSMStatus forValue(String value) { 31 | for (HSMStatus hsmStatus : HSMStatus.values()) { 32 | if (hsmStatus.getStatus().equals(value)) { 33 | return hsmStatus; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | 40 | @JsonValue 41 | public String toJson() { 42 | return getStatus(); 43 | } 44 | 45 | public String getStatus() { 46 | return status; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return getStatus(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMComponentButtonType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * HSMComponentButtonType 8 | * 9 | * @see HSMComponentButtonType 10 | * @author ssk910 11 | */ 12 | public enum HSMComponentButtonType { 13 | 14 | PHONE_NUMBER("PHONE_NUMBER"), 15 | URL("URL"), 16 | QUICK_REPLY("QUICK_REPLY"), 17 | OTP("OTP"), 18 | COPY_CODE("COPY_CODE"); 19 | 20 | private final String type; 21 | 22 | HSMComponentButtonType(String type) { 23 | this.type = type; 24 | } 25 | 26 | @JsonCreator 27 | public static HSMComponentButtonType forValue(String value) { 28 | for (HSMComponentButtonType hsmComponentButtonType : HSMComponentButtonType.values()) { 29 | if (hsmComponentButtonType.getType().equals(value)) { 30 | return hsmComponentButtonType; 31 | } 32 | } 33 | 34 | return null; 35 | } 36 | 37 | @JsonValue 38 | public String toJson() { 39 | return getType(); 40 | } 41 | 42 | public String getType() { 43 | return type; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getType(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/PhoneNumber.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import com.messagebird.objects.PhoneNumberFeature; 4 | 5 | import java.util.EnumSet; 6 | 7 | public class PhoneNumber { 8 | private String number; 9 | private String country; 10 | private String region; 11 | private String locality; 12 | private EnumSet features; 13 | private String type; 14 | 15 | public String getNumber() { 16 | return this.number; 17 | } 18 | 19 | public String getCountry() { 20 | return this.country; 21 | } 22 | 23 | public String getRegion() { 24 | return this.region; 25 | } 26 | 27 | public String getLocality() { 28 | return this.locality; 29 | } 30 | 31 | public EnumSet getFeatures() { 32 | return this.features; 33 | } 34 | 35 | public String getType() { 36 | return this.type; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "PhoneNumber{" + 42 | "number='" + number + "\'" + 43 | ", country='" + country + "\'" + 44 | ", region='" + region + "\'" + 45 | ", locality='" + locality + "\'" + 46 | ", features=" + features + 47 | ", type='" + type + "\'" + 48 | "}"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ListBase.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Provides an object to deserialize to for endpoints returning listings. 7 | * 8 | * @param Type of the items, e.g. Contact or Message. 9 | */ 10 | public class ListBase { 11 | 12 | private Integer offset; 13 | private Integer limit; 14 | private Integer totalCount; 15 | private Links links; 16 | private List items; 17 | 18 | public ListBase() { 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return "ListBase{" + 24 | "offset=" + offset + 25 | ", limit=" + limit + 26 | ", totalCount=" + totalCount + 27 | ", links=" + links + 28 | ", items=" + items + 29 | '}'; 30 | } 31 | 32 | 33 | public Integer getOffset() { 34 | return offset; 35 | } 36 | 37 | public Integer getLimit() { 38 | return limit; 39 | } 40 | 41 | public Integer getTotalCount() { 42 | return totalCount; 43 | } 44 | 45 | public Links getLinks() { 46 | return links; 47 | } 48 | 49 | public List getItems() { 50 | return items; 51 | } 52 | 53 | public void setItems(List items) { 54 | this.items = items; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationPlatformConstants.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | /** 4 | * Platforms are communication channels that a conversation can communicate through. 5 | */ 6 | public class ConversationPlatformConstants { 7 | // PlatformSMS identifies the MessageBird SMS platform. 8 | public static final String SMS = "sms"; 9 | 10 | // PlatformWhatsApp identifies the WhatsApp platform. 11 | public static final String WHATSAPP = "whatsapp"; 12 | 13 | // PlatformFacebook identifies the Facebook platform. 14 | public static final String FACEBOOK = "facebook"; 15 | 16 | // PlatformTelegram identifies the Telegram platform. 17 | public static final String TELEGRAM = "telegram"; 18 | 19 | // PlatformLine identifies the LINE platform. 20 | public static final String LINE = "line"; 21 | 22 | // PlatformWeChat identifies the WeChat platform. 23 | public static final String WECHAT = "wechat"; 24 | 25 | // PlatformEmail identifies the Email platform. 26 | public static final String EMAIL = "email"; 27 | 28 | // PlatformEvents identifies the Events platform 29 | public static final String EVENTS = "events"; 30 | 31 | // PlatformWhatsAppSandbox identified the WhatsApp sandbox platform. 32 | public static final String WHATSAPP_SANDBOX = "whatsapp_sandbox"; 33 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteVoiceCall.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.exceptions.NotFoundException; 7 | 8 | public class ExampleDeleteVoiceCall { 9 | 10 | public static void main(String[] args) { 11 | if (args.length < 2) { 12 | System.out.println("Please specify your access key and a call ID : java -jar test_accesskey e8077d803532c0b5937c639b60216938"); 13 | return; 14 | } 15 | 16 | //First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | //Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | //Deleting voice call by id 24 | System.out.println("Deleting voice call"); 25 | messageBirdClient.deleteVoiceCall(args[1]); 26 | System.out.println("Voice call [" + args[1] + "] deleted."); 27 | 28 | } catch (GeneralException | NotFoundException | UnauthorizedException exception) { 29 | exception.printStackTrace(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Group.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Complete Group object. To create and update groups, use GroupRequest. 7 | */ 8 | public class Group { 9 | 10 | private String id; 11 | private String href; 12 | private String name; 13 | private ContactReference contacts; 14 | private Date createdDatetime; 15 | private Date updatedDatetime; 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public String getHref() { 22 | return href; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public ContactReference getContacts() { 30 | return contacts; 31 | } 32 | 33 | public Date getCreatedDatetime() { 34 | return createdDatetime; 35 | } 36 | 37 | public Date getUpdatedDatetime() { 38 | return updatedDatetime; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "Group{" + 44 | "id='" + id + '\'' + 45 | ", href='" + href + '\'' + 46 | ", name='" + name + '\'' + 47 | ", contacts=" + contacts + 48 | ", createdDatetime=" + createdDatetime + 49 | ", updatedDatetime=" + updatedDatetime + 50 | '}'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleGetOutboundSmsPrices.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdServiceImpl; 3 | import com.messagebird.exceptions.MessageBirdException; 4 | import com.messagebird.objects.OutboundSmsPriceResponse; 5 | 6 | public class ExampleGetOutboundSmsPrices { 7 | 8 | public static void main(String[] args) { 9 | if (args.length != 1 && args.length != 2) { 10 | System.out.println("Please specify your access key and (optionally) SMPP username"); 11 | return; 12 | } 13 | 14 | final MessageBirdClient messageBirdClient = new MessageBirdClient(new MessageBirdServiceImpl(args[0])); 15 | 16 | try { 17 | System.out.println("Get a list of outbound SMS prices"); 18 | 19 | final OutboundSmsPriceResponse outboundSmsPriceResponse; 20 | 21 | if (args.length == 2) { 22 | final String smppUsername = args[1]; 23 | outboundSmsPriceResponse = messageBirdClient.getOutboundSmsPrices(smppUsername); 24 | } else { 25 | outboundSmsPriceResponse = messageBirdClient.getOutboundSmsPrices(); 26 | } 27 | 28 | System.out.println("response: " + outboundSmsPriceResponse); 29 | } catch (MessageBirdException e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/CustomDetails.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Custom fields of this contact. 5 | */ 6 | public class CustomDetails { 7 | 8 | private String custom1; 9 | private String custom2; 10 | private String custom3; 11 | private String custom4; 12 | 13 | public String getCustom1() { 14 | return custom1; 15 | } 16 | 17 | public String getCustom2() { 18 | return custom2; 19 | } 20 | 21 | public String getCustom3() { 22 | return custom3; 23 | } 24 | 25 | public String getCustom4() { 26 | return custom4; 27 | } 28 | 29 | public void setCustom1(String custom1) { 30 | this.custom1 = custom1; 31 | } 32 | 33 | public void setCustom2(String custom2) { 34 | this.custom2 = custom2; 35 | } 36 | 37 | public void setCustom3(String custom3) { 38 | this.custom3 = custom3; 39 | } 40 | 41 | public void setCustom4(String custom4) { 42 | this.custom4 = custom4; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "CustomDetails{" + 48 | "custom1='" + custom1 + '\'' + 49 | ", custom2='" + custom2 + '\'' + 50 | ", custom3='" + custom3 + '\'' + 51 | ", custom4='" + custom4 + '\'' + 52 | '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListTemplates.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.integrations.TemplateList; 7 | 8 | /** 9 | * List templates 10 | * 11 | * @see List templates 12 | * @author ssk910 13 | */ 14 | public class ExampleListTemplates { 15 | 16 | public static void main(String[] args) { 17 | if (args.length == 0) { 18 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 19 | return; 20 | } 21 | 22 | // First create your service object 23 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 24 | 25 | // Add the service to the client 26 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 27 | 28 | try { 29 | System.out.println("Retrieving WhatsApp Template list"); 30 | final TemplateList templateList = messageBirdClient.listWhatsAppTemplates(); 31 | System.out.println(templateList.toString()); 32 | } catch (GeneralException | UnauthorizedException exception) { 33 | exception.printStackTrace(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/WebhookList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class WebhookList implements Serializable { 10 | 11 | private static final long serialVersionUID = -5524142916135114801L; 12 | 13 | private List data; 14 | @JsonProperty("_list") 15 | private Map links; 16 | private Pagination pagination; 17 | 18 | public List getData() { 19 | return data; 20 | } 21 | 22 | public void setData(List data) { 23 | this.data = data; 24 | } 25 | 26 | public Map getLinks() { 27 | return links; 28 | } 29 | 30 | public void setLinks(Map links) { 31 | this.links = links; 32 | } 33 | 34 | public Pagination getPagination() { 35 | return pagination; 36 | } 37 | 38 | public void setPagination(Pagination pagination) { 39 | this.pagination = pagination; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "WebhookList{" + 45 | "data=" + data + 46 | ", links=" + links + 47 | ", pagination=" + pagination + 48 | '}'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationMessageDirection.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Indicates the direction of a message. 8 | */ 9 | public enum ConversationMessageDirection { 10 | 11 | /** 12 | * Received is an in bound message received from a customer. 13 | */ 14 | RECEIVED("received"), 15 | 16 | /** 17 | * Sent is an outbound message sent through the API. 18 | */ 19 | SENT("sent"); 20 | 21 | private final String direction; 22 | 23 | ConversationMessageDirection(final String direction) { 24 | this.direction = direction; 25 | } 26 | 27 | public String getDirection() { 28 | return direction; 29 | } 30 | 31 | @JsonCreator 32 | public static ConversationMessageDirection forValue(String value) { 33 | if ("received".equals(value)) { 34 | return ConversationMessageDirection.RECEIVED; 35 | } else if ("sent".equals(value)) { 36 | return ConversationMessageDirection.SENT; 37 | } 38 | 39 | return null; 40 | } 41 | 42 | @JsonValue 43 | public String toJson() { 44 | return getDirection(); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return getDirection(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListVoiceCallFlow.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.voicecalls.VoiceCallFlowList; 7 | 8 | public class ExampleListVoiceCallFlow { 9 | 10 | public static void main(String[] args) { 11 | if (args.length < 1) { 12 | System.out.println("Please specify your access key, example : java -jar test_accesskey"); 13 | return; 14 | } 15 | 16 | // First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | // Add the service to the cligient 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | // Get list of call flows with offset and limit 24 | System.out.println("Retrieving call flows list"); 25 | VoiceCallFlowList voiceCallFlowList = messageBirdClient.listVoiceCallFlows(0, 0); 26 | 27 | // Display balance 28 | System.out.println(voiceCallFlowList.toString()); 29 | } catch (UnauthorizedException | GeneralException exception) { 30 | exception.printStackTrace(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationContentType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * The type of content that the message holds. Indicates what field is set on a 8 | * ConversationContent object. 9 | */ 10 | public enum ConversationContentType { 11 | 12 | AUDIO("audio"), 13 | FILE("file"), 14 | HSM("hsm"), 15 | IMAGE("image"), 16 | LOCATION("location"), 17 | TEXT("text"), 18 | VIDEO("video"), 19 | EMAIL("email"); 20 | 21 | private final String type; 22 | 23 | ConversationContentType(final String type) { 24 | this.type = type; 25 | } 26 | 27 | @JsonCreator 28 | public static ConversationContentType forValue(String value) { 29 | for (ConversationContentType conversationContentType : ConversationContentType.values()) { 30 | if (conversationContentType.getType().equals(value)) { 31 | return conversationContentType; 32 | } 33 | } 34 | 35 | return null; 36 | } 37 | 38 | @JsonValue 39 | public String toJson() { 40 | return getType(); 41 | } 42 | 43 | public String getType() { 44 | return type; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return getType(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallResponseList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class VoiceCallResponseList implements Serializable { 10 | 11 | private static final long serialVersionUID = -3429781513863789117L; 12 | 13 | private List data; 14 | @JsonProperty("_links") 15 | private Map links; 16 | private Pagination pagination; 17 | 18 | public List getData() { 19 | return data; 20 | } 21 | 22 | public void setData(List data) { 23 | this.data = data; 24 | } 25 | 26 | public Map getLinks() { 27 | return links; 28 | } 29 | 30 | public void setLinks(Map links) { 31 | this.links = links; 32 | } 33 | 34 | public Pagination getPagination() { 35 | return pagination; 36 | } 37 | 38 | public void setPagination(Pagination pagination) { 39 | this.pagination = pagination; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "VoiceCallResponse{" + 45 | "data=" + data + 46 | ", links=" + links + 47 | ", pagination=" + pagination + 48 | '}'; 49 | } 50 | } -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_flow_view.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "e781a76f-14ad-45b0-8490-409300244e20", 5 | "steps": [ 6 | { 7 | "id": "a8e44a38-b935-482f-b17f-ed3472c6292c", 8 | "action": "transfer", 9 | "options": { 10 | "destination" : "31612345678", 11 | "payload" : "Test payload", 12 | "language" : "en-GB", 13 | "voice" : "male", 14 | "repeat" : 1, 15 | "media" : "test.mp3", 16 | "length" : 1, 17 | "maxLength" : 2, 18 | "timeout" : 3, 19 | "finishOnKey" : "1", 20 | "transcribe" : "false", 21 | "transcribeLanguage" : "en-GB", 22 | "record" : "both", 23 | "url" : "http://", 24 | "ifMachine" : "ifMachine", 25 | "machineTimeout" : 200, 26 | "onFinish" : "http://", 27 | "mask" : false 28 | } 29 | } 30 | ], 31 | "record": true, 32 | "default": false, 33 | "createdAt": "2019-08-06T14:13:06Z", 34 | "updatedAt": "2019-08-06T14:13:06Z" 35 | } 36 | ], 37 | "_links": { 38 | "self": "/call-flows/70fbdda2-4f1f-44ce-8792-75af32cf598c" 39 | } 40 | } -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_flows_post.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "e781a76f-14ad-45b0-8490-409300244e20", 5 | "steps": [ 6 | { 7 | "id": "a8e44a38-b935-482f-b17f-ed3472c6292c", 8 | "action": "transfer", 9 | "options": { 10 | "destination" : "31612345678", 11 | "payload" : "Test payload", 12 | "language" : "en-GB", 13 | "voice" : "male", 14 | "repeat" : 1, 15 | "media" : "test.mp3", 16 | "length" : 1, 17 | "maxLength" : 2, 18 | "timeout" : 3, 19 | "finishOnKey" : "1", 20 | "transcribe" : "false", 21 | "transcribeLanguage" : "en-GB", 22 | "record" : "both", 23 | "url" : "http://", 24 | "ifMachine" : "ifMachine", 25 | "machineTimeout" : 200, 26 | "onFinish" : "http://", 27 | "mask" : false 28 | } 29 | } 30 | ], 31 | "record": true, 32 | "default": false, 33 | "createdAt": "2019-08-06T14:13:06Z", 34 | "updatedAt": "2019-08-06T14:13:06Z" 35 | } 36 | ], 37 | "_links": { 38 | "self": "/call-flows/e781a76f-14ad-45b0-8490-409300244e20" 39 | } 40 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewVoiceCallFlow.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.exceptions.NotFoundException; 7 | import com.messagebird.objects.voicecalls.VoiceCallFlowResponse; 8 | 9 | public class ExampleViewVoiceCallFlow { 10 | 11 | public static void main(String[] args) { 12 | if (args.length < 2) { 13 | System.out.println("Please specify your access key and a voice call flow ID"); 14 | return; 15 | } 16 | 17 | //First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | //Add the service to the client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | 23 | try { 24 | //Deleting voice call by id 25 | System.out.println("Requesting a Voice Call Flow"); 26 | VoiceCallFlowResponse voiceCallFlowResponse = messageBirdClient 27 | .viewVoiceCallFlow(args[1]); 28 | System.out.println("Voice call flow retrieved "); 29 | 30 | } catch (GeneralException | UnauthorizedException | NotFoundException exception) { 31 | exception.printStackTrace(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationChannelStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Status for a Conversation channel. Only ACTIVE channels can be used for 8 | * messaging. 9 | */ 10 | public enum ConversationChannelStatus { 11 | 12 | ACTIVATING("activating"), 13 | ACTIVATION_CODE_REQUIRED("activation_code_required"), 14 | ACTIVATION_REQUIRED("activation_required"), 15 | ACTIVE("active"), 16 | DELETED("deleted"), 17 | INACTIVE("inactive"), 18 | PENDING("pending"); 19 | 20 | private final String status; 21 | 22 | ConversationChannelStatus(final String status) { 23 | this.status = status; 24 | } 25 | 26 | public String getStatus() { 27 | return status; 28 | } 29 | 30 | @JsonCreator 31 | public static ConversationChannelStatus forValue(final String value) { 32 | for (ConversationChannelStatus status : ConversationChannelStatus.values()) { 33 | if (status.getStatus().equals(value)) { 34 | return status; 35 | } 36 | } 37 | 38 | return null; 39 | } 40 | 41 | @JsonValue 42 | public String toJson() { 43 | return getStatus(); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getStatus(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_flow_update_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "e781a76f-14ad-45b0-8490-409300244e20", 5 | "steps": [ 6 | { 7 | "id": "a8e44a38-b935-482f-b17f-ed3472c6292c", 8 | "action": "transfer", 9 | "options": { 10 | "destination" : "31612345678", 11 | "payload" : "Test payload", 12 | "language" : "en-GB", 13 | "voice" : "male", 14 | "repeat" : 1, 15 | "media" : "test.mp3", 16 | "length" : 1, 17 | "maxLength" : 2, 18 | "timeout" : 3, 19 | "finishOnKey" : "1", 20 | "transcribe" : "false", 21 | "transcribeLanguage" : "en-GB", 22 | "record" : "both", 23 | "url" : "http://", 24 | "ifMachine" : "ifMachine", 25 | "machineTimeout" : 200, 26 | "onFinish" : "http://", 27 | "mask" : false 28 | } 29 | } 30 | ], 31 | "record": true, 32 | "default": false, 33 | "createdAt": "2019-08-06T14:13:06Z", 34 | "updatedAt": "2019-08-06T14:13:06Z" 35 | } 36 | ], 37 | "_links": { 38 | "self": "/call-flows/e781a76f-14ad-45b0-8490-409300244e20" 39 | } 40 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleCreateChildAccount.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.ChildAccountRequest; 7 | import com.messagebird.objects.ChildAccountCreateResponse; 8 | 9 | public class ExampleCreateChildAccount { 10 | public static void main(String[] args) { 11 | if (args.length < 2) { 12 | System.out.println("Please specify your access key and name of child account arguments"); 13 | return; 14 | } 15 | 16 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 17 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 18 | 19 | try { 20 | System.out.println("Creating a child account of partner accounts"); 21 | final ChildAccountRequest childAccountRequest = new ChildAccountRequest(); 22 | childAccountRequest.setName(args[1]); 23 | ChildAccountCreateResponse childAccount = messageBirdClient.createChildAccount(childAccountRequest); 24 | System.out.println("Child account is created: " + childAccount.toString()); 25 | 26 | } catch (GeneralException | UnauthorizedException exception) { 27 | exception.printStackTrace(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_flow_view_title.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "title": "Call title", 5 | "id": "e781a76f-14ad-45b0-8490-409300244e20", 6 | "steps": [ 7 | { 8 | "id": "a8e44a38-b935-482f-b17f-ed3472c6292c", 9 | "action": "transfer", 10 | "options": { 11 | "destination" : "31612345678", 12 | "payload" : "Test payload", 13 | "language" : "en-GB", 14 | "voice" : "male", 15 | "repeat" : 1, 16 | "media" : "test.mp3", 17 | "length" : 1, 18 | "maxLength" : 2, 19 | "timeout" : 3, 20 | "finishOnKey" : "1", 21 | "transcribe" : "false", 22 | "transcribeLanguage" : "en-GB", 23 | "record" : "both", 24 | "url" : "http://", 25 | "ifMachine" : "ifMachine", 26 | "machineTimeout" : 200, 27 | "onFinish" : "http://", 28 | "mask" : false 29 | } 30 | } 31 | ], 32 | "record": true, 33 | "default": false, 34 | "createdAt": "2019-08-06T14:13:06Z", 35 | "updatedAt": "2019-08-06T14:13:06Z" 36 | } 37 | ], 38 | "_links": { 39 | "self": "/call-flows/70fbdda2-4f1f-44ce-8792-75af32cf598c" 40 | } 41 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListPurchasedNumbers.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.PhoneNumberFeature; 8 | import com.messagebird.objects.PurchasedNumbersFilter; 9 | 10 | public class ExampleListPurchasedNumbers { 11 | public static void main(String[] args) { 12 | if (args.length < 1) { 13 | System.out.println("Please specify your access key."); 14 | return; 15 | } 16 | // First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | // Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | PurchasedNumbersFilter filter = new PurchasedNumbersFilter(); 23 | filter.setLimit(25); 24 | 25 | try { 26 | System.out.println(messageBirdClient.listPurchasedNumbers(filter)); 27 | } catch (UnauthorizedException | NotFoundException | GeneralException exception) { 28 | if (exception.getErrors() != null) { 29 | System.out.println(exception.getErrors().toString()); 30 | } 31 | exception.printStackTrace(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/Balance.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * MessageBird provides an API to get the balance and balance information of your account. 7 | * This object is returned after a balance request to MessageBird 8 | * 9 | * Created by rvt on 1/5/15. 10 | */ 11 | public class Balance implements Serializable{ 12 | 13 | private static final long serialVersionUID = 3337612669443153675L; 14 | 15 | private String payment; 16 | private String type; 17 | private float amount; 18 | 19 | public Balance() { 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "Balance{" + 25 | "payment='" + payment + '\'' + 26 | ", type='" + type + '\'' + 27 | ", amount=" + amount + 28 | '}'; 29 | } 30 | 31 | /** 32 | * Your payment method. Possible values are: prepaid & postpaid 33 | * @return 34 | */ 35 | public String getPayment() { 36 | return payment; 37 | } 38 | 39 | /** 40 | * Your payment type. Possible values are: credits & euros 41 | * @return 42 | */ 43 | public String getType() { 44 | return type; 45 | } 46 | 47 | /** 48 | * The amount of balance of the payment type. When postpaid is your payment method, the amount will be 0. 49 | * @return 50 | */ 51 | public float getAmount() { 52 | return amount; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/Pagination.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Pagination implements Serializable { 6 | 7 | private static final long serialVersionUID = -1107723710694243206L; 8 | 9 | private int totalCount; 10 | private int pageCount; 11 | private int currentPage; 12 | private int perPage; 13 | 14 | public int getTotalCount() { 15 | return totalCount; 16 | } 17 | 18 | public void setTotalCount(int totalCount) { 19 | this.totalCount = totalCount; 20 | } 21 | 22 | public int getPageCount() { 23 | return pageCount; 24 | } 25 | 26 | public void setPageCount(int pageCount) { 27 | this.pageCount = pageCount; 28 | } 29 | 30 | public int getCurrentPage() { 31 | return currentPage; 32 | } 33 | 34 | public void setCurrentPage(int currentPage) { 35 | this.currentPage = currentPage; 36 | } 37 | 38 | public int getPerPage() { 39 | return perPage; 40 | } 41 | 42 | public void setPerPage(int perPage) { 43 | this.perPage = perPage; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "Pagination{" + 49 | "totalCount=" + totalCount + 50 | ", pageCount=" + pageCount + 51 | ", currentPage=" + currentPage + 52 | ", perPage=" + perPage + 53 | '}'; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLanguagePolicy.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Determines the lanuage policy for a HSM. 8 | */ 9 | public enum ConversationHsmLanguagePolicy { 10 | 11 | /** 12 | * Messages are delivered in exactly the language/locale requested. 13 | */ 14 | DETERMINISTIC("deterministic"), 15 | 16 | /** 17 | * Messages are delivered in the user's device language. If that is not 18 | * found, the requested locale is used. 19 | */ 20 | FALLBACK("fallback"); 21 | 22 | private final String policy; 23 | 24 | ConversationHsmLanguagePolicy(final String policy) { 25 | this.policy = policy; 26 | } 27 | 28 | @JsonCreator 29 | public static ConversationHsmLanguagePolicy forValue(String value) { 30 | if ("deterministic".equals(value)) { 31 | return ConversationHsmLanguagePolicy.DETERMINISTIC; 32 | } else if ("fallback".equals(value)) { 33 | return ConversationHsmLanguagePolicy.FALLBACK; 34 | } 35 | 36 | return null; 37 | } 38 | 39 | @JsonValue 40 | public String toJson() { 41 | return policy; 42 | } 43 | 44 | public String getPolicy() { 45 | return policy; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return getPolicy(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationEmailAttachment.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationEmailAttachment { 4 | private String id; 5 | private String name; 6 | private String type; 7 | private String URL; 8 | private String length; 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public String getType() { 27 | return type; 28 | } 29 | 30 | public void setType(String type) { 31 | this.type = type; 32 | } 33 | 34 | public String getURL() { 35 | return URL; 36 | } 37 | 38 | public void setURL(String URL) { 39 | this.URL = URL; 40 | } 41 | 42 | public String getLength() { 43 | return length; 44 | } 45 | 46 | public void setLength(String length) { 47 | this.length = length; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ConversationEmailAttachment{" + 53 | "id='" + id + '\'' + 54 | ", name='" + name + '\'' + 55 | ", type='" + type + '\'' + 56 | ", URL='" + URL + '\'' + 57 | ", length='" + length + '\'' + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/MessageComponentType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | import java.util.*; 7 | 8 | public enum MessageComponentType { 9 | 10 | HEADER("header"), 11 | BODY("body"), 12 | FOOTER("footer"), 13 | BUTTON("button"), 14 | CARD("card"), 15 | CAROUSEL("carousel"), 16 | LIMITED_TIME_OFFER("limited_time_offer"), 17 | COPY_CODE("copy_code"); 18 | 19 | private static final Map TYPE_MAP; 20 | 21 | static { 22 | Map map = new HashMap<>(); 23 | for (MessageComponentType componentType : MessageComponentType.values()) { 24 | map.put(componentType.getType().toLowerCase(), componentType); 25 | } 26 | TYPE_MAP = Collections.unmodifiableMap(map); 27 | } 28 | 29 | private final String type; 30 | 31 | MessageComponentType(final String type) { 32 | this.type = type; 33 | } 34 | 35 | @JsonCreator 36 | public static MessageComponentType forValue(String value) { 37 | Objects.requireNonNull(value, "Value cannot be null"); 38 | return TYPE_MAP.get(value.toLowerCase(Locale.ROOT)); 39 | } 40 | 41 | @JsonValue 42 | public String toJson() { 43 | return getType(); 44 | } 45 | 46 | public String getType() { 47 | return type; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return getType(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListVoiceMessages.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.VoiceMessageList; 7 | 8 | /** 9 | * Created by rvt on 1/8/15. 10 | */ 11 | public class ExampleListVoiceMessages { 12 | public static void main(String[] args) { 13 | 14 | if (args.length == 0) { 15 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | System.out.println("Retrieving message list"); 27 | final VoiceMessageList messageList = messageBirdClient.listVoiceMessages(2, 10); 28 | 29 | // Display 30 | System.out.println(messageList.toString()); 31 | 32 | } catch (UnauthorizedException | GeneralException exception) { 33 | if (exception.getErrors() != null) { 34 | System.out.println(exception.getErrors().toString()); 35 | } 36 | exception.printStackTrace(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMExample.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * HSMExample object 7 | * 8 | * @see HSMExample object 9 | * @author ssk910 10 | */ 11 | public class HSMExample { 12 | 13 | /* Example values for HEADER type components, TEXT format */ 14 | private List header_text; 15 | 16 | /* Example set of values for the body text variables */ 17 | private List> body_text; 18 | 19 | /* Example values for HEADER type components, IMAGE format */ 20 | private List header_url; 21 | 22 | public List getHeader_text() { 23 | return header_text; 24 | } 25 | 26 | public void setHeader_text(List header_text) { 27 | this.header_text = header_text; 28 | } 29 | 30 | public List> getBody_text() { 31 | return body_text; 32 | } 33 | 34 | public void setBody_text(List> body_text) { 35 | this.body_text = body_text; 36 | } 37 | 38 | public List getHeader_url() { 39 | return header_url; 40 | } 41 | 42 | public void setHeader_url(List header_url) { 43 | this.header_url = header_url; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "HSMExample{" + 49 | "header_text=" + header_text + 50 | ", body_text=" + body_text + 51 | ", header_url=" + header_url + 52 | '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/src/main/java/ExamplePurchaseNumber.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.PurchasedNumberCreatedResponse; 7 | 8 | public class ExamplePurchaseNumber { 9 | public static void main(String[] args) { 10 | if (args.length < 4) { 11 | System.out.println("Please specify your access key, number, country code and billing interval months, eg: ExamplePurchaseNumber test_accesskey 3197010240563 NL 1"); 12 | return; 13 | } 14 | // First create your service object 15 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0], "https://numbers.messagebird.com"); 16 | 17 | // Add the service to the client 18 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 19 | 20 | try { 21 | PurchasedNumberCreatedResponse purchasedNumberCreatedResponse = messageBirdClient.purchaseNumber(args[1], args[2], Integer.parseInt(args[3])); 22 | 23 | System.out.println(purchasedNumberCreatedResponse); 24 | } catch (UnauthorizedException | GeneralException exception) { 25 | if (exception.getErrors() != null) { 26 | System.out.println(exception.getErrors().toString()); 27 | } 28 | exception.printStackTrace(); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLocalizableParameterCurrency.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | /** 4 | * Parameter for HSMs that localizes currencies. 5 | */ 6 | public class ConversationHsmLocalizableParameterCurrency { 7 | 8 | private String currencyCode; 9 | private int amount; 10 | 11 | /** 12 | * Instantiates a localizable parameter for currencies. 13 | * 14 | * @param currencyCode ISO 4217 compliant currency code. 15 | * @param amount Amount multiplied by 1000. E.g. 12.34 becomes 12340. 16 | */ 17 | public ConversationHsmLocalizableParameterCurrency(final String currencyCode, final int amount) { 18 | this.currencyCode = currencyCode; 19 | this.amount = amount; 20 | } 21 | 22 | public ConversationHsmLocalizableParameterCurrency() { 23 | // 24 | } 25 | 26 | public String getCurrencyCode() { 27 | return currencyCode; 28 | } 29 | 30 | public void setCurrencyCode(final String currencyCode) { 31 | this.currencyCode = currencyCode; 32 | } 33 | 34 | public int getAmount() { 35 | return amount; 36 | } 37 | 38 | public void setAmount(final int amount) { 39 | this.amount = amount; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "ConversationHsmLocalizableParameterCurrency{" + 45 | "amount=" + amount + 46 | ", currencyCode='" + currencyCode + '\'' + 47 | '}'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/exceptions/GeneralException.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.exceptions; 2 | 3 | import com.messagebird.objects.ErrorReport; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * General exceptions send by the system. It might or might not contain a list of error codes 9 | * 10 | * Created by rvt on 1/5/15. 11 | */ 12 | public class GeneralException extends MessageBirdException { 13 | private Integer responseCode=null; 14 | public GeneralException(List errors) { 15 | super(errors); 16 | } 17 | 18 | public GeneralException(String s, List errors) { 19 | super(s, errors); 20 | } 21 | public GeneralException(String s) { 22 | super(s, null); 23 | } 24 | 25 | public GeneralException(String s, Throwable throwable, List errors) { 26 | super(s, throwable, errors); 27 | } 28 | 29 | public GeneralException(Throwable throwable, List errors) { 30 | super(throwable, errors); 31 | } 32 | public GeneralException(Throwable throwable) { 33 | super(throwable, null); 34 | } 35 | 36 | public GeneralException(String s, Integer responseCode) { 37 | this(s); 38 | this.responseCode = responseCode; 39 | } 40 | 41 | public GeneralException(String s, int responseCode, List errorReport) { 42 | super(s, errorReport); 43 | this.responseCode = responseCode; 44 | } 45 | 46 | public Integer getResponseCode() { 47 | return responseCode; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, MessageBird 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of java-rest-api nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLanguage.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | /** 4 | * Language options used for localization. Code can be in language or 5 | * language_locale formats (e.g. "en" and "en_US"). The policy indicates 6 | * whether the message is delivered exactly in the locale requested 7 | * (deterministic). If the fallback policy is used, WhatsApp will attempt to 8 | * deliver the HSM in the user's device language. If that is not found, the 9 | * fallback is used. 10 | */ 11 | public class ConversationHsmLanguage { 12 | 13 | private String code; 14 | private ConversationHsmLanguagePolicy policy; 15 | 16 | public ConversationHsmLanguage(final String code, final ConversationHsmLanguagePolicy policy) { 17 | this.code = code; 18 | this.policy = policy; 19 | } 20 | 21 | public ConversationHsmLanguage() { 22 | // 23 | } 24 | 25 | public String getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(final String code) { 30 | this.code = code; 31 | } 32 | 33 | public ConversationHsmLanguagePolicy getPolicy() { 34 | return policy; 35 | } 36 | 37 | public void setPolicy(final ConversationHsmLanguagePolicy policy) { 38 | this.policy = policy; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "ConversationHsmLanguage{" + 44 | "code='" + code + '\'' + 45 | ", policy=" + policy + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteMessage.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | /** 9 | * Created by rvt on 1/8/15. 10 | */ 11 | public class ExampleDeleteMessage { 12 | public static void main(String[] args) { 13 | 14 | if (args.length == 0) { 15 | System.out.println("Please specify your access key example and a id to delete: java -jar test_accesskey 0f15f050454ad3db04286d6b30005106"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Deleting message by id 27 | System.out.println("Delete message:"); 28 | messageBirdClient.deleteMessage(args[1]); 29 | System.out.println("Message ["+args[1]+"] deleted."); 30 | 31 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 32 | if (exception.getErrors() != null) { 33 | System.out.println(exception.getErrors().toString()); 34 | } 35 | exception.printStackTrace(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteRecording.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | public class ExampleDeleteRecording { 9 | public static void main(String[] args) { 10 | 11 | if (args.length < 3) { 12 | System.out.println("Please specify your access key and a call_id, leg_id, and recording_id to delete: java -jar " ); 13 | return; 14 | } 15 | 16 | // First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | // Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | // Deleting message by id 24 | System.out.println("Delete recording:"); 25 | messageBirdClient.deleteRecording(args[1],args[2],args[3]); 26 | System.out.println("Recording ID ["+args[3]+"] deleted."); 27 | 28 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 29 | if (exception.getErrors() != null) { 30 | System.out.println(exception.getErrors().toString()); 31 | } 32 | exception.printStackTrace(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListMessages.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.MessageList; 7 | 8 | /** 9 | * Created by rvt on 1/8/15. 10 | */ 11 | public class ExampleListMessages { 12 | public static void main(String[] args) { 13 | 14 | if (args.length == 0) { 15 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Get list of messages with offset and limit 27 | System.out.println("Retrieving message list"); 28 | final MessageList messageList = messageBirdClient.listMessages(3, null); 29 | 30 | // Display balance 31 | System.out.println(messageList.toString()); 32 | } catch (UnauthorizedException | GeneralException exception) { 33 | if (exception.getErrors() != null) { 34 | System.out.println(exception.getErrors().toString()); 35 | } 36 | exception.printStackTrace(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListTemplatesByWABAID.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.integrations.TemplateList; 7 | 8 | /** 9 | * List templates by WABA ID 10 | * 11 | * @see List templates by WABA ID 12 | * @author ssk910 13 | */ 14 | public class ExampleListTemplatesByWABAID { 15 | 16 | public static void main(String[] args) { 17 | if (args.length < 2) { 18 | System.out.println("Please specify your access key and WABA ID example : java -jar test_accesskey \"WABA ID\""); 19 | return; 20 | } 21 | 22 | // First create your service object 23 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 24 | 25 | // Add the service to the client 26 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 27 | 28 | try { 29 | System.out.println("Retrieving WhatsApp Template list by WABA"); 30 | final TemplateList templateList = messageBirdClient.listWhatsAppTemplates(0, 25, args[1], null); 31 | System.out.println(templateList.toString()); 32 | } catch (GeneralException | UnauthorizedException | IllegalArgumentException exception) { 33 | exception.printStackTrace(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewWebhook.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.voicecalls.WebhookResponseData; 8 | 9 | public class ExampleViewWebhook { 10 | public static void main(String[] args) { 11 | if (args.length < 2) { 12 | System.out.println("Please specify your access key, webhook id :" + 13 | " java -jar test_accesskey e8077d803532c0b5937c639b60216938"); 14 | return; 15 | } 16 | 17 | //First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | //Add the service to the client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | 23 | try { 24 | System.out.println("Viewing webhook.."); 25 | final String webhookId = args[1]; 26 | //Viewing webhook by webhook id 27 | final WebhookResponseData webhookResponseDataList = messageBirdClient.viewWebhook(webhookId); 28 | //Display Webhook Response Data 29 | System.out.println(webhookResponseDataList.toString()); 30 | } catch (GeneralException | UnauthorizedException | NotFoundException exception) { 31 | exception.printStackTrace(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDeleteTemplatesByName.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | /** 9 | * List templates by name 10 | * 11 | * @see List templates by name 12 | * @author ssk910 13 | */ 14 | public class ExampleDeleteTemplatesByName { 15 | 16 | public static void main(String[] args) { 17 | if (args.length < 2) { 18 | System.out.println("Please specify your access key and a template name example : java -jar test_accesskey \"My template name\""); 19 | return; 20 | } 21 | 22 | // First create your service object 23 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 24 | 25 | // Add the service to the client 26 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 27 | 28 | // template name from input 29 | final String templateName = args[1]; 30 | 31 | try { 32 | System.out.println("Deleting WhatsApp Templates by name : " + templateName); 33 | messageBirdClient.deleteTemplatesBy(templateName); 34 | System.out.println("Template [" + templateName + "] deleted."); 35 | } catch (GeneralException | UnauthorizedException | NotFoundException exception) { 36 | exception.printStackTrace(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleReadBalance.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.Balance; 8 | 9 | /** 10 | * Created by rvt on 1/5/15. 11 | */ 12 | public class ExampleReadBalance { 13 | 14 | public static void main(String[] args) { 15 | 16 | if (args.length == 0) { 17 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 18 | return; 19 | } 20 | 21 | // First create your service object 22 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 23 | 24 | // Add the service to the client 25 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 26 | 27 | try { 28 | // Get Balance 29 | System.out.println("Retrieving your balance:"); 30 | final Balance balance = messageBirdClient.getBalance(); 31 | 32 | // Display balance 33 | System.out.println(balance.toString()); 34 | 35 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 36 | if (exception.getErrors() != null) { 37 | System.out.println(exception.getErrors().toString()); 38 | } 39 | exception.printStackTrace(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListTemplatesForChannelID.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.integrations.TemplateList; 7 | 8 | /** 9 | * List templates for Channel ID 10 | * 11 | * @see List templates for Channel ID 12 | * @author ssk910 13 | */ 14 | public class ExampleListTemplatesForChannelID { 15 | 16 | public static void main(String[] args) { 17 | if (args.length < 2) { 18 | System.out.println("Please specify your access key and channel ID example : java -jar test_accesskey"); 19 | return; 20 | } 21 | 22 | // First create your service object 23 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 24 | 25 | // Add the service to the client 26 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 27 | 28 | try { 29 | System.out.println("Retrieving WhatsApp Template list for a channel"); 30 | final TemplateList templateList = messageBirdClient.listWhatsAppTemplates(0, 25, null, args[1]); 31 | System.out.println(templateList.toString()); 32 | } catch (GeneralException | UnauthorizedException | IllegalArgumentException exception) { 33 | exception.printStackTrace(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListVoiceCalls.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.voicecalls.VoiceCallResponseList; 7 | 8 | public class ExampleListVoiceCalls { 9 | 10 | public static void main(String[] args) { 11 | 12 | if (args.length < 3) { 13 | System.out.println("Please specify your access key example, page, page size : java -jar test_accesskey 1 2"); 14 | return; 15 | } 16 | 17 | //First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | //Add the service to the client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | 23 | try { 24 | //Getting list of message with given page and page size parameters 25 | System.out.println("Retrieving voice call list"); 26 | final Integer page = Integer.valueOf(args[1]); 27 | final Integer pageSize = Integer.valueOf(args[2]); 28 | final VoiceCallResponseList voiceCallResponseList = messageBirdClient.listAllVoiceCalls(page, pageSize) ; 29 | //Display result 30 | System.out.println(voiceCallResponseList.toString()); 31 | 32 | } catch (GeneralException | UnauthorizedException exception) { 33 | exception.printStackTrace(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationSendResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationSendResponse { 4 | private String id; //messageID 5 | private String status; 6 | private FallbackOptionResponse fallback; 7 | 8 | public static class FallbackOptionResponse{ 9 | private String id; 10 | 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return "FallbackOptionResponse{" + 23 | "id='" + id + '\'' + 24 | '}'; 25 | } 26 | } 27 | 28 | public String getId() { 29 | return id; 30 | } 31 | 32 | public void setId(String id) { 33 | this.id = id; 34 | } 35 | 36 | public String getStatus() { 37 | return status; 38 | } 39 | 40 | public void setStatus(String status) { 41 | this.status = status; 42 | } 43 | 44 | public FallbackOptionResponse getFallback() { 45 | return fallback; 46 | } 47 | 48 | public void setFallback(FallbackOptionResponse fallback) { 49 | this.fallback = fallback; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return "ConversationSendResponse{" + 55 | "id='" + id + '\'' + 56 | ", status='" + status + '\'' + 57 | ", fallback=" + fallback + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleUpdateConversation.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.conversations.*; 7 | 8 | public class ExampleUpdateConversation { 9 | 10 | public static void main(String[] args) { 11 | if (args.length < 3) { 12 | System.out.println("Please specify your access key, the ID of a conversation and the status to update the conversation to." + 13 | " Example : java -jar test_accesskey test_conversationId archived"); 14 | return; 15 | } 16 | 17 | // First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | // Add the service to the client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | final ConversationStatus newStatus = ConversationStatus.forValue(args[2]); 23 | try { 24 | final Conversation response = messageBirdClient.updateConversation(args[1], newStatus); 25 | // Display message response 26 | System.out.println(response.toString()); 27 | } catch (UnauthorizedException | GeneralException exception) { 28 | if (exception.getErrors() != null) { 29 | System.out.println(exception.getErrors().toString()); 30 | } 31 | exception.printStackTrace(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewMessage.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.MessageResponse; 8 | 9 | /** 10 | * Created by rvt on 1/7/15. 11 | */ 12 | public class ExampleViewMessage { 13 | public static void main(String[] args) { 14 | if (args.length < 2) { 15 | System.out.println("Please specify your access key and a message ID : java -jar test_accesskey e8077d803532c0b5937c639b60216938"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Get Hlr using msgId and msisdn 27 | System.out.println("getting message info message:"); 28 | final MessageResponse response = messageBirdClient.viewMessage(args[1]); 29 | System.out.println(response.toString()); 30 | 31 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 32 | if (exception.getErrors() != null) { 33 | System.out.println(exception.getErrors().toString()); 34 | } 35 | exception.printStackTrace(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/test/resources/fixtures/call_flows_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "id": "e781a76f-14ad-45b0-8490-409300244e20", 5 | "steps": [ 6 | { 7 | "id": "a8e44a38-b935-482f-b17f-ed3472c6292c", 8 | "action": "transfer", 9 | "options": { 10 | "destination" : "31612345678", 11 | "payload" : "Test payload", 12 | "language" : "en-GB", 13 | "voice" : "male", 14 | "repeat" : 1, 15 | "media" : "test.mp3", 16 | "length" : 1, 17 | "maxLength" : 2, 18 | "timeout" : 3, 19 | "finishOnKey" : "1", 20 | "transcribe" : "false", 21 | "transcribeLanguage" : "en-GB", 22 | "record" : "both", 23 | "url" : "http://", 24 | "ifMachine" : "ifMachine", 25 | "machineTimeout" : 200, 26 | "onFinish" : "http://", 27 | "mask" : false 28 | } 29 | } 30 | ], 31 | "record": true, 32 | "default": false, 33 | "createdAt": "2019-08-06T14:13:06Z", 34 | "updatedAt": "2019-08-06T14:13:06Z", 35 | "_links": { 36 | "self": "/call-flows/70fbdda2-4f1f-44ce-8792-75af32cf598c" 37 | } 38 | } 39 | ], 40 | "_links": { 41 | "self": "/call-flows?page=1" 42 | }, 43 | "pagination": { 44 | "totalCount": 10, 45 | "pageCount": 3, 46 | "currentPage": 2, 47 | "perPage": 12 48 | } 49 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/HlrDetails.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | /** 4 | * Created by faizan on 01/02/16. 5 | */ 6 | public class HlrDetails { 7 | String status_desc; 8 | String imsi; 9 | String country_iso; 10 | String country_name; 11 | String location_msc; 12 | String location_iso; 13 | int ported; 14 | int roaming; 15 | 16 | 17 | @Override 18 | public String toString() { 19 | return "HlrDetails{" + 20 | "status_desc='" + status_desc + '\'' + 21 | ", imsi='" + imsi + '\'' + 22 | ", country_iso=" + country_iso + 23 | ", country_name='" + country_name + '\'' + 24 | ", location_msc='" + location_msc + '\'' + 25 | ", location_iso='" + location_iso + '\'' + 26 | ", ported=" + Integer.toString(ported) + 27 | ", roaming=" + Integer.toString(roaming) + 28 | '}'; 29 | } 30 | 31 | public String getStatus_desc() { 32 | return status_desc; 33 | } 34 | 35 | public String getImsi() { 36 | return imsi; 37 | } 38 | 39 | public String getCountry_iso() { 40 | return country_iso; 41 | } 42 | 43 | public String getCountry_name() { 44 | return country_name; 45 | } 46 | 47 | public String getLocation_msc() { 48 | return location_msc; 49 | } 50 | 51 | public String getLocation_iso() { 52 | return location_iso; 53 | } 54 | 55 | public int getPorted() { 56 | return ported; 57 | } 58 | 59 | public int getRoaming() { 60 | return roaming; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/OutboundSmsPrice.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class OutboundSmsPrice { 6 | private BigDecimal price; 7 | private String currencyCode; 8 | private String mccmnc; 9 | private String mcc; 10 | private String mnc; 11 | private String countryName; 12 | private String countryIsoCode; 13 | private String operatorName; 14 | 15 | public BigDecimal getPrice() { 16 | return price; 17 | } 18 | 19 | public String getCurrencyCode() { 20 | return currencyCode; 21 | } 22 | 23 | public String getMccmnc() { 24 | return mccmnc; 25 | } 26 | 27 | public String getMcc() { 28 | return mcc; 29 | } 30 | 31 | public String getMnc() { 32 | return mnc; 33 | } 34 | 35 | public String getCountryName() { 36 | return countryName; 37 | } 38 | 39 | public String getCountryIsoCode() { 40 | return countryIsoCode; 41 | } 42 | 43 | public String getOperatorName() { 44 | return operatorName; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "OutboundSmsPrice{" + 50 | "price=" + price + 51 | ", currencyCode='" + currencyCode + '\'' + 52 | ", mccmnc='" + mccmnc + '\'' + 53 | ", mcc='" + mcc + '\'' + 54 | ", mnc='" + mnc + '\'' + 55 | ", countryName='" + countryName + '\'' + 56 | ", countryIsoCode='" + countryIsoCode + '\'' + 57 | ", operatorName='" + operatorName + '\'' + 58 | '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/ChildAccountCreateResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects; 2 | 3 | import java.util.List; 4 | 5 | public class ChildAccountCreateResponse extends ChildAccountResponse{ 6 | private List accessKeys; 7 | private String signingKey; 8 | private String invoiceAggregation; 9 | private String paymentMoment; 10 | 11 | public List getAccessKeys() { 12 | return accessKeys; 13 | } 14 | 15 | public void setAccessKeys(List accessKeys) { 16 | this.accessKeys = accessKeys; 17 | } 18 | 19 | public String getSigningKey() { 20 | return signingKey; 21 | } 22 | 23 | public void setSigningKey(String signingKey) { 24 | this.signingKey = signingKey; 25 | } 26 | 27 | public String getInvoiceAggregation() { 28 | return invoiceAggregation; 29 | } 30 | 31 | public void setInvoiceAggregation(String invoiceAggregation) { 32 | this.invoiceAggregation = invoiceAggregation; 33 | } 34 | 35 | public String getPaymentMoment() { 36 | return paymentMoment; 37 | } 38 | 39 | public void setPaymentMoment(String paymentMoment) { 40 | this.paymentMoment = paymentMoment; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "ChildAccountCreateResponse{" + 46 | "id='" + getId() + '\'' + 47 | ", name='" + getName() + '\'' + 48 | ", accessKeys=" + accessKeys + '\'' + 49 | ", invoiceAggregation='" + invoiceAggregation + '\'' + 50 | ", paymentMoment='" + paymentMoment + '\'' + 51 | '}'; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleSendVerifyToken.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.Verify; 7 | import com.messagebird.objects.VerifyRequest; 8 | 9 | /** 10 | * Created by faizan on 10/12/15. 11 | */ 12 | public class ExampleSendVerifyToken { 13 | 14 | public static void main(String[] args) { 15 | if (args.length < 2) { 16 | System.out.println("Please specify your access key and a recipient : java -jar test_accesskey recipientNumber"); 17 | return; 18 | } 19 | 20 | // First create your service object 21 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 22 | 23 | // Add the service to the client 24 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 25 | 26 | try { 27 | // Send verify token 28 | System.out.println("sending verify token request:"); 29 | VerifyRequest verifyRequest = new VerifyRequest(args[1]); 30 | verifyRequest.setTimeout(120); 31 | final Verify verify = messageBirdClient.sendVerifyToken(verifyRequest); 32 | System.out.println(verify.toString()); 33 | } catch (UnauthorizedException | GeneralException exception) { 34 | if (exception.getErrors() != null) { 35 | System.out.println(exception.getErrors().toString()); 36 | } 37 | exception.printStackTrace(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookEvent.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Represents events that webhooks can subscribe to. 8 | */ 9 | public enum ConversationWebhookEvent { 10 | 11 | /** 12 | * New conversation has been created. 13 | */ 14 | CONVERSATION_CREATED("conversation.created"), 15 | 16 | /** 17 | * Conversation has been updated with a new status. 18 | */ 19 | CONVERSATION_UPDATED("conversation.updated"), 20 | 21 | /** 22 | * New message has been created. Triggered for both sent and received 23 | * messages. 24 | */ 25 | MESSAGE_CREATED("message.created"), 26 | 27 | /** 28 | * Message has been updated with a new status. 29 | */ 30 | MESSAGE_UPDATED("message.updated"); 31 | 32 | private final String event; 33 | 34 | ConversationWebhookEvent(final String event) { 35 | this.event = event; 36 | } 37 | 38 | @JsonCreator 39 | public static ConversationWebhookEvent forValue(final String value) { 40 | for (ConversationWebhookEvent event : ConversationWebhookEvent.values()) { 41 | if (event.getEvent().equals(value)) { 42 | return event; 43 | } 44 | } 45 | 46 | return null; 47 | } 48 | 49 | @JsonValue 50 | public String toJson() { 51 | return getEvent(); 52 | } 53 | 54 | public String getEvent() { 55 | return event; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return getEvent(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewVoiceCall.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.voicecalls.VoiceCallResponse; 8 | 9 | public class ExampleViewVoiceCall { 10 | 11 | public static void main(String[] args) { 12 | if (args.length < 2) { 13 | System.out.println("Please specify your access key and a call ID : java -jar test_accesskey e8077d803532c0b5937c639b60216938"); 14 | return; 15 | } 16 | 17 | //First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | //Add service to client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | 23 | try { 24 | System.out.println("Getting a voice call"); 25 | final String callId = args[1]; 26 | //Sending call id parameter to client 27 | final VoiceCallResponse voiceCallResponse = messageBirdClient.viewVoiceCall(callId); 28 | //Display voice call response object 29 | System.out.println(voiceCallResponse.toString()); 30 | 31 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 32 | if (exception.getErrors() != null) { 33 | System.out.println(exception.getErrors().toString()); 34 | } 35 | exception.printStackTrace(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/integrations/HSMComponentType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.integrations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | import java.util.Map; 6 | import java.util.HashMap; 7 | import java.util.Collections; 8 | import java.util.Locale; 9 | import java.util.Objects; 10 | 11 | /** 12 | * An enum for HSMComponentType 13 | * 14 | * @see HSMComponentType 15 | */ 16 | public enum HSMComponentType { 17 | BODY("BODY"), 18 | HEADER("HEADER"), 19 | FOOTER("FOOTER"), 20 | BUTTONS("BUTTONS"), 21 | CAROUSEL("CAROUSEL"), 22 | LIMITED_TIME_OFFER("LIMITED_TIME_OFFER"); 23 | 24 | private static final Map TYPE_MAP; 25 | 26 | static { 27 | Map map = new HashMap<>(); 28 | for (HSMComponentType hsmComponentType : HSMComponentType.values()) { 29 | map.put(hsmComponentType.getType().toLowerCase(), hsmComponentType); 30 | } 31 | TYPE_MAP = Collections.unmodifiableMap(map); 32 | } 33 | 34 | private final String type; 35 | 36 | HSMComponentType(String type) { 37 | this.type = type; 38 | } 39 | 40 | @JsonCreator 41 | public static HSMComponentType forValue(String value) { 42 | Objects.requireNonNull(value, "Value cannot be null"); 43 | return TYPE_MAP.get(value.toLowerCase(Locale.ROOT)); 44 | } 45 | 46 | @JsonValue 47 | public String toJson() { 48 | return getType(); 49 | } 50 | 51 | public String getType() { 52 | return type; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return getType(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleSendWebhook.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.voicecalls.Webhook; 7 | import com.messagebird.objects.voicecalls.WebhookResponseData; 8 | 9 | public class ExampleSendWebhook { 10 | 11 | public static void main(String[] args) { 12 | if (args.length < 3) { 13 | System.out.println("Please specify your access key, url and token of webhook :" + 14 | " java -jar test_accesskey webhook-url webhook-token"); 15 | return; 16 | } 17 | 18 | //First create your service object 19 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 20 | 21 | //Add the service to the client 22 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 23 | 24 | try { 25 | //Creating webhook object to send client 26 | System.out.println("Creating new webhook.."); 27 | final Webhook webhook = new Webhook(); 28 | webhook.setUrl(args[1]); 29 | webhook.setToken(args[2]); 30 | //Sending webhook object to client 31 | final WebhookResponseData webhookResponseDataList = messageBirdClient.createWebhook(webhook); 32 | //Display webhook response 33 | System.out.println(webhookResponseDataList.toString()); 34 | } catch (GeneralException | UnauthorizedException exception) { 35 | exception.printStackTrace(); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/TemplateMediaType.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | import java.util.Map; 6 | import java.util.HashMap; 7 | import java.util.Collections; 8 | 9 | public enum TemplateMediaType { 10 | 11 | IMAGE("image"), 12 | DOCUMENT("document"), 13 | VIDEO("video"), 14 | TEXT("text"), 15 | CURRENCY("currency"), 16 | DATETIME("date_time"), 17 | PAYLOAD("payload"), 18 | EXPIRATION_TIME("expiration_time"), 19 | COUPON_CODE("coupon_code"); 20 | 21 | private static final Map TYPE_MAP; 22 | 23 | static { 24 | Map map = new HashMap<>(); 25 | for (TemplateMediaType templateMediaType : TemplateMediaType.values()) { 26 | map.put(templateMediaType.getType().toLowerCase(), templateMediaType); 27 | } 28 | TYPE_MAP = Collections.unmodifiableMap(map); 29 | } 30 | 31 | 32 | private final String type; 33 | 34 | TemplateMediaType(final String type) { 35 | this.type = type; 36 | } 37 | 38 | @JsonCreator 39 | public static TemplateMediaType forValue(String value) { 40 | if (value == null) { 41 | throw new IllegalArgumentException("Value cannot be null"); 42 | } 43 | return TYPE_MAP.get(value.toLowerCase()); 44 | } 45 | 46 | @JsonValue 47 | public String toJson() { 48 | return getType(); 49 | } 50 | 51 | public String getType() { 52 | return type; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return getType(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/RecordingResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public class RecordingResponse implements Serializable { 11 | 12 | private static final long serialVersionUID = -3645909436942694671L; 13 | 14 | private List data; 15 | @JsonProperty("_links") 16 | private Map links; 17 | private Pagination pagination; 18 | 19 | private RecordingResponse(){ 20 | 21 | } 22 | 23 | public RecordingResponse(List data, Map _links, Pagination pagination) { 24 | this.data = data; 25 | this.pagination = pagination; 26 | this.links = _links; 27 | } 28 | 29 | public List getData() { 30 | return data; 31 | } 32 | 33 | public void setData(List data) { 34 | this.data = data; 35 | } 36 | 37 | public Map getLinks() { 38 | return links; 39 | } 40 | 41 | public Pagination getPagination() { 42 | return pagination; 43 | } 44 | 45 | public void setPagination(Pagination pagination) { 46 | this.pagination = pagination; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "RecordingResponse{" + 52 | "data=" + data + 53 | ", links=" + links + 54 | ", pagination=" + pagination + 55 | '}'; 56 | } 57 | 58 | public void calculate(int a1){ 59 | System.out.println(a1); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListTemplatesByName.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.integrations.TemplateResponse; 8 | import java.util.List; 9 | 10 | /** 11 | * List templates by name 12 | * 13 | * @see List templates by name 14 | * @author ssk910 15 | */ 16 | public class ExampleListTemplatesByName { 17 | 18 | public static void main(String[] args) { 19 | if (args.length < 2) { 20 | System.out.println("Please specify your access key and a template name example : java -jar test_accesskey \"My template name\""); 21 | return; 22 | } 23 | 24 | // First create your service object 25 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 26 | 27 | // Add the service to the client 28 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 29 | 30 | // template name from input 31 | final String templateName = args[1]; 32 | 33 | try { 34 | System.out.println("Retrieving WhatsApp Template list by name : " + templateName); 35 | final List templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName); 36 | System.out.println(templateList.toString()); 37 | } catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) { 38 | exception.printStackTrace(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewVoiceMessage.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.NotFoundException; 5 | import com.messagebird.objects.VoiceMessageResponse; 6 | import com.messagebird.exceptions.GeneralException; 7 | import com.messagebird.exceptions.UnauthorizedException; 8 | 9 | /** 10 | * Created by rvt on 1/8/15. 11 | */ 12 | public class ExampleViewVoiceMessage { 13 | public static void main(String[] args) { 14 | if (args.length < 2) { 15 | System.out.println("Please specify your access key and a voice message ID : java -jar test_accesskey e8077d803532c0b5937c639b60216938"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Get Hlr using msgId and msisdn 27 | System.out.println("Getting message info message:"); 28 | final String voiceMessageId = args[1]; 29 | final VoiceMessageResponse response = messageBirdClient.viewVoiceMessage(voiceMessageId); 30 | //Display Voice message response 31 | System.out.println(response.toString()); 32 | 33 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 34 | if (exception.getErrors() != null) { 35 | System.out.println(exception.getErrors().toString()); 36 | } 37 | exception.printStackTrace(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallFlowList.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import java.util.Map; 6 | import com.fasterxml.jackson.annotation.JsonCreator; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | /** 10 | * Represents a listing of VoiceCallFlow objects, along with pagination details. 11 | * @TODO needs a little polishing (reorganise methods, rename properties, add 12 | * missing properties) 13 | */ 14 | public class VoiceCallFlowList implements Serializable { 15 | 16 | @JsonProperty("_links") 17 | private Map links; 18 | 19 | private Pagination pagination; 20 | 21 | private List items; 22 | 23 | @JsonCreator 24 | public VoiceCallFlowList(@JsonProperty("data") List data) { 25 | this.items = data; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return pagination.toString(); 31 | } 32 | 33 | public void setPagination(Pagination pagination) { 34 | this.pagination = pagination; 35 | } 36 | 37 | public Integer getTotalCount() { 38 | return this.pagination.getTotalCount(); 39 | } 40 | 41 | public Integer getPageCount() { 42 | return this.pagination.getPageCount(); 43 | } 44 | 45 | public Integer getCurrentPage() { 46 | return this.pagination.getCurrentPage(); 47 | } 48 | 49 | public Integer getPerPage() { 50 | return this.pagination.getPerPage(); 51 | } 52 | 53 | 54 | public List getItems() { 55 | return items; 56 | } 57 | 58 | public void setItems(List items) { 59 | this.items = items; 60 | } 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationEmailInlineImage.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | public class ConversationEmailInlineImage { 4 | private String id; 5 | private String name; 6 | private String type; 7 | private String URL; 8 | private int length; 9 | private String contentId; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public void setName(String name) { 24 | this.name = name; 25 | } 26 | 27 | public String getType() { 28 | return type; 29 | } 30 | 31 | public void setType(String type) { 32 | this.type = type; 33 | } 34 | 35 | public String getURL() { 36 | return URL; 37 | } 38 | 39 | public void setURL(String URL) { 40 | this.URL = URL; 41 | } 42 | 43 | public int getLength() { 44 | return length; 45 | } 46 | 47 | public void setLength(int length) { 48 | this.length = length; 49 | } 50 | 51 | public String getContentId() { 52 | return contentId; 53 | } 54 | 55 | public void setContentId(String contentId) { 56 | this.contentId = contentId; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "ConversationEmailInlineImage{" + 62 | "id='" + id + '\'' + 63 | ", name='" + name + '\'' + 64 | ", type='" + type + '\'' + 65 | ", URL='" + URL + '\'' + 66 | ", length=" + length + 67 | ", contentId='" + contentId + '\'' + 68 | '}'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListMessagesFiltered.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.MessageList; 7 | import java.util.LinkedHashMap; 8 | import java.util.Map; 9 | 10 | 11 | public class ExampleListMessagesFiltered { 12 | public static void main(String[] args) { 13 | 14 | if (args.length == 0) { 15 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Get list of messages with offset and limit 27 | System.out.println("Retrieving message list"); 28 | 29 | // Create filters 30 | Map filters = new LinkedHashMap<>(); 31 | filters.put("status", "scheduled"); 32 | 33 | final MessageList messageList = messageBirdClient.listMessagesFiltered(3, null, filters); 34 | 35 | // Display messages 36 | System.out.println(messageList.toString()); 37 | } catch (UnauthorizedException | GeneralException exception) { 38 | if (exception.getErrors() != null) { 39 | System.out.println(exception.getErrors().toString()); 40 | } 41 | exception.printStackTrace(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleCreateVoiceCallFlow.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.voicecalls.VoiceCallFlowRequest; 7 | import com.messagebird.objects.VoiceStep; 8 | 9 | import java.util.Collections; 10 | 11 | public class ExampleCreateVoiceCallFlow { 12 | 13 | public static void main(String[] args) { 14 | if (args.length < 2) { 15 | System.out.println("Please specify your access key and voice call flow arguments"); 16 | return; 17 | } 18 | 19 | //First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | //Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | final VoiceCallFlowRequest voiceCallFlowRequest = new VoiceCallFlowRequest(); 26 | 27 | voiceCallFlowRequest.setRecord(true); // Can be false as well, see docs 28 | VoiceStep voiceStep = new VoiceStep(); 29 | voiceCallFlowRequest.setSteps(Collections.singletonList(voiceStep)); // VoiceStep Object 30 | voiceCallFlowRequest.setDefaultCall(true); // Can be false as well, see docs 31 | 32 | try { 33 | //Creating voice call by id 34 | System.out.println("Creting a Voice Call Flow"); 35 | messageBirdClient.sendVoiceCallFlow(voiceCallFlowRequest); 36 | System.out.println("Voice call flow created"); 37 | 38 | } catch (GeneralException | UnauthorizedException exception) { 39 | exception.printStackTrace(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/TranscriptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class TranscriptionResponse implements Serializable { 10 | 11 | private static final long serialVersionUID = -25064223639161201L; 12 | private List data; 13 | 14 | @JsonProperty("_links") 15 | private Map links; 16 | private Pagination pagination; 17 | 18 | public TranscriptionResponse() {} 19 | 20 | public TranscriptionResponse(List data, Map links, Pagination pagination) { 21 | this.data = data; 22 | this.links = links; 23 | this.pagination = pagination; 24 | } 25 | 26 | public List getData() { 27 | return data; 28 | } 29 | 30 | public void setData(List data) { 31 | this.data = data; 32 | } 33 | 34 | public static long getSerialVersionUID() { 35 | return serialVersionUID; 36 | } 37 | 38 | public Map getLinks() { 39 | return links; 40 | } 41 | 42 | public void setLinks(Map links) { 43 | this.links = links; 44 | } 45 | 46 | public Pagination getPagination() { 47 | return pagination; 48 | } 49 | 50 | public void setPagination(Pagination pagination) { 51 | this.pagination = pagination; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "TranscriptionResponse{" + 57 | "data=" + data + 58 | ", links=" + links + 59 | ", pagination=" + pagination + 60 | '}'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewRecording.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.voicecalls.RecordingResponse; 8 | 9 | public class ExampleViewRecording { 10 | public static void main(String[] args) { 11 | if (args.length < 4) { 12 | System.out.println("Please specify your access key and call id and leg id and recording id example :" + 13 | " java -jar test_accesskey e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938"); 14 | return; 15 | } 16 | 17 | // First create your service object 18 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 19 | 20 | // Add the service to the client 21 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 22 | 23 | try { 24 | System.out.println("Getting a recording"); 25 | final String callId = args[1]; 26 | final String legId = args[2]; 27 | final String recordingId = args[3]; 28 | //Sending call id and leg id and recording id parameters to client 29 | final RecordingResponse recording = messageBirdClient.viewRecording(callId, legId, recordingId); 30 | //Display recording response 31 | System.out.println(recording.toString()); 32 | 33 | } catch (GeneralException | NotFoundException | UnauthorizedException exception) { 34 | exception.printStackTrace(); 35 | } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListConversationMessagesWithQueryParam.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.conversations.ConversationMessageList; 8 | import java.util.HashMap; 9 | 10 | public class ExampleListConversationMessagesWithQueryParam { 11 | public static void main(String[] args) { 12 | 13 | if (args.length == 0) { 14 | System.out.println("Please specify your access key example : java -jar test_accesskey"); 15 | return; 16 | } 17 | 18 | // First create your service object 19 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 20 | 21 | // Add the service to the client 22 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 23 | 24 | try { 25 | // Get list of conversation messages with query param 26 | System.out.println("Retrieving message list"); 27 | final ConversationMessageList conversationMessageList = messageBirdClient.listConversationMessagesWithQueryParam( 28 | new HashMap() { 29 | { 30 | put("ids", "9f0b413e79e24d76b01b895381b12a6d,d46054ee0f7245bcbc7ba586878d0ab4"); 31 | } 32 | }); 33 | 34 | // Display conversation Message list 35 | System.out.println(conversationMessageList.toString()); 36 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 37 | if (exception.getErrors() != null) { 38 | System.out.println(exception.getErrors().toString()); 39 | } 40 | exception.printStackTrace(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleFetchTemplateByNameAndLanguage.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.integrations.TemplateResponse; 8 | 9 | /** 10 | * Fetch template by name and language 11 | * 12 | * @see Fetch template by name and language 13 | * @author ssk910 14 | */ 15 | public class ExampleFetchTemplateByNameAndLanguage { 16 | 17 | public static void main(String[] args) { 18 | if (args.length < 3) { 19 | System.out.println("Please specify your access key and a template name example : java -jar test_accesskey \"My template name\" \"Template language\""); 20 | return; 21 | } 22 | 23 | // First create your service object 24 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 25 | 26 | // Add the service to the client 27 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 28 | 29 | // template name and language from input 30 | final String templateName = args[1]; 31 | final String language = args[2]; 32 | 33 | try { 34 | System.out.println("Fetching WhatsApp Template list by {name: " + templateName + ", language: " + language + "}"); 35 | final TemplateResponse template = messageBirdClient.fetchWhatsAppTemplateBy(templateName, language); 36 | System.out.println(template.toString()); 37 | } catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) { 38 | exception.printStackTrace(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewLookup.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.NotFoundException; 5 | import com.messagebird.exceptions.GeneralException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.Lookup; 8 | 9 | import java.math.BigInteger; 10 | 11 | public class ExampleViewLookup { 12 | 13 | public static void main(String[] args) { 14 | 15 | if (args.length < 2) { 16 | System.out.println("Please specify your access key and phone in that order example : java -jar test_accesskey 31612345678"); 17 | return; 18 | } 19 | 20 | // First create your service object 21 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 22 | 23 | // Add the service to the client 24 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 25 | 26 | try { 27 | // View Lookup 28 | System.out.println("Viewing Lookup:"); 29 | final Lookup lookupRequest = new Lookup(new BigInteger(args[1])); 30 | // Optionally set a country code (in the case of national numbers) 31 | if (args.length > 2 && args[2] != null && !args[2].isEmpty()) { 32 | lookupRequest.setCountryCode(args[2]); 33 | } 34 | 35 | final Lookup lookup = messageBirdClient.viewLookup(lookupRequest); 36 | System.out.println(lookup.toString()); 37 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 38 | if (exception.getErrors() != null) { 39 | System.out.println(exception.getErrors().toString()); 40 | } 41 | 42 | exception.printStackTrace(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleReadHlr.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.NotFoundException; 5 | import com.messagebird.objects.Hlr; 6 | import com.messagebird.exceptions.GeneralException; 7 | import com.messagebird.exceptions.UnauthorizedException; 8 | 9 | import java.math.BigInteger; 10 | 11 | /** 12 | * Created by rvt on 1/7/15. 13 | */ 14 | public class ExampleReadHlr { 15 | 16 | public static void main(String[] args) { 17 | 18 | if (args.length < 2) { 19 | System.out.println("Please specify your access key and phone in that order example : java -jar test_accesskey 31612345678"); 20 | return; 21 | } 22 | 23 | // First create your service object 24 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 25 | 26 | // Add the service to the client 27 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 28 | 29 | try { 30 | // Get Hlr using msgId and msisdn 31 | System.out.println("Retrieving HLR:"); 32 | final Hlr hlr1 = messageBirdClient.getRequestHlr(new BigInteger(args[1]), "ExampleReadHlr reference"); 33 | System.out.println(hlr1.toString()); 34 | 35 | // Get Hlr using the id only 36 | System.out.println("Now using returned id to get Hlr:"); 37 | final Hlr hlr2 = messageBirdClient.getViewHlr(hlr1.getId()); 38 | System.out.println(hlr2.toString()); 39 | 40 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 41 | if (exception.getErrors() != null) { 42 | System.out.println(exception.getErrors().toString()); 43 | } 44 | exception.printStackTrace(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListOfRecording.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.voicecalls.RecordingResponse; 7 | 8 | public class ExampleListOfRecording { 9 | public static void main(String[] args) { 10 | if (args.length < 3) { 11 | System.out.println("Please specify your access key and call id and leg id example :" + 12 | " java -jar test_accesskey e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938"); 13 | return; 14 | } 15 | 16 | // First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | // Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | System.out.println("Getting a recording"); 24 | final String callId = args[1]; 25 | final String legId = args[2]; 26 | //Sending call id and leg id and recording id parameters to client 27 | final RecordingResponse recordings = messageBirdClient.listRecordings(callId, legId, 0, 0); 28 | if (recordings.getData() == null) { 29 | System.out.println("No record data found"); 30 | } 31 | //Display recording responses 32 | for(int i = 0; i< recordings.getData().size(); i++) { 33 | System.out.println(recordings.getData().get(i).toString()); 34 | System.out.println(); 35 | } 36 | 37 | } catch (GeneralException | UnauthorizedException exception) { 38 | exception.printStackTrace(); 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleDownloadRecording.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | public class ExampleDownloadRecording { 9 | public static void main(String[] args) { 10 | if (args.length < 4) { 11 | System.out.println("Please specify your access key and call id and leg id and recording id and base path(optional) example :" + 12 | " java -jar test_accesskey e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938 /users/{user}/test"); 13 | return; 14 | } 15 | 16 | // First create your service object 17 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 18 | 19 | // Add the service to the client 20 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 21 | 22 | try { 23 | System.out.println("Getting a recording"); 24 | final String callId = args[1]; 25 | final String legId = args[2]; 26 | final String recordingId = args[3]; 27 | String basePath = null; 28 | if (args.length > 4) { 29 | basePath = args[4]; 30 | } 31 | //Sending call id and leg id and recording id parameters to client 32 | final String filePath = messageBirdClient.downloadRecording(callId, legId, recordingId, basePath); 33 | if (filePath != null) { 34 | System.out.println("Record file is downloaded to "+filePath); 35 | } 36 | 37 | } catch (GeneralException | NotFoundException | UnauthorizedException exception) { 38 | exception.printStackTrace(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleSendMessage.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.objects.MessageResponse; 5 | import com.messagebird.exceptions.GeneralException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | 8 | import java.math.BigInteger; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by rvt on 1/7/15. 14 | */ 15 | public class ExampleSendMessage { 16 | 17 | public static void main(String[] args) { 18 | if (args.length < 3) { 19 | System.out.println("Please specify your access key, one ore more phone numbers and a message body example : java -jar test_accesskey 31612345678,3161112233 \"My message to be send\""); 20 | return; 21 | } 22 | 23 | // First create your service object 24 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 25 | 26 | // Add the service to the client 27 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 28 | 29 | try { 30 | // Get Hlr using msgId and msisdn 31 | System.out.println("Sending message:"); 32 | final List phones = new ArrayList<>(); 33 | for (final String phoneNumber : args[1].split(",")) { 34 | phones.add(new BigInteger(phoneNumber)); 35 | } 36 | 37 | final MessageResponse response = messageBirdClient.sendMessage("MessageBird", args[2], phones); 38 | //Display message response 39 | System.out.println(response.toString()); 40 | } catch (UnauthorizedException | GeneralException exception) { 41 | if (exception.getErrors() != null) { 42 | System.out.println(exception.getErrors().toString()); 43 | } 44 | exception.printStackTrace(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewLookupHlr.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.NotFoundException; 5 | import com.messagebird.exceptions.GeneralException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.LookupHlr; 8 | 9 | import java.math.BigInteger; 10 | 11 | public class ExampleViewLookupHlr { 12 | 13 | public static void main(String[] args) { 14 | 15 | if (args.length < 2) { 16 | System.out.println("Please specify your access key and phone in that order example : java -jar test_accesskey 31612345678"); 17 | return; 18 | } 19 | 20 | // First create your service object 21 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 22 | 23 | // Add the service to the client 24 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 25 | 26 | try { 27 | // View Lookup HLR 28 | System.out.println("Viewing Lookup HLR:"); 29 | final LookupHlr lookupHlrRequest = new LookupHlr(); 30 | lookupHlrRequest.setPhoneNumber(new BigInteger(args[1])); 31 | // Optionally set a country code (in the case of national numbers) 32 | if (args.length > 2 && args[2] != null && !args[2].isEmpty()) { 33 | lookupHlrRequest.setCountryCode(args[2]); 34 | } 35 | final LookupHlr lookupHlr = messageBirdClient.viewLookupHlr(lookupHlrRequest); 36 | System.out.println(lookupHlr.toString()); 37 | } catch (UnauthorizedException | GeneralException | NotFoundException exception) { 38 | if (exception.getErrors()!=null) { 39 | System.out.println(exception.getErrors().toString()); 40 | } 41 | exception.printStackTrace(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/conversations/ConversationMessageStatus.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.conversations; 2 | 3 | import com.fasterxml.jackson.annotation.JsonCreator; 4 | import com.fasterxml.jackson.annotation.JsonValue; 5 | 6 | /** 7 | * Response object for a message's status, e.g. delivered or failed. 8 | */ 9 | public enum ConversationMessageStatus { 10 | 11 | DELETED("deleted"), 12 | DELIVERED("delivered"), 13 | FAILED("failed"), 14 | PENDING("pending"), 15 | READ("read"), 16 | RECEIVED("received"), 17 | SENT("sent"), 18 | UNSUPPORTED("unsupported"), 19 | ACCEPTED("accepted"), 20 | REJECTED("rejected"), 21 | UNKNOWN("unknown"), 22 | //WA specific statuses 23 | TRANSMITTED("transmitted"), 24 | //SMS specific statuses 25 | DELIVERY_FAILED("delivery_failed"), 26 | BUFFERED("buffered"), 27 | EXPIRED("expired"), 28 | //Email specific statuses 29 | CLICKED("clicked"), 30 | OPENED("opened"), 31 | BOUNCE("bounce"), 32 | SPAM_COMPLAINT("spam_complaint"), 33 | OUT_OF_BOUNDED("out_of_bounded"), 34 | DELAYED("delayed"), 35 | LIST_UNSUBSCRIBE("list_unsubscribe"), 36 | DISPATCHED("dispatched"); 37 | 38 | private final String status; 39 | 40 | ConversationMessageStatus(final String status) { 41 | this.status = status; 42 | } 43 | 44 | public String getStatus() { 45 | return status; 46 | } 47 | 48 | @JsonCreator 49 | public static ConversationMessageStatus forValue(final String value) { 50 | for (ConversationMessageStatus status : ConversationMessageStatus.values()) { 51 | if (status.getStatus().equals(value)) { 52 | return status; 53 | } 54 | } 55 | 56 | return null; 57 | } 58 | 59 | @JsonValue 60 | public String toJson() { 61 | return getStatus(); 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return getStatus(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleRequestLookupHlr.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.UnauthorizedException; 6 | import com.messagebird.objects.LookupHlr; 7 | 8 | import java.math.BigInteger; 9 | 10 | public class ExampleRequestLookupHlr { 11 | 12 | public static void main(String[] args) { 13 | 14 | if (args.length < 3) { 15 | System.out.println("Please specify your access key, phone and reference in that order example : java -jar test_accesskey 31612345678 reference"); 16 | return; 17 | } 18 | 19 | // First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | // Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | // Request Lookup HLR 27 | System.out.println("Requesting Lookup HLR:"); 28 | final LookupHlr lookupHlrRequest = new LookupHlr(); 29 | lookupHlrRequest.setPhoneNumber(new BigInteger(args[1])); 30 | lookupHlrRequest.setReference(args[2]); 31 | // Optionally set a country code (in the case of national numbers) 32 | if (args.length > 3 && args[3] != null && !args[3].isEmpty()) { 33 | lookupHlrRequest.setCountryCode(args[3]); 34 | } 35 | final LookupHlr lookupHlr = messageBirdClient.requestLookupHlr(lookupHlrRequest); 36 | System.out.println(lookupHlr.toString()); 37 | } catch (UnauthorizedException | GeneralException exception) { 38 | if (exception.getErrors() != null) { 39 | System.out.println(exception.getErrors().toString()); 40 | } 41 | exception.printStackTrace(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleListTemplatesByNameAndWABAID.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.integrations.TemplateResponse; 8 | import java.util.List; 9 | 10 | /** 11 | * List templates by name and WABA ID 12 | * 13 | * @see List templates by name and WABA ID 14 | * @author ssk910 15 | */ 16 | public class ExampleListTemplatesByNameAndWABAID { 17 | 18 | public static void main(String[] args) { 19 | if (args.length < 3) { 20 | System.out.println("Please specify your access key, template name and WABA ID example : java -jar test_accesskey \"My template name\" \"WABA ID\""); 21 | return; 22 | } 23 | 24 | // First create your service object 25 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 26 | 27 | // Add the service to the client 28 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 29 | 30 | // template name from input 31 | final String templateName = args[1]; 32 | 33 | // WABA ID from input 34 | final String wabaID = args[2]; 35 | 36 | try { 37 | System.out.println("Retrieving WhatsApp Template list by name '" + templateName + "' and WABA ID '" + wabaID + "'"); 38 | final List templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName, wabaID, null); 39 | System.out.println(templateList.toString()); 40 | } catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) { 41 | exception.printStackTrace(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /examples/src/main/java/ExampleViewTranscription.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.voicecalls.TranscriptionResponse; 8 | 9 | public class ExampleViewTranscription { 10 | 11 | public static void main(String[] args) { 12 | if (args.length < 5) { 13 | System.out.println("Please specify your access key, call ID, leg ID, recording ID and transcriptionId :" + 14 | " java -jar test_accesskey e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938" + 15 | " e8077d803532c0b5937c639b60216938 e8077d803532c0b5937c639b60216938"); 16 | return; 17 | } 18 | 19 | //First create your service object 20 | final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]); 21 | 22 | //Add the service to the client 23 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 24 | 25 | try { 26 | System.out.println("Getting transcription list"); 27 | final String callId = args[1]; 28 | final String legId = args[2]; 29 | final String recordingId = args[3]; 30 | final String transactionId = args[4]; 31 | // Sending call ID, leg ID, recording ID, page, page size parameters to client 32 | final TranscriptionResponse responseList = messageBirdClient.viewTranscription(callId, legId, recordingId, transactionId) ; 33 | //Display transcription response 34 | System.out.println(responseList.toString()); 35 | 36 | } catch (GeneralException | UnauthorizedException | NotFoundException exceptions) { 37 | exceptions.printStackTrace(); 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallFlowRequest.java: -------------------------------------------------------------------------------- 1 | package com.messagebird.objects.voicecalls; 2 | 3 | import java.util.List; 4 | import java.util.Date; 5 | import com.messagebird.objects.*; 6 | import com.fasterxml.jackson.annotation.JsonProperty; 7 | 8 | /** 9 | * Contains writable values for VoiceCallFlow objects. 10 | */ 11 | public class VoiceCallFlowRequest { 12 | 13 | 14 | private String id; 15 | private String title; 16 | private boolean record; 17 | private List steps; 18 | 19 | @JsonProperty("default") 20 | private boolean defaultCall; 21 | 22 | public VoiceCallFlowRequest(String id) 23 | { 24 | this.id = id; 25 | } 26 | 27 | public VoiceCallFlowRequest() 28 | { 29 | } 30 | 31 | public String getId() { 32 | return id; 33 | } 34 | 35 | public void setId(String id) { 36 | this.id = id; 37 | } 38 | 39 | @Deprecated 40 | public String getTitle() { 41 | return title; 42 | } 43 | 44 | @Deprecated 45 | public void setTitle(String title) { 46 | this.title = title; 47 | } 48 | 49 | public boolean isRecord() { 50 | return record; 51 | } 52 | 53 | public void setRecord(boolean record) { 54 | this.record = record; 55 | } 56 | 57 | public List getSteps() { 58 | return steps; 59 | } 60 | 61 | public void setSteps(List steps) { 62 | this.steps = steps; 63 | } 64 | 65 | public boolean isDefaultCall() { 66 | return defaultCall; 67 | } 68 | 69 | public void setDefaultCall(boolean defaultCall) { 70 | this.defaultCall = defaultCall; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "VoiceCallFlowRequest{" + 76 | "title='" + title + '\'' + 77 | ", record=" + record + 78 | ", steps=" + steps + 79 | ", default=" + defaultCall + 80 | '}'; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/src/main/java/ExampleVerifyEmail.java: -------------------------------------------------------------------------------- 1 | import com.messagebird.MessageBirdClient; 2 | import com.messagebird.MessageBirdService; 3 | import com.messagebird.MessageBirdServiceImpl; 4 | import com.messagebird.exceptions.GeneralException; 5 | import com.messagebird.exceptions.NotFoundException; 6 | import com.messagebird.exceptions.UnauthorizedException; 7 | import com.messagebird.objects.Verify; 8 | import com.messagebird.objects.VerifyMessage; 9 | import com.messagebird.objects.VerifyRequest; 10 | 11 | /** 12 | * Created by leandro.pinto on 23/06/21. 13 | */ 14 | public class ExampleVerifyEmail { 15 | 16 | public static void main(String[] args) throws UnauthorizedException, GeneralException, NotFoundException { 17 | 18 | final String ACCESS_KEY = args[0]; 19 | final String METHOD = args[1]; 20 | 21 | final MessageBirdService wsr = new MessageBirdServiceImpl(ACCESS_KEY); 22 | final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); 23 | Verify verify = null; 24 | 25 | switch (METHOD) { 26 | case "send": 27 | VerifyRequest request = new VerifyRequest(""); 28 | request.setType("email"); 29 | request.setOriginator(""); 30 | request.setSubject(""); 31 | request.setTimeout(300); 32 | 33 | verify = messageBirdClient.sendVerifyToken(request); 34 | System.out.println(verify.toString()); 35 | 36 | break; 37 | case "verify": 38 | final String VERIFY_ID = args[2]; 39 | final String TOKEN = args[3]; 40 | 41 | verify = messageBirdClient.verifyToken(VERIFY_ID, TOKEN); 42 | System.out.println(verify.toString()); 43 | break; 44 | case "view": 45 | final String MESSAGE_ID = args[2]; 46 | VerifyMessage verifyMessage = messageBirdClient.getVerifyEmailMessage(MESSAGE_ID); 47 | System.out.println(verifyMessage.toString()); 48 | break; 49 | } 50 | } 51 | } 52 | --------------------------------------------------------------------------------