zkt_client 0.1.0

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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.byebug_history +256 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +20 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +854 -0
  9. data/Rakefile +12 -0
  10. data/lib/generators/zkt_client/USAGE +1 -0
  11. data/lib/generators/zkt_client/install_generator.rb +18 -0
  12. data/lib/generators/zkt_client/templates/configure_template.rake +10 -0
  13. data/lib/zkt_client/access_token.rb +36 -0
  14. data/lib/zkt_client/configuration.rb +55 -0
  15. data/lib/zkt_client/exceptions.rb +11 -0
  16. data/lib/zkt_client/http_client.rb +111 -0
  17. data/lib/zkt_client/models/area.rb +14 -0
  18. data/lib/zkt_client/models/base.rb +67 -0
  19. data/lib/zkt_client/models/concerns/helperable.rb +84 -0
  20. data/lib/zkt_client/models/concerns/validatable.rb +86 -0
  21. data/lib/zkt_client/models/department.rb +14 -0
  22. data/lib/zkt_client/models/device.rb +14 -0
  23. data/lib/zkt_client/models/employee.rb +40 -0
  24. data/lib/zkt_client/models/position.rb +14 -0
  25. data/lib/zkt_client/models/transaction.rb +16 -0
  26. data/lib/zkt_client/monky_patcher/array.rb +28 -0
  27. data/lib/zkt_client/monky_patcher/base.rb +17 -0
  28. data/lib/zkt_client/monky_patcher/false.rb +15 -0
  29. data/lib/zkt_client/monky_patcher/hash.rb +5 -0
  30. data/lib/zkt_client/monky_patcher/integer.rb +15 -0
  31. data/lib/zkt_client/monky_patcher/nil.rb +15 -0
  32. data/lib/zkt_client/monky_patcher/string.rb +15 -0
  33. data/lib/zkt_client/monky_patcher/true.rb +15 -0
  34. data/lib/zkt_client/version.rb +5 -0
  35. data/lib/zkt_client.rb +46 -0
  36. data/sig/zkt_client.rbs +4 -0
  37. metadata +212 -0
data/README.md ADDED
@@ -0,0 +1,854 @@
1
+ # ZktClient
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/zkt_client.svg)](http://badge.fury.io/rb/zkt_client)
4
+ ![Ruby Version](https://img.shields.io/badge/Ruby-%3E%3D%203.3.3-red)
5
+ [![Downloads count](https://img.shields.io/gem/dt/zkt_client.svg?style=flat)](https://rubygems.org/gems/zkt_client)
6
+ [![CI Status](https://github.com/Ahmed-Salem-Baqtyan/zkt_client/workflows/CI/badge.svg)](https://github.com/Ahmed-Salem-Baqtyan/zkt_client/actions?workflow=CI)
7
+ [![Maintenability](https://codeclimate.com/github/Ahmed-Salem-Baqtyan/zkt_client/badges/gpa.svg)](https://codeclimate.com/github/Ahmed-Salem-Baqtyan/zkt_client)
8
+
9
+ Ruby API Client for [Zkt platform](https://zkteco.eu/products/time-attendance/software/zkbio-time) it will help you to make an easy integration with [Zkt APIs](http://time.xmzkteco.com:8097/docs/api-docs/).
10
+
11
+ ## Documentation
12
+
13
+ See the [Ruby API docs](http://time.xmzkteco.com:8097/docs/api-docs/).
14
+
15
+ # Key features:
16
+
17
+ * Provides a methods to do the requests.
18
+ * Returns the response as (JSON or Objects) depending on your configurations.
19
+ * Handle the errors for you.
20
+
21
+ # Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'zkt_client'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ ```bash
32
+ $ bundle install
33
+ ```
34
+
35
+ Or install it yourself as:
36
+
37
+ ```bash
38
+ $ gem install zkt_client
39
+ ```
40
+
41
+ # Configuration in Rails
42
+ #### You have two ways to tell ZktClient about your configurations:
43
+ * Pass them throught the configure file
44
+
45
+
46
+ To generate a configuration file please run the following command
47
+
48
+ rails g zkt_client:install # config/initializers/zkt_client.rb
49
+
50
+ And write them there:
51
+ ```ruby
52
+ ZktClient.configure do |config|
53
+ # ZktClient configurations
54
+ # config.host = 'http://localhost:3000' # Required
55
+ # config.username = 'admin' # Required unless access_token is set
56
+ # config.password = 'admin' # Required unless access_token is set
57
+ # config.access_token = 'YOUR_ACCESS_TOKEN' # Required unless username and password are set
58
+ # config.is_object_response_enabled = true # Optional default is false
59
+ end
60
+ ```
61
+ * Pass them throught the ENV variables
62
+
63
+ ```ruby
64
+ # ZKT_CLIENT_HOST => For your host
65
+ # ZKT_CLIENT_USERNAME => For your username
66
+ # ZKT_CLIENT_PASSWORD => For your password
67
+ # ZKT_CLIENT_ACCESS_TOKEN => For your token (Optional if username & password provided)
68
+ # ZKT_OBJECT_RESPONSE_ENABLED => true to let ZktClient to return the response as objects.
69
+ ```
70
+
71
+ # Important notes
72
+ * The return response will be JSON by default.
73
+ * The `is_object_response_enabled` option will let you to ask ZktClint to return the response as objects instead of JSON (but the pagination keys will not back to you in the list response if the option is enabled)
74
+ * If you provide the `access_token` directly, ZktClient will use that token to make the requests without doing login request (In this case ZktClient will not bring the token from the login API).
75
+ * If you passed the `username & password` in this case ZktClient will make a login request to bring the `access_token` and then will make the other requests for you.
76
+ * If you passed both `username + password` and `access_token`, ZktClient will take the `access_token` only.
77
+
78
+ # Usage
79
+
80
+ Table of Contents
81
+ -----------------
82
+ - [Helper Methods](#helper-methods)
83
+ - [Area Methods](#area-methods)
84
+ - [Show Area](#show-area)
85
+ - [List Areas](#list-areas)
86
+ - [Update Area](#update-area)
87
+ - [Create Area](#create-area)
88
+ - [Delete Area](#delete-area)
89
+ * [Department Methods](#department-methods)
90
+ - [Show Department](#show-department)
91
+ - [List Departments](#list-departments)
92
+ - [Update Department](#update-department)
93
+ - [Create Department](#create-department)
94
+ - [Delete Department](#delete-department)
95
+ * [Device Methods](#device-methods)
96
+ - [Show Device](#show-device)
97
+ - [List Devices](#list-devices)
98
+ - [Update Device](#update-device)
99
+ - [Create Device](#create-device)
100
+ - [Delete Device](#delete-device)
101
+ * [Employee Methods](#employee-methods)
102
+ - [Show Employee](#show-employee)
103
+ - [List Employees](#list-employees)
104
+ - [Update Employee](#update-employee)
105
+ - [Create Employee](#create-employee)
106
+ - [Delete Employee](#delete-employee)
107
+ * [Position Methods](#position-methods)
108
+ - [Show Position](#show-position)
109
+ - [List Positions](#list-positions)
110
+ - [Update Position](#update-position)
111
+ - [Create Position](#create-position)
112
+ - [Delete Position](#delete-position)
113
+ * [Transaction Methods](#transaction-methods)
114
+ - [Show Transaction](#show-transaction)
115
+ - [List Transactions](#list-transactions)
116
+ - [Delete Transaction](#delete-transaction)
117
+ * [Exceptions](#exceptions)
118
+
119
+
120
+ Helper Methods
121
+ ------------
122
+ ```ruby
123
+ ZktClient.configured? # Returns true if you provide the required configurations otherwise false (to check if ZktClient configured or not)
124
+ ```
125
+
126
+ Area Methods
127
+ ------------
128
+
129
+ #### Show Area
130
+
131
+ ```ruby
132
+ # ZktClient::Area.show(id)
133
+
134
+ ZktClient::Area.show(4)
135
+
136
+ # JSON response
137
+ { "id"=>4, "area_code"=>"4", "area_name"=>"Baqtyan", "parent_area"=>nil, "parent_area_name"=>nil }
138
+
139
+ # Object response
140
+ <OpenStruct id=4, area_code="4", area_name="Baqtyan", parent_area=nil, parent_area_name=nil>
141
+ ```
142
+
143
+ #### List Areas
144
+
145
+ ```ruby
146
+ # ZktClient::Area.list(**options)
147
+ # NOTE: Check the ZKT APIs documention for more details.
148
+
149
+ ZktClient::Area.list(page: 1)
150
+
151
+ # JSON response
152
+ {
153
+ "count"=>12,
154
+ "next"=>"http://biotime8.zkteco.eu/personnel/api/areas/?page=2",
155
+ "previous"=>nil,
156
+ "msg"=>"",
157
+ "code"=>0,
158
+ "data"=>[{ "id"=>1, "area_code"=>"11", "area_name"=>"Baqtyan", "parent_area"=>nil, "parent_area_name"=>nil }],
159
+ }
160
+
161
+ # Object response
162
+ [<OpenStruct id=1, area_code="11", area_name="Baqtyan", parent_area=nil, parent_area_name=nil>]
163
+ ```
164
+
165
+ #### Create Area
166
+
167
+ ```ruby
168
+ # ZktClient::Area.create(params)
169
+
170
+ ZktClient::Area.create(area_code: 100, area_name: 'Ahmed Baqtyan')
171
+
172
+ # JSON response
173
+ { "id"=>15, "area_code"=>"100", "area_name"=>"Ahmed Baqtyan", "parent_area"=>nil }
174
+
175
+ # Object response
176
+ <OpenStruct id=15, area_code="100", area_name="Ahmed Baqtyan", parent_area=nil, parent_area_name=nil>
177
+ ```
178
+
179
+ #### Update Area
180
+
181
+ ```ruby
182
+ # ZktClient::Area.update(id, **params)
183
+
184
+ ZktClient::Area.update(4, area_name: 'Salim Baqtyan')
185
+
186
+ # JSON response
187
+ { "id"=>4, "area_code"=>"4", "area_name"=>"Salim Baqtyan", "parent_area"=>nil }
188
+
189
+ # Object response
190
+ <OpenStruct id=4, area_code="4", area_name="Salim Baqtyan", parent_area=nil, parent_area_name=nil>
191
+ ```
192
+
193
+ #### Delete Area
194
+
195
+ ```ruby
196
+ # ZktClient::Area.delete(id)
197
+
198
+ ZktClient::Area.delete(16) # true
199
+ ```
200
+ ------------------------------------------------------------------------------------------
201
+
202
+ Department Methods
203
+ ------------
204
+
205
+ #### Show Department
206
+
207
+ ```ruby
208
+ # ZktClient::Department.show(id)
209
+
210
+ ZktClient::Department.show(4)
211
+
212
+ # JSON response
213
+ { "id"=>1, "dept_code"=>"1", "dept_name"=>"Secretaria", "parent_dept"=>nil }
214
+
215
+ # Object response
216
+ <OpenStruct id=1, dept_code="1", dept_name="Secretaria", parent_dept=nil>
217
+ ```
218
+
219
+ #### List Departments
220
+
221
+ ```ruby
222
+ # ZktClient::Department.list(**options)
223
+ # NOTE: Check the ZKT APIs documention for more details.
224
+
225
+ ZktClient::Department.list(page: 1)
226
+
227
+ # JSON response
228
+ {
229
+ "count"=>8,
230
+ "next"=>nil,
231
+ "previous"=>nil,
232
+ "msg"=>"",
233
+ "code"=>0,
234
+ "data"=>
235
+ [{ "id"=>1, "dept_code"=>"1", "dept_name"=>"Secretaria", "parent_dept"=>nil }]
236
+ }
237
+
238
+ # Object response
239
+ [<OpenStruct id=1, dept_code="1", dept_name="Secretaria", parent_dept=nil>]
240
+ ```
241
+
242
+ #### Create Department
243
+
244
+ ```ruby
245
+ # ZktClient::Department.create(params)
246
+
247
+ ZktClient::Department.create(dept_code: 1000, dept_name: 'Baqtyan 1000')
248
+
249
+ # JSON response
250
+ { "id"=>15, "dept_code"=>"1000", "dept_name"=>"Baqtyan 1000", "parent_dept"=>nil }
251
+
252
+ # Object response
253
+ <OpenStruct id=15, dept_code="1000", dept_name="Baqtyan 1000", parent_dept=nil>
254
+ ```
255
+
256
+ #### Update Department
257
+
258
+ ```ruby
259
+ # ZktClient::Department.update(id, **params)
260
+
261
+ ZktClient::Department.update(15, dept_name: 'Baqtyan 10001')
262
+
263
+ # JSON response
264
+ { "id"=>15, "dept_code"=>"1000", "dept_name"=>"Baqtyan 10001", "parent_dept"=>nil }
265
+
266
+ # Object response
267
+ <OpenStruct id=15, dept_code="1000", dept_name="Baqtyan 10001", parent_dept=nil>
268
+ ```
269
+
270
+ #### Delete Department
271
+
272
+ ```ruby
273
+ # ZktClient::Department.delete(id)
274
+
275
+ ZktClient::Department.delete(15)
276
+
277
+ # JSON response
278
+ true
279
+
280
+ # Object response
281
+ true
282
+ ```
283
+
284
+ ------------------------------------------------------------------------------------------
285
+
286
+ Device Methods
287
+ ------------
288
+
289
+ #### Show Device
290
+
291
+ ```ruby
292
+ # ZktClient::Device.show(id)
293
+
294
+ ZktClient::Device.show(1)
295
+
296
+ # JSON response
297
+ {
298
+ "id"=>12,
299
+ "sn"=>"AEVL201160168",
300
+ "ip_address"=>"192.168.1.201",
301
+ "alias"=>"2",
302
+ "terminal_name"=>nil,
303
+ "fw_ver"=>nil,
304
+ "push_ver"=>nil,
305
+ "state"=>"3",
306
+ "terminal_tz"=>0,
307
+ "area"=>{"id"=>12, "area_code"=>"151", "area_name"=>"empty"},
308
+ "last_activity"=>nil,
309
+ "user_count"=>nil,
310
+ "fp_count"=>nil,
311
+ "face_count"=>nil,
312
+ "palm_count"=>nil,
313
+ "transaction_count"=>nil,
314
+ "push_time"=>nil,
315
+ "transfer_time"=>"00:00;14:05",
316
+ "transfer_interval"=>1,
317
+ "is_attendance"=>1,
318
+ "area_name"=>"empty"
319
+ }
320
+
321
+ # Object response
322
+ <OpenStruct id=12, sn="AEVL201160168", ip_address="192.168.1.201", alias="2", terminal_name=nil, fw_ver=nil, push_ver=nil, state="3", terminal_tz=0, area={"id"=>12, "area_code"=>"151", "area_name"=>"empty"}, last_activity=nil, user_count=nil, fp_count=nil, face_count=nil, palm_count=nil, transaction_count=nil, push_time=nil, transfer_time="00:00;14:05", transfer_interval=1, is_attendance=1, area_name="empty">
323
+ ```
324
+
325
+ #### List Devices
326
+
327
+ ```ruby
328
+ # ZktClient::Device.list(**options)
329
+ # NOTE: Check the ZKT APIs documention for more details.
330
+
331
+ ZktClient::Device.list(page: 1)
332
+
333
+ # JSON response
334
+ {
335
+ "count"=>3,
336
+ "next"=>nil,
337
+ "previous"=>nil,
338
+ "msg"=>"",
339
+ "code"=>0,
340
+ "data"=>[
341
+ {
342
+ "id"=>12,
343
+ "sn"=>"AEVL201160168",
344
+ "ip_address"=>"192.168.1.201",
345
+ "alias"=>"2",
346
+ "terminal_name"=>nil,
347
+ "fw_ver"=>nil,
348
+ "push_ver"=>nil,
349
+ "state"=>"3",
350
+ "terminal_tz"=>0,
351
+ "area"=>{"id"=>12, "area_code"=>"151", "area_name"=>"empty"},
352
+ "last_activity"=>nil,
353
+ "user_count"=>nil,
354
+ "fp_count"=>nil,
355
+ "face_count"=>nil,
356
+ "palm_count"=>nil,
357
+ "transaction_count"=>nil,
358
+ "push_time"=>nil,
359
+ "transfer_time"=>"00:00;14:05",
360
+ "transfer_interval"=>1,
361
+ "is_attendance"=>1,
362
+ "area_name"=>"empty"
363
+ }
364
+ ]
365
+ }
366
+
367
+ # Object response
368
+ [<OpenStruct id=12, sn="AEVL201160168", ip_address="192.168.1.201", alias="2", terminal_name=nil, fw_ver=nil, push_ver=nil, state="3", terminal_tz=0, area={"id"=>12, "area_code"=>"151", "area_name"=>"empty"}, last_activity=nil, user_count=nil, fp_count=nil, face_count=nil, palm_count=nil, transaction_count=nil, push_time=nil, transfer_time="00:00;14:05", transfer_interval=1, is_attendance=1, area_name="empty">]
369
+ ```
370
+
371
+ #### Create Device
372
+
373
+ ```ruby
374
+ # ZktClient::Device.create(params)
375
+
376
+ ZktClient::Device.create(area_code: 100, area_name: 'Ahmed Baqtyan')
377
+
378
+ # JSON response
379
+ { "id"=>15, "area_code"=>"100", "area_name"=>"Ahmed Baqtyan", "parent_area"=>nil }
380
+
381
+ # Object response
382
+ <OpenStruct id=15, area_code="100", area_name="Ahmed Baqtyan", parent_area=nil, parent_area_name=nil>
383
+ ```
384
+
385
+ #### Update Device
386
+
387
+ ```ruby
388
+ # ZktClient::Device.update(id, **params)
389
+
390
+ ZktClient::Device.update(12, sn: '11111111122', alias: 'Baqtyan device')
391
+
392
+ # JSON response
393
+ { "id"=>12, "sn"=>"AEVL201160168", "ip_address"=>"192.168.1.201", "alias"=>"Baqtyan device", "area"=>12, "heartbeat"=>10 }
394
+
395
+ # Object response
396
+ <OpenStruct id=12, sn="AEVL201160168", ip_address="192.168.1.201", alias="Baqtyan device", area=12, heartbeat=10>
397
+ ```
398
+
399
+ #### Delete Device
400
+
401
+ ```ruby
402
+ # ZktClient::Device.delete(id)
403
+
404
+ ZktClient::Device.delete(16)
405
+
406
+ # JSON response
407
+ true
408
+
409
+ # Object response
410
+ true
411
+ ```
412
+
413
+ ------------------------------------------------------------------------------------------
414
+
415
+ Employee Methods
416
+ ------------
417
+
418
+ #### Show Employee
419
+
420
+ ```ruby
421
+ # ZktClient::Employee.show(id)
422
+
423
+ ZktClient::Employee.show(4)
424
+
425
+ # JSON response
426
+ {
427
+ "id"=>16,
428
+ "emp_code"=>"1",
429
+ "first_name"=>"Test",
430
+ "last_name"=>nil,
431
+ "nickname"=>"",
432
+ "format_name"=>"1 Test",
433
+ "photo"=>"",
434
+ "full_name"=>"Test ",
435
+ "device_password"=>nil,
436
+ "card_no"=>nil,
437
+ "department"=>{"id"=>13, "dept_code"=>"5", "dept_name"=>"Test"},
438
+ "position"=>nil,
439
+ "hire_date"=>"2024-09-20",
440
+ "gender"=>nil,
441
+ "birthday"=>nil,
442
+ "verify_mode"=>0,
443
+ "emp_type"=>nil,
444
+ "contact_tel"=>"",
445
+ "office_tel"=>nil,
446
+ "mobile"=>"",
447
+ "national"=>"",
448
+ "city"=>"",
449
+ "address"=>"",
450
+ "postcode"=>"",
451
+ "email"=>"",
452
+ "enroll_sn"=>"",
453
+ "ssn"=>nil,
454
+ "religion"=>"",
455
+ "attemployee"=>{"id"=>16, "enable_attendance"=>true, "enable_overtime"=>true, "enable_holiday"=>true, "enable_schedule"=>true},
456
+ "dev_privilege"=>0,
457
+ "area"=>[{"id"=>13, "area_code"=>"1", "area_name"=>"TestMadrid"}],
458
+ "app_status"=>0,
459
+ "app_role"=>1,
460
+ "update_time"=>"2024-09-20 11:08:14",
461
+ "fingerprint"=>"Ver 10:1",
462
+ "face"=>"-",
463
+ "palm"=>"-",
464
+ "vl_face"=>"-",
465
+ "vl_palm"=>"-",
466
+ "vl_face_photo"=>"-"
467
+ }
468
+
469
+ # Object response
470
+ <OpenStruct id=16, emp_code="1", first_name="Test", last_name=nil, nickname="", format_name="1 Test", photo="", full_name="Test ", device_password=nil, card_no=nil, department={"id"=>13, "dept_code"=>"5", "dept_name"=>"Test"}, position=nil, hire_date="2024-09-20", gender=nil, birthday=nil, verify_mode=0, emp_type=nil, contact_tel="", office_tel=nil, mobile="", national="", city="", address="", postcode="", email="", enroll_sn="", ssn=nil, religion="", attemployee={"id"=>16, "enable_attendance"=>true, "enable_overtime"=>true, "enable_holiday"=>true, "enable_schedule"=>true}, dev_privilege=0, area=[{"id"=>13, "area_code"=>"1", "area_name"=>"TestMadrid"}], app_status=0, app_role=1, update_time="2024-09-20 11:08:14", fingerprint="Ver 10:1", face="-", palm="-", vl_face="-", vl_palm="-", vl_face_photo="-">
471
+ ```
472
+
473
+ #### List Employees
474
+
475
+ ```ruby
476
+ # ZktClient::AEmployeerea.list(**options)
477
+ # NOTE: Check the ZKT APIs documention for more details.
478
+
479
+ ZktClient::Employee.list(page: 1)
480
+
481
+ # JSON response
482
+ {
483
+ "count"=>26,
484
+ "next"=>"http://biotime8.zkteco.eu/personnel/api/employees/?page=2",
485
+ "previous"=>nil,
486
+ "msg"=>"",
487
+ "code"=>0,
488
+ "data"=>[
489
+ {
490
+ "id"=>16,
491
+ "emp_code"=>"1",
492
+ "first_name"=>"Test",
493
+ "last_name"=>nil,
494
+ "nickname"=>"",
495
+ "format_name"=>"1 Test",
496
+ "photo"=>"",
497
+ "full_name"=>"Test ",
498
+ "device_password"=>nil,
499
+ "card_no"=>nil,
500
+ "department"=>{"id"=>13, "dept_code"=>"5", "dept_name"=>"Test"},
501
+ "position"=>nil,
502
+ "hire_date"=>"2024-09-20",
503
+ "gender"=>nil,
504
+ "birthday"=>nil,
505
+ "verify_mode"=>0,
506
+ "emp_type"=>nil,
507
+ "contact_tel"=>"",
508
+ "office_tel"=>nil,
509
+ "mobile"=>"",
510
+ "national"=>"",
511
+ "city"=>"",
512
+ "address"=>"",
513
+ "postcode"=>"",
514
+ "email"=>"",
515
+ "enroll_sn"=>"",
516
+ "ssn"=>nil,
517
+ "religion"=>"",
518
+ "attemployee"=>{"id"=>16, "enable_attendance"=>true, "enable_overtime"=>true, "enable_holiday"=>true, "enable_schedule"=>true},
519
+ "dev_privilege"=>0,
520
+ "area"=>[{"id"=>13, "area_code"=>"1", "area_name"=>"TestMadrid"}],
521
+ "app_status"=>0,
522
+ "app_role"=>1,
523
+ "update_time"=>"2024-09-20 11:08:14",
524
+ "fingerprint"=>"Ver 10:1",
525
+ "face"=>"-",
526
+ "palm"=>"-",
527
+ "vl_face"=>"-",
528
+ "vl_palm"=>"-",
529
+ "vl_face_photo"=>"-"
530
+ }
531
+ ]
532
+ }
533
+
534
+ # Object response
535
+ [<OpenStruct id=16, emp_code="1", first_name="Test", last_name=nil, nickname="", format_name="1 Test", photo="", full_name="Test ", device_password=nil, card_no=nil, department={"id"=>13, "dept_code"=>"5", "dept_name"=>"Test"}, position=nil, hire_date="2024-09-20", gender=nil, birthday=nil, verify_mode=0, emp_type=nil, contact_tel="", office_tel=nil, mobile="", national="", city="", address="", postcode="", email="", enroll_sn="", ssn=nil, religion="", attemployee={"id"=>16, "enable_attendance"=>true, "enable_overtime"=>true, "enable_holiday"=>true, "enable_schedule"=>true}, dev_privilege=0, area=[{"id"=>13, "area_code"=>"1", "area_name"=>"TestMadrid"}], app_status=0, app_role=1, update_time="2024-09-20 11:08:14", fingerprint="Ver 10:1", face="-", palm="-", vl_face="-", vl_palm="-", vl_face_photo="-">]
536
+ ```
537
+
538
+ #### Create Employee
539
+
540
+ ```ruby
541
+ # ZktClient::Employee.create(params)
542
+
543
+ ZktClient::Employee.create(emp_code: 100, first_name: 'Ahmed Baqtyan', department: 1, area: [1])
544
+
545
+ # JSON response
546
+ {
547
+ "id"=>42,
548
+ "emp_code"=>"100",
549
+ "first_name"=>"Ahmed Baqtyan",
550
+ "last_name"=>nil,
551
+ "nickname"=>nil,
552
+ "device_password"=>nil,
553
+ "card_no"=>nil,
554
+ "department"=>1,
555
+ "position"=>nil,
556
+ "hire_date"=>"2024-09-21",
557
+ "gender"=>nil,
558
+ "birthday"=>nil,
559
+ "verify_mode"=>-1,
560
+ "emp_type"=>nil,
561
+ "contact_tel"=>nil,
562
+ "office_tel"=>nil,
563
+ "mobile"=>nil,
564
+ "national"=>nil,
565
+ "city"=>nil,
566
+ "address"=>nil,
567
+ "postcode"=>nil,
568
+ "email"=>nil,
569
+ "enroll_sn"=>"",
570
+ "ssn"=>nil,
571
+ "religion"=>nil,
572
+ "dev_privilege"=>0,
573
+ "self_password"=>"pbkdf2_sha256$390000$nN5kdBx0CHTMZ1j1wvs7M7$zn3e9jKcDDkHTqPlcXrPe8I0cCsZ6rvTEqIzFxiZcWE=",
574
+ "flow_role"=>[],
575
+ "area"=>[1],
576
+ "app_status"=>0,
577
+ "app_role"=>1
578
+ }
579
+
580
+ # Object response
581
+ <OpenStruct id=43, emp_code="1001", first_name="Ahmed Baqtyan", last_name=nil, nickname=nil, device_password=nil, card_no=nil, department=1, position=nil, hire_date="2024-09-21", gender=nil, birthday=nil, verify_mode=-1, emp_type=nil, contact_tel=nil, office_tel=nil, mobile=nil, national=nil, city=nil, address=nil, postcode=nil, email=nil, enroll_sn="", ssn=nil, religion=nil, dev_privilege=0, self_password="pbkdf2_sha256$390000$Thqtm5LEM6MLqmpdOsH76Y$eakgvOfq5xawUJzhGMByr/gn9uQ4YquQTfIvhscPayA=", flow_role=[], area=[1], app_status=0, app_role=1>
582
+ ```
583
+
584
+ #### Update Employee
585
+
586
+ ```ruby
587
+ # ZktClient::Employee.update(id, **params)
588
+
589
+ ZktClient::Employee.update(42, area: [1], first_name: 'Salim Baqtyan')
590
+
591
+ # JSON response
592
+ {
593
+ "emp_code"=>"100",
594
+ "first_name"=>"Salim Baqtyan",
595
+ "last_name"=>nil,
596
+ "nickname"=>nil,
597
+ "device_password"=>nil,
598
+ "card_no"=>nil,
599
+ "department"=>1,
600
+ "position"=>nil,
601
+ "hire_date"=>"2024-09-21",
602
+ "gender"=>nil,
603
+ "birthday"=>nil,
604
+ "verify_mode"=>-1,
605
+ "emp_type"=>nil,
606
+ "contact_tel"=>nil,
607
+ "office_tel"=>nil,
608
+ "mobile"=>nil,
609
+ "national"=>nil,
610
+ "city"=>nil,
611
+ "address"=>nil,
612
+ "postcode"=>nil,
613
+ "email"=>nil,
614
+ "enroll_sn"=>"",
615
+ "ssn"=>nil,
616
+ "religion"=>nil,
617
+ "dev_privilege"=>0,
618
+ "self_password"=>"pbkdf2_sha256$390000$nN5kdBx0CHTMZ1j1wvs7M7$zn3e9jKcDDkHTqPlcXrPe8I0cCsZ6rvTEqIzFxiZcWE=",
619
+ "flow_role"=>[],
620
+ "area"=>[1],
621
+ "app_status"=>0,
622
+ "app_role"=>1
623
+ }
624
+
625
+ # Object response
626
+ <OpenStruct emp_code="100", first_name="Salim Baqtyan", last_name=nil, nickname=nil, device_password=nil, card_no=nil, department=1, position=nil, hire_date="2024-09-21", gender=nil, birthday=nil, verify_mode=-1, emp_type=nil, contact_tel=nil, office_tel=nil, mobile=nil, national=nil, city=nil, address=nil, postcode=nil, email=nil, enroll_sn="", ssn=nil, religion=nil, dev_privilege=0, self_password="pbkdf2_sha256$390000$nN5kdBx0CHTMZ1j1wvs7M7$zn3e9jKcDDkHTqPlcXrPe8I0cCsZ6rvTEqIzFxiZcWE=", flow_role=[], area=[1], app_status=0, app_role=1>
627
+ ```
628
+
629
+ #### Delete Employee
630
+
631
+ ```ruby
632
+ # ZktClient::Employee.delete(id)
633
+
634
+ ZktClient::Employee.delete(42)
635
+
636
+ # JSON response
637
+ true
638
+
639
+ # Object response
640
+ true
641
+ ```
642
+
643
+ ------------------------------------------------------------------------------------------
644
+
645
+ Position Methods
646
+ ------------
647
+
648
+ #### Show Position
649
+
650
+ ```ruby
651
+ # ZktClient::Position.show(id)
652
+
653
+ ZktClient::Position.show(4)
654
+
655
+ # JSON response
656
+ { "id"=>1, "position_code"=>"1", "position_name"=>"Secretaria", "parent_position"=>nil, "parent_position_name"=>nil }
657
+
658
+ # Object response
659
+ <OpenStruct id=1, position_code="1", position_name="Secretaria", parent_position=nil, parent_position_name=nil>
660
+ ```
661
+
662
+ #### List Positions
663
+
664
+ ```ruby
665
+ # ZktClient::Position.list(**options)
666
+ # NOTE: Check the ZKT APIs documention for more details.
667
+
668
+ ZktClient::Position.list(page: 1)
669
+
670
+ # JSON response
671
+ {
672
+ "count"=>8,
673
+ "next"=>nil,
674
+ "previous"=>nil,
675
+ "msg"=>"",
676
+ "code"=>0,
677
+ "data"=>[{ "id"=>1, "position_code"=>"1", "position_name"=>"Secretaria", "parent_position"=>nil, "parent_position_name"=>nil }]
678
+ }
679
+
680
+ # Object response
681
+ [<OpenStruct id=1, position_code="1", position_name="Secretaria", parent_position=nil, parent_position_name=nil>]
682
+ ```
683
+
684
+ #### Create Position
685
+
686
+ ```ruby
687
+ # ZktClient::Position.create(params)
688
+
689
+ ZktClient::Position.create(position_code: 100, position_name: 'Ahmed Baqtyan position')
690
+
691
+ # JSON response
692
+ { "position_code"=>"100", "position_name"=>"Ahmed Baqtyan position", "parent_position"=>nil }
693
+
694
+ # Object response
695
+ <OpenStruct position_code="100", position_name="Ahmed Baqtyan position", parent_position=nil>
696
+ ```
697
+
698
+ #### Update Position
699
+
700
+ ```ruby
701
+ # ZktClient::Position.update(id, **params)
702
+
703
+ ZktClient::Position.update(10, position_name: 'Ahmed Baqtyan position updated')
704
+
705
+ # JSON response
706
+ { "id"=>4, "area_code"=>"4", "area_name"=>"Salim Baqtyan", "parent_area"=>nil }
707
+
708
+ # Object response
709
+ <OpenStruct id=4, area_code="4", area_name="Salim Baqtyan", parent_area=nil, parent_area_name=nil>
710
+ ```
711
+
712
+ #### Delete Position
713
+
714
+ ```ruby
715
+ # ZktClient::Position.delete(id)
716
+
717
+ ZktClient::Position.delete(10)
718
+
719
+ # JSON response
720
+ true
721
+
722
+ # Object response
723
+ true
724
+ ```
725
+
726
+ ------------------------------------------------------------------------------------------
727
+
728
+ Transaction Methods
729
+ ------------
730
+
731
+ #### Show Transaction
732
+
733
+ ```ruby
734
+ # ZktClient::Transaction.show(id)
735
+
736
+ ZktClient::Transaction.show(1)
737
+
738
+ # JSON response
739
+ {
740
+ "id"=>1,
741
+ "emp"=>16,
742
+ "emp_code"=>"1",
743
+ "first_name"=>"Test",
744
+ "last_name"=>nil,
745
+ "department"=>"Test",
746
+ "position"=>nil,
747
+ "punch_time"=>"2024-09-05 01:01:00",
748
+ "punch_state"=>"0",
749
+ "punch_state_display"=>"Check In",
750
+ "verify_type"=>0,
751
+ "verify_type_display"=>"Any",
752
+ "work_code"=>nil,
753
+ "gps_location"=>"",
754
+ "area_alias"=>nil,
755
+ "terminal_sn"=>"",
756
+ "temperature"=>0.0,
757
+ "is_mask"=>"-",
758
+ "terminal_alias"=>nil,
759
+ "upload_time"=>"2024-09-10 14:34:58"
760
+ }
761
+
762
+ # Object response
763
+ <OpenStruct id=1, emp=16, emp_code="1", first_name="Test", last_name=nil, department="Test", position=nil, punch_time="2024-09-05 01:01:00", punch_state="0", punch_state_display="Check In", verify_type=0, verify_type_display="Any", work_code=nil, gps_location="", area_alias=nil, terminal_sn="", temperature=0.0, is_mask="-", terminal_alias=nil, upload_time="2024-09-10 14:34:58">
764
+ ```
765
+
766
+ #### List Transactions
767
+
768
+ ```ruby
769
+ # ZktClient::Transaction.list(**options)
770
+ # NOTE: Check the ZKT APIs documention for more details.
771
+
772
+ ZktClient::Transaction.list(page: 1)
773
+
774
+ # JSON response
775
+ {
776
+ "count"=>25,
777
+ "next"=>"http://biotime8.zkteco.eu/iclock/api/transactions/?page=2",
778
+ "previous"=>nil,
779
+ "msg"=>"",
780
+ "code"=>0,
781
+ "data"=>
782
+ [
783
+ {
784
+ "id"=>1,
785
+ "emp"=>16,
786
+ "emp_code"=>"1",
787
+ "first_name"=>"Test",
788
+ "last_name"=>nil,
789
+ "department"=>"Test",
790
+ "position"=>nil,
791
+ "punch_time"=>"2024-09-05 01:01:00",
792
+ "punch_state"=>"0",
793
+ "punch_state_display"=>"Check In",
794
+ "verify_type"=>0,
795
+ "verify_type_display"=>"Any",
796
+ "work_code"=>nil,
797
+ "gps_location"=>"",
798
+ "area_alias"=>nil,
799
+ "terminal_sn"=>"",
800
+ "temperature"=>0.0,
801
+ "is_mask"=>"-",
802
+ "terminal_alias"=>nil,
803
+ "upload_time"=>"2024-09-10 14:34:58"
804
+ }
805
+ ]
806
+ }
807
+
808
+ # Object response
809
+ [<OpenStruct id=1, emp=16, emp_code="1", first_name="Test", last_name=nil, department="Test", position=nil, punch_time="2024-09-05 01:01:00", punch_state="0", punch_state_display="Check In", verify_type=0, verify_type_display="Any", work_code=nil, gps_location="", area_alias=nil, terminal_sn="", temperature=0.0, is_mask="-", terminal_alias=nil, upload_time="2024-09-10 14:34:58">]
810
+ ```
811
+
812
+ #### Delete Transaction
813
+
814
+ ```ruby
815
+ # ZktClient::Transaction.delete(id)
816
+
817
+ ZktClient::Transaction.delete(16)
818
+
819
+ # JSON response
820
+ true
821
+
822
+ # Object response
823
+ true
824
+ ```
825
+
826
+ Exceptions
827
+ ------------
828
+
829
+ Class | Description | Message
830
+ ---------------------------------------- | :---------------------------------------------------------------: | ------------------------------------
831
+ `ZktClient::MissingConfigurationError` | If you do a request without configure ZktCleint configurations. | Configurations are missing!
832
+ `ZktClient::RecordNotFound` | When the request status id 404 | Picked from the response itself
833
+ `ZktClient::BadRequestError` | When the request status is 404 | Picked from the response itself
834
+ `ZktClient::UnprocessableEntityError` | When the request status is 422 | Picked from the response itself
835
+ `ZktClient::ServerError` | When the request status is (500..599) | Picked from the response itself
836
+ `ZktClient::RequestFailedError` | When the request status with another status | Picked from the response itself
837
+
838
+ ## Development
839
+
840
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
841
+
842
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
843
+
844
+ ## Contributing
845
+
846
+ Bug reports and pull requests are welcome on GitHub at [Zkt Client Repo](https://github.com/Ahmed-Salem-Baqtyan/zkt_client). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
847
+
848
+ ## License
849
+
850
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
851
+
852
+ ## Code of Conduct
853
+
854
+ Everyone interacting in the ZktClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/zkt_client/blob/main/CODE_OF_CONDUCT.md).