Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdk95 #56

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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 pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>me.figo</groupId>
<artifactId>sdk</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
<packaging>jar</packaging>

<name>Figo Java SDK</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/figo/FigoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public <T> T queryApi(String path, Object data, String method, Type typeOfT) thr
connection.setRequestProperty("Authorization", authorization);
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("User-Agent", "Figo/Java 3.1.1");
connection.setRequestProperty("User-Agent", "Figo/Java 3.1.3");

// add payload
if (data != null) {
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/me/figo/FigoException.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package me.figo;

import java.util.Map;

import com.google.gson.annotations.Expose;

/***
Expand Down Expand Up @@ -80,6 +82,9 @@ public static class ErrorObject {
@Expose
private String code;

@Expose
private Map<String, String[]> data;

@Expose
private String description;

Expand All @@ -101,18 +106,16 @@ public String getGroup() {
return group;
}

public Map<String, String[]> getData() {
return data;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ErrorObject [");
if (code != null)
builder.append("code=").append(code).append(", ");
if (description != null)
builder.append("description=").append(description).append(", ");
if (group != null)
builder.append("group=").append(group);
builder.append("]");
return builder.toString();
return "ErrorObject [" + (code != null ? "code=" + code + ", " : "")
+ (data != null ? "data=" + data + ", " : "")
+ (description != null ? "description=" + description + ", " : "")
+ (group != null ? "group=" + group : "") + "]";
}
}
}
47 changes: 37 additions & 10 deletions src/main/java/me/figo/FigoSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,30 @@
import java.util.Collections;
import java.util.List;

import me.figo.internal.*;
import me.figo.models.*;
import me.figo.internal.ModifyStandingOrderRequest;
import me.figo.internal.SetupAccountRequest;
import me.figo.internal.SubmitPaymentRequest;
import me.figo.internal.SyncTokenRequest;
import me.figo.internal.TaskResponseType;
import me.figo.internal.TaskStatusRequest;
import me.figo.internal.TaskStatusResponse;
import me.figo.internal.TaskTokenResponse;
import me.figo.internal.VisitedRequest;
import me.figo.models.Account;
import me.figo.models.AccountBalance;
import me.figo.models.Bank;
import me.figo.models.BankLoginSettings;
import me.figo.models.Notification;
import me.figo.models.Payment;
import me.figo.models.PaymentContainer;
import me.figo.models.PaymentProposal;
import me.figo.models.PaymentProposal.PaymentProposalResponse;
import me.figo.models.Security;
import me.figo.models.Service;
import me.figo.models.ServiceLoginSettings;
import me.figo.models.StandingOrder;
import me.figo.models.Transaction;
import me.figo.models.User;

/**
* Main entry point to the data access-part of the figo connect java library.
Expand Down Expand Up @@ -347,6 +368,20 @@ public Account getAccount(String accountId) throws FigoException, IOException {
return this.queryApi("/rest/accounts/" + accountId, null, "GET", Account.class);
}

/**
* Modify an account
*
* @param account
* the modified account to be saved
* @return Account object for the updated account returned by server
*
* @exception FigoException Base class for all figoExceptions
* @exception IOException IOException
*/
public Account updateAccount(Account account) throws FigoException, IOException {
return this.queryApi("/rest/accounts/" + account.getAccountId(), account, "PUT", Account.class);
}

/**
* Remove an account
*
Expand Down Expand Up @@ -1400,14 +1435,6 @@ public void cancelTask(String taskToken) throws FigoException, IOException {
@Override
protected <T> T processResponse(HttpURLConnection connection, Type typeOfT) throws IOException, FigoException {
// process response

try {
@SuppressWarnings("unused")
int code = connection.getResponseCode();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return super.processResponse(connection, typeOfT);
}
}
2 changes: 1 addition & 1 deletion src/main/java/me/figo/internal/FigoTrustManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class FigoTrustManager implements X509TrustManager {

private static final List<String> VALID_FINGERPRINTS = new ArrayList<String>(Arrays.asList(
"070F14AEB94AFB3DF800E82B69A8515CEED2F5B1BA897BEF6432458F61CF9E33",
"CDF3D326278991B9CDAE4B106C9681B7EBB33810C472376A4D9C84B7B3DCD68D",
"79B2A29300853B0692B1B5F2247948583AA5220FC5CDE9499AC8451EDBE0DA50"));

/**
Expand Down
22 changes: 10 additions & 12 deletions src/test/java/me/figo/APITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.Arrays;
import java.util.List;


import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
Expand Down Expand Up @@ -131,15 +130,14 @@ public void testWrongCredentialsErrorMessage() throws FigoException, IOException
}
}

@Test
public void testGetErrorMessage() throws IOException {
try {
FigoSession fs = new FigoSession(accessToken.access_token);
Account acc = fs.getAccount("666");
fail(acc.getName());
}
catch(FigoException e) {
assertEquals("The requested object does not exist.", e.getErrorDescription());
}
}
@Test
public void testGetErrorMessage() throws IOException {
try {
FigoSession fs = new FigoSession(accessToken.access_token);
Account acc = fs.getAccount("666");
fail(acc.getName());
} catch (FigoException e) {
assertEquals("The requested object does not exist.", e.getErrorDescription());
}
}
}