bobhr 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bob/api.rb +19 -1
- data/lib/bob/reports.rb +11 -1
- data/lib/bob/version.rb +1 -1
- data/lib/bob/webhooks.rb +10 -0
- data/lib/bob.rb +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a4cfc182047ea0cc73d936310c357503289d39887a234d5ec98d4342912d340
|
4
|
+
data.tar.gz: 3ded6f900318c2984a2fb02784b4ecdbd880ac3ddf711d31207d852c38f869e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e894d067445285d3dd4beafb06f8bc62e7d5aaedc9c47131ef8db93c2af2a357c222de13205fdd948fb47ad346941c9533dde687de3416cee7192ebdee2382e9
|
7
|
+
data.tar.gz: b6582c5fb8de24a7d76b368061224359c2a0f02ece2cfc02510d115fd97dbfedf7775083d31ddc22c528f0bd900f20cb0038d8462874bafadc4661a1844abc82
|
data/lib/bob/api.rb
CHANGED
@@ -4,14 +4,17 @@ require 'rest-client'
|
|
4
4
|
require 'json'
|
5
5
|
require 'uri'
|
6
6
|
require 'base64'
|
7
|
+
require 'csv'
|
7
8
|
|
8
9
|
module Bob
|
9
10
|
class API
|
10
11
|
BASE_URL = 'https://api.hibob.com'
|
11
12
|
|
12
|
-
def self.get(endpoint, params = {})
|
13
|
+
def self.get(endpoint, params = {}, csv_response: false)
|
13
14
|
url = build_url(endpoint, params)
|
14
15
|
response = RestClient.get(url, headers)
|
16
|
+
return create_csv(response.body) if csv_response
|
17
|
+
|
15
18
|
JSON.parse(response.body)
|
16
19
|
end
|
17
20
|
|
@@ -52,5 +55,20 @@ module Bob
|
|
52
55
|
|
53
56
|
url
|
54
57
|
end
|
58
|
+
|
59
|
+
def self.create_csv(content)
|
60
|
+
file_name = SecureRandom.alphanumeric(15)
|
61
|
+
|
62
|
+
content.gsub!("\r", '').gsub!('', '')
|
63
|
+
splitted = content.split("\n")
|
64
|
+
CSV.open("tmp/#{file_name}.csv", 'wb') do |csv|
|
65
|
+
csv << splitted.shift.split(',')
|
66
|
+
splitted.each do |row|
|
67
|
+
csv << row.split(',')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
"tmp/#{file_name}.csv"
|
72
|
+
end
|
55
73
|
end
|
56
74
|
end
|
data/lib/bob/reports.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'net/sftp'
|
4
|
+
|
3
5
|
module Bob
|
4
6
|
class Reports < API
|
5
7
|
def self.all
|
@@ -7,7 +9,15 @@ module Bob
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def self.read(report_id)
|
10
|
-
get("company/reports/#{report_id}/download?format=csv")
|
12
|
+
get("company/reports/#{report_id}/download?format=csv", {}, csv_response: true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.sftp_upload(sftp_details:, report_id:)
|
16
|
+
file_name = read(report_id)
|
17
|
+
|
18
|
+
Net::SFTP.start(sftp_details[:host], sftp_details[:user], password: sftp_details[:password]) do |sftp|
|
19
|
+
sftp.upload!(file_name, sftp_details[:remote_file_path])
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
13
23
|
end
|
data/lib/bob/version.rb
CHANGED
data/lib/bob/webhooks.rb
ADDED
data/lib/bob.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bobhr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lien Van Den Steen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-sftp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Ruby gem for Bob API
|
42
56
|
email:
|
43
57
|
- lienvandensteen@gmail.com
|
@@ -64,6 +78,7 @@ files:
|
|
64
78
|
- lib/bob/reports.rb
|
65
79
|
- lib/bob/time_off.rb
|
66
80
|
- lib/bob/version.rb
|
81
|
+
- lib/bob/webhooks.rb
|
67
82
|
- lib/bobhr.rb
|
68
83
|
homepage: https://github.com/lienvdsteen/hibob
|
69
84
|
licenses:
|
@@ -85,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
100
|
- !ruby/object:Gem::Version
|
86
101
|
version: '0'
|
87
102
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
103
|
+
rubygems_version: 3.3.7
|
89
104
|
signing_key:
|
90
105
|
specification_version: 4
|
91
106
|
summary: Ruby gem for Bob API
|