class ShopkeepReports::Downloader
Public Class Methods
new()
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 3 def initialize raise ShopkeepException, "Configuration is invalid" unless Configuration.instance.valid? end
Public Instance Methods
customer_report()
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 7 def customer_report Client.instance.authorize Client.instance.download_report(configuration.uri('/customers/create_export'), 'post') end
download_inventory()
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 32 def download_inventory Client.instance.authorize Client.instance.download_report_link(configuration.uri('/stock_items_exports/export_bulk_inventory')) end
download_transactions(args = {})
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 37 def download_transactions(args = {}) start_date = args.fetch(:start_date, Time.now.beginning_of_day) end_date = args.fetch(:end_date, Time.now) detailed = args.fetch(:detailed, false) tenders = args.fetch(:tenders, false) link = "" if detailed == true link = "/exports/items" elsif tenders == true link = "/exports/tenders" end Client.instance.authorize Client.instance.download_transaction_report_link(configuration.transaction_uri(link), start_date.iso8601, end_date.iso8601) end
returned_items_report(start_date = nil, end_date = nil)
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 27 def returned_items_report(start_date = nil, end_date = nil) Client.instance.authorize Client.instance.download_report(configuration.uri('/returned_items/new_export'), 'get', start_date, end_date) end
returns_report(start_date = nil, end_date = nil)
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 22 def returns_report(start_date = nil, end_date = nil) Client.instance.authorize Client.instance.download_report(configuration.uri('/returns/new_export'), 'get', start_date, end_date) end
sales_report(start_date = nil, end_date = nil)
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 12 def sales_report(start_date = nil, end_date = nil) Client.instance.authorize Client.instance.download_report(configuration.uri('/exports/sales/new'), 'get', start_date, end_date) end
sold_items_report(start_date = nil, end_date = nil)
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 17 def sold_items_report(start_date = nil, end_date = nil) Client.instance.authorize Client.instance.download_report(configuration.uri('/sold_items/new_export'), 'get', start_date, end_date) end
Private Instance Methods
configuration()
click to toggle source
# File lib/shopkeep_reports/downloader.rb, line 53 def configuration ShopkeepReports.configuration end