Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
devton committed Jun 25, 2024
1 parent 2133710 commit a72ad15
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,46 @@ If bundler is not being used to manage dependencies, install the gem by executin
## Usage

TODO:
- Client
- Create Ledger
- Find Ledger
- Create Balances
- Find Balances
- Create Transactions
- Find Transactions
- Do Search
- [x] Create Ledger
- [x] Find Ledger
- [ ] Create Balances
- [ ] Find Balances
- [ ] Create Transactions
- [ ] Find Transactions
- [ ] Do Search

## Configuration
## Client connection

```
Blnk.address = 'localhost:4444'
Blnk.secret_token = 'secret_token'
Blnk.search_api_key = 'secret_api_key'
require 'blnk'
Blnk.address = '192.168.2.7:5001'
Blnk.secret_token = 'your_strong_secret_key'
Blnk.search_api_key = Blnk.secret_token
```


## Ledger usage

```
ledger = Blnk::Ledger.new(name: 'ledger_name', metadata: { customer_id: 'mycustomerid' })
ledger.save
ledger = Blnk::Ledger.create(name: 'ledger_name', metadata: { customer_id: 'mycustomerid' })
ledger = Blnk::Ledger.find('ledger_id')
ledger = Blnk::Ledger.new(name: 'foo bar').save
ledger = Blnk::Ledger.create(name: 'foobar')
ledger = Blnk::Ledger.find 'ledger_id'
ledgers = Blnk::Ledger.all
ledgers = Blnk::Ledger.search(
q: 'USD',
filter_by: 'balances > 1400',
sort_by: 'created_at:desc',
page: 1,
per_page: 50
)
```

## Creating a transaction

```
client.create_transaction(destination: 'bal_ref_id', source: '@world', allow_overdraft: true, inflight: false)
```


Expand Down
4 changes: 4 additions & 0 deletions lib/blnk/ledger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def self.all
end
end

def self.create(*)
new(*).save
end

def save
response = post_request(path: '/ledgers', body: body_data)
return response.parse unless response.status.success?
Expand Down

0 comments on commit a72ad15

Please sign in to comment.