fluidattacks_zoho_sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fluidattacks_zoho_sdk might be problematic. Click here for more details.
- fluidattacks_zoho_sdk-1.0.0/.envrc +3 -0
- fluidattacks_zoho_sdk-1.0.0/PKG-INFO +9 -0
- fluidattacks_zoho_sdk-1.0.0/build/default.nix +7 -0
- fluidattacks_zoho_sdk-1.0.0/build/filter.nix +12 -0
- fluidattacks_zoho_sdk-1.0.0/flake.lock +351 -0
- fluidattacks_zoho_sdk-1.0.0/flake.nix +19 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/__init__.py +8 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/_decoders.py +177 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/__init__.py +51 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/_access.py +86 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/_core.py +39 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/_decode.py +62 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/_refresh.py +123 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/auth/_revoke.py +98 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/ids.py +59 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/py.typed +0 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/zoho_desk/__init__.py +0 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/zoho_desk/_decode.py +192 -0
- fluidattacks_zoho_sdk-1.0.0/fluidattacks_zoho_sdk/zoho_desk/core.py +117 -0
- fluidattacks_zoho_sdk-1.0.0/mypy.ini +30 -0
- fluidattacks_zoho_sdk-1.0.0/pyproject.toml +27 -0
- fluidattacks_zoho_sdk-1.0.0/ruff.toml +37 -0
- fluidattacks_zoho_sdk-1.0.0/tests/__init__.py +0 -0
- fluidattacks_zoho_sdk-1.0.0/tests/arch/__init__.py +0 -0
- fluidattacks_zoho_sdk-1.0.0/tests/arch/arch.py +47 -0
- fluidattacks_zoho_sdk-1.0.0/tests/arch/test_arch.py +43 -0
- fluidattacks_zoho_sdk-1.0.0/tests/desk/__init__.py +0 -0
- fluidattacks_zoho_sdk-1.0.0/tests/desk/data_agent.json +24 -0
- fluidattacks_zoho_sdk-1.0.0/tests/desk/data_contact.json +42 -0
- fluidattacks_zoho_sdk-1.0.0/tests/desk/data_ticket.json +100 -0
- fluidattacks_zoho_sdk-1.0.0/tests/desk/test_decode.py +146 -0
- fluidattacks_zoho_sdk-1.0.0/tests/py.typed +0 -0
- fluidattacks_zoho_sdk-1.0.0/uv.lock +752 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fluidattacks_zoho_sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: zoho SDK
|
|
5
|
+
Author-email: Product Team <development@fluidattacks.com>
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: fa-purity >=2.5.0, <3.0.0
|
|
8
|
+
Requires-Dist: fluidattacks-etl-utils >=1.0.0, <2.0.0
|
|
9
|
+
Requires-Dist: pure-requests >=3.0.0, <4.0.0
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": {
|
|
3
|
+
"flake-parts": {
|
|
4
|
+
"inputs": {
|
|
5
|
+
"nixpkgs-lib": "nixpkgs-lib"
|
|
6
|
+
},
|
|
7
|
+
"locked": {
|
|
8
|
+
"lastModified": 1754487366,
|
|
9
|
+
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
|
|
10
|
+
"owner": "hercules-ci",
|
|
11
|
+
"repo": "flake-parts",
|
|
12
|
+
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
|
|
13
|
+
"type": "github"
|
|
14
|
+
},
|
|
15
|
+
"original": {
|
|
16
|
+
"owner": "hercules-ci",
|
|
17
|
+
"repo": "flake-parts",
|
|
18
|
+
"type": "github"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"nix_filter": {
|
|
22
|
+
"locked": {
|
|
23
|
+
"lastModified": 1731533336,
|
|
24
|
+
"narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
|
|
25
|
+
"owner": "numtide",
|
|
26
|
+
"repo": "nix-filter",
|
|
27
|
+
"rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
|
|
28
|
+
"type": "github"
|
|
29
|
+
},
|
|
30
|
+
"original": {
|
|
31
|
+
"owner": "numtide",
|
|
32
|
+
"repo": "nix-filter",
|
|
33
|
+
"type": "github"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"nix_filter_2": {
|
|
37
|
+
"locked": {
|
|
38
|
+
"lastModified": 1731533336,
|
|
39
|
+
"narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
|
|
40
|
+
"owner": "numtide",
|
|
41
|
+
"repo": "nix-filter",
|
|
42
|
+
"rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
|
|
43
|
+
"type": "github"
|
|
44
|
+
},
|
|
45
|
+
"original": {
|
|
46
|
+
"owner": "numtide",
|
|
47
|
+
"repo": "nix-filter",
|
|
48
|
+
"type": "github"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"nixpkgs": {
|
|
52
|
+
"locked": {
|
|
53
|
+
"lastModified": 1736441877,
|
|
54
|
+
"narHash": "sha256-m3+PhBFkDwqo9lBplG4AyMW8P4/KcioJRS1UG8N7okM=",
|
|
55
|
+
"owner": "nixos",
|
|
56
|
+
"repo": "nixpkgs",
|
|
57
|
+
"rev": "ce3899414dab3297cf025bfa356dc2da426feefd",
|
|
58
|
+
"type": "github"
|
|
59
|
+
},
|
|
60
|
+
"original": {
|
|
61
|
+
"owner": "nixos",
|
|
62
|
+
"repo": "nixpkgs",
|
|
63
|
+
"type": "github"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"nixpkgs-lib": {
|
|
67
|
+
"locked": {
|
|
68
|
+
"lastModified": 1753579242,
|
|
69
|
+
"narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=",
|
|
70
|
+
"owner": "nix-community",
|
|
71
|
+
"repo": "nixpkgs.lib",
|
|
72
|
+
"rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e",
|
|
73
|
+
"type": "github"
|
|
74
|
+
},
|
|
75
|
+
"original": {
|
|
76
|
+
"owner": "nix-community",
|
|
77
|
+
"repo": "nixpkgs.lib",
|
|
78
|
+
"type": "github"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"nixpkgs_2": {
|
|
82
|
+
"locked": {
|
|
83
|
+
"lastModified": 1758690382,
|
|
84
|
+
"narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
|
|
85
|
+
"owner": "nixos",
|
|
86
|
+
"repo": "nixpkgs",
|
|
87
|
+
"rev": "e643668fd71b949c53f8626614b21ff71a07379d",
|
|
88
|
+
"type": "github"
|
|
89
|
+
},
|
|
90
|
+
"original": {
|
|
91
|
+
"owner": "nixos",
|
|
92
|
+
"ref": "nixos-unstable",
|
|
93
|
+
"repo": "nixpkgs",
|
|
94
|
+
"type": "github"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"nixpkgs_3": {
|
|
98
|
+
"locked": {
|
|
99
|
+
"lastModified": 1758690382,
|
|
100
|
+
"narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
|
|
101
|
+
"owner": "nixos",
|
|
102
|
+
"repo": "nixpkgs",
|
|
103
|
+
"rev": "e643668fd71b949c53f8626614b21ff71a07379d",
|
|
104
|
+
"type": "github"
|
|
105
|
+
},
|
|
106
|
+
"original": {
|
|
107
|
+
"owner": "nixos",
|
|
108
|
+
"ref": "nixos-unstable",
|
|
109
|
+
"repo": "nixpkgs",
|
|
110
|
+
"type": "github"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"nixpkgs_4": {
|
|
114
|
+
"locked": {
|
|
115
|
+
"lastModified": 1761373498,
|
|
116
|
+
"narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=",
|
|
117
|
+
"owner": "nixos",
|
|
118
|
+
"repo": "nixpkgs",
|
|
119
|
+
"rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce",
|
|
120
|
+
"type": "github"
|
|
121
|
+
},
|
|
122
|
+
"original": {
|
|
123
|
+
"owner": "nixos",
|
|
124
|
+
"ref": "nixos-unstable",
|
|
125
|
+
"repo": "nixpkgs",
|
|
126
|
+
"type": "github"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"nixpkgs_flake": {
|
|
130
|
+
"locked": {
|
|
131
|
+
"lastModified": 1756313514,
|
|
132
|
+
"narHash": "sha256-3Xbak0pXR8ziNv1ghHyJ5a5Ti2kt/LWq6hKZVJTvjBs=",
|
|
133
|
+
"owner": "nixos",
|
|
134
|
+
"repo": "nixpkgs",
|
|
135
|
+
"rev": "181464235b2daff8725773fef43ffc9d6b02e1c2",
|
|
136
|
+
"type": "github"
|
|
137
|
+
},
|
|
138
|
+
"original": {
|
|
139
|
+
"owner": "nixos",
|
|
140
|
+
"repo": "nixpkgs",
|
|
141
|
+
"type": "github"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"observes_flake_builder": {
|
|
145
|
+
"inputs": {
|
|
146
|
+
"nix_filter": "nix_filter",
|
|
147
|
+
"nixpkgs_flake": "nixpkgs_flake",
|
|
148
|
+
"pynix_flake": "pynix_flake",
|
|
149
|
+
"pyproject-build-systems": "pyproject-build-systems",
|
|
150
|
+
"pyproject-nix": "pyproject-nix_2",
|
|
151
|
+
"shell-helpers": "shell-helpers",
|
|
152
|
+
"uv2nix": "uv2nix_2"
|
|
153
|
+
},
|
|
154
|
+
"locked": {
|
|
155
|
+
"dir": "observes/common/std_flake_2",
|
|
156
|
+
"lastModified": 1761684858,
|
|
157
|
+
"narHash": "sha256-gybMRO/MSOPXQjI//u2UKfvs8pD0sACqL2Kjp+xR4rI=",
|
|
158
|
+
"owner": "fluidattacks",
|
|
159
|
+
"repo": "universe",
|
|
160
|
+
"rev": "c5053864bb838edbe226d74a650d901c0270843b",
|
|
161
|
+
"type": "github"
|
|
162
|
+
},
|
|
163
|
+
"original": {
|
|
164
|
+
"dir": "observes/common/std_flake_2",
|
|
165
|
+
"owner": "fluidattacks",
|
|
166
|
+
"repo": "universe",
|
|
167
|
+
"rev": "c5053864bb838edbe226d74a650d901c0270843b",
|
|
168
|
+
"type": "github"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"pynix_flake": {
|
|
172
|
+
"inputs": {
|
|
173
|
+
"nix_filter": "nix_filter_2",
|
|
174
|
+
"nixpkgs": "nixpkgs"
|
|
175
|
+
},
|
|
176
|
+
"locked": {
|
|
177
|
+
"lastModified": 1758642502,
|
|
178
|
+
"narHash": "sha256-PD/bQMz2dqZSkydHyvRh+jS/0qoV8SdcIVs6sassteQ=",
|
|
179
|
+
"owner": "dmurciaatfluid",
|
|
180
|
+
"repo": "python_nix_builder",
|
|
181
|
+
"rev": "809aafe2e1995e72c15378d099bf251b78f04a20",
|
|
182
|
+
"type": "gitlab"
|
|
183
|
+
},
|
|
184
|
+
"original": {
|
|
185
|
+
"owner": "dmurciaatfluid",
|
|
186
|
+
"repo": "python_nix_builder",
|
|
187
|
+
"type": "gitlab"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"pyproject-build-systems": {
|
|
191
|
+
"inputs": {
|
|
192
|
+
"nixpkgs": "nixpkgs_2",
|
|
193
|
+
"pyproject-nix": "pyproject-nix",
|
|
194
|
+
"uv2nix": "uv2nix"
|
|
195
|
+
},
|
|
196
|
+
"locked": {
|
|
197
|
+
"lastModified": 1759113590,
|
|
198
|
+
"narHash": "sha256-fgxP2RCN4cg0jYiMYoETYc7TZ2JjgyvJa2y9l8oSUFE=",
|
|
199
|
+
"owner": "pyproject-nix",
|
|
200
|
+
"repo": "build-system-pkgs",
|
|
201
|
+
"rev": "dbfc0483b5952c6b86e36f8b3afeb9dde30ea4b5",
|
|
202
|
+
"type": "github"
|
|
203
|
+
},
|
|
204
|
+
"original": {
|
|
205
|
+
"owner": "pyproject-nix",
|
|
206
|
+
"repo": "build-system-pkgs",
|
|
207
|
+
"type": "github"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"pyproject-nix": {
|
|
211
|
+
"inputs": {
|
|
212
|
+
"nixpkgs": [
|
|
213
|
+
"observes_flake_builder",
|
|
214
|
+
"pyproject-build-systems",
|
|
215
|
+
"nixpkgs"
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
"locked": {
|
|
219
|
+
"lastModified": 1758265079,
|
|
220
|
+
"narHash": "sha256-amLaLNwKSZPShQHzfgmc/9o76dU8xzN0743dWgvYlr8=",
|
|
221
|
+
"owner": "nix-community",
|
|
222
|
+
"repo": "pyproject.nix",
|
|
223
|
+
"rev": "02e9418fd4af638447dca4b17b1280da95527fc9",
|
|
224
|
+
"type": "github"
|
|
225
|
+
},
|
|
226
|
+
"original": {
|
|
227
|
+
"owner": "nix-community",
|
|
228
|
+
"repo": "pyproject.nix",
|
|
229
|
+
"type": "github"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"pyproject-nix_2": {
|
|
233
|
+
"inputs": {
|
|
234
|
+
"nixpkgs": "nixpkgs_3"
|
|
235
|
+
},
|
|
236
|
+
"locked": {
|
|
237
|
+
"lastModified": 1760402624,
|
|
238
|
+
"narHash": "sha256-jF6UKLs2uGc2rtved8Vrt58oTWjTQoAssuYs/0578Z4=",
|
|
239
|
+
"owner": "pyproject-nix",
|
|
240
|
+
"repo": "pyproject.nix",
|
|
241
|
+
"rev": "84c4ea102127c77058ea1ed7be7300261fafc7d2",
|
|
242
|
+
"type": "github"
|
|
243
|
+
},
|
|
244
|
+
"original": {
|
|
245
|
+
"owner": "pyproject-nix",
|
|
246
|
+
"repo": "pyproject.nix",
|
|
247
|
+
"type": "github"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"pyproject-nix_3": {
|
|
251
|
+
"inputs": {
|
|
252
|
+
"nixpkgs": [
|
|
253
|
+
"observes_flake_builder",
|
|
254
|
+
"uv2nix",
|
|
255
|
+
"nixpkgs"
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
"locked": {
|
|
259
|
+
"lastModified": 1760402624,
|
|
260
|
+
"narHash": "sha256-jF6UKLs2uGc2rtved8Vrt58oTWjTQoAssuYs/0578Z4=",
|
|
261
|
+
"owner": "pyproject-nix",
|
|
262
|
+
"repo": "pyproject.nix",
|
|
263
|
+
"rev": "84c4ea102127c77058ea1ed7be7300261fafc7d2",
|
|
264
|
+
"type": "github"
|
|
265
|
+
},
|
|
266
|
+
"original": {
|
|
267
|
+
"owner": "pyproject-nix",
|
|
268
|
+
"repo": "pyproject.nix",
|
|
269
|
+
"type": "github"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"root": {
|
|
273
|
+
"inputs": {
|
|
274
|
+
"observes_flake_builder": "observes_flake_builder"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"shell-helpers": {
|
|
278
|
+
"inputs": {
|
|
279
|
+
"flake-parts": "flake-parts",
|
|
280
|
+
"nixpkgs": [
|
|
281
|
+
"observes_flake_builder",
|
|
282
|
+
"nixpkgs_flake"
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
"locked": {
|
|
286
|
+
"dir": "common/utils/shell-helpers",
|
|
287
|
+
"lastModified": 1752896460,
|
|
288
|
+
"narHash": "sha256-AsyTatXMx839cGsF6knwTrDZHk3Eue2QD3eSP7bkmpg=",
|
|
289
|
+
"owner": "fluidattacks",
|
|
290
|
+
"repo": "universe",
|
|
291
|
+
"rev": "27749d2c3a2b018eb010a322e5e1352f993c9e86",
|
|
292
|
+
"type": "github"
|
|
293
|
+
},
|
|
294
|
+
"original": {
|
|
295
|
+
"dir": "common/utils/shell-helpers",
|
|
296
|
+
"owner": "fluidattacks",
|
|
297
|
+
"repo": "universe",
|
|
298
|
+
"rev": "27749d2c3a2b018eb010a322e5e1352f993c9e86",
|
|
299
|
+
"type": "github"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"uv2nix": {
|
|
303
|
+
"inputs": {
|
|
304
|
+
"nixpkgs": [
|
|
305
|
+
"observes_flake_builder",
|
|
306
|
+
"pyproject-build-systems",
|
|
307
|
+
"nixpkgs"
|
|
308
|
+
],
|
|
309
|
+
"pyproject-nix": [
|
|
310
|
+
"observes_flake_builder",
|
|
311
|
+
"pyproject-build-systems",
|
|
312
|
+
"pyproject-nix"
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
"locked": {
|
|
316
|
+
"lastModified": 1758933732,
|
|
317
|
+
"narHash": "sha256-HAmm1GBS1myZCFuog0DC2ZLaynvZtiUI2Crmo+cdQI0=",
|
|
318
|
+
"owner": "pyproject-nix",
|
|
319
|
+
"repo": "uv2nix",
|
|
320
|
+
"rev": "273ce18f913d8559e0d04f820d724308966d7c4d",
|
|
321
|
+
"type": "github"
|
|
322
|
+
},
|
|
323
|
+
"original": {
|
|
324
|
+
"owner": "pyproject-nix",
|
|
325
|
+
"repo": "uv2nix",
|
|
326
|
+
"type": "github"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"uv2nix_2": {
|
|
330
|
+
"inputs": {
|
|
331
|
+
"nixpkgs": "nixpkgs_4",
|
|
332
|
+
"pyproject-nix": "pyproject-nix_3"
|
|
333
|
+
},
|
|
334
|
+
"locked": {
|
|
335
|
+
"lastModified": 1761527626,
|
|
336
|
+
"narHash": "sha256-neDfvbpFlzUQfH9C+hVRUX0/RXUbJBidw4pFcdMYhZA=",
|
|
337
|
+
"owner": "pyproject-nix",
|
|
338
|
+
"repo": "uv2nix",
|
|
339
|
+
"rev": "46a8e8bbb2d9e34b686329ac16e4a8861394f03a",
|
|
340
|
+
"type": "github"
|
|
341
|
+
},
|
|
342
|
+
"original": {
|
|
343
|
+
"owner": "pyproject-nix",
|
|
344
|
+
"repo": "uv2nix",
|
|
345
|
+
"type": "github"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
"root": "root",
|
|
350
|
+
"version": 7
|
|
351
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
description = "Zoho API auth SDK";
|
|
3
|
+
|
|
4
|
+
inputs = {
|
|
5
|
+
observes_flake_builder = {
|
|
6
|
+
url =
|
|
7
|
+
"github:fluidattacks/universe/c5053864bb838edbe226d74a650d901c0270843b?shallow=1&dir=observes/common/std_flake_2";
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
outputs = { self, ... }@inputs:
|
|
12
|
+
let
|
|
13
|
+
build_args = { system, python_version, nixpkgs, builders, scripts }:
|
|
14
|
+
import ./build {
|
|
15
|
+
inherit nixpkgs builders scripts;
|
|
16
|
+
src = import ./build/filter.nix nixpkgs.nix-filter self;
|
|
17
|
+
};
|
|
18
|
+
in { packages = inputs.observes_flake_builder.outputs.build build_args; };
|
|
19
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
IO,
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
from fa_purity import Maybe, ResultE, Unsafe
|
|
6
|
+
from fa_purity.date_time import DatetimeUTC
|
|
7
|
+
from fa_purity.json import (
|
|
8
|
+
JsonObj,
|
|
9
|
+
JsonPrimitiveUnfolder,
|
|
10
|
+
JsonUnfolder,
|
|
11
|
+
UnfoldedFactory,
|
|
12
|
+
Unfolder,
|
|
13
|
+
)
|
|
14
|
+
from fluidattacks_etl_utils.decode import DecodeUtils
|
|
15
|
+
from fluidattacks_etl_utils.natural import Natural
|
|
16
|
+
|
|
17
|
+
from fluidattacks_zoho_sdk.auth import Credentials
|
|
18
|
+
from fluidattacks_zoho_sdk.ids import (
|
|
19
|
+
AccountId,
|
|
20
|
+
ContactId,
|
|
21
|
+
CrmId,
|
|
22
|
+
DeparmentId,
|
|
23
|
+
ProductId,
|
|
24
|
+
ProfileId,
|
|
25
|
+
RoleId,
|
|
26
|
+
TeamId,
|
|
27
|
+
TicketId,
|
|
28
|
+
UserId,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _decode_zoho_creds(raw: JsonObj) -> ResultE[Credentials]:
|
|
33
|
+
client_id = JsonUnfolder.require(raw, "client_id", Unfolder.to_primitive).bind(
|
|
34
|
+
JsonPrimitiveUnfolder.to_str,
|
|
35
|
+
)
|
|
36
|
+
client_secret = JsonUnfolder.require(raw, "client_secret", Unfolder.to_primitive).bind(
|
|
37
|
+
JsonPrimitiveUnfolder.to_str,
|
|
38
|
+
)
|
|
39
|
+
refresh_token = JsonUnfolder.require(raw, "refresh_token", Unfolder.to_primitive).bind(
|
|
40
|
+
JsonPrimitiveUnfolder.to_str,
|
|
41
|
+
)
|
|
42
|
+
scopes_result = JsonUnfolder.require(
|
|
43
|
+
raw,
|
|
44
|
+
"scopes",
|
|
45
|
+
lambda i: Unfolder.to_list_of(
|
|
46
|
+
i,
|
|
47
|
+
lambda x: Unfolder.to_primitive(x).bind(JsonPrimitiveUnfolder.to_str),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
return client_id.bind(
|
|
51
|
+
lambda cid: client_secret.bind(
|
|
52
|
+
lambda secret: refresh_token.bind(
|
|
53
|
+
lambda token: scopes_result.map(
|
|
54
|
+
lambda scopes: Credentials(cid, secret, token, frozenset(scopes)),
|
|
55
|
+
),
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_sub_json(raw: JsonObj, key: str) -> JsonObj:
|
|
62
|
+
return (
|
|
63
|
+
JsonUnfolder.require(raw, key, lambda v: Unfolder.to_json(v))
|
|
64
|
+
.alt(Unsafe.raise_exception)
|
|
65
|
+
.to_union()
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def decode_optional_date(raw: JsonObj, key: str) -> ResultE[Maybe[DatetimeUTC]]:
|
|
70
|
+
return JsonUnfolder.optional(raw, key, DecodeUtils.to_opt_date_time).map(
|
|
71
|
+
lambda v: v.bind(lambda j: j),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def decode_require_date(raw: JsonObj, key: str) -> ResultE[DatetimeUTC]:
|
|
76
|
+
return JsonUnfolder.require(raw, key, DecodeUtils.to_date_time)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def decode_maybe_str(raw: JsonObj, key: str) -> ResultE[Maybe[str]]:
|
|
80
|
+
return JsonUnfolder.optional(raw, key, DecodeUtils.to_opt_str).map(
|
|
81
|
+
lambda v: v.bind(lambda j: j),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def decode_zoho_creds(auth_file: IO[str]) -> ResultE[Credentials]:
|
|
86
|
+
return UnfoldedFactory.load(auth_file).bind(_decode_zoho_creds)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def decode_user_id(raw: JsonObj) -> ResultE[UserId]:
|
|
90
|
+
return (
|
|
91
|
+
JsonUnfolder.require(raw, "id", DecodeUtils.to_str)
|
|
92
|
+
.bind(lambda v: Natural.from_int(int(v)))
|
|
93
|
+
.map(UserId)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def decode_rol_id(raw: JsonObj) -> ResultE[RoleId]:
|
|
98
|
+
return (
|
|
99
|
+
JsonUnfolder.require(raw, "roleId", DecodeUtils.to_str)
|
|
100
|
+
.bind(lambda v: Natural.from_int(int(v)))
|
|
101
|
+
.map(RoleId)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def decode_profile_id(raw: JsonObj) -> ResultE[ProfileId]:
|
|
106
|
+
return (
|
|
107
|
+
JsonUnfolder.require(raw, "profileId", DecodeUtils.to_str)
|
|
108
|
+
.bind(lambda v: Natural.from_int(int(v)))
|
|
109
|
+
.map(ProfileId)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def decode_account_id(raw: JsonObj) -> ResultE[AccountId]:
|
|
114
|
+
return (
|
|
115
|
+
JsonUnfolder.require(raw, "accountId", DecodeUtils.to_str)
|
|
116
|
+
.bind(lambda v: Natural.from_int(int(v)))
|
|
117
|
+
.map(AccountId)
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def decode_crm_id(raw: JsonObj) -> ResultE[CrmId]:
|
|
122
|
+
return (
|
|
123
|
+
JsonUnfolder.require(get_sub_json(raw, "zohoCRMContact"), "id", DecodeUtils.to_str)
|
|
124
|
+
.bind(lambda v: Natural.from_int(int(v)))
|
|
125
|
+
.map(lambda obj: CrmId(obj))
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def decode_deparment_id(raw: JsonObj) -> ResultE[DeparmentId]:
|
|
130
|
+
return (
|
|
131
|
+
JsonUnfolder.optional(raw, "departmentId", DecodeUtils.to_opt_str)
|
|
132
|
+
.map(
|
|
133
|
+
lambda v: v.bind(lambda x: x).map(
|
|
134
|
+
lambda j: Natural.from_int(int(j)).alt(Unsafe.raise_exception).to_union(),
|
|
135
|
+
),
|
|
136
|
+
)
|
|
137
|
+
.map(lambda obj: DeparmentId(obj))
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def decode_product_id(raw: JsonObj) -> ResultE[ProductId]:
|
|
142
|
+
return (
|
|
143
|
+
JsonUnfolder.optional(raw, "productId", DecodeUtils.to_opt_str)
|
|
144
|
+
.map(
|
|
145
|
+
lambda v: v.bind(lambda x: x).map(
|
|
146
|
+
lambda j: Natural.from_int(int(j)).alt(Unsafe.raise_exception).to_union(),
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
.map(lambda obj: ProductId(obj))
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def decode_team_id(raw: JsonObj) -> ResultE[TeamId]:
|
|
154
|
+
return JsonUnfolder.require(raw, "teamId", DecodeUtils.to_str).bind(
|
|
155
|
+
lambda v: Natural.from_int(int(v)).map(lambda obj: TeamId(obj)),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def decode_ticket_id(raw: JsonObj) -> ResultE[TicketId]:
|
|
160
|
+
return JsonUnfolder.require(raw, "id", DecodeUtils.to_str).bind(
|
|
161
|
+
lambda v: Natural.from_int(int(v)).map(lambda obj: TicketId(obj)),
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def decode_contact_id(raw: JsonObj) -> ResultE[ContactId]:
|
|
166
|
+
return JsonUnfolder.require(get_sub_json(raw, "contact"), "id", DecodeUtils.to_str).bind(
|
|
167
|
+
lambda v: Natural.from_int(int(v)).map(lambda obj: ContactId(obj)),
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def decode_account_id_ticket(raw: JsonObj) -> ResultE[AccountId]:
|
|
172
|
+
account_obj = get_sub_json(raw, "contact")
|
|
173
|
+
return JsonUnfolder.require(
|
|
174
|
+
get_sub_json(account_obj, "account"),
|
|
175
|
+
"id",
|
|
176
|
+
DecodeUtils.to_str,
|
|
177
|
+
).bind(lambda v: Natural.from_int(int(v)).map(lambda obj: AccountId(obj)))
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from dataclasses import (
|
|
3
|
+
dataclass,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
from fa_purity import (
|
|
7
|
+
Cmd,
|
|
8
|
+
)
|
|
9
|
+
from fa_purity.json import (
|
|
10
|
+
JsonObj,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from . import (
|
|
14
|
+
_access,
|
|
15
|
+
_refresh,
|
|
16
|
+
_revoke,
|
|
17
|
+
)
|
|
18
|
+
from ._core import (
|
|
19
|
+
Credentials,
|
|
20
|
+
RefreshToken,
|
|
21
|
+
Token,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
ACCOUNTS_URL = "https://accounts.zoho.com" # for US region
|
|
25
|
+
LOG = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class AuthApi:
|
|
30
|
+
new_access_token: Cmd[Token]
|
|
31
|
+
manual_new_refresh_token: Cmd[RefreshToken]
|
|
32
|
+
manual_revoke_token: Cmd[JsonObj]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True)
|
|
36
|
+
class AuthApiFactory:
|
|
37
|
+
@staticmethod
|
|
38
|
+
def auth_api(creds: Credentials) -> AuthApi:
|
|
39
|
+
return AuthApi(
|
|
40
|
+
_access.new_access_token(creds),
|
|
41
|
+
_refresh.generate_refresh_token(creds),
|
|
42
|
+
_revoke.revoke_refresh_token(),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
__version__ = "1.0.0"
|
|
47
|
+
__all__ = [
|
|
48
|
+
"Credentials",
|
|
49
|
+
"RefreshToken",
|
|
50
|
+
"Token",
|
|
51
|
+
]
|