Skip to content

Commit fd9ff05

Browse files
authored
Merge pull request #32 from sebinsua/fix/changes-to-teller-api
Changes in response to changes within the Teller API
2 parents 10a367c + 6424d93 commit fd9ff05

File tree

8 files changed

+253
-166
lines changed

8 files changed

+253
-166
lines changed

Cargo.lock

Lines changed: 60 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "teller_cli"
3-
version = "0.0.8"
3+
version = "0.0.9"
44
authors = ["Seb Insua <me@sebinsua.com>"]
55

66
[[bin]]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,9 @@ This relates to the following error:
181181
src/openssl_shim.c:1:10: fatal error: 'openssl/hmac.h' file not found
182182
#include <openssl/hmac.h>
183183
```
184+
185+
If `brew` complains about not being able to force-link `openssl` then you could try building like this:
186+
187+
```sh
188+
OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include DEP_OPENSSL_INCLUDE=/usr/local/opt/openssl/include cargo build
189+
```

src/api/client.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,33 @@ use api::error::TellerClientError;
99

1010
pub type ApiServiceResult<T> = Result<T, TellerClientError>;
1111

12-
#[derive(Debug, RustcDecodable)]
13-
struct AccountResponse {
14-
data: Account,
15-
}
12+
type AccountResponse = Account;
1613

17-
#[derive(Debug, RustcDecodable)]
18-
struct AccountsResponse {
19-
data: Vec<Account>,
20-
}
14+
type AccountsResponse = Vec<Account>;
2115

22-
#[derive(Debug, RustcDecodable)]
23-
struct TransactionsResponse {
24-
data: Vec<Transaction>,
25-
}
16+
type TransactionsResponse = Vec<Transaction>;
2617

2718
#[derive(Debug, RustcDecodable, Clone)]
2819
pub struct Account {
29-
pub name: String,
30-
pub institution: String,
31-
pub id: String,
32-
pub currency: String,
33-
pub bank_code: String,
20+
pub account_number: String,
3421
pub balance: String,
35-
pub account_number_last_4: String,
22+
pub bank_code: String,
23+
pub currency: String,
24+
// pub enrollment_id: String,
25+
pub id: String,
26+
pub institution: String,
27+
pub name: String,
3628
}
3729

3830
#[derive(Debug, RustcDecodable, Clone)]
3931
pub struct Transaction {
40-
pub description: String,
41-
pub date: String,
42-
pub counterparty: String,
4332
pub amount: String,
33+
pub counterparty: String,
34+
pub date: String,
35+
pub description: String,
36+
// pub id: String,
37+
// pub running_balance: String,
38+
// pub type: String,
4439
}
4540

4641
pub fn parse_utc_date_from_transaction(t: &Transaction) -> Date<UTC> {
@@ -100,14 +95,14 @@ impl<'a> TellerClient<'a> {
10095
let body = try!(self.get_body(&format!("{}/accounts", TELLER_API_SERVER_URL)));
10196
let accounts_response: AccountsResponse = try!(json::decode(&body));
10297

103-
Ok(accounts_response.data)
98+
Ok(accounts_response)
10499
}
105100

106101
pub fn get_account(&self, account_id: &str) -> ApiServiceResult<Account> {
107102
let body = try!(self.get_body(&format!("{}/accounts/{}", TELLER_API_SERVER_URL, account_id)));
108103
let account_response: AccountResponse = try!(json::decode(&body));
109104

110-
Ok(account_response.data)
105+
Ok(account_response)
111106
}
112107

113108
pub fn raw_transactions(&self,
@@ -127,7 +122,7 @@ impl<'a> TellerClient<'a> {
127122
let body = try!(self.get_body(&url.as_str()));
128123
let transactions_response: TransactionsResponse = try!(json::decode(&body));
129124

130-
Ok(transactions_response.data)
125+
Ok(transactions_response)
131126
}
132127

133128
#[allow(unused_variables)]
@@ -215,7 +210,7 @@ mod tests {
215210
currency: "GBP".to_string(),
216211
bank_code: "00000000".to_string(),
217212
balance: "1000.00".to_string(),
218-
account_number_last_4: "0000".to_string(),
213+
account_number: "00000000".to_string(),
219214
};
220215
assert!(true);
221216
}
@@ -256,7 +251,7 @@ mod tests {
256251
assert_eq!("1000.00", account.balance);
257252
assert_eq!("GBP", account.currency);
258253
assert_eq!("000000", account.bank_code);
259-
assert_eq!("0000", account.account_number_last_4);
254+
assert_eq!("00000000", account.account_number);
260255
}
261256

262257
#[test]

src/api/mocks/get-account.http

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ server: Teller API
66
Connection: keep-alive
77

88
{
9-
"data":{
10-
"refreshed_at":"2016-01-28T02:19:22Z",
11-
"name":"current",
12-
"links":{
13-
"transactions":"https://api.teller.io/accounts/123/transactions",
14-
"self":"https://api.teller.io/accounts/123",
15-
"direct_debits":"https://api.teller.io/accounts/123/direct_debits"
16-
},
17-
"institution":"natwest",
18-
"id":"123",
19-
"currency":"GBP",
20-
"bank_code":"000000",
21-
"balance":"1000.00",
22-
"account_number_last_4":"0000"
23-
}
9+
"account_number":"00000000",
10+
"balance":"1000.00",
11+
"bank_code":"000000",
12+
"currency":"GBP",
13+
"enrollment_id":"123",
14+
"id":"123",
15+
"institution":"natwest",
16+
"links":{
17+
"direct_debits":"https://api.teller.io/accounts/123/direct_debits",
18+
"payees": "https://api.teller.io/accounts/123/payees",
19+
"self":"https://api.teller.io/accounts/123",
20+
"standing_orders":"https://api.teller.io/accounts/123/standing_orders",
21+
"transactions":"https://api.teller.io/accounts/123/transactions"
22+
},
23+
"name":"current"
2424
}

src/api/mocks/get-accounts.http

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,39 @@ date: Thu, 28 Jan 2016 13:00:51 GMT
55
server: Teller API
66
Connection: keep-alive
77

8-
{
9-
"meta":{
10-
"pagination":{
11-
"prev":null,
12-
"next":null,
13-
"last":"https://api.teller.io/accounts?page=1&page_size=250",
14-
"first":"https://api.teller.io/accounts?page=1&page_size=250"
15-
}
16-
},
17-
"links":{
18-
"self":"https://api.teller.io/accounts?page=1&page_size=250"
19-
},
20-
"data":[
21-
{
22-
"refreshed_at":"2016-01-10T01:09:12Z",
23-
"name":"Savings",
24-
"links":{
25-
"transactions":"https://api.teller.io/accounts/123/transactions",
26-
"self":"https://api.teller.io/accounts/123",
27-
"direct_debits":"https://api.teller.io/accounts/123/direct_debits"
28-
},
29-
"institution":"natwest",
30-
"id":"123",
31-
"currency":"GBP",
32-
"bank_code":"000000",
33-
"balance":"10000.00",
34-
"account_number_last_4":"0000"
35-
},
36-
{
37-
"refreshed_at":"2016-01-10T01:09:13Z",
38-
"name":"Current",
39-
"links":{
40-
"transactions":"https://api.teller.io/accounts/456/transactions",
41-
"self":"https://api.teller.io/accounts/456",
42-
"direct_debits":"https://api.teller.io/accounts/456/direct_debits"
43-
},
44-
"institution":"natwest",
45-
"id":"456",
46-
"currency":"GBP",
47-
"bank_code":"000001",
48-
"balance":"1000.00",
49-
"account_number_last_4":"0001"
50-
}
51-
]
52-
}
8+
[
9+
{
10+
"account_number":"00000000",
11+
"balance":"10000.00",
12+
"bank_code":"000000",
13+
"currency":"GBP",
14+
"enrollment_id":"123",
15+
"id":"123",
16+
"institution":"natwest",
17+
"links":{
18+
"direct_debits":"https://api.teller.io/accounts/123/direct_debits",
19+
"payees": "https://api.teller.io/accounts/123/payees",
20+
"self":"https://api.teller.io/accounts/123",
21+
"standing_orders":"https://api.teller.io/accounts/123/standing_orders",
22+
"transactions":"https://api.teller.io/accounts/123/transactions"
23+
},
24+
"name":"Savings"
25+
},
26+
{
27+
"account_number":"00000000",
28+
"balance":"1000.00",
29+
"bank_code":"000000",
30+
"currency":"GBP",
31+
"enrollment_id":"456",
32+
"id":"456",
33+
"institution":"natwest",
34+
"links":{
35+
"direct_debits":"https://api.teller.io/accounts/456/direct_debits",
36+
"payees": "https://api.teller.io/accounts/456/payees",
37+
"self":"https://api.teller.io/accounts/456",
38+
"standing_orders":"https://api.teller.io/accounts/456/standing_orders",
39+
"transactions":"https://api.teller.io/accounts/456/transactions"
40+
},
41+
"name":"Current"
42+
}
43+
]

0 commit comments

Comments
 (0)