attend 0.1.0 → 2.0.1
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.
- checksums.yaml +5 -5
- data/.rubocop.yml +6 -1
- data/.ruby-version +1 -1
- data/.travis.yml +3 -2
- data/Gemfile.lock +60 -37
- data/README.md +22 -20
- data/attend.gemspec +10 -9
- data/exe/attend +15 -36
- data/lib/attend/get_absent_days.rb +17 -0
- data/lib/attend/register_attendances.rb +25 -0
- data/lib/attend/version.rb +1 -1
- data/lib/attend.rb +28 -1
- data/lib/zoho/people/api.rb +61 -0
- data/lib/zoho/people/attendance.rb +15 -4
- data/lib/zoho/people/attendance_report/record.rb +20 -0
- data/lib/zoho/people/attendance_report.rb +23 -0
- metadata +27 -24
- data/entrypoiny.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3821ac26f7e464f34f20aebddf9c0ea6ec05a48e2449f7f0761241968e40d9d0
|
|
4
|
+
data.tar.gz: 66e6a441166ad77a8b4dbbf0d228f323480f37ed6f7b74539de7036c5455c10c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de9de2168901829ef26ea336d63cacabea6b9239a58913df3ec77ac5ba4e4f2106157ac5c324546d177e84442e7284690f6349b745a6483c562ebebfa9542256
|
|
7
|
+
data.tar.gz: 18a15085d5f615e4ad42889fab043e37ee372ab233907c41069a281b8f663d813c6ef35019cda1e567523b6af4fcc92ebc7e75cc0bd8cd255f335873dd117afa
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.0.0
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,57 +1,80 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
attend (0.1
|
|
5
|
-
clamp (~> 1.
|
|
6
|
-
|
|
4
|
+
attend (2.0.1)
|
|
5
|
+
clamp (~> 1.3)
|
|
6
|
+
http (~> 4.4)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rainbow (2.2.2)
|
|
11
|
+
addressable (2.8.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
ast (2.4.2)
|
|
14
|
+
clamp (1.3.2)
|
|
15
|
+
diff-lcs (1.4.4)
|
|
16
|
+
domain_name (0.5.20190701)
|
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
18
|
+
ffi (1.15.4)
|
|
19
|
+
ffi-compiler (1.0.1)
|
|
20
|
+
ffi (>= 1.0.0)
|
|
22
21
|
rake
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
http (4.4.1)
|
|
23
|
+
addressable (~> 2.3)
|
|
24
|
+
http-cookie (~> 1.0)
|
|
25
|
+
http-form_data (~> 2.2)
|
|
26
|
+
http-parser (~> 1.2.0)
|
|
27
|
+
http-cookie (1.0.4)
|
|
28
|
+
domain_name (~> 0.5)
|
|
29
|
+
http-form_data (2.3.0)
|
|
30
|
+
http-parser (1.2.3)
|
|
31
|
+
ffi-compiler (>= 1.0, < 2.0)
|
|
32
|
+
parallel (1.21.0)
|
|
33
|
+
parser (3.0.2.0)
|
|
34
|
+
ast (~> 2.4.1)
|
|
35
|
+
public_suffix (4.0.6)
|
|
36
|
+
rainbow (3.0.0)
|
|
37
|
+
rake (13.0.6)
|
|
38
|
+
regexp_parser (2.1.1)
|
|
39
|
+
rexml (3.2.5)
|
|
40
|
+
rspec (3.10.0)
|
|
41
|
+
rspec-core (~> 3.10.0)
|
|
42
|
+
rspec-expectations (~> 3.10.0)
|
|
43
|
+
rspec-mocks (~> 3.10.0)
|
|
44
|
+
rspec-core (3.10.1)
|
|
45
|
+
rspec-support (~> 3.10.0)
|
|
46
|
+
rspec-expectations (3.10.1)
|
|
31
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
32
|
-
rspec-support (~> 3.
|
|
33
|
-
rspec-mocks (3.
|
|
48
|
+
rspec-support (~> 3.10.0)
|
|
49
|
+
rspec-mocks (3.10.2)
|
|
34
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
35
|
-
rspec-support (~> 3.
|
|
36
|
-
rspec-support (3.
|
|
37
|
-
rubocop (
|
|
51
|
+
rspec-support (~> 3.10.0)
|
|
52
|
+
rspec-support (3.10.2)
|
|
53
|
+
rubocop (1.22.0)
|
|
38
54
|
parallel (~> 1.10)
|
|
39
|
-
parser (>=
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
parser (>= 3.0.0.0)
|
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
58
|
+
rexml
|
|
59
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
|
42
60
|
ruby-progressbar (~> 1.7)
|
|
43
|
-
unicode-display_width (
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
62
|
+
rubocop-ast (1.12.0)
|
|
63
|
+
parser (>= 3.0.1.1)
|
|
64
|
+
ruby-progressbar (1.11.0)
|
|
65
|
+
unf (0.1.4)
|
|
66
|
+
unf_ext
|
|
67
|
+
unf_ext (0.0.8)
|
|
68
|
+
unicode-display_width (2.1.0)
|
|
46
69
|
|
|
47
70
|
PLATFORMS
|
|
48
71
|
ruby
|
|
49
72
|
|
|
50
73
|
DEPENDENCIES
|
|
51
74
|
attend!
|
|
52
|
-
bundler (~> 1
|
|
53
|
-
rspec (~> 3.
|
|
54
|
-
rubocop (~>
|
|
75
|
+
bundler (~> 2.1)
|
|
76
|
+
rspec (~> 3.9)
|
|
77
|
+
rubocop (~> 1.11)
|
|
55
78
|
|
|
56
79
|
BUNDLED WITH
|
|
57
|
-
|
|
80
|
+
2.2.13
|
data/README.md
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
# Attend
|
|
1
|
+
# Attend [](https://travis-ci.org/mckomo/attend)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
3
|
+
Register your attendance at Zoho using CLI.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
Install `attend` Ruby gem:
|
|
10
8
|
|
|
11
|
-
```
|
|
12
|
-
gem
|
|
9
|
+
```bash
|
|
10
|
+
gem install attend
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
$ bundle
|
|
18
|
-
|
|
19
|
-
Or install it yourself as:
|
|
20
|
-
|
|
21
|
-
$ gem install attend
|
|
13
|
+
and that's it!
|
|
22
14
|
|
|
23
15
|
## Usage
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
First of all you need to set [Zoho Poeople auth token](https://www.zoho.com/people/help/api/auth-token.html) as env variable in your terminal. After that you will be ready to use `attend`.
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
```bash
|
|
20
|
+
export ZOHO_PEOPLE_ROOT_TOKEN='YOUR_TOKEN'
|
|
21
|
+
```
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
To register attendance on current day:
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
```bash
|
|
26
|
+
attend --email "your.employee@email.com" --check_in "10:00" --check_out "18:00"
|
|
27
|
+
# Successfully registered attendance from 2017-07-04T10:00:00+10:00 to 2017-07-04T18:00:00+18:00
|
|
28
|
+
```
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
You can also register attendance for a few days:
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
```bash
|
|
33
|
+
attend --email "your.employee@email.com" --check_in "10:00" --check_out "18:00" --from "04/07/2017" --to "07/07/2017"
|
|
34
|
+
# Successfully registered attendance from 2017-07-04T10:00:00+10:00 to 2017-07-04T18:00:00+18:00
|
|
35
|
+
# Successfully registered attendance from 2017-07-05T10:00:00+10:00 to 2017-07-05T18:00:00+18:00
|
|
36
|
+
# ...
|
|
37
|
+
```
|
data/attend.gemspec
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
lib = File.expand_path('
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
5
|
require 'attend/version'
|
|
7
6
|
|
|
@@ -12,8 +11,10 @@ Gem::Specification.new do |spec|
|
|
|
12
11
|
spec.email = ['mckomo@gmail.com']
|
|
13
12
|
spec.license = 'MIT'
|
|
14
13
|
|
|
15
|
-
spec.
|
|
16
|
-
|
|
14
|
+
spec.required_ruby_version = '>= 2.7.2'
|
|
15
|
+
|
|
16
|
+
spec.summary = 'Register Zoho People attendance using CLI'
|
|
17
|
+
spec.description = 'Attend is CLI tool that will help you register your Zoho People attendance in fast and easy way'
|
|
17
18
|
spec.homepage = 'https://github.com/mckomo/attend'
|
|
18
19
|
|
|
19
20
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
@@ -23,10 +24,10 @@ Gem::Specification.new do |spec|
|
|
|
23
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
25
|
spec.require_paths = ['lib']
|
|
25
26
|
|
|
26
|
-
spec.add_dependency '
|
|
27
|
-
spec.add_dependency '
|
|
27
|
+
spec.add_dependency 'clamp', '~> 1.3'
|
|
28
|
+
spec.add_dependency 'http', '~> 4.4'
|
|
28
29
|
|
|
29
|
-
spec.add_development_dependency 'bundler', '~> 1
|
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
|
31
|
-
spec.add_development_dependency 'rubocop', '~>
|
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 1.11'
|
|
32
33
|
end
|
data/exe/attend
CHANGED
|
@@ -1,54 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
STDOUT.sync = true
|
|
2
5
|
|
|
3
6
|
require 'clamp'
|
|
4
7
|
require 'date'
|
|
5
|
-
require 'httparty'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
DATE_FORMAT = 'dd/MM/yyyy HH:mm:ss'
|
|
9
|
+
require_relative '../lib/attend'
|
|
9
10
|
|
|
10
|
-
parse_date =
|
|
11
|
+
parse_date = Date.method(:parse)
|
|
11
12
|
|
|
12
13
|
Clamp do
|
|
13
14
|
option '--email', 'EMAIL', 'employee email id', required: true
|
|
14
|
-
option '--check_in', 'CHECK_IN', 'check in time',
|
|
15
|
-
option '--check_out', 'CHECK_OUT', 'check out time',
|
|
15
|
+
option '--check_in', 'CHECK_IN', 'check in time', default: '9:00'
|
|
16
|
+
option '--check_out', 'CHECK_OUT', 'check out time', default: '17:00'
|
|
16
17
|
option '--from', 'FROM', 'date of the first work day', default: Date.today, &parse_date
|
|
17
18
|
option '--to', 'TO', 'date of the las work day', default: Date.today, &parse_date
|
|
18
19
|
option '--dry', :flag, 'enables dry run'
|
|
20
|
+
option '--verbose', :flag, 'print verbose error message'
|
|
19
21
|
|
|
20
22
|
def execute
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if dry?
|
|
28
|
-
puts "DRY RUN: Committing attendance from #{check_in_time} to #{check_out_time}"
|
|
29
|
-
next
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
response = post_attendance(check_in_time, check_out_time)
|
|
33
|
-
|
|
34
|
-
if response.ok?
|
|
35
|
-
puts "Successfully registered attendance from #{check_in_time} to #{check_out_time}"
|
|
36
|
-
elsif response
|
|
37
|
-
raise "Failed to register attendance. Error: #{response.body}"
|
|
38
|
-
end
|
|
23
|
+
Attend.register(email: email, from: from, to: to, check_in: check_in, check_out: check_out, dry_run: dry?)
|
|
24
|
+
rescue StandardError => e
|
|
25
|
+
if verbose?
|
|
26
|
+
puts e.full_message
|
|
27
|
+
else
|
|
28
|
+
puts e.message
|
|
39
29
|
end
|
|
40
|
-
end
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
parameters = {
|
|
44
|
-
'authtoken' => AUTH_TOKEN,
|
|
45
|
-
'dateFormat' => DATE_FORMAT,
|
|
46
|
-
'checkIn' => check_in_time.strftime('%d/%m/%Y %H:%M:%S'),
|
|
47
|
-
'checkOut' => check_out_time.strftime('%d/%m/%Y %H:%M:%S'),
|
|
48
|
-
'emailId' => email,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
HTTParty.post('https://people.zoho.com/people/api/attendance', query: parameters)
|
|
31
|
+
exit 1
|
|
52
32
|
end
|
|
53
33
|
end
|
|
54
|
-
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Attend
|
|
4
|
+
class GetAbsentDays
|
|
5
|
+
attr_reader :zoho
|
|
6
|
+
|
|
7
|
+
def initialize(zoho:)
|
|
8
|
+
@zoho = zoho
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(email:, from:, to:)
|
|
12
|
+
attendance_report = zoho.get_attendance_report(email: email, from: from, to: to)
|
|
13
|
+
|
|
14
|
+
attendance_report.records.select(&:missing_work?).map(&:date)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Attend
|
|
4
|
+
class RegisterAttendances
|
|
5
|
+
attr_reader :zoho, :dry_run
|
|
6
|
+
|
|
7
|
+
def initialize(zoho:, dry_run: true)
|
|
8
|
+
@zoho = zoho
|
|
9
|
+
@dry_run = dry_run
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call(attendances)
|
|
13
|
+
attendances.each do |attendance|
|
|
14
|
+
if dry_run
|
|
15
|
+
puts "DRY RUN: Committing #{attendance}"
|
|
16
|
+
next
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
zoho.post_attendance(attendance)
|
|
20
|
+
|
|
21
|
+
puts "Successfully registered #{attendance}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/attend/version.rb
CHANGED
data/lib/attend.rb
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'attend/version'
|
|
4
|
+
require_relative './zoho/people/api'
|
|
5
|
+
require_relative './zoho/people/attendance'
|
|
6
|
+
require_relative './attend/get_absent_days'
|
|
7
|
+
require_relative './attend/register_attendances'
|
|
4
8
|
|
|
5
9
|
module Attend
|
|
6
|
-
|
|
10
|
+
def self.register(email:, from:, to:, check_in:, check_out:, dry_run: true)
|
|
11
|
+
absent_days = GetAbsentDays.new(zoho: zoho_api).call(email: email, from: from, to: to)
|
|
12
|
+
|
|
13
|
+
if absent_days.empty?
|
|
14
|
+
puts "No absent days between #{from} and #{to}"
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attendances = absent_days.map do |day|
|
|
19
|
+
day_beginning = day.to_datetime
|
|
20
|
+
|
|
21
|
+
Zoho::People::Attendance.new(email: email,
|
|
22
|
+
check_in: day_beginning.new_offset("+#{check_in}"),
|
|
23
|
+
check_out: day_beginning.new_offset("+#{check_out}"))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
RegisterAttendances.new(zoho: zoho_api, dry_run: dry_run).call(attendances)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.zoho_api
|
|
30
|
+
Zoho::People::API.new
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private_class_method :zoho_api
|
|
7
34
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'http'
|
|
4
|
+
|
|
5
|
+
require_relative './attendance_report'
|
|
6
|
+
|
|
7
|
+
module Zoho
|
|
8
|
+
module People
|
|
9
|
+
class API
|
|
10
|
+
URL = 'https://people.zoho.com/people/api'
|
|
11
|
+
|
|
12
|
+
attr_reader :auth_token
|
|
13
|
+
|
|
14
|
+
def initialize(auth_token: ENV['ZOHO_PEOPLE_ROOT_TOKEN'])
|
|
15
|
+
raise 'You must provide Zoho People authorization token' unless auth_token
|
|
16
|
+
|
|
17
|
+
@auth_token = auth_token
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def post_attendance(attendance)
|
|
21
|
+
params = {
|
|
22
|
+
'authtoken' => auth_token,
|
|
23
|
+
'dateFormat' => 'dd/MM/yyyy HH:mm:ss',
|
|
24
|
+
'emailId' => attendance.email,
|
|
25
|
+
'checkIn' => attendance.check_in.strftime('%d/%m/%Y %H:%M:%S'),
|
|
26
|
+
'checkOut' => attendance.check_out.strftime('%d/%m/%Y %H:%M:%S')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
request(:post, 'attendance', params: params)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_attendance_report(email:, from:, to:)
|
|
33
|
+
params = {
|
|
34
|
+
'authtoken' => auth_token,
|
|
35
|
+
'dateFormat' => 'yyyy-MM-dd',
|
|
36
|
+
'emailId' => email,
|
|
37
|
+
'sdate' => from.strftime('%Y-%m-%d'),
|
|
38
|
+
'edate' => to.strftime('%Y-%m-%d')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
data = request(:get, 'attendance/getUserReport', params: params)
|
|
42
|
+
|
|
43
|
+
AttendanceReport.parse(data)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def request(method, endpoint, options)
|
|
49
|
+
response = HTTP.method(method).call("#{URL}/#{endpoint}", options)
|
|
50
|
+
|
|
51
|
+
if response.status.success?
|
|
52
|
+
response.parse
|
|
53
|
+
elsif response
|
|
54
|
+
raise "Failed to #{method.to_s.upcase} #{endpoint}. Error: #{response.body}"
|
|
55
|
+
else
|
|
56
|
+
raise 'Failed to request Zoho API'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -3,14 +3,25 @@
|
|
|
3
3
|
module Zoho
|
|
4
4
|
module People
|
|
5
5
|
class Attendance
|
|
6
|
-
|
|
6
|
+
attr_reader :check_in, :check_out, :email
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
def initialize(email:, check_in:, check_out:)
|
|
9
|
+
raise ArgumentError, 'check_in must be DateTime instance' unless check_in.is_a?(DateTime)
|
|
10
|
+
raise ArgumentError, 'check_out must be DateTime instance' unless check_out.is_a?(DateTime)
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
@email = email
|
|
11
13
|
@check_in = check_in
|
|
12
14
|
@check_out = check_out
|
|
13
|
-
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_s
|
|
18
|
+
"attendance from #{format(check_in)} to #{format(check_out)}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def format(datetime)
|
|
24
|
+
datetime.strftime('%F@%H:%M')
|
|
14
25
|
end
|
|
15
26
|
end
|
|
16
27
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Zoho
|
|
4
|
+
module People
|
|
5
|
+
class AttendanceReport
|
|
6
|
+
class Record
|
|
7
|
+
attr_reader :date, :status
|
|
8
|
+
|
|
9
|
+
def initialize(date:, status:)
|
|
10
|
+
@date = date
|
|
11
|
+
@status = status
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def missing_work?
|
|
15
|
+
status.empty? || status == 'Absent'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative './attendance_report/record'
|
|
4
|
+
|
|
5
|
+
module Zoho
|
|
6
|
+
module People
|
|
7
|
+
class AttendanceReport
|
|
8
|
+
attr_reader :records
|
|
9
|
+
|
|
10
|
+
def self.parse(data)
|
|
11
|
+
records = data.map do |date, entry|
|
|
12
|
+
Record.new(date: Date.parse(date), status: entry['Status'])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
new(records)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initialize(records)
|
|
19
|
+
@records = records.sort_by(&:date)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
metadata
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: attend
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Komorowski
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: clamp
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.3'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: http
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '4.4'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '4.4'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: bundler
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '1
|
|
47
|
+
version: '2.1'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '1
|
|
54
|
+
version: '2.1'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3.
|
|
61
|
+
version: '3.9'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3.
|
|
68
|
+
version: '3.9'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rubocop
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: '1.11'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
83
|
-
description: Attend is
|
|
84
|
-
|
|
82
|
+
version: '1.11'
|
|
83
|
+
description: Attend is CLI tool that will help you register your Zoho People attendance
|
|
84
|
+
in fast and easy way
|
|
85
85
|
email:
|
|
86
86
|
- mckomo@gmail.com
|
|
87
87
|
executables:
|
|
@@ -102,16 +102,20 @@ files:
|
|
|
102
102
|
- attend.gemspec
|
|
103
103
|
- bin/console
|
|
104
104
|
- bin/setup
|
|
105
|
-
- entrypoiny.rb
|
|
106
105
|
- exe/attend
|
|
107
106
|
- lib/attend.rb
|
|
107
|
+
- lib/attend/get_absent_days.rb
|
|
108
|
+
- lib/attend/register_attendances.rb
|
|
108
109
|
- lib/attend/version.rb
|
|
110
|
+
- lib/zoho/people/api.rb
|
|
109
111
|
- lib/zoho/people/attendance.rb
|
|
112
|
+
- lib/zoho/people/attendance_report.rb
|
|
113
|
+
- lib/zoho/people/attendance_report/record.rb
|
|
110
114
|
homepage: https://github.com/mckomo/attend
|
|
111
115
|
licenses:
|
|
112
116
|
- MIT
|
|
113
117
|
metadata: {}
|
|
114
|
-
post_install_message:
|
|
118
|
+
post_install_message:
|
|
115
119
|
rdoc_options: []
|
|
116
120
|
require_paths:
|
|
117
121
|
- lib
|
|
@@ -119,16 +123,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
119
123
|
requirements:
|
|
120
124
|
- - ">="
|
|
121
125
|
- !ruby/object:Gem::Version
|
|
122
|
-
version:
|
|
126
|
+
version: 2.7.2
|
|
123
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
128
|
requirements:
|
|
125
129
|
- - ">="
|
|
126
130
|
- !ruby/object:Gem::Version
|
|
127
131
|
version: '0'
|
|
128
132
|
requirements: []
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
signing_key:
|
|
133
|
+
rubygems_version: 3.2.13
|
|
134
|
+
signing_key:
|
|
132
135
|
specification_version: 4
|
|
133
|
-
summary: Register Zoho
|
|
136
|
+
summary: Register Zoho People attendance using CLI
|
|
134
137
|
test_files: []
|
data/entrypoiny.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'httparty'
|
|
4
|
-
|
|
5
|
-
DATE_FORMAT = 'dd/MM/yyyy HH:mm:ss'
|
|
6
|
-
AUTH_TOKEN = '3322c84ac90c17b50ad5268795854197'
|
|
7
|
-
|
|
8
|
-
attendance_endpoint = 'https://people.zoho.com/people/api/attendance'
|
|
9
|
-
|
|
10
|
-
parameters = {
|
|
11
|
-
'authtoken' => AUTH_TOKEN,
|
|
12
|
-
'dateFormat' => DATE_FORMAT,
|
|
13
|
-
'checkIn' => '26/06/2017 10:00:00',
|
|
14
|
-
'checkOut' => '26/06/2017 18:00:00',
|
|
15
|
-
'emailId' => 'krzysztof.kucharski@codete.com'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
response = HTTParty.post(attendance_endpoint, query: parameters)
|
|
19
|
-
|
|
20
|
-
puts response.body, response.code, response.message, response.headers.inspect
|