Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

SDK Updates #4

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
689 changes: 580 additions & 109 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha05'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.2'
classpath 'gradle.plugin.de.fuerstenau:BuildConfigPlugin:1.1.8'
Expand Down
16 changes: 10 additions & 6 deletions client-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha05'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
Expand All @@ -23,7 +23,7 @@ version properties.getProperty("bintray.version")

android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 16
Expand Down Expand Up @@ -51,13 +51,17 @@ repositories {
dependencies {

// Client
compile project(':client')
implementation project(':client')

// Cards UI
compile project(':luhn')
implementation project(':luhn')

testCompile 'junit:junit:4.12'
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
implementation ('io.card:android-sdk:5.5.1'){
exclude group: "com.android.support"
}

testImplementation 'junit:junit:4.12'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
}

task sourcesJar(type: Jar) {
Expand Down
28 changes: 14 additions & 14 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha05'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
Expand All @@ -25,7 +25,7 @@ version properties.getProperty("bintray.version")

android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 16
Expand Down Expand Up @@ -88,26 +88,26 @@ repositories {
dependencies {

// annotations
compile 'javax.annotation:javax.annotation-api:1.2'
implementation 'javax.annotation:javax.annotation-api:1.2'
// compile 'com.android.support:support-annotations:25.3.1'

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'

// permissions
compile 'com.karumi:dexter:4.1.0'
implementation 'com.karumi:dexter:4.1.0'

// grpc
compile 'io.grpc:grpc-stub:1.5.0'
compile 'io.grpc:grpc-okhttp:1.5.0'
compile 'io.grpc:grpc-protobuf-lite:1.5.0'
implementation 'io.grpc:grpc-stub:1.5.0'
implementation 'io.grpc:grpc-okhttp:1.5.0'
implementation 'io.grpc:grpc-protobuf-lite:1.5.0'

compile 'com.birbit:android-priority-jobqueue:2.0.1'
implementation 'com.birbit:android-priority-jobqueue:2.0.1'

testCompile 'junit:junit:4.12'
testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1'
testImplementation 'junit:junit:4.12'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
}

task sourcesJar(type: Jar) {
Expand Down
13 changes: 9 additions & 4 deletions client/src/main/java/com/africastalking/AfricasTalking.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.app.Activity;
import android.text.TextUtils;

import com.africastalking.services.AccountService;
import com.africastalking.services.ApplicationService;
import com.africastalking.services.AirtimeService;
import com.africastalking.services.PaymentService;
import com.africastalking.services.Service;
Expand Down Expand Up @@ -44,17 +44,17 @@ public final class AfricasTalking {
);


public static void initialize(String host, int port, boolean disableTLS) throws IOException {
public static void initialize(String host, int port, boolean disableTLS) {
Service.HOST = host;
Service.PORT = port;
Service.DISABLE_TLS = disableTLS;
}

public static void initialize(String host, int port) throws IOException {
public static void initialize(String host, int port) {
initialize(host, port, false);
}

public static void initialize(String host) throws IOException {
public static void initialize(String host) {
initialize(host, Service.PORT, false);
}

Expand Down Expand Up @@ -89,8 +89,13 @@ public static PaymentService getPaymentService() throws IOException {
return Service.newInstance("payment");
}

/*
public static AccountService getAccountService() throws IOException {
return Service.newInstance("account");
} */

public static ApplicationService getApplicationService() throws IOException {
return Service.newInstance("application");
}

public static TokenService getTokenService() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.gson.annotations.SerializedName;

public final class AccountResponse {
public final class ApplicationResponse {

@SerializedName("UserData")
public UserData userData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.africastalking.services;

import com.africastalking.models.account.AccountResponse;
import com.africastalking.models.account.ApplicationResponse;

import retrofit2.Call;
import retrofit2.http.GET;
Expand All @@ -11,5 +11,5 @@
*/
public interface AccountServiceInterface {
@GET("user")
Call<AccountResponse> getUser(@Query("username") String username);
Call<ApplicationResponse> getUser(@Query("username") String username);
}
22 changes: 11 additions & 11 deletions ...ricastalking/services/AccountService.java → ...stalking/services/ApplicationService.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


import com.africastalking.utils.Callback;
import com.africastalking.models.account.AccountResponse;
import com.africastalking.models.account.ApplicationResponse;

import retrofit2.Response;
import retrofit2.Retrofit;
Expand All @@ -12,20 +12,20 @@
/**
* Account service. Retrieve user account info
*/
public class AccountService extends Service {
public class ApplicationService extends Service {

static AccountService sInstance;
private AccountServiceInterface service;
static ApplicationService sInstance;
private ApplicationServiceInterface service;

AccountService() throws IOException {
ApplicationService() throws IOException {
super();
}

@Override
protected AccountService getInstance() throws IOException {
protected ApplicationService getInstance() throws IOException {

if (sInstance == null) {
sInstance = new AccountService();
sInstance = new ApplicationService();
}

return sInstance;
Expand All @@ -39,7 +39,7 @@ protected void initService() {
.baseUrl(url)
.build();

service = retrofit.create(AccountServiceInterface.class);
service = retrofit.create(ApplicationServiceInterface.class);
}

@Override
Expand All @@ -65,8 +65,8 @@ protected void destroyService() {
* @return String in specified format, xml or json
* @throws IOException
*/
public AccountResponse getUser() throws IOException {
Response<AccountResponse> resp = service.getUser(username).execute();
public ApplicationResponse getUser() throws IOException {
Response<ApplicationResponse> resp = service.getUser(username).execute();
if (!resp.isSuccessful()) {
throw new IOException(resp.errorBody().string());
}
Expand All @@ -81,7 +81,7 @@ public AccountResponse getUser() throws IOException {
* </p>
* @param callback
*/
public void getUser(final Callback<AccountResponse> callback) {
public void getUser(final Callback<ApplicationResponse> callback) {
service.getUser(username).enqueue(makeCallback(callback));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.africastalking.services;

import com.africastalking.models.account.ApplicationResponse;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;

/**
* Account Endpoints
*/
public interface ApplicationServiceInterface {
@GET("user")
Call<ApplicationResponse> getUser(@Query("username") String username);
}
8 changes: 4 additions & 4 deletions client/src/main/java/com/africastalking/services/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ protected ClientTokenResponse fetchToken(String host, int port) throws IOExcepti

public static <T extends Service> T newInstance(String service) throws IOException {

if (service.contentEquals("account")) {
if (AccountService.sInstance == null) {
AccountService.sInstance = new AccountService();
if (service.contentEquals("application")) {
if (ApplicationService.sInstance == null) {
ApplicationService.sInstance = new ApplicationService();
}
return (T) AccountService.sInstance;
return (T) ApplicationService.sInstance;
}


Expand Down
Loading