intercom 2.2.2 → 2.2.3
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 +4 -4
- data/README.md +11 -1
- data/changes.txt +3 -0
- data/lib/intercom.rb +10 -0
- data/lib/intercom/request.rb +9 -0
- data/lib/intercom/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9e9fc89a1afe0812e99ba788f34abb10a2efee6
|
4
|
+
data.tar.gz: 22a8b523d0118dca4f92f9429ddc046ab3126d1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06825933a4db65f7ea657c6525bc350d9df83cb3ad84a5baf4bb7043f061f32ccd8d7480d8a0bbe73614dda861375f4bd990c80d140f5b6feb90b60bab99ea94
|
7
|
+
data.tar.gz: f7059cecea4a6add02f0fcf1d28ea717a78829631393ed7f6d4e017e342e366da481affe6c9d4bf0aa95fa37f5d94f106f723126a30999f60e0594848d8c6e88
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Additionally, the new version uses Ruby 2.
|
|
19
19
|
|
20
20
|
Using bundler:
|
21
21
|
|
22
|
-
gem 'intercom', "~> 2.2.
|
22
|
+
gem 'intercom', "~> 2.2.3"
|
23
23
|
|
24
24
|
## Basic Usage
|
25
25
|
|
@@ -343,3 +343,13 @@ Intercom::BadRequestError
|
|
343
343
|
Intercom::RateLimitExceeded
|
344
344
|
Intercom::AttributeNotSetError # Raised when you try to call a getter that does not exist on an object
|
345
345
|
```
|
346
|
+
|
347
|
+
### Rate Limiting
|
348
|
+
|
349
|
+
Calling `Intercom.rate_limit_details` returns a Hash that contains details about your app's current rate limit.
|
350
|
+
|
351
|
+
```ruby
|
352
|
+
Intercom.rate_limit_details
|
353
|
+
#=> {:limit=>180, :remaining=>179, :reset_at=>2014-10-07 14:58:00 +0100}
|
354
|
+
```
|
355
|
+
|
data/changes.txt
CHANGED
data/lib/intercom.rb
CHANGED
@@ -36,6 +36,7 @@ module Intercom
|
|
36
36
|
@current_endpoint = nil
|
37
37
|
@app_id = nil
|
38
38
|
@app_api_key = nil
|
39
|
+
@rate_limit_details = {}
|
39
40
|
|
40
41
|
def self.app_id=(app_id)
|
41
42
|
@app_id = app_id
|
@@ -48,10 +49,19 @@ module Intercom
|
|
48
49
|
def self.app_api_key=(app_api_key)
|
49
50
|
@app_api_key = app_api_key
|
50
51
|
end
|
52
|
+
|
51
53
|
def self.app_api_key
|
52
54
|
@app_api_key
|
53
55
|
end
|
54
56
|
|
57
|
+
def self.rate_limit_details=(rate_limit_details)
|
58
|
+
@rate_limit_details = rate_limit_details
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.rate_limit_details
|
62
|
+
@rate_limit_details
|
63
|
+
end
|
64
|
+
|
55
65
|
# This method is obsolete and used to warn of backwards incompatible changes on upgrading
|
56
66
|
def self.api_key=(val)
|
57
67
|
raise ArgumentError, "#{compatibility_warning_text} #{compatibility_workaround_text} #{related_docs_text}"
|
data/lib/intercom/request.rb
CHANGED
@@ -61,6 +61,7 @@ module Intercom
|
|
61
61
|
client(base_uri).start do |http|
|
62
62
|
begin
|
63
63
|
response = http.request(net_http_method)
|
64
|
+
set_rate_limit_details(response)
|
64
65
|
decoded = decode(response['content-encoding'], response.body)
|
65
66
|
unless decoded.strip.empty?
|
66
67
|
parsed_body = JSON.parse(decoded)
|
@@ -77,6 +78,14 @@ module Intercom
|
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
81
|
+
def set_rate_limit_details(response)
|
82
|
+
rate_limit_details = {}
|
83
|
+
rate_limit_details[:limit] = response['X-RateLimit-Limit'].to_i if response['X-RateLimit-Limit']
|
84
|
+
rate_limit_details[:remaining] = response['X-RateLimit-Remaining'].to_i if response['X-RateLimit-Remaining']
|
85
|
+
rate_limit_details[:reset_at] = Time.at(response['X-RateLimit-Reset'].to_i) if response['X-RateLimit-Reset']
|
86
|
+
Intercom.rate_limit_details = rate_limit_details
|
87
|
+
end
|
88
|
+
|
80
89
|
def decode(content_encoding, body)
|
81
90
|
return body if (!body) || body.empty? || content_encoding != 'gzip'
|
82
91
|
Zlib::GzipReader.new(StringIO.new(body)).read
|
data/lib/intercom/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2014-10-
|
18
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: minitest
|