diff --git a/build.gradle b/build.gradle index 66ef630..9bddcf3 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ version '1.0-SNAPSHOT' apply plugin: 'java' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 1.7 +targetCompatibility = 1.7 repositories { mavenCentral() diff --git a/src/main/java/com/kavenegar/sdk/KavenegarApi.java b/src/main/java/com/kavenegar/sdk/KavenegarApi.java index f99c271..a80462c 100644 --- a/src/main/java/com/kavenegar/sdk/KavenegarApi.java +++ b/src/main/java/com/kavenegar/sdk/KavenegarApi.java @@ -10,7 +10,7 @@ import com.kavenegar.sdk.excepctions.BaseException; import com.kavenegar.sdk.excepctions.HttpException; import com.kavenegar.sdk.models.*; -import org.apache.commons.lang3.StringUtils; +import com.kavenegar.sdk.utils.StringUtils; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.entity.UrlEncodedFormEntity; @@ -32,6 +32,7 @@ */ public class KavenegarApi { + static final String API_PATH = "https://api.kavenegar.com/v1/%s/%s.json"; private String apiKey; @@ -99,11 +100,11 @@ public List send(String sender, List receptors, String messa JsonArray entry = execute(getApiPath("sms/send"), "sender", sender, - "receptor", String.join(",", receptors), + "receptor", StringUtils.join(",", receptors), "message", message, "type", type.getValue(), "date", date, - "localid", localIds == null ? "" : String.join(",", localIds) + "localid", localIds == null ? "" : StringUtils.join(",", localIds) ).getAsJsonArray(); List list = new ArrayList<>(); diff --git a/src/main/java/com/kavenegar/sdk/utils/StringUtils.java b/src/main/java/com/kavenegar/sdk/utils/StringUtils.java new file mode 100644 index 0000000..7dd12a7 --- /dev/null +++ b/src/main/java/com/kavenegar/sdk/utils/StringUtils.java @@ -0,0 +1,23 @@ +package com.kavenegar.sdk.utils; + + +import java.util.List; + +/** + * Created by mohsenk on 2/23/17. + */ +public class StringUtils { + + public static String join(CharSequence delimiter, List elements) { + if (elements == null || elements.isEmpty()) { + return ""; + } + // Number of elements not likely worth Arrays.stream overhead. + String result = elements.get(0).toString(); + for (int i = 1; i < elements.size(); i++) { + result += delimiter + elements.get(i).toString(); + } + return result; + } + +}