Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {

}

project.version = "1.0.0-beta02";
project.version = "1.0.0-beta03-SNAPSHOT"
}

task clean(type: Delete) {
Expand Down
4 changes: 2 additions & 2 deletions ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.0.0"

api 'com.hyperwallet.android:core-sdk:1.0.0-beta02'
api "com.hyperwallet.android:core-sdk:1.0.0-beta03-SNAPSHOT"

androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation "androidx.test:runner:1.1.1"
Expand All @@ -61,7 +61,7 @@ dependencies {
androidTestImplementation "com.squareup.leakcanary:leakcanary-android-instrumentation:1.6.3"
androidTestImplementation "com.squareup.leakcanary:leakcanary-support-fragment:1.6.3"

testImplementation group: 'org.mockito', name: 'mockito-core', version: "2.23.4"
testImplementation group: 'org.mockito', name: 'mockito-core', version: "2.25.0"
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: "1.1.1"
testImplementation "org.robolectric:robolectric:4.1"
testImplementation "com.squareup.okhttp3:mockwebserver:3.11.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@
* USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

package com.hyperwallet.android.ui.repository;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.hyperwallet.android.model.HyperwalletErrors;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationFieldResult;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationKeyResult;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationField;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationKey;

public interface TransferMethodConfigurationRepository {

//TODO update GQL integration development feature
void getKeys(@NonNull final LoadKeysCallback loadKeysCallback);

void getFields(@NonNull final String country, @NonNull final String currency,
Expand All @@ -48,15 +46,16 @@ void getFields(@NonNull final String country, @NonNull final String currency,
void refreshFields();

interface LoadKeysCallback {
void onKeysLoaded(
@Nullable final HyperwalletTransferMethodConfigurationKeyResult transferMethodConfigurationKeyResult);

void onKeysLoaded(@Nullable final HyperwalletTransferMethodConfigurationKey transferMethodConfigurationKey);

void onError(@NonNull final HyperwalletErrors errors);
}

interface LoadFieldsCallback {
void onFieldsLoaded(@Nullable final HyperwalletTransferMethodConfigurationFieldResult
transferMethodConfigurationFieldResult);

void onFieldsLoaded(@Nullable final HyperwalletTransferMethodConfigurationField field,
@Nullable final String processingTime);

void onError(@NonNull final HyperwalletErrors errors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

package com.hyperwallet.android.ui.repository;

import android.os.Handler;
Expand All @@ -36,20 +35,22 @@
import com.hyperwallet.android.Hyperwallet;
import com.hyperwallet.android.exception.HyperwalletException;
import com.hyperwallet.android.listener.HyperwalletListener;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationFieldResult;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationKeyResult;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationField;
import com.hyperwallet.android.model.meta.HyperwalletTransferMethodConfigurationKey;
import com.hyperwallet.android.model.meta.keyed.HyperwalletTransferMethodType;
import com.hyperwallet.android.model.meta.query.HyperwalletTransferMethodConfigurationFieldQuery;
import com.hyperwallet.android.model.meta.query.HyperwalletTransferMethodConfigurationKeysQuery;
import com.hyperwallet.android.ui.util.EspressoIdlingResource;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

public class TransferMethodConfigurationRepositoryImpl implements TransferMethodConfigurationRepository {
private HyperwalletTransferMethodConfigurationKeyResult mTransferMethodConfigurationKeyResult;
private HyperwalletTransferMethodConfigurationKey mTransferMethodConfigurationKey;
private final Handler mHandler;
private final Map<FieldMapKey, HyperwalletTransferMethodConfigurationFieldResult> mFieldMap;
private final Map<FieldMapKey, HyperwalletTransferMethodConfigurationField> mFieldMap;

TransferMethodConfigurationRepositoryImpl() {
mHandler = new Handler();
Expand All @@ -63,11 +64,10 @@ Hyperwallet getHyperwallet() {

@VisibleForTesting()
protected TransferMethodConfigurationRepositoryImpl(@Nullable Handler handler,
HyperwalletTransferMethodConfigurationKeyResult
transferMethodConfigurationKeyResult, Map<FieldMapKey,
HyperwalletTransferMethodConfigurationFieldResult> fieldMap) {
HyperwalletTransferMethodConfigurationKey transferMethodConfigurationKey,
Map<FieldMapKey, HyperwalletTransferMethodConfigurationField> fieldMap) {
mHandler = handler;
mTransferMethodConfigurationKeyResult = transferMethodConfigurationKeyResult;
mTransferMethodConfigurationKey = transferMethodConfigurationKey;
mFieldMap = fieldMap;
}

Expand All @@ -77,11 +77,11 @@ void getTransferMethodConfigurationKeyResult(final LoadKeysCallback loadKeysCall
EspressoIdlingResource.increment();

getHyperwallet().retrieveTransferMethodConfigurationKeys(query,
new HyperwalletListener<HyperwalletTransferMethodConfigurationKeyResult>() {
new HyperwalletListener<HyperwalletTransferMethodConfigurationKey>() {
@Override
public void onSuccess(@Nullable HyperwalletTransferMethodConfigurationKeyResult result) {
mTransferMethodConfigurationKeyResult = result;
loadKeysCallback.onKeysLoaded(mTransferMethodConfigurationKeyResult);
public void onSuccess(@Nullable HyperwalletTransferMethodConfigurationKey result) {
mTransferMethodConfigurationKey = result;
loadKeysCallback.onKeysLoaded(mTransferMethodConfigurationKey);
EspressoIdlingResource.decrement();
}

Expand All @@ -106,18 +106,19 @@ void getTransferMethodConfigurationFieldResult(@NonNull final String country,
@NonNull final String transferMethodProfileType,
@NonNull final LoadFieldsCallback loadFieldsCallback) {
HyperwalletTransferMethodConfigurationFieldQuery query =
new HyperwalletTransferMethodConfigurationFieldQuery(country, currency, transferMethodType,
transferMethodProfileType);
new HyperwalletTransferMethodConfigurationFieldQuery(country, currency,
transferMethodType, transferMethodProfileType);
EspressoIdlingResource.increment();

getHyperwallet().retrieveTransferMethodConfigurationFields(
query,
new HyperwalletListener<HyperwalletTransferMethodConfigurationFieldResult>() {
new HyperwalletListener<HyperwalletTransferMethodConfigurationField>() {
@Override
public void onSuccess(HyperwalletTransferMethodConfigurationFieldResult result) {
public void onSuccess(HyperwalletTransferMethodConfigurationField result) {
FieldMapKey fieldMapKey = new FieldMapKey(country, currency, transferMethodType);
mFieldMap.put(fieldMapKey, result);
loadFieldsCallback.onFieldsLoaded(result);
loadFieldsCallback.onFieldsLoaded(result,
getProcessingTime(country, currency, transferMethodType));
EspressoIdlingResource.decrement();
}

Expand All @@ -137,10 +138,10 @@ public Handler getHandler() {

@Override
public synchronized void getKeys(@NonNull final LoadKeysCallback loadKeysCallback) {
if (mTransferMethodConfigurationKeyResult == null) {
if (mTransferMethodConfigurationKey == null) {
getTransferMethodConfigurationKeyResult(loadKeysCallback);
} else {
loadKeysCallback.onKeysLoaded(mTransferMethodConfigurationKeyResult);
loadKeysCallback.onKeysLoaded(mTransferMethodConfigurationKey);
}
}

Expand All @@ -149,27 +150,45 @@ public synchronized void getFields(@NonNull final String country, @NonNull final
@NonNull final String transferMethodType,
@NonNull final String transferMethodProfileType,
@NonNull final LoadFieldsCallback loadFieldsCallback) {

FieldMapKey fieldMapKey = new FieldMapKey(country, currency, transferMethodType);
HyperwalletTransferMethodConfigurationFieldResult transferMethodConfigurationFieldResult = mFieldMap.get(
fieldMapKey);
HyperwalletTransferMethodConfigurationField transferMethodConfigurationField = mFieldMap.get(fieldMapKey);
// if there is no value for country-currency-type combination,
// it means api call was never made or this combination or it was refreshed
if (transferMethodConfigurationFieldResult == null) {
getTransferMethodConfigurationFieldResult(country, currency, transferMethodType, transferMethodProfileType, loadFieldsCallback);
if (transferMethodConfigurationField == null) {
getTransferMethodConfigurationFieldResult(country, currency, transferMethodType,
transferMethodProfileType, loadFieldsCallback);
} else {
loadFieldsCallback.onFieldsLoaded(transferMethodConfigurationFieldResult);
loadFieldsCallback.onFieldsLoaded(transferMethodConfigurationField,
getProcessingTime(country, currency, transferMethodType));
}
}

@Override
public void refreshKeys() {
mTransferMethodConfigurationKeyResult = null;
mTransferMethodConfigurationKey = null;
}

@Override
public void refreshFields() {
mFieldMap.clear();
}

//TODO this method is just temporary, placed to get the processing time
//Next iteration from API will have ProcessingTime as a separate node
@Nullable
private String getProcessingTime(String country, String currency, String transferMethodType) {
if (mTransferMethodConfigurationKey != null) {
Set<HyperwalletTransferMethodType> transferMethodTypes = mTransferMethodConfigurationKey
.getTransferMethodType(country, currency);
for (HyperwalletTransferMethodType type : transferMethodTypes) {
if (type.getName().equals(transferMethodType)) {
return type.getProcessingTime();
}
}
}
return null;
}
}

class FieldMapKey {
Expand Down Expand Up @@ -213,6 +232,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(mCountry, mCurrency, mTransferMethodType);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ void createTransferMethod(@NonNull HyperwalletTransferMethod transferMethod,
@NonNull LoadTransferMethodCallback callback);

/**
* Load transfe methods available associated with current context
* Load transfer methods available associated with current context
*
* @param callback @see {@link LoadTransferMethodListCallback}
*/
void loadTransferMethod(@NonNull LoadTransferMethodListCallback callback);
void loadTransferMethods(@NonNull LoadTransferMethodListCallback callback);

/**
* Deactivate transfer method specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createTransferMethod(@NonNull final HyperwalletTransferMethod transf
}

@Override
public void loadTransferMethod(@NonNull final LoadTransferMethodListCallback callback) {
public void loadTransferMethods(@NonNull final LoadTransferMethodListCallback callback) {
getHyperwallet().listTransferMethods(null,
new HyperwalletListener<HyperwalletPageList<HyperwalletTransferMethod>>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import com.hyperwallet.android.model.HyperwalletError;
import com.hyperwallet.android.model.HyperwalletTransferMethod;
import com.hyperwallet.android.model.meta.Fee;
import com.hyperwallet.android.model.meta.HyperwalletField;
import com.hyperwallet.android.model.meta.HyperwalletFee;
import com.hyperwallet.android.model.meta.field.HyperwalletFieldGroup;

import java.util.List;

Expand All @@ -38,9 +38,9 @@ interface View {

void showErrorLoadTransferMethodConfigurationFields(@NonNull final List<HyperwalletError> errors);

void showTransferMethodFields(@NonNull final List<HyperwalletField> fields);
void showTransferMethodFields(@NonNull final List<HyperwalletFieldGroup> fields);

void showTransactionInformation(List<Fee> fees, String processingTime);
void showTransactionInformation(List<HyperwalletFee> fees, String processingTime);

void showCreateButtonProgressBar();

Expand Down
Loading