Skip to content

Commit 56111d3

Browse files
committed
server response
1 parent 1ad57b2 commit 56111d3

8 files changed

Lines changed: 43 additions & 54 deletions

File tree

.idea/DtonatorPreferences.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2727
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
2828

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

3232

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
1212
<meta-data android:name="mobtexting.api_key" android:value="@string/mobtextingapikey" />
13+
<meta-data android:name="mobtexting.sender_id" android:value="@string/mobtextingsenderid" />
1314
<activity android:name=".MainActivity">
1415
<intent-filter>
1516
<action android:name="android.intent.action.MAIN" />

app/src/main/java/com/mobtexting/sms/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected void onCreate(Bundle savedInstanceState) {
1818
setContentView(R.layout.activity_main);
1919

2020
mobtexting=new Mobtexting(this);
21-
mobtexting.sendSMS("This is a test","7250705072","Mobtext",this);
21+
mobtexting.sendSMS("This is a test","7488792140",this);
2222
}
2323

2424
@Override
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<resources>
22
<string name="app_name">mobtexting-android-sdk</string>
3-
<string name="mobtextingapikey">gdfgdgdfgfd</string>
3+
<string name="mobtextingapikey">sadasdasd</string>
4+
<string name="mobtextingsenderid">sadasd</string>
45
</resources>

mobtextingsms/src/main/java/com/mobtexting/Mobtexting.java

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,35 @@ public class Mobtexting {
2424
private static final String TAG = "Communicator";
2525
private static final String SERVER_URL = "http://api.mobtexting.com";
2626
private Retrofit retrofit;
27-
private String api_key1,sender_id;
27+
private String api_key1, sender_id;
2828
private Context context;
2929

30-
public Mobtexting(Context context){
31-
this.context=context;
30+
/**
31+
* @param context
32+
*/
33+
public Mobtexting(Context context) {
34+
this.context = context;
3235
}
3336

37+
/**
38+
* send SMS using POST method
39+
*
40+
* @param message
41+
* @param mobile_no
42+
* @param mobtextingInterface
43+
*/
3444
public void sendSMS(String message, String mobile_no, final MobtextingInterface mobtextingInterface) {
3545
try {
3646
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
3747
Bundle bundle = ai.metaData;
38-
api_key1= bundle.getString("mobtexting.api_key");
39-
sender_id= bundle.getString("mobtexting.sender_id");
40-
}catch (Exception e){
48+
api_key1 = bundle.getString("mobtexting.api_key");
49+
sender_id = bundle.getString("mobtexting.sender_id");
50+
} catch (Exception e) {
4151
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."));
4252
return;
4353
}
44-
if(api_key1!=null&&!api_key1.equals("")) {
45-
if(sender_id!=null&&!sender_id.equals("")) {
54+
if (api_key1 != null && !api_key1.equals("")) {
55+
if (sender_id != null && !sender_id.equals("")) {
4656
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
4757
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
4858
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
@@ -82,46 +92,12 @@ public void onFailure(Call<ServerResponse> call, Throwable t) {
8292
mobtextingInterface.onError(new ModelError("500", "No Internet", "Check your internet connection!"));
8393
}
8494
});
85-
}else{
95+
} else {
8696
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."));
8797
}
88-
}else{
98+
} else {
8999
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."));
90100
}
91101
}
92-
93-
/*public void loginGet(String username, String password) {
94-
95-
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
96-
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
97-
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
98-
httpClient.addInterceptor(logging);
99-
100-
Retrofit retrofit = new Retrofit.Builder()
101-
.client(httpClient.build())
102-
.addConverterFactory(GsonConverterFactory.create())
103-
.baseUrl(SERVER_URL)
104-
.build();
105-
106-
Interface service = retrofit.create(Interface.class);
107-
108-
Call<ServerResponse> call = service.get("login", username, password);
109-
110-
call.enqueue(new Callback<ServerResponse>() {
111-
@Override
112-
public void onResponse(Call<ServerResponse> call, Response<ServerResponse> response) {
113-
// response.isSuccessful() is true if the response code is 2xx
114-
Log.e(TAG, "Success");
115-
}
116-
117-
@Override
118-
public void onFailure(Call<ServerResponse> call, Throwable t) {
119-
// handle execution failures like no internet connectivity
120-
Log.d("internet",t.getMessage());
121-
}
122-
});
123-
}*/
124-
125-
126102
}
127103

mobtextingsms/src/main/java/com/mobtexting/ServerResponse.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
package com.mobtexting;
22

3+
import com.google.gson.annotations.Expose;
34
import com.google.gson.annotations.SerializedName;
45

5-
import java.io.Serializable;
6+
import java.util.List;
67

7-
public class ServerResponse implements Serializable{
8+
public class ServerResponse {
89

10+
@Expose
11+
@SerializedName("sms_id")
12+
private List<String> smsId;
13+
@Expose
914
@SerializedName("description")
1015
private String description;
16+
@Expose
1117
@SerializedName("error")
1218
private int error;
19+
@Expose
1320
@SerializedName("status")
1421
private String status;
1522

16-
public ServerResponse(String description, int error, String status) {
17-
this.description = description;
18-
this.error = error;
19-
this.status = status;
23+
public List<String> getSmsId() {
24+
return smsId;
25+
}
26+
27+
public void setSmsId(List<String> smsId) {
28+
this.smsId = smsId;
2029
}
2130

2231
public String getDescription() {

0 commit comments

Comments
 (0)