Skip to content

Commit

Permalink
Merge pull request #7 from jackthorley/Unicode-Character-Send-Functio…
Browse files Browse the repository at this point in the history
…nality-When-Sending-SMS

Add characterSet overload for SMSMessageRequest for messaging service
  • Loading branch information
hawx committed Jan 27, 2016
2 parents 285ae4e + fc0a40d commit ab767b9
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</properties>
<groupId>esendex-java-sdk</groupId>
<artifactId>esendex-java-sdk</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package esendex.sdk.java.model.domain.impl;

import esendex.sdk.java.model.types.CharacterSet;
import esendex.sdk.java.model.types.MessageType;

/**
Expand All @@ -11,7 +12,8 @@ public abstract class BaseMessageRequest {

private String from;
private Integer validity;
private MessageType messageType;
private MessageType messageType;
private CharacterSet characterSet;

public BaseMessageRequest(MessageType type) {
this.messageType = type;
Expand All @@ -29,6 +31,14 @@ public Integer getValidity() {
return validity;
}

public CharacterSet getCharacterSet() {
return characterSet;
}

public void setCharacterSet(CharacterSet characterSet) {
this.characterSet = characterSet;
}

/**
* Sets the alphanumeric originator for the message to
* appear to originate from.
Expand Down Expand Up @@ -61,6 +71,6 @@ public String toString() {
"\nvalidity: " + validity +
"\nmessageType: " + messageType;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import esendex.sdk.java.model.types.MessageType;

// TODO: Auto-generated Javadoc
/**
* The Class MessageCollectionRequest.
* @param <T> the generic type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected void populateRequest(MessageCollectionRequestDto dto) {
dto.setFrom(request.getFrom());
dto.setType(request.getMessageType());
dto.setValidity(request.getValidity());
dto.setCharacterSet(request.getCharacterSet());
}

public MessageCollectionRequestAssembler(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@

package esendex.sdk.java.model.domain.impl;

import esendex.sdk.java.model.types.CharacterSet;
import esendex.sdk.java.model.types.MessageType;

public abstract class MessageRequest extends BaseMessageRequest {

private String to;
private CharacterSet characterSet;
private String to;
private String body;

public MessageRequest(String to, String body, MessageType type) {
super(type);
this.to = to;
this.body = body;
this.characterSet = CharacterSet.GSM;
}

public MessageRequest(String to, String body, MessageType type, CharacterSet characterSet) {
super(type);
this.to = to;
this.body = body;
this.characterSet = characterSet;
}

public String getTo() {
Expand All @@ -22,6 +32,8 @@ public String getBody() {
return body;
}

public CharacterSet getCharacterSet() { return characterSet;}

public void setTo(String to) {
this.to = to;
}
Expand All @@ -30,6 +42,7 @@ public void setBody(String body) {
this.body = body;
}

public void setCharacterSet(CharacterSet characterSet) { this.characterSet = characterSet; }
/**
* {@inheritDoc}
*/
Expand All @@ -40,4 +53,6 @@ public String toString() {
"\nbody: " + body;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ protected void populateRequest(MessageRequestDto dto) {
dto.setFrom(request.getFrom());
dto.setValidity(request.getValidity());
dto.setType(request.getMessageType());
dto.setCharacterSet(request.getCharacterSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package esendex.sdk.java.model.domain.request;

import esendex.sdk.java.model.domain.impl.MessageRequest;
import esendex.sdk.java.model.types.CharacterSet;
import esendex.sdk.java.model.types.MessageType;

public class SmsMessageRequest extends MessageRequest {
Expand All @@ -15,6 +16,10 @@ public SmsMessageRequest(String to, String body) {
super(to, body, MessageType.SMS);
}

public SmsMessageRequest(String to, String body, CharacterSet characterSet) {
super(to, body, MessageType.SMS, characterSet);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package esendex.sdk.java.model.transfer.message;

import esendex.sdk.java.model.transfer.Dto;
import esendex.sdk.java.model.types.CharacterSet;
import esendex.sdk.java.model.types.MessageLanguage;
import esendex.sdk.java.model.types.MessageType;

Expand All @@ -18,6 +19,7 @@ public abstract class AbstractMessageRequestDto extends Dto {
private MessageLanguage lang; // voice
private Integer retries; // voice
private Integer validity; // all
private CharacterSet characterset; // sms

/**
* Sets the alphanumeric originator for the message to
Expand Down Expand Up @@ -61,6 +63,14 @@ public void setValidity(Integer validity) {
this.validity = validity;
}

/**
* Sets the retries.
* @param characterSet the new retries
*/
public void setCharacterSet(CharacterSet characterSet) {
this.characterset = characterSet;
}

/**
* {@inheritDoc}
*/
Expand All @@ -71,7 +81,8 @@ public String toString() {
"\ntype: " + type +
"\nlang: " + lang +
"\nretries: " + retries +
"\nvalidity: " + validity;
"\nvalidity: " + validity +
"\ncharacterSet:" + characterset;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Date;
import java.util.List;

// TODO: Auto-generated Javadoc
/**
* The Class MessageCollectionRequestDto.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package esendex.sdk.java.model.transfer.message;

// TODO: Auto-generated Javadoc
/**
* The Class MessageRequest.
*/
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/esendex/sdk/java/model/types/CharacterSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package esendex.sdk.java.model.types;

public enum CharacterSet {

AUTO ("Auto"),
GSM ("GSM"),
UNICODE ("Unicode");

private String representation;

private CharacterSet(String representation) {
this.representation = representation;
}

/**
* To string.
* @return the string {@inheritDoc}
*/
public String toString() {
return representation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import esendex.sdk.java.EsendexException;

// TODO: Auto-generated Javadoc

/**
* Exception to indicate that data could not be treated as xml,
* probably due to not being well formed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import esendex.sdk.java.EsendexException;

// TODO: Auto-generated Javadoc

/**
* Exception to indicate that well formed XML could not be mapped to a
* suitable Dto object. This may be due to configuration of the XmlParser.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

// TODO: Auto-generated Javadoc

/**
* Pretty printer for the formating of XML in a neat indented fashion.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

package esendex.sdk.java.service.auth;

// TODO: Auto-generated Javadoc

/**
* Simple holder for a user/password pair. Used for Basic Authentication and
* initial aquisition of a session for Session Authentication.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import esendex.sdk.java.service.auth.SessionAuthenticator;
import esendex.sdk.java.service.auth.UserPassword;

// TODO: Auto-generated Javadoc

/**
* The Class SessionServiceFactoryImpl.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.esendex.java.sdk.integration.messagingservice;

import com.esendex.java.sdk.BaseTest;
import esendex.sdk.java.EsendexException;
import esendex.sdk.java.model.domain.request.SmsMessageRequest;
import esendex.sdk.java.model.domain.response.MessageResultResponse;
import esendex.sdk.java.model.types.CharacterSet;
import esendex.sdk.java.service.MessagingService;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class SendServiceSingleUnicodeSMSIT extends BaseTest {

private static MessageResultResponse resultResponse;

@BeforeClass
public static void whenSendingASingleMessage() throws EsendexException {

MessagingService messagingService = getFactory().getMessagingService();

resultResponse = messagingService.sendMessage(ACCOUNT, new SmsMessageRequest(DESTINATION_NUMBER, "\u1F43", CharacterSet.UNICODE));
}

@Test
public void thenABatchIdIsReturned() {
assertNotNull(resultResponse.getBatchId());
}

@Test
public void thenAMessageHeaderIsReturned() {
assertTrue(resultResponse.getMessageIds().size() == 1);
assertNotNull(resultResponse.getMessageIds().get(0));
}
}

0 comments on commit ab767b9

Please sign in to comment.