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 @@ -21,7 +21,7 @@ allprojects {
mavenLocal()
}

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

task clean(type: Delete) {
Expand Down
5 changes: 4 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ publishing {
artifact(aarArtifact)

pom {
name = 'Hyperwallet Android Core SDK'
description = 'Hyperwallet Core SDK for Android to integrate with Hyperwallet Platform'
url = 'https://github.com/hyperwallet/hyperwallet-android-sdk'
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
Expand Down Expand Up @@ -148,7 +151,7 @@ publishing {

tasks.withType(Sign) {
onlyIf {
isReleaseVersion
isReleaseVersion && !gradle.taskGraph.hasTask("publishToMavenLocal")
}
}

Expand Down
166 changes: 138 additions & 28 deletions core/src/main/java/com/hyperwallet/android/Hyperwallet.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@

import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.BANK_CARD;

import androidx.annotation.NonNull;

import com.hyperwallet.android.util.DateUtil;

import java.util.Date;
import java.util.Map;

/**
* Represents the bank card pagination fields
*/
public class HyperwalletBankCardPagination extends HyperwalletTransferMethodPagination {

protected static final String TRANSFER_METHOD_CREATE_ON = "createdOn";

private Date mCreatedOn;

/**
* Constructors the bank card pagination
*/
Expand All @@ -41,6 +50,21 @@ public HyperwalletBankCardPagination() {
*/
public HyperwalletBankCardPagination(Map<String, String> urlQueryMap) {
super(urlQueryMap);
mCreatedOn = getDateValueBy(urlQueryMap, TRANSFER_METHOD_CREATE_ON);
setType(BANK_CARD);
}

public Date getCreatedOn() {
return mCreatedOn;
}

@NonNull
@Override
public Map<String, String> buildQuery() {
Map<String, String> query = super.buildQuery();
if (mCreatedOn != null) {
query.put(TRANSFER_METHOD_CREATE_ON, DateUtil.toDateTimeFormat(mCreatedOn));
}
return query;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2018 Hyperwallet
*
* 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.
*/
package com.hyperwallet.android.model;

import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.PAYPAL_ACCOUNT;

import androidx.annotation.NonNull;

import com.hyperwallet.android.util.DateUtil;

import java.util.Date;
import java.util.Map;

/**
* Represents the PayPal Account pagination fields
*/
public class HyperwalletPayPalAccountPagination extends HyperwalletTransferMethodPagination {

protected static final String TRANSFER_METHOD_CREATE_ON = "createdOn";

private Date mCreatedOn;

/**
* Constructs the default implementation of the PayPal Account pagination.
*/
public HyperwalletPayPalAccountPagination() {
super();
setType(PAYPAL_ACCOUNT);
}

/**
* Constructs the PayPal Account pagination based in the preview request with extra parameters.
*
* @param urlQueryMap the map with properties to build the pagination
*/
public HyperwalletPayPalAccountPagination(Map<String, String> urlQueryMap) {
super(urlQueryMap);
mCreatedOn = getDateValueBy(urlQueryMap, TRANSFER_METHOD_CREATE_ON);
setType(PAYPAL_ACCOUNT);
}

public Date getCreatedOn() {
return mCreatedOn;
}

@NonNull
@Override
public Map<String, String> buildQuery() {
Map<String, String> query = super.buildQuery();
if (mCreatedOn != null) {
query.put(TRANSFER_METHOD_CREATE_ON, DateUtil.toDateTimeFormat(mCreatedOn));
}
return query;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public HyperwalletTransferMethodPagination(@NonNull Map<String, String> urlQuery
* @return the valid Date value or null
*/
@Nullable
private Date getDateValueBy(@NonNull Map<String, String> urlQueryMap, @NonNull String queryKey) {
Date getDateValueBy(@NonNull Map<String, String> urlQueryMap, @NonNull String queryKey) {
if (containsKeyAndHasValue(urlQueryMap, queryKey)) {
return fromDateTimeString(urlQueryMap.get(queryKey));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class PayPalAccount extends HyperwalletTransferMethod {

/**
* Constructor to build bank card, based on json object
* Constructor to build PayPal Account, based on json object
*/
public PayPalAccount(@NonNull JSONObject jsonObject) throws JSONException {
super(jsonObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import com.hyperwallet.android.model.meta.HyperwalletRetrieveTransferMethodConfigurationFieldsTest;
import com.hyperwallet.android.transfermethod.HyperwalletCreateBankAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletCreateBankCardTest;
import com.hyperwallet.android.transfermethod.HyperwalletCreatePayPalAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletDeactivateBankAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletDeactivateBankCardTest;
import com.hyperwallet.android.transfermethod.HyperwalletDeactivatePayPalAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletGetBankAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletGetBankCardTest;
import com.hyperwallet.android.transfermethod.HyperwalletGetPayPalTest;
import com.hyperwallet.android.transfermethod.HyperwalletListBankAccountsTest;
import com.hyperwallet.android.transfermethod.HyperwalletListBankCardsTest;
import com.hyperwallet.android.transfermethod.HyperwalletListPayPalAccountsTest;
import com.hyperwallet.android.transfermethod.HyperwalletListTransferMethodsTest;
import com.hyperwallet.android.transfermethod.HyperwalletRetrieveTransferMethodConfigurationKeysTest;
import com.hyperwallet.android.transfermethod.HyperwalletUpdateBankAccountTest;
import com.hyperwallet.android.transfermethod.HyperwalletUpdateBankCardTest;
import com.hyperwallet.android.transfermethod.HyperwalletUpdatePayPalAccountTest;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
Expand All @@ -23,16 +28,21 @@
HyperwalletCreateBankAccountTest.class,
HyperwalletListBankAccountsTest.class,
HyperwalletCreateBankCardTest.class,
HyperwalletCreatePayPalAccountTest.class,
HyperwalletGetBankAccountTest.class,
HyperwalletGetBankCardTest.class,
HyperwalletGetPayPalTest.class,
HyperwalletUpdateBankAccountTest.class,
HyperwalletUpdateBankCardTest.class,
HyperwalletUpdatePayPalAccountTest.class,
HyperwalletDeactivateBankAccountTest.class,
HyperwalletDeactivateBankCardTest.class,
HyperwalletDeactivatePayPalAccountTest.class,
HyperwalletListTransferMethodsTest.class,
HyperwalletListBankCardsTest.class,
HyperwalletRetrieveTransferMethodConfigurationKeysTest.class,
HyperwalletRetrieveTransferMethodConfigurationFieldsTest.class
HyperwalletRetrieveTransferMethodConfigurationFieldsTest.class,
HyperwalletListPayPalAccountsTest.class
})
public class HyperwalletTestSuite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class HyperwalletBankCardPaginationTest {
private static final String ACCOUNT_TYPE = "type";
private static final String CREATE_BEFORE = "createdBefore";
private static final String CREATE_AFTER = "createdAfter";
private final static String CREATE_ON = "createdOn";
private static final String LIMIT = "limit";
private static final String OFFSET = "offset";
private static final String SORT_BY = "sortBy";
Expand All @@ -36,6 +37,7 @@ public void testHyperwalletBankCardPagination_withUrlQueryMap() {
query.put(LIMIT, String.valueOf(limit));
query.put(CREATE_BEFORE, "2017-01-01T10:12:22");
query.put(CREATE_AFTER, "2017-01-01T00:00:00");
query.put(CREATE_ON, "2017-01-01T10:00:40");

HyperwalletBankCardPagination pagination = new HyperwalletBankCardPagination(query);
assertThat(pagination.getLimit(), is(limit));
Expand Down Expand Up @@ -92,6 +94,7 @@ public void testBuildQuery_returnsQueryParameters() {
query.put(LIMIT, String.valueOf(limit));
query.put(CREATE_BEFORE, "2017-01-01T10:12:22");
query.put(CREATE_AFTER, "2017-01-01T00:00:00");
query.put(CREATE_ON, "2017-01-01T10:00:40");

HyperwalletBankCardPagination pagination = new HyperwalletBankCardPagination(query);
Map<String, String> resultQuery = pagination.buildQuery();
Expand All @@ -110,6 +113,7 @@ public void testBuildQuery_returnsQueryParameters() {
assertThat(resultQuery.get(SORT_BY), is(ASCENDANT_CREATE_ON));
assertThat(resultQuery.get(CREATE_BEFORE), is("2017-01-01T10:12:22"));
assertThat(resultQuery.get(CREATE_AFTER), is("2017-01-01T00:00:00"));
assertThat(resultQuery.get(CREATE_ON), is("2017-01-01T10:00:40"));
assertThat(resultQuery.get(ACCOUNT_TYPE), is(BANK_CARD));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package com.hyperwallet.android.model;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import static com.hyperwallet.android.model.HyperwalletStatusTransition.StatusDefinition.ACTIVATED;
import static com.hyperwallet.android.model.HyperwalletTransferMethod.TransferMethodTypes.PAYPAL_ACCOUNT;
import static com.hyperwallet.android.model.HyperwalletTransferMethodPagination.TransferMethodSortable.ASCENDANT_CREATE_ON;
import static com.hyperwallet.android.model.HyperwalletTransferMethodPagination.TransferMethodSortable.ASCENDANT_STATUS;

import org.junit.Assert;
import org.junit.Test;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

public class HyperwalletPayPalAccountPaginationTest {
private final static String OFFSET = "offset";
private final static String LIMIT = "limit";
private final static String CREATE_BEFORE = "createdBefore";
private final static String CREATE_AFTER = "createdAfter";
private final static String CREATE_ON = "createdOn";
private final static String TRANSFER_METHOD_TYPE = "type";
private final static String STATUS = "status";
private final static String SORT_BY = "sortBy";


@Test
public void testHyperwalletPayPalAccountPagination_withUrlQueryMap() {
Map<String, String> query = new HashMap<>();
query.put(OFFSET, "100");
query.put(LIMIT, "200");
query.put(CREATE_BEFORE, "2017-01-01T10:12:22");
query.put(CREATE_AFTER, "2017-01-01T00:00:00");
query.put(CREATE_ON, "2017-01-01T10:10:00");
query.put(TRANSFER_METHOD_TYPE, PAYPAL_ACCOUNT);
query.put(STATUS, ACTIVATED);
query.put(SORT_BY, ASCENDANT_STATUS);

HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination(query);

assertThat(pagination.getLimit(), is(200));
assertThat(pagination.getOffset(), is(100));
assertThat(pagination.getType(), is(PAYPAL_ACCOUNT));
assertThat(pagination.getStatus(), is(ACTIVATED));
assertThat(pagination.getSortBy(), is(ASCENDANT_STATUS));

Calendar createdBefore = Calendar.getInstance();
createdBefore.setTime(pagination.getCreatedBefore());
assertThat(createdBefore.get(Calendar.YEAR), is(2017));
assertThat(createdBefore.get(Calendar.MONTH), is(Calendar.JANUARY));
assertThat(createdBefore.get(Calendar.DAY_OF_MONTH), is(1));
assertThat(createdBefore.get(Calendar.HOUR), is(10));
assertThat(createdBefore.get(Calendar.MINUTE), is(12));
assertThat(createdBefore.get(Calendar.SECOND), is(22));

Calendar createdAfter = Calendar.getInstance();
createdAfter.setTime(pagination.getCreatedAfter());
assertThat(createdAfter.get(Calendar.YEAR), is(2017));
assertThat(createdAfter.get(Calendar.MONTH), is(Calendar.JANUARY));
assertThat(createdAfter.get(Calendar.DAY_OF_MONTH), is(1));
assertThat(createdAfter.get(Calendar.HOUR), is(0));
assertThat(createdAfter.get(Calendar.MINUTE), is(0));
assertThat(createdAfter.get(Calendar.SECOND), is(0));

Calendar createdOn = Calendar.getInstance();
createdOn.setTime(pagination.getCreatedOn());
assertThat(createdOn.get(Calendar.YEAR), is(2017));
assertThat(createdOn.get(Calendar.MONTH), is(Calendar.JANUARY));
assertThat(createdOn.get(Calendar.DAY_OF_MONTH), is(1));
assertThat(createdOn.get(Calendar.HOUR), is(10));
assertThat(createdOn.get(Calendar.MINUTE), is(10));
assertThat(createdOn.get(Calendar.SECOND), is(0));

}


@Test
public void testHyperwalletPayPalAccountPagination_verifyDefaultValues() {

HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination();
assertThat(pagination.getLimit(), is(10));
assertThat(pagination.getOffset(), is(0));
assertThat(pagination.getType(), is(PAYPAL_ACCOUNT));
assertThat(pagination.getStatus(), is(nullValue()));
assertThat(pagination.getSortBy(), is(nullValue()));
assertThat(pagination.getCreatedBefore(), is(nullValue()));
assertThat(pagination.getCreatedAfter(), is(nullValue()));
}


@Test
public void testBuildQuery_verifyDefaultValues() {
HyperwalletPagination pagination = new HyperwalletPagination();

Map<String, String> query = pagination.buildQuery();

Assert.assertNotNull(query);
assertThat(query.size(), is(2));
assertThat(query.get(OFFSET), is("0"));
assertThat(query.get(LIMIT), is("10"));
assertThat(query.get(TRANSFER_METHOD_TYPE), is(nullValue()));
assertThat(query.get(STATUS), is(nullValue()));
assertThat(query.get(SORT_BY), is(nullValue()));
assertThat(query.get(CREATE_BEFORE), is(nullValue()));
assertThat(query.get(CREATE_AFTER), is(nullValue()));
assertThat(query.get(CREATE_ON), is(nullValue()));
assertThat(query.get(TRANSFER_METHOD_TYPE), is(nullValue()));

}


@Test
public void testBuildQuery_returnsQueryParameters() {

Map<String, String> query = new HashMap<>();
query.put(OFFSET, "100");
query.put(LIMIT, "200");
query.put(CREATE_BEFORE, "2017-01-01T10:12:22");
query.put(CREATE_AFTER, "2017-01-01T00:00:000");
query.put(CREATE_ON, "2017-01-01T10:10:00");
query.put(TRANSFER_METHOD_TYPE, PAYPAL_ACCOUNT);
query.put(STATUS, ACTIVATED);
query.put(SORT_BY, ASCENDANT_CREATE_ON);

HyperwalletPayPalAccountPagination pagination = new HyperwalletPayPalAccountPagination(query);
Map<String, String> resultQuery = pagination.buildQuery();

assertThat(resultQuery.containsKey(STATUS), is(true));
assertThat(resultQuery.containsKey(SORT_BY), is(true));
assertThat(resultQuery.containsKey(OFFSET), is(true));
assertThat(resultQuery.containsKey(LIMIT), is(true));
assertThat(resultQuery.containsKey(CREATE_BEFORE), is(true));
assertThat(resultQuery.containsKey(CREATE_AFTER), is(true));
assertThat(resultQuery.containsKey(TRANSFER_METHOD_TYPE), is(true));

assertThat(resultQuery.get(LIMIT), is("200"));
assertThat(resultQuery.get(OFFSET), is("100"));
assertThat(resultQuery.get(STATUS), is(ACTIVATED));
assertThat(resultQuery.get(SORT_BY), is(ASCENDANT_CREATE_ON));
assertThat(resultQuery.get(CREATE_BEFORE), is("2017-01-01T10:12:22"));
assertThat(resultQuery.get(CREATE_AFTER), is("2017-01-01T00:00:00"));
assertThat(resultQuery.get(CREATE_ON), is("2017-01-01T10:10:00"));
assertThat(resultQuery.get(TRANSFER_METHOD_TYPE), is(PAYPAL_ACCOUNT));

}


}
Loading