bobhr 0.3.4 → 0.4.0

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: 90881d623b810aaf7a5469ea86edbad348cf430961b4f166667c30931881a054
4
- data.tar.gz: bfc0f96e9a49e0c11ebeb326a006ea5a2c03dafc8b9d3ae50be63171b93abd8f
3
+ metadata.gz: 4a4cfc182047ea0cc73d936310c357503289d39887a234d5ec98d4342912d340
4
+ data.tar.gz: 3ded6f900318c2984a2fb02784b4ecdbd880ac3ddf711d31207d852c38f869e7
5
5
  SHA512:
6
- metadata.gz: c68aa05573becd8c2532b7150161c86fc32a791173ec8f63edbc4461cab734f929ee6c535d2cf10813b634958f1b6f455e22182356b15198c0a080a2a96bd1f7
7
- data.tar.gz: 18735135af683b46d6b17ac7d27f8426ee43e8815db6dfea552072d71a3e0851dd6e5c5569c939b545f5fa45abce466de5931083caa9b56796403c9d6339ca6e
6
+ metadata.gz: e894d067445285d3dd4beafb06f8bc62e7d5aaedc9c47131ef8db93c2af2a357c222de13205fdd948fb47ad346941c9533dde687de3416cee7192ebdee2382e9
7
+ data.tar.gz: b6582c5fb8de24a7d76b368061224359c2a0f02ece2cfc02510d115fd97dbfedf7775083d31ddc22c528f0bd900f20cb0038d8462874bafadc4661a1844abc82
data/lib/bob/api.rb CHANGED
@@ -10,7 +10,7 @@ module Bob
10
10
  class API
11
11
  BASE_URL = 'https://api.hibob.com'
12
12
 
13
- def self.get(endpoint, params = {}, csv_response = false)
13
+ def self.get(endpoint, params = {}, csv_response: false)
14
14
  url = build_url(endpoint, params)
15
15
  response = RestClient.get(url, headers)
16
16
  return create_csv(response.body) if csv_response
@@ -56,17 +56,19 @@ module Bob
56
56
  url
57
57
  end
58
58
 
59
- private
60
-
61
59
  def self.create_csv(content)
62
- content.gsub!("\r", '').gsub!("", '')
60
+ file_name = SecureRandom.alphanumeric(15)
61
+
62
+ content.gsub!("\r", '').gsub!('', '')
63
63
  splitted = content.split("\n")
64
- CSV.open("response.csv", "wb") do |csv|
64
+ CSV.open("tmp/#{file_name}.csv", 'wb') do |csv|
65
65
  csv << splitted.shift.split(',')
66
66
  splitted.each do |row|
67
67
  csv << row.split(',')
68
68
  end
69
69
  end
70
+
71
+ "tmp/#{file_name}.csv"
70
72
  end
71
73
  end
72
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", {}, true)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bob
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.0'
5
5
  end
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.4
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-15 00:00:00.000000000 Z
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
@@ -86,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
100
  - !ruby/object:Gem::Version
87
101
  version: '0'
88
102
  requirements: []
89
- rubygems_version: 3.2.31
103
+ rubygems_version: 3.3.7
90
104
  signing_key:
91
105
  specification_version: 4
92
106
  summary: Ruby gem for Bob API