fragment-alpha-sdk 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fragment_client.rb +18 -4
- data/lib/queries.graphql +271 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123eb6ee84493101bbe1b79713f786d25ec62f30adfe298684f698d60058cca4
|
4
|
+
data.tar.gz: 1ab1324fe497737d22abd0d0c4e9a49456ae30897fb4057d20183545b57d1262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d38fdf8f38acfbec7a8561f1cae835cf8727e2fb724ec28cfeadc9878559eb5d1e1cff0d9384ac43e74ded16b22af255c2487fb4ef27cd7b7d0db26a78b30eb
|
7
|
+
data.tar.gz: a576073d63e2faa3e0ccda0263d41addc835a9f0404791570283b9f71acd1e2cd7b4ad9ea5c40d02e881635544888ab67ab6cb9e5373eca8a03a39629c7a1f33
|
data/lib/fragment_client.rb
CHANGED
@@ -15,7 +15,7 @@ module FragmentGraphQl
|
|
15
15
|
extend T::Sig
|
16
16
|
sig { params(context: T.untyped).returns(T::Hash[T.untyped, T.untyped]) }
|
17
17
|
def headers(context)
|
18
|
-
{ 'Authorization' => 'Bearer %s'
|
18
|
+
{ 'Authorization' => 'Bearer %s' % context[:access_token] }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -24,7 +24,7 @@ module FragmentGraphQl
|
|
24
24
|
Client = T.let(GraphQL::Client.new(schema: Schema, execute: http), GraphQL::Client)
|
25
25
|
|
26
26
|
Queries = T.let(Client.parse(
|
27
|
-
File.
|
27
|
+
File.read("#{__dir__}/queries.graphql")
|
28
28
|
), T.untyped)
|
29
29
|
end
|
30
30
|
|
@@ -32,8 +32,8 @@ end
|
|
32
32
|
class FragmentClient
|
33
33
|
extend T::Sig
|
34
34
|
|
35
|
-
sig { params(client_id: String, client_secret: String).void }
|
36
|
-
def initialize(client_id, client_secret)
|
35
|
+
sig { params(client_id: String, client_secret: String, extra_queries_filename: T.nilable(String)).void }
|
36
|
+
def initialize(client_id, client_secret, extra_queries_filename: nil)
|
37
37
|
conn = create_conn(client_id, client_secret)
|
38
38
|
@token = T.let(get_token(conn, client_id), String)
|
39
39
|
FragmentGraphQl::Queries.constants.each do |q|
|
@@ -44,6 +44,20 @@ class FragmentClient
|
|
44
44
|
query(FragmentGraphQl::Queries.const_get(q), v)
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
return if extra_queries_filename.nil?
|
49
|
+
|
50
|
+
queries = FragmentGraphQl::Client.parse(
|
51
|
+
File.read(extra_queries_filename)
|
52
|
+
)
|
53
|
+
queries.constants.each do |q|
|
54
|
+
name = q.to_s.gsub(/[a-z]([A-Z])/) do |m|
|
55
|
+
format('%<lower>s_%<upper>s', lower: m[0], upper: m[1].downcase)
|
56
|
+
end.gsub(/^[A-Z]/, &:downcase)
|
57
|
+
define_singleton_method(name) do |v|
|
58
|
+
query(queries.const_get(q), v)
|
59
|
+
end
|
60
|
+
end
|
47
61
|
end
|
48
62
|
|
49
63
|
def create_conn(client_id, client_secret)
|
data/lib/queries.graphql
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
mutation CreateLedger($ik: ID!, $ledger: CreateLedgerInput!) {
|
2
2
|
createLedger(ik: $ik, ledger: $ledger) {
|
3
|
+
__typename
|
3
4
|
... on CreateLedgerResult {
|
4
5
|
ledger {
|
5
6
|
id
|
@@ -36,6 +37,175 @@ mutation CreateLedgerAccounts(
|
|
36
37
|
isIkReplay
|
37
38
|
}
|
38
39
|
}
|
40
|
+
... on BadRequestError {
|
41
|
+
code
|
42
|
+
message
|
43
|
+
}
|
44
|
+
... on InternalError {
|
45
|
+
code
|
46
|
+
message
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
mutation ReconcileTx($entry: LedgerEntryInput!) {
|
52
|
+
reconcileTx(entry: $entry) {
|
53
|
+
__typename
|
54
|
+
... on ReconcileTxResult {
|
55
|
+
entry {
|
56
|
+
id
|
57
|
+
date
|
58
|
+
description
|
59
|
+
}
|
60
|
+
lines {
|
61
|
+
id
|
62
|
+
date
|
63
|
+
amount
|
64
|
+
type
|
65
|
+
}
|
66
|
+
}
|
67
|
+
... on BadRequestError {
|
68
|
+
code
|
69
|
+
message
|
70
|
+
}
|
71
|
+
... on InternalError {
|
72
|
+
code
|
73
|
+
message
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
mutation AddLedgerEntry($entry: LedgerEntryInput!, $ik: ID!) {
|
79
|
+
addLedgerEntry(entry: $entry, ik: $ik) {
|
80
|
+
__typename
|
81
|
+
... on AddLedgerEntryResult {
|
82
|
+
entry {
|
83
|
+
id
|
84
|
+
date
|
85
|
+
description
|
86
|
+
}
|
87
|
+
lines {
|
88
|
+
id
|
89
|
+
date
|
90
|
+
description
|
91
|
+
amount
|
92
|
+
type
|
93
|
+
}
|
94
|
+
}
|
95
|
+
... on BadRequestError {
|
96
|
+
code
|
97
|
+
message
|
98
|
+
}
|
99
|
+
... on InternalError {
|
100
|
+
code
|
101
|
+
message
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
mutation UpdateLedger($ledger: LedgerMatchInput!, $update: UpdateLedgerInput!) {
|
107
|
+
updateLedger(ledger: $ledger, update: $update) {
|
108
|
+
__typename
|
109
|
+
... on UpdateLedgerResult {
|
110
|
+
ledger {
|
111
|
+
id
|
112
|
+
name
|
113
|
+
}
|
114
|
+
}
|
115
|
+
... on BadRequestError {
|
116
|
+
code
|
117
|
+
message
|
118
|
+
}
|
119
|
+
... on InternalError {
|
120
|
+
code
|
121
|
+
message
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
mutation UpdateLedgerAccount(
|
127
|
+
$ledgerAccount: LedgerAccountMatchInput!
|
128
|
+
$update: UpdateLedgerAccountInput!
|
129
|
+
) {
|
130
|
+
updateLedgerAccount(ledgerAccount: $ledgerAccount, update: $update) {
|
131
|
+
__typename
|
132
|
+
... on UpdateLedgerAccountResult {
|
133
|
+
ledgerAccount {
|
134
|
+
id
|
135
|
+
name
|
136
|
+
}
|
137
|
+
}
|
138
|
+
... on BadRequestError {
|
139
|
+
code
|
140
|
+
message
|
141
|
+
}
|
142
|
+
... on InternalError {
|
143
|
+
code
|
144
|
+
message
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
mutation NewCustomLink($name: String!, $ik: ID!) {
|
150
|
+
createCustomLink(name: $name, ik: $ik) {
|
151
|
+
__typename
|
152
|
+
... on CreateCustomLinkResult {
|
153
|
+
link {
|
154
|
+
id
|
155
|
+
name
|
156
|
+
}
|
157
|
+
isIkReplay
|
158
|
+
}
|
159
|
+
... on BadRequestError {
|
160
|
+
code
|
161
|
+
message
|
162
|
+
}
|
163
|
+
... on InternalError {
|
164
|
+
code
|
165
|
+
message
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
mutation SyncBankAccounts(
|
171
|
+
$link: LinkMatchInput!
|
172
|
+
$accounts: [CustomAccountInput!]!
|
173
|
+
) {
|
174
|
+
syncCustomAccounts(link: $link, accounts: $accounts) {
|
175
|
+
__typename
|
176
|
+
... on SyncCustomAccountsResult {
|
177
|
+
accounts {
|
178
|
+
id
|
179
|
+
externalId
|
180
|
+
name
|
181
|
+
currency {
|
182
|
+
code
|
183
|
+
customCurrencyId
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
... on BadRequestError {
|
188
|
+
code
|
189
|
+
message
|
190
|
+
}
|
191
|
+
... on InternalError {
|
192
|
+
code
|
193
|
+
message
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
mutation MakeBankTransfer($bankTransfer: MakeBankTransferInput!, $ik: ID!) {
|
199
|
+
makeBankTransfer(bankTransfer: $bankTransfer, ik: $ik) {
|
200
|
+
__typename
|
201
|
+
... on MakeBankTransferResult {
|
202
|
+
bankTransfer {
|
203
|
+
id
|
204
|
+
description
|
205
|
+
status
|
206
|
+
}
|
207
|
+
isIkReplay
|
208
|
+
}
|
39
209
|
... on Error {
|
40
210
|
code
|
41
211
|
message
|
@@ -108,22 +278,112 @@ query Ledger($ledger: LedgerMatchInput!) {
|
|
108
278
|
}
|
109
279
|
}
|
110
280
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
281
|
+
query GetLedgerAccounts(
|
282
|
+
$ledgerId: ID!
|
283
|
+
$after: String
|
284
|
+
$first: Int
|
285
|
+
$before: String
|
286
|
+
) {
|
287
|
+
ledger(ledger: { id: $ledgerId }) {
|
288
|
+
id
|
289
|
+
name
|
290
|
+
ledgerAccounts(after: $after, first: $first, before: $before) {
|
291
|
+
nodes {
|
116
292
|
id
|
293
|
+
name
|
294
|
+
type
|
295
|
+
}
|
296
|
+
pageInfo {
|
297
|
+
hasNextPage
|
298
|
+
endCursor
|
299
|
+
hasPreviousPage
|
300
|
+
startCursor
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
query GetAccountLinesOnDate(
|
307
|
+
$ledgerAccountId: ID!
|
308
|
+
$filter: LedgerLinesFilterSet
|
309
|
+
) {
|
310
|
+
ledgerAccount(ledgerAccount: { id: $ledgerAccountId }) {
|
311
|
+
lines(filter: $filter) {
|
312
|
+
nodes {
|
313
|
+
id
|
314
|
+
posted
|
117
315
|
date
|
316
|
+
amount
|
317
|
+
description
|
318
|
+
ledgerEntryId
|
118
319
|
}
|
119
320
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
query GetLedgerEntries($ledgerAccountId: ID!, $filter: LedgerLinesFilterSet) {
|
325
|
+
ledgerAccount(ledgerAccount: { id: $ledgerAccountId }) {
|
326
|
+
lines(filter: $filter) {
|
327
|
+
nodes {
|
328
|
+
id
|
329
|
+
posted
|
330
|
+
date
|
331
|
+
amount
|
332
|
+
description
|
333
|
+
ledgerEntryId
|
334
|
+
}
|
123
335
|
}
|
124
|
-
|
125
|
-
|
126
|
-
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
query GetLinkedLedgerAccounts(
|
340
|
+
$ledgerId: ID!
|
341
|
+
$filter: LedgerAccountsFilterSet!
|
342
|
+
) {
|
343
|
+
ledger(ledger: { id: $ledgerId }) {
|
344
|
+
id
|
345
|
+
ledgerAccounts(filter: $filter) {
|
346
|
+
nodes {
|
347
|
+
id
|
348
|
+
name
|
349
|
+
linkedAccount {
|
350
|
+
id
|
351
|
+
name
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
query GetBalances($ledgerId: ID!) {
|
359
|
+
ledger(ledger: { id: $ledgerId }) {
|
360
|
+
ledgerAccounts {
|
361
|
+
nodes {
|
362
|
+
id
|
363
|
+
name
|
364
|
+
type
|
365
|
+
|
366
|
+
ownBalance
|
367
|
+
childBalance
|
368
|
+
balance
|
369
|
+
|
370
|
+
childBalances {
|
371
|
+
nodes {
|
372
|
+
currency {
|
373
|
+
code
|
374
|
+
}
|
375
|
+
amount
|
376
|
+
}
|
377
|
+
}
|
378
|
+
balances {
|
379
|
+
nodes {
|
380
|
+
currency {
|
381
|
+
code
|
382
|
+
}
|
383
|
+
amount
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
127
387
|
}
|
128
388
|
}
|
129
389
|
}
|