diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/LICENSE b/LICENSE deleted file mode 100644 index efe0324..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2010-2016 Google, Inc. http://angularjs.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 3230a07..0000000 --- a/Readme.md +++ /dev/null @@ -1,55 +0,0 @@ -Welcome to __Instasent Java SDK__. This repository contains Instasent's Java SDK and samples for REST API. - -## Installation -Download JAR and import it in your app. -https://github.com/instasent/instasent-java-lib/releases/download/0.1.1/instasent-java-lib.jar. -## Example -### Send an SMS -You can check 'examples/ExampleSendSms.java' file. -```java -import com.instasent.InstasentClient; -import java.io.IOException; -import java.util.Map; - -public class main { - public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); - Map response = instasentClient.sendSms( "My company", "+34666666666", "test message"); - System.out.println(response); - } -} -``` -## Available functions -``` -SMS - -instasentClient.sendSms(sender, to, text, callback); -instasentClient.getSms(page, per_page) -instasentClient.getSmsById(message_id) - -Verify - -instasentClient.requestVerify(from, to, text, token_length, timeout, client_id); -instasentClient.getVerify(page, per_page) -instasentClient.getVerifyById(message_id) -instasentClient.checkVerify(id, token) - -Lookup - -instasentClient.doLookup(to; -instasentClient.getLookups(page, per_page) -instasentClient.getLookupById(message_id) - -Account - -instasentClient.getAccountBalance(); - - -``` -## Documentation -Complete documentation at : -[http://docs.instasent.com/](http://docs.instasent.com/). -# Getting help - -If you need help installing or using the library, please contact Instasent Support at support@instasent.com first. -If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo! diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index e026b3f..0000000 --- a/api/.gitignore +++ /dev/null @@ -1,69 +0,0 @@ - -# Created by https://www.gitignore.io/api/intellij,java - -### Intellij ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/workspace.xml -.idea/tasks.xml -.idea/dictionaries -.idea/vcs.xml -.idea/jsLibraryMappings.xml - -# Sensitive or high-churn files: -.idea/dataSources.ids -.idea/dataSources.xml -.idea/dataSources.local.xml -.idea/sqlDataSources.xml -.idea/dynamic.xml -.idea/uiDesigner.xml - -# Gradle: -.idea/gradle.xml -.idea/libraries - -# Mongo Explorer plugin: -.idea/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -### Intellij Patch ### -# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 - -# *.iml -# modules.xml - - -### Java ### -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* \ No newline at end of file diff --git a/api/instasent-java-lib.iml b/api/instasent-java-lib.iml deleted file mode 100644 index 43b030f..0000000 --- a/api/instasent-java-lib.iml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/api/module_instasent-java-lib.xml b/api/module_instasent-java-lib.xml deleted file mode 100644 index 0c20fab..0000000 --- a/api/module_instasent-java-lib.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/Account/GetAccountBalance.java b/examples/Account/GetAccountBalance.java index 6e7e5ab..25c5866 100644 --- a/examples/Account/GetAccountBalance.java +++ b/examples/Account/GetAccountBalance.java @@ -5,7 +5,7 @@ public class GetAccountBalance { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getAccountBalance(); System.out.println(response); } diff --git a/examples/Lookup/DoLookup.java b/examples/Lookup/DoLookup.java index 0529344..09ebedf 100644 --- a/examples/Lookup/DoLookup.java +++ b/examples/Lookup/DoLookup.java @@ -5,7 +5,7 @@ public class DoLookup { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("id", true); + InstasentClient instasentClient = new InstasentClient("id"); Map response = instasentClient.doLookup("+34666666666"); System.out.println(response); } diff --git a/examples/Lookup/GetLookup.java b/examples/Lookup/GetLookup.java index ed751e5..cf47957 100644 --- a/examples/Lookup/GetLookup.java +++ b/examples/Lookup/GetLookup.java @@ -5,7 +5,7 @@ public class GetLookup { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getLookups(1, 10); System.out.println(response); } diff --git a/examples/Lookup/GetLookupById.java b/examples/Lookup/GetLookupById.java index df10d28..c967199 100644 --- a/examples/Lookup/GetLookupById.java +++ b/examples/Lookup/GetLookupById.java @@ -5,7 +5,7 @@ public class GetLookupById { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getLookupById("id"); System.out.println(response); } diff --git a/examples/Sms/GetSms.java b/examples/Sms/GetSms.java index fcf559f..68dfde5 100644 --- a/examples/Sms/GetSms.java +++ b/examples/Sms/GetSms.java @@ -6,7 +6,7 @@ public class GetSms { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getSms( 1, 10); System.out.println(response); diff --git a/examples/Sms/GetSmsById.java b/examples/Sms/GetSmsById.java index cf6cb49..a7a79b4 100644 --- a/examples/Sms/GetSmsById.java +++ b/examples/Sms/GetSmsById.java @@ -6,7 +6,7 @@ public class getSmsById { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getSmsById("message-id"); System.out.println(response); diff --git a/examples/Sms/SendSms.java b/examples/Sms/SendSms.java index 9d0870e..ed794a8 100644 --- a/examples/Sms/SendSms.java +++ b/examples/Sms/SendSms.java @@ -6,7 +6,7 @@ public class SendSms { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.sendSms( "My company", "+34666666666", "test message"); System.out.println(response); diff --git a/examples/Sms/SendUnicodeSms.java b/examples/Sms/SendUnicodeSms.java new file mode 100644 index 0000000..75b49be --- /dev/null +++ b/examples/Sms/SendUnicodeSms.java @@ -0,0 +1,15 @@ +import java.io.IOException; +import java.util.Map; +import com.instasent.InstasentClient; + +public class SendUnicodeSms { + + public static void main(String[] args) throws IOException { + + InstasentClient instasentClient = new InstasentClient("my-token"); + Map response = instasentClient.sendUnicodeSms( "My company", "+34666666666", "test message"); + System.out.println(response); + + } + +} diff --git a/examples/Verify/CheckVerify.java b/examples/Verify/CheckVerify.java index add8ea4..1bf5d0a 100644 --- a/examples/Verify/CheckVerify.java +++ b/examples/Verify/CheckVerify.java @@ -5,7 +5,7 @@ public class CheckVerify { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.checkVerify("id", "token"); System.out.println(response); } diff --git a/examples/Verify/GetVerify.java b/examples/Verify/GetVerify.java index f6340b6..801a05d 100644 --- a/examples/Verify/GetVerify.java +++ b/examples/Verify/GetVerify.java @@ -5,7 +5,7 @@ public class GetVerify { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getVerify(1, 10); System.out.println(response); } diff --git a/examples/Verify/GetVerifyById.java b/examples/Verify/GetVerifyById.java index 3c79aef..c616e30 100644 --- a/examples/Verify/GetVerifyById.java +++ b/examples/Verify/GetVerifyById.java @@ -5,7 +5,7 @@ public class GetVerifyById { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.getVerifyById("id"); System.out.println(response); } diff --git a/examples/Verify/RequestVerify.java b/examples/Verify/RequestVerify.java index 9e68f7a..c129893 100644 --- a/examples/Verify/RequestVerify.java +++ b/examples/Verify/RequestVerify.java @@ -5,7 +5,7 @@ public class RequestVerify { public static void main(String[] args) throws IOException { - InstasentClient instasentClient = new InstasentClient("my-token", true); + InstasentClient instasentClient = new InstasentClient("my-token"); Map response = instasentClient.requestVerify("my-company", "+34666666666", "Your code is %token%", "", "", ""); System.out.println(response); } diff --git a/instasentclient.iml b/instasentclient.iml new file mode 100644 index 0000000..1d7bb2b --- /dev/null +++ b/instasentclient.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b00c9b7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + com.instasent + instasent-client + 1.0 + + + + com.squareup.okhttp3 + okhttp + 3.8.0 + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + + + + + maven-assembly-plugin + + + + fully.qualified.MainClass + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + \ No newline at end of file diff --git a/api/src/com/instasent/InstasentClient.java b/src/main/java/com/instasent/InstasentClient.java similarity index 88% rename from api/src/com/instasent/InstasentClient.java rename to src/main/java/com/instasent/InstasentClient.java index cbab939..3063f5d 100644 --- a/api/src/com/instasent/InstasentClient.java +++ b/src/main/java/com/instasent/InstasentClient.java @@ -31,6 +31,22 @@ public Map sendSms(String from, String to, String text) { return this.execRequest(url, httpMethod, data); } + public Map sendUnicodeSms(String from, String to, String text) { + String url; + + url = this.secureChannel + "/sms/"; + + String httpMethod = "POST"; + + Map data = new HashMap(); + data.put("allowUnicode", "1"); + data.put("from", from); + data.put("to", to); + data.put("text", text); + + return this.execRequest(url, httpMethod, data); + } + public Map getSms(int page, int per_page) { String url; @@ -64,7 +80,6 @@ private Map execRequest(String url, String httpMethod, Map