shopkeep_reports 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18c96c6e9fc3f2a103d5955e74a5ec599f196735
4
- data.tar.gz: 02091b900d5250f3c16fe3ea7ef3af02148aa824
3
+ metadata.gz: d3895011f90d9ffa29050e704cb541eb51951029
4
+ data.tar.gz: f31f12dcdbc309145f15b2eb58ccc3c9d5fc37a6
5
5
  SHA512:
6
- metadata.gz: f24b5c374e68350b49b7999a58dc84c8e10f1047f51ffc316d020e01aa69655d72082337fc56a63ccae2f8391f43a5099f52c7a4afe5bc30ad49bbc84eedf905
7
- data.tar.gz: 6cbffd1b40ab9df694018def1d5aebe640a1d7cf36d24fd92ada59594c86feabbbbbe36427f019ed17f4a841d088de3c9220a206ce6fb8be1467dcf2b0817670
6
+ metadata.gz: 8287e92acc664c0280f2f61f03fb31a8694b5ce751914f39feadf05659c3ac98c77cfed4171c4f3b3b08fb6c80898082a008092c141c21922472867cfd7e60bf
7
+ data.tar.gz: 208e34c898b73dbc4d646da8daf637aade6904163cd82f27d77a1ae50d89271296b35127fb56baafdcb27c2e4efb3b64b733db9c8e41ec0af0b0fab06c2a719f
@@ -56,6 +56,27 @@ module ShopkeepReports
56
56
  raise ShopkeepException, "#{e.message}"
57
57
  end
58
58
 
59
+ def download_transaction_report_link(report_link)
60
+ new_agent = Mechanize.new
61
+ new_agent.cookie_jar = @@cookie_jar
62
+ new_agent.get(report_link)
63
+ sleep(5)
64
+ export_list = new_agent.get(configuration.uri("/export_center.json"))
65
+ export_json = export_list.body
66
+ export_hash = JSON.parse(export_json)
67
+ report_to_download = export_hash["aaData"].first["url"]
68
+ download = new_agent.get(configuration.uri(report_to_download))
69
+ file_body = download.body
70
+ file_name = File.join(configuration.tmp_directory, download.filename)
71
+ File.open(file_name, "wb") do |file|
72
+ file.write(file_body)
73
+ end
74
+ file_name
75
+ rescue Exception => e
76
+ reset
77
+ raise ShopkeepException, "#{e.message}"
78
+ end
79
+
59
80
  def download_report_link(report_link)
60
81
  new_agent = Mechanize.new
61
82
  new_agent.cookie_jar = @@cookie_jar
@@ -46,7 +46,7 @@ module ShopkeepReports
46
46
  tenders: tenders
47
47
  }
48
48
  Client.instance.authorize
49
- Client.instance.download_report_link(configuration.uri("/transactions.csv?#{query.to_query}"))
49
+ Client.instance.download_transaction_report_link(configuration.uri("/transactions.csv?#{query.to_query}"))
50
50
  end
51
51
 
52
52
  private
@@ -54,4 +54,4 @@ module ShopkeepReports
54
54
  ShopkeepReports.configuration
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module ShopkeepReports
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopkeep_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kunwar Aditya Raghuwanshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler