Class: ShopkeepReports::Downloader
- Inherits:
-
Object
- Object
- ShopkeepReports::Downloader
- Defined in:
- lib/shopkeep_reports/downloader.rb
Instance Method Summary collapse
- #customer_report ⇒ Object
- #download_inventory ⇒ Object
- #download_transactions(args = {}) ⇒ Object
-
#initialize ⇒ Downloader
constructor
A new instance of Downloader.
- #returned_items_report(start_date = nil, end_date = nil) ⇒ Object
- #returns_report(start_date = nil, end_date = nil) ⇒ Object
- #sales_report(start_date = nil, end_date = nil) ⇒ Object
- #sold_items_report(start_date = nil, end_date = nil) ⇒ Object
Constructor Details
#initialize ⇒ Downloader
Returns a new instance of Downloader.
3 4 5 |
# File 'lib/shopkeep_reports/downloader.rb', line 3 def initialize raise ShopkeepException, "Configuration is invalid" unless Configuration.instance.valid? end |
Instance Method Details
#customer_report ⇒ Object
7 8 9 10 |
# File 'lib/shopkeep_reports/downloader.rb', line 7 def customer_report Client.instance. Client.instance.download_report(configuration.uri('/customers/create_export'), 'post') end |
#download_inventory ⇒ Object
32 33 34 35 |
# File 'lib/shopkeep_reports/downloader.rb', line 32 def download_inventory Client.instance. Client.instance.download_report_link(configuration.uri('/stock_items_exports/export_bulk_inventory')) end |
#download_transactions(args = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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. 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) ⇒ Object
27 28 29 30 |
# File 'lib/shopkeep_reports/downloader.rb', line 27 def returned_items_report(start_date = nil, end_date = nil) Client.instance. Client.instance.download_report(configuration.uri('/returned_items/new_export'), 'get', start_date, end_date) end |
#returns_report(start_date = nil, end_date = nil) ⇒ Object
22 23 24 25 |
# File 'lib/shopkeep_reports/downloader.rb', line 22 def returns_report(start_date = nil, end_date = nil) Client.instance. Client.instance.download_report(configuration.uri('/returns/new_export'), 'get', start_date, end_date) end |
#sales_report(start_date = nil, end_date = nil) ⇒ Object
12 13 14 15 |
# File 'lib/shopkeep_reports/downloader.rb', line 12 def sales_report(start_date = nil, end_date = nil) Client.instance. Client.instance.download_report(configuration.uri('/exports/sales/new'), 'get', start_date, end_date) end |
#sold_items_report(start_date = nil, end_date = nil) ⇒ Object
17 18 19 20 |
# File 'lib/shopkeep_reports/downloader.rb', line 17 def sold_items_report(start_date = nil, end_date = nil) Client.instance. Client.instance.download_report(configuration.uri('/sold_items/new_export'), 'get', start_date, end_date) end |