usabilla_api 1.1.1 → 1.1.2

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: 6ab9ee5f48a68b85da16ceba8fa24ac83965c3c2
4
- data.tar.gz: cb4d01d5f6f88cf8cf1bf3c7a7a510c7caf15aa5
3
+ metadata.gz: 5b66214b5c6c7b4487f79a3cc60e5e7d5f586aa5
4
+ data.tar.gz: 3877f1cc54cc0ff5d6c26b89f83eaae54adbdc84
5
5
  SHA512:
6
- metadata.gz: 60f636ffe0da8712bde51839450c08bbd5a158a76e3583327a81a81a2b2f217fc303b84b6cc8514dc5f8e5cf159bf93365f0d43247c7e4c71bed70893bd04b58
7
- data.tar.gz: 8689e92b81e5a43409dcc7d84be90903393b8c0ace3bc5097c2135c54988dc5df37d6b4ee1baf4fca1b903f4f170153e1867a1dea09ef4800ea049f99a61bcee
6
+ metadata.gz: 54d8d0c1dfbb4536f785c47fc44b117bde9290202ab0b4a5c70343b70c38f916afe3cdc739e44fb7f601993ce4a4e215adfbdf1cd25a1fc066d558311d45cd6b
7
+ data.tar.gz: b03657d1f988807d8d1dfc22f98d09253dc57db71bed5e1c67bae03b220f80188f9358de64df3ac217b2c6a8e73d81d5620bc5a0544270b1a82125d07261c68a
@@ -1,6 +1,7 @@
1
1
  require 'rest-client'
2
2
  require 'openssl'
3
3
  require 'json'
4
+ require 'date'
4
5
 
5
6
  module UsabillaApi
6
7
 
@@ -14,8 +15,10 @@ module UsabillaApi
14
15
  @base_scope = UsabillaApi.configuration.base_scope
15
16
  @access_key = UsabillaApi.configuration.access_key
16
17
  @secret_key = UsabillaApi.configuration.secret_key
17
- @query_parameters = params || ''
18
- @query_id = @query_parameters["id"] || String.new
18
+ @query_id = params['id'] || String.new
19
+ @query_limit = params['limit'] || String.new
20
+ @query_since = params['since'] || String.new
21
+ @query_days_ago = params['days_ago'] || nil
19
22
  end
20
23
 
21
24
  def get_buttons
@@ -56,7 +59,7 @@ module UsabillaApi
56
59
  datestamp = t.strftime('%Y%m%d') # Date w/o time, used in credential scope
57
60
  long_date = t.strftime('%Y%m%dT%H%M%SZ')
58
61
 
59
- query_string = "limit=#{@query_parameters['limit']}&since=#{@query_parameters['since']}"
62
+ query_string = "limit=#{@query_limit}&since=#{get_since_timestamp}"
60
63
  canonical_headers = "date:#{usbldate}\nhost:#{@host}\n"
61
64
  signed_headers = 'date;host'
62
65
  payload_hash = OpenSSL::Digest::SHA256.new.hexdigest
@@ -94,5 +97,14 @@ module UsabillaApi
94
97
  uri.gsub(':id', @query_id)
95
98
  end
96
99
 
100
+ def since_filter(amount)
101
+ date_now = DateTime.now.new_offset(0)
102
+ date_ago = date_now - amount.to_i
103
+ (date_ago.to_time.to_f * 1000).to_i
104
+ end
105
+
106
+ def get_since_timestamp
107
+ @query_days_ago ? since_filter(@query_days_ago) : @query_since
108
+ end
97
109
  end
98
110
  end
@@ -1,3 +1,3 @@
1
1
  module UsabillaApi
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usabilla_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Molinaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-30 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client