bobhr 0.3.0 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49f184d406b6d8d4ca486575bf5a5128d5bfdddade6b16ddbdc05d167b639c1e
4
- data.tar.gz: 54291512a0368b35ee9ad1f6bf06ce2423a0f53cee26ec369944951cd1138ae9
3
+ metadata.gz: 90881d623b810aaf7a5469ea86edbad348cf430961b4f166667c30931881a054
4
+ data.tar.gz: bfc0f96e9a49e0c11ebeb326a006ea5a2c03dafc8b9d3ae50be63171b93abd8f
5
5
  SHA512:
6
- metadata.gz: ad5429acf3625d89a60241df8ccfb3125c25d8db0f2d5cbe00a36e0c7c7629b317f5d988a8548c3bd1c4904e7453d3cf96ec9883e444cb367cc0ffe2e7dd963f
7
- data.tar.gz: abfe38397ae9647c606c99eaad0ff04f913452519073c168c970525ccdaa42a5aab928210f0484b51ce3e3e661a2e60ef7aac6f2d0ba92d012d80f2167692412
6
+ metadata.gz: c68aa05573becd8c2532b7150161c86fc32a791173ec8f63edbc4461cab734f929ee6c535d2cf10813b634958f1b6f455e22182356b15198c0a080a2a96bd1f7
7
+ data.tar.gz: 18735135af683b46d6b17ac7d27f8426ee43e8815db6dfea552072d71a3e0851dd6e5c5569c939b545f5fa45abce466de5931083caa9b56796403c9d6339ca6e
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,18 @@ module Bob
52
55
 
53
56
  url
54
57
  end
58
+
59
+ private
60
+
61
+ def self.create_csv(content)
62
+ content.gsub!("\r", '').gsub!("", '')
63
+ splitted = content.split("\n")
64
+ CSV.open("response.csv", "wb") do |csv|
65
+ csv << splitted.shift.split(',')
66
+ splitted.each do |row|
67
+ csv << row.split(',')
68
+ end
69
+ end
70
+ end
55
71
  end
56
72
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bob
4
+ class Reports < API
5
+ def self.all
6
+ get('company/reports')
7
+ end
8
+
9
+ def self.read(report_id)
10
+ get("company/reports/#{report_id}/download?format=csv", {}, true)
11
+ end
12
+ end
13
+ end
data/lib/bob/time_off.rb CHANGED
@@ -9,5 +9,9 @@ module Bob
9
9
  def self.today
10
10
  get('timeoff/outtoday')
11
11
  end
12
+
13
+ def self.find_for_employee(employee_id, request_id)
14
+ get("timeoff/employees/#{employee_id}/requests/#{request_id}")
15
+ end
12
16
  end
13
17
  end
data/lib/bob/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bob
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.4'
5
5
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bob
4
+ class Webhooks
5
+ def self.calculate_signature(body:, key: ENV['BOB_WEBHOOK_SECRET'])
6
+ digest = OpenSSL::Digest.new('sha512')
7
+ Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, body))
8
+ end
9
+ end
10
+ end
data/lib/bob.rb CHANGED
@@ -7,6 +7,8 @@ require_relative 'bob/employees'
7
7
  require_relative 'bob/time_off'
8
8
  require_relative 'bob/onboarding_wizards'
9
9
  require_relative 'bob/metadata'
10
+ require_relative 'bob/reports'
11
+ require_relative 'bob/webhooks'
10
12
 
11
13
  module Bob
12
14
  extend Configuration
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.3.0
4
+ version: 0.3.4
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-01-05 00:00:00.000000000 Z
11
+ date: 2022-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -61,8 +61,10 @@ files:
61
61
  - lib/bob/metadata/company_fields.rb
62
62
  - lib/bob/metadata/company_lists.rb
63
63
  - lib/bob/onboarding_wizards.rb
64
+ - lib/bob/reports.rb
64
65
  - lib/bob/time_off.rb
65
66
  - lib/bob/version.rb
67
+ - lib/bob/webhooks.rb
66
68
  - lib/bobhr.rb
67
69
  homepage: https://github.com/lienvdsteen/hibob
68
70
  licenses: