shopkeep_reports 1.1.0 → 2.0.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: d3895011f90d9ffa29050e704cb541eb51951029
4
- data.tar.gz: f31f12dcdbc309145f15b2eb58ccc3c9d5fc37a6
3
+ metadata.gz: 4a5026b4d4d59c46876338d8bd8f6f17d68a2504
4
+ data.tar.gz: d0e9bb4728b3e3904d909198c42eed92a6aa149e
5
5
  SHA512:
6
- metadata.gz: 8287e92acc664c0280f2f61f03fb31a8694b5ce751914f39feadf05659c3ac98c77cfed4171c4f3b3b08fb6c80898082a008092c141c21922472867cfd7e60bf
7
- data.tar.gz: 208e34c898b73dbc4d646da8daf637aade6904163cd82f27d77a1ae50d89271296b35127fb56baafdcb27c2e4efb3b64b733db9c8e41ec0af0b0fab06c2a719f
6
+ metadata.gz: b1a76e7bb4cfe415448692b44ec27f141317af5130617c9bd9aa7a80f0b3bd26e2f88147a1304316890deb7d42beb6e2fdc2fc12cdc6d959044b1785232b62af
7
+ data.tar.gz: ff01435e42b627e563061878743e7b0027d41111a784234d3bdaf2ac178d7198736b909756c0f0c89dfc1c1cd93c55b90241b0ae04bd0a4edef0f73208b74966
@@ -56,10 +56,10 @@ module ShopkeepReports
56
56
  raise ShopkeepException, "#{e.message}"
57
57
  end
58
58
 
59
- def download_transaction_report_link(report_link)
59
+ def download_transaction_report_link(report_link, start, finish)
60
60
  new_agent = Mechanize.new
61
61
  new_agent.cookie_jar = @@cookie_jar
62
- new_agent.get(report_link)
62
+ new_agent.post(report_link, { 'authenticity_token' => @@token, 'start' => start, 'finish' => finish })
63
63
  sleep(5)
64
64
  export_list = new_agent.get(configuration.uri("/export_center.json"))
65
65
  export_json = export_list.body
@@ -32,6 +32,10 @@ module ShopkeepReports
32
32
  "https://" + @account + ".shopkeepapp.com" + path
33
33
  end
34
34
 
35
+ def transaction_uri(path)
36
+ "https://www.shopkeepapp.com" + path
37
+ end
38
+
35
39
  private
36
40
  def default_email
37
41
  ENV['SHOPKEEP_EMAIL']
@@ -45,4 +49,4 @@ module ShopkeepReports
45
49
  ENV['SHOPKEEP_ACCOUNT']
46
50
  end
47
51
  end
48
- end
52
+ end
@@ -39,14 +39,14 @@ module ShopkeepReports
39
39
  end_date = args.fetch(:end_date, Time.now)
40
40
  detailed = args.fetch(:detailed, false)
41
41
  tenders = args.fetch(:tenders, false)
42
- query = {
43
- start_time: start_date.strftime("%B %d %Y %I:%M %p"),
44
- end_time: end_date.strftime("%B %d %Y %I:%M %p"),
45
- detailed: detailed,
46
- tenders: tenders
47
- }
42
+ link = ""
43
+ if detailed == true
44
+ link = "/exports/rogue/transacted_items"
45
+ elsif tenders == true
46
+ link = "/exports/rogue/tenders"
47
+ end
48
48
  Client.instance.authorize
49
- Client.instance.download_transaction_report_link(configuration.uri("/transactions.csv?#{query.to_query}"))
49
+ Client.instance.download_transaction_report_link(configuration.transaction_uri(link), start_date.iso8601, end_date.iso8601)
50
50
  end
51
51
 
52
52
  private
@@ -1,3 +1,3 @@
1
1
  module ShopkeepReports
2
- VERSION = "1.1.0"
2
+ VERSION = "2.0.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.1.0
4
+ version: 2.0.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: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler