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
authorization_header, build_url, content_headers, create_csv, delete, get, 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) ⇒ Object
11
12
13
|
# File 'lib/bob/api/reports.rb', line 11
def self.read(report_id)
get("company/reports/#{report_id}/download?format=csv", {}, csv_response: true)
end
|
.sftp_upload(sftp_details:, report_id:) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/bob/api/reports.rb', line 15
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
|