Skip to content

Commit 5f558f3

Browse files
committed
README
1 parent 59760af commit 5f558f3

File tree

1 file changed

+62
-6
lines changed

1 file changed

+62
-6
lines changed

README.md

+62-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Teller
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/teller`. To experiment with that code, run `bin/console` for an interactive prompt.
4-
5-
TODO: Delete this and the text above, and describe your gem
3+
The official Ruby language bindings for the Teller API.
64

75
## Installation
86

@@ -22,7 +20,66 @@ Or install it yourself as:
2220

2321
## Usage
2422

25-
TODO: Write usage instructions here
23+
First configure the library for your application
24+
25+
```ruby
26+
Teller::Config.setup do |c|
27+
c.certificate = "/path/to/teller/cert.pem"
28+
c.private_key = "/path/to/its/private_key.pem"
29+
c.access_token = "access-token-from-teller-connect-enrollment"
30+
end
31+
```
32+
33+
Statically configuring an access token might make sense if you're just building something using your own accounts, but it doesn't if you're building something for thousands of users, which is why you can also set your config when instantiating the client.
34+
35+
```ruby
36+
client = Teller::Client.new access_token: "test_token_ky6igyqi3qxa4"
37+
```
38+
39+
During instantiation the client will take whatever static config you've made (if any), and apply config given to the constructor. Config values supplied at instantiation will override conflicting statically configured values.
40+
41+
Now you have your client configured you can use it to explore the API.
42+
43+
```ruby
44+
account = client.accounts.first
45+
# => #<Teller::Resource type="credit", subtype="credit_card", status="open", name="Platinum Card", links={"transactions"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000/transactions", "self"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000", "balances"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000/balances"}, last_four="7857", institution={"name"=>"Security Credit Union", "id"=>"security_cu"}, id="acc_oiin624kqjrg2mp2ea000", enrollment_id="enr_oiin624rqaojse22oe000", currency="USD">
46+
47+
account.name
48+
# => "Platinum Card"
49+
```
50+
51+
You can easily load related resources linked to in the "links" section of the API response"
52+
53+
```ruby
54+
account.balances
55+
# => #<Teller::Resource links={"self"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000/balances", "account"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000"}, ledger="4698.93", available="204.12", account_id="acc_oiin624kqjrg2mp2ea000">
56+
57+
account.transactions
58+
# => [#<Teller::Resource type="card_payment", status="pending", running_balance=nil, links={"self"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000/transactions/txn_oj0t0gfqpvj7favgn8000", "account"=>"https://api.teller.io/accounts/acc_oiin624kqjrg2mp2ea000"}, id="txn_oj0t0gfqpvj7favgn8000", details={"processing_status"=>"complete", "counterparty"=>{"type"=>"organization", "name"=>"WILLIAMS-SONOMA"}, "category"=>"shopping"}, description="Williams-Sonoma", date="2023-07-23", amount="96.95", account_id="acc_oiin624kqjrg2mp2ea000">, ...]
59+
```
60+
61+
You can also fetch arbitrary members of a collection resource
62+
63+
```ruby
64+
client.accounts.get("acc_oiin624jqjrg2mp2ea000")
65+
# => #<Teller::Resource type="depository", subtype="savings", status="open", name="Essential Savings", links={"transactions"=>"https://api.teller.io/accounts/acc_oiin624jqjrg2mp2ea000/transactions", "self"=>"https://api.teller.io/accounts/acc_oiin624jqjrg2mp2ea000", "details"=>"https://api.teller.io/accounts/acc_oiin624jqjrg2mp2ea000/details", "balances"=>"https://api.teller.io/accounts/acc_oiin624jqjrg2mp2ea000/balances"}, last_four="3528", institution={"name"=>"Security Credit Union", "id"=>"security_cu"}, id="acc_oiin624jqjrg2mp2ea000", enrollment_id="enr_oiin624rqaojse22oe000", currency="USD">
66+
```
67+
68+
The client caches API responses after the first time you invoke a method that requests a given resource. To force the client to redo the request you can call reload
69+
70+
```ruby
71+
# When called the first time the client will make a request to the Teller API
72+
client.accounts
73+
74+
# On subsequent invocations locally cached data is returned
75+
client.accounts
76+
client.accounts
77+
client.accounts
78+
79+
# Calling reload will always result in a new API request
80+
client.accounts.reload
81+
```
82+
2683

2784
## Development
2885

@@ -32,8 +89,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3289

3390
## Contributing
3491

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/teller.
36-
92+
Bug reports and pull requests are welcome on GitHub at https://github.com/tellerhq/teller-ruby.
3793

3894
## License
3995

0 commit comments

Comments
 (0)