File tree 2 files changed +20
-10
lines changed
2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,10 @@ TODO:
20
20
- [x] Create Ledger
21
21
- [x] Find Ledger
22
22
- [x] List Ledgers
23
- - [ ] Search Ledgers
23
+ - [x ] Search Ledgers
24
24
- [x] Create Balances
25
25
- [x] Find Balance
26
- - [ ] Search Balances
26
+ - [x ] Search Balances
27
27
- [ ] Create Transaction
28
28
- [ ] Find Transaction
29
29
- [ ] Search Transactions
@@ -45,14 +45,10 @@ ledger = Blnk::Ledger.create(name: 'foobar')
45
45
ledger = Blnk ::Ledger .find ' ledger_id'
46
46
ledgers = Blnk ::Ledger .all
47
47
48
- # search not implemented yet
49
- ledgers = Blnk ::Ledger .search(
50
- q: ' USD' ,
51
- filter_by: ' balances > 1400' ,
52
- sort_by: ' created_at:desc' ,
53
- page: 1 ,
54
- per_page: 50
55
- )
48
+ ledgers = Blnk ::Ledger .search(q: ' *' )
49
+
50
+ # for search fields check the documentation
51
+ https: // docs.blnkledger.com/ ledger/ tutorial/ search/ overview
56
52
57
53
58
54
# Balance integrations
Original file line number Diff line number Diff line change 3
3
module Blnk
4
4
# Resoureable module that bring some tweaks for basic REST api integration
5
5
class Resourceable < OpenStruct
6
+ class SearchResult < OpenStruct ; end
7
+
6
8
include Client
7
9
8
10
def self . resource_name = raise NotImplementedError
@@ -33,6 +35,18 @@ def self.create(*)
33
35
new ( response . parse )
34
36
end
35
37
38
+ def self . search ( **args )
39
+ response = new . post_request (
40
+ path : "/search/#{ resource_name } " ,
41
+ body : args
42
+ )
43
+ return response unless response . status . success?
44
+
45
+ sr = SearchResult . new ( response . parse )
46
+ sr . resource_name = resource_name
47
+ sr
48
+ end
49
+
36
50
def persisted? = raise NotImplementedError
37
51
def body_data = raise NotImplementedError
38
52
end
You can’t perform that action at this time.
0 commit comments