bobhr 0.2.0 → 0.3.3

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: d48ea76f624d83c68b49953dcb9a5329250bf404e7936d7c8ab99a4ca349165d
4
- data.tar.gz: 3cbd7409788e5ba53e5714c2d52979695b8e566d1ca8b63713f2a9a329dde012
3
+ metadata.gz: 372b43f26c87a5eb6756486b7fae157c03ac8c018b37fae8bce1535e89e143c0
4
+ data.tar.gz: '0385c30f1f4371f410f11e0de393eeea984788f6f49d50d384002d4d6ca09c1c'
5
5
  SHA512:
6
- metadata.gz: 3e234bf17c1997741a47490b3d70cb5a55b160b1435c13b21f89ec6dc0766a3d37569df2db74937b794af260f8a94655d3028910b7da28e367515e2bb3aed6be
7
- data.tar.gz: 64d73f5a829cdb79eba59b20e2bd651d29487e88fcaea30effceeac0cf7a15e8b16eb093a77374236f531de3773fb59036ee1748b8c9975ed4f10ab9a875e388
6
+ metadata.gz: 05d570b22c1d4c37324bbe32bd7b6a6ff95d50fb71ba2c9e1ac4d27f33f0f92f554e4b25cc930f7f8e37b004e9b8e007ebd088bd1e5f9f20fedef0517047e26a
7
+ data.tar.gz: 4884d586604c41533afda06c8c012e9c9821a090ae0123596da7ca9a81fd3ca58dc346ad9f85fcd55f6ffe24b4dc2a6c5debc18c36a487b22e27129ca1fa0cd5
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
@@ -3,11 +3,15 @@
3
3
  module Bob
4
4
  class TimeOff < API
5
5
  def self.all_changed_since(since)
6
- get('timeoff/requests/changes', { since: since })
6
+ get('timeoff/requests/changes', { since: since })['changes']
7
7
  end
8
8
 
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.2.0'
4
+ VERSION = '0.3.3'
5
5
  end
data/lib/bob.rb CHANGED
@@ -7,6 +7,7 @@ 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'
10
11
 
11
12
  module Bob
12
13
  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.2.0
4
+ version: 0.3.3
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: 2021-12-21 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -61,6 +61,7 @@ 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
66
67
  - lib/bobhr.rb
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  requirements: []
87
- rubygems_version: 3.2.31
88
+ rubygems_version: 3.2.32
88
89
  signing_key:
89
90
  specification_version: 4
90
91
  summary: Ruby gem for Bob API