Skip to content

Commit

Permalink
server response
Browse files Browse the repository at this point in the history
  • Loading branch information
dkgupta2501 committed May 3, 2018
1 parent 1ad57b2 commit 56111d3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 54 deletions.
4 changes: 3 additions & 1 deletion .idea/DtonatorPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.github.mobtexting:mobtexting-android-sdk:76f4cbcdd4'
implementation 'com.github.mobtexting:mobtexting-android-sdk:v1.0-alpha'
implementation 'com.msg91.sendotp.library:library:3.1'


Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="mobtexting.api_key" android:value="@string/mobtextingapikey" />
<meta-data android:name="mobtexting.sender_id" android:value="@string/mobtextingsenderid" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/mobtexting/sms/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

mobtexting=new Mobtexting(this);
mobtexting.sendSMS("This is a test","7250705072","Mobtext",this);
mobtexting.sendSMS("This is a test","7488792140",this);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="app_name">mobtexting-android-sdk</string>
<string name="mobtextingapikey">gdfgdgdfgfd</string>
<string name="mobtextingapikey">sadasdasd</string>
<string name="mobtextingsenderid">sadasd</string>
</resources>
64 changes: 20 additions & 44 deletions mobtextingsms/src/main/java/com/mobtexting/Mobtexting.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,35 @@ public class Mobtexting {
private static final String TAG = "Communicator";
private static final String SERVER_URL = "http://api.mobtexting.com";
private Retrofit retrofit;
private String api_key1,sender_id;
private String api_key1, sender_id;
private Context context;

public Mobtexting(Context context){
this.context=context;
/**
* @param context
*/
public Mobtexting(Context context) {
this.context = context;
}

/**
* send SMS using POST method
*
* @param message
* @param mobile_no
* @param mobtextingInterface
*/
public void sendSMS(String message, String mobile_no, final MobtextingInterface mobtextingInterface) {
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
api_key1= bundle.getString("mobtexting.api_key");
sender_id= bundle.getString("mobtexting.sender_id");
}catch (Exception e){
api_key1 = bundle.getString("mobtexting.api_key");
sender_id = bundle.getString("mobtexting.sender_id");
} catch (Exception e) {
mobtextingInterface.onError(new ModelError("100", "API key", "Dear developer. Don't forget to configure <meta-data android:name=\"mobtexting.api_key\" android:value=\"testValue\"/> in your AndroidManifest.xml file."));
return;
}
if(api_key1!=null&&!api_key1.equals("")) {
if(sender_id!=null&&!sender_id.equals("")) {
if (api_key1 != null && !api_key1.equals("")) {
if (sender_id != null && !sender_id.equals("")) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
Expand Down Expand Up @@ -82,46 +92,12 @@ public void onFailure(Call<ServerResponse> call, Throwable t) {
mobtextingInterface.onError(new ModelError("500", "No Internet", "Check your internet connection!"));
}
});
}else{
} else {
mobtextingInterface.onError(new ModelError("100", "Sender ID", "Dear developer. Don't forget to configure <meta-data android:name=\"mobtexting.sender_id\" android:value=\"testValue\"/> in your AndroidManifest.xml file."));
}
}else{
} else {
mobtextingInterface.onError(new ModelError("100", "API key", "Dear developer. Don't forget to configure <meta-data android:name=\"mobtexting.api_key\" android:value=\"testValue\"/> in your AndroidManifest.xml file."));
}
}

/*public void loginGet(String username, String password) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(logging);
Retrofit retrofit = new Retrofit.Builder()
.client(httpClient.build())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(SERVER_URL)
.build();
Interface service = retrofit.create(Interface.class);
Call<ServerResponse> call = service.get("login", username, password);
call.enqueue(new Callback<ServerResponse>() {
@Override
public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) {
// response.isSuccessful() is true if the response code is 2xx
Log.e(TAG, "Success");
}
@Override
public void onFailure(Call<ServerResponse> call, Throwable t) {
// handle execution failures like no internet connectivity
Log.d("internet",t.getMessage());
}
});
}*/


}

21 changes: 15 additions & 6 deletions mobtextingsms/src/main/java/com/mobtexting/ServerResponse.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package com.mobtexting;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.List;

public class ServerResponse implements Serializable{
public class ServerResponse {

@Expose
@SerializedName("sms_id")
private List<String> smsId;
@Expose
@SerializedName("description")
private String description;
@Expose
@SerializedName("error")
private int error;
@Expose
@SerializedName("status")
private String status;

public ServerResponse(String description, int error, String status) {
this.description = description;
this.error = error;
this.status = status;
public List<String> getSmsId() {
return smsId;
}

public void setSmsId(List<String> smsId) {
this.smsId = smsId;
}

public String getDescription() {
Expand Down

0 comments on commit 56111d3

Please sign in to comment.