Class: Bob::Reports
- Inherits:
-
API
show all
- Defined in:
- lib/bob/api/reports.rb
Constant Summary
Constants inherited
from API
API::BASE_URL, API::SANDBOX_URL
Class Method Summary
collapse
Methods inherited from API
build_url, create_csv, delete, get, headers, post, post_file, post_media, put
Class Method Details
.all ⇒ Object
7
8
9
|
# File 'lib/bob/api/reports.rb', line 7
def self.all
get('company/reports')
end
|
.read(report_id, params = {}) ⇒ Object
11
12
13
14
15
|
# File 'lib/bob/api/reports.rb', line 11
def self.read(report_id, params = {})
params = { format: 'csv' }.merge(params)
get("company/reports/#{report_id}/download", params, csv_response: true)
end
|
.read_table_report(report_id) ⇒ Object
17
18
19
|
# File 'lib/bob/api/reports.rb', line 17
def self.read_table_report(report_id)
get("people/custom-tables/metadata/#{report_id}")
end
|
.sftp_upload(sftp_details:, report_id:) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bob/api/reports.rb', line 21
def self.sftp_upload(sftp_details:, report_id:)
file_name = read(report_id)
uri = URI.parse("sftp://#{sftp_details[:host]}")
Net::SFTP.start(uri.host, sftp_details[:user], password: sftp_details[:password]) do |sftp|
sftp.upload!(file_name, sftp_details[:remote_file_path])
end
File.delete(file_name)
true
end
|