Class: Analytics::Request
- Inherits:
-
Struct
- Object
- Struct
- Analytics::Request
- Defined in:
- lib/analytics/request.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#relative_path ⇒ Object
Returns the value of attribute relative_path.
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token
4 5 6 |
# File 'lib/analytics/request.rb', line 4 def access_token @access_token end |
#base_url ⇒ Object
Returns the value of attribute base_url
4 5 6 |
# File 'lib/analytics/request.rb', line 4 def base_url @base_url end |
#relative_path ⇒ Object
Returns the value of attribute relative_path
4 5 6 |
# File 'lib/analytics/request.rb', line 4 def relative_path @relative_path end |
Instance Method Details
#full_path ⇒ Object
5 6 7 |
# File 'lib/analytics/request.rb', line 5 def full_path "#{base_url.to_s}/#{relative_path.to_s}" end |
#request ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/analytics/request.rb', line 9 def request retried = false begin access_token.get(full_path).body rescue ::OAuth2::Error => e # One of the 403 error code means that you already did 10 requests for a second if e.code["code"] == 403 && !retried sleep 1 retried = true retry end raise Analytics::Error::PermissionInsufficient end end |
#response ⇒ Object
24 25 26 |
# File 'lib/analytics/request.rb', line 24 def response @response ||= MultiJson.load(request) end |