<commit_before>module ShopkeepReports
  class Downloader
    def initialize
      raise ShopkeepException, "Configuration is invalid" unless Configuration.instance.valid?
    end

    def customer_report
      Client.instance.authorize
      Client.instance.download_report(configuration.uri('/customers/create_export'), 'post')
    end

    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

    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

    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

    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

    def download_inventory
      Client.instance.authorize
      Client.instance.download_report_link(configuration.uri('/stock_items_exports/export_bulk_inventory'))
    end

    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)
      query = {
        start_date: start_date.strftime("%B %d %Y %I:%M %p"),
        end_date: end_date.strftime("%B %d %Y %I:%M %p"),
        detailed: detailed,
        tenders: tenders
      }
      Client.instance.authorize
      Client.instance.download_report_link(configuration.uri("/transactions.csv?#{query.to_query}"))
    end

    private
    def configuration
      ShopkeepReports.configuration
    end
  end
end<commit_msg>Fix Start & End Time query params<commit_after>module ShopkeepReports
  class Downloader
    def initialize
      raise ShopkeepException, "Configuration is invalid" unless Configuration.instance.valid?
    end

    def customer_report
      Client.instance.authorize
      Client.instance.download_report(configuration.uri('/customers/create_export'), 'post')
    end

    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

    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

    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

    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

    def download_inventory
      Client.instance.authorize
      Client.instance.download_report_link(configuration.uri('/stock_items_exports/export_bulk_inventory'))
    end

    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)
      query = {
        start_time: start_date.strftime("%B %d %Y %I:%M %p"),
        end_time: end_date.strftime("%B %d %Y %I:%M %p"),
        detailed: detailed,
        tenders: tenders
      }
      Client.instance.authorize
      Client.instance.download_report_link(configuration.uri("/transactions.csv?#{query.to_query}"))
    end

    private
    def configuration
      ShopkeepReports.configuration
    end
  end
end
{'fraction_non_alphanumeric': 0.10525036460865338, 'fraction_numerical': 0.0, 'mean_word_length': 3.628796400449944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '801045', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1216, 'n_words': 224}