esendex.sdk.java.http.HttpQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.everit.osgi.bundles.com.esendex.javasdk Show documentation
Show all versions of org.everit.osgi.bundles.com.esendex.javasdk Show documentation
The Esendex Java SDK is an easy to use client for our REST API that you can use to integrate SMS and Voice messaging into your Java application.
The newest version!
package esendex.sdk.java.http;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class HttpQuery {
private StringBuilder queryString = new StringBuilder();
public static final Key RETURN_MESSAGE_HEADERS
= new Key("returnMessageHeaders");
public static final Key COUNT
= new Key("count");
public static final Key START_INDEX
= new Key("startIndex");
public static final Key ACTION
= new Key("action");
public static final Key FILTER_VALUE
= new Key("filterValue");
public static final Key FILTER_BY
= new Key("filterBy");
public static final String ACCOUNT_FILTER = "account";
public enum Action {
READ,
UNREAD;
public String toString() {
return name().toLowerCase();
}
}
public enum FilterBy {
ACCOUNT ("");
String value;
private FilterBy(String v) {
this.value = v;
}
}
public void addParameter(Key key, E value) {
if (queryString.length() > 0) queryString.append('&');
queryString.append(key.name);
queryString.append('=');
try {
String encodedValue = URLEncoder.encode(value.toString(), "UTF-8");
queryString.append(encodedValue);
} catch (UnsupportedEncodingException e) {
queryString.append(value.toString());
}
}
@Override
public String toString() {
return queryString.toString();
}
private static class Key {
String name;
Key(String n) {
name = n;
}
}
}