rjmetrics-client 0.5.2 → 0.6.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 +4 -4
- data/lib/rjmetrics-client/client.rb +25 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0770039de26e1d00fdc334ea6438df2ac7c7228
|
4
|
+
data.tar.gz: 7d69102d518e3948ddbf7bccfa02bad89409ea80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db62e2cfe36cf4824e61a6b7eebcd689af8290e6556ed5148a1a02c0e392b29a4bd022a7394cf011ed08fb4a2083423d7e5904f64c2220b9c5e4af24800e9e61
|
7
|
+
data.tar.gz: 2bf01c227c17fdc1ec555a736eb8cbeff315fa247a8d6ebe063df295b1517cc5336ac450374a0e64963857a0a8c8e7cd8f6d6cd328fd1206a797e8d13731dc5e
|
@@ -30,11 +30,10 @@ module RJMetrics
|
|
30
30
|
@timeout_in_seconds = timeout_in_seconds
|
31
31
|
end
|
32
32
|
|
33
|
-
# Checks if the provided Client ID and API Key are valid
|
33
|
+
# Checks if the provided Client ID and API Key are valid.
|
34
34
|
def authenticated?
|
35
|
-
test_data = {:keys => [:id], :id => 1}
|
36
35
|
begin
|
37
|
-
|
36
|
+
makeAuthAPICall()
|
38
37
|
rescue InvalidRequestException
|
39
38
|
return false
|
40
39
|
end
|
@@ -91,6 +90,29 @@ module RJMetrics
|
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
93
|
+
# Authenticates with the RJMetrics Data Import API
|
94
|
+
def makeAuthAPICall(url = API_BASE)
|
95
|
+
request_url = "#{url}/client/#{@client_id}/authenticate?apikey=#{@api_key}"
|
96
|
+
begin
|
97
|
+
response = RestClient.get(request_url)
|
98
|
+
return response
|
99
|
+
rescue RestClient::Exception => error
|
100
|
+
begin
|
101
|
+
response = JSON.parse(error.response)
|
102
|
+
|
103
|
+
unless response
|
104
|
+
raise InvalidRequestException, "The Import API returned: #{error.http_code} #{error.message}"
|
105
|
+
end
|
106
|
+
|
107
|
+
raise InvalidRequestException,
|
108
|
+
"The Import API returned: #{response['code']} #{response['message']}. Reasons: #{response['reasons']}"
|
109
|
+
rescue JSON::ParserError, TypeError => json_parse_error
|
110
|
+
raise InvalidResponseException,
|
111
|
+
"RestClientError: #{error.class}\n Message: #{error.message}\n Response Code: #{error.http_code}\n Full Response: #{error.response}"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
94
116
|
def makePushDataAPICall(table_name, data, url = API_BASE)
|
95
117
|
request_url = "#{url}/client/#{@client_id}/table/#{table_name}/data?apikey=#{@api_key}"
|
96
118
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjmetrics-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.5.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: RJMetrics Data Import API Client Library
|