rtx-api 0.3.1 → 0.3.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 +4 -4
- data/lib/rtx/api/client.rb +25 -6
- data/lib/rtx/api/resources.rb +1 -0
- data/lib/rtx/api/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: 3e8e770ba4720010d7e1b230e02327da4a26b0da
|
4
|
+
data.tar.gz: 49141abf05dc7227b67d7469f4cc8ad32970a603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0a2083bb4061e976d501a742ed33fc0b392e3ce2cf366e081de77599132b61f412720ed9cd1de95cbe46b9ea355d7384522c54b7d3603d9459c00a9ca469c87
|
7
|
+
data.tar.gz: 3e15cce436dae73c010af01792146f24ab475e2eb35bf4b939586d9ea7a8d9f1d93b3a78dc9d8bd4369f284b6736186dabf27302718a6523008cfce40c170204
|
data/lib/rtx/api/client.rb
CHANGED
@@ -21,10 +21,22 @@ module RTX
|
|
21
21
|
if request.code != 201
|
22
22
|
raise API::Errors::AuthenticationError.new("Authentication Login Error: #{response}")
|
23
23
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
set_attributes(response[:token], response[:expires_at], response[:account_id], response[:profile_id])
|
25
|
+
end
|
26
|
+
|
27
|
+
def authenticate_as(email, &block)
|
28
|
+
authenticate if !authenticated?
|
29
|
+
response = collection(:users, email: email)
|
30
|
+
if response[:_total] == 1
|
31
|
+
user = response[:_embedded][:users][0]
|
32
|
+
auth_response = post(:auth_tokens, account_id: user[:account_id], user_id: user[:id])
|
33
|
+
client = self.class.new(auth_response[:email], auth_response[:token])
|
34
|
+
client.set_attributes(auth_response[:token], auth_response[:expires_at], auth_response[:account_id], auth_response[:profile_id])
|
35
|
+
block.call(client)
|
36
|
+
else
|
37
|
+
raise API::Errors::ClientError.new("User not found with associated email address: #{email}")
|
38
|
+
end
|
39
|
+
true
|
28
40
|
end
|
29
41
|
|
30
42
|
def expired?
|
@@ -105,12 +117,19 @@ module RTX
|
|
105
117
|
path
|
106
118
|
end
|
107
119
|
|
120
|
+
def set_attributes(token, expires, account_id, profile_id)
|
121
|
+
@token = token
|
122
|
+
@expires = expires
|
123
|
+
@account_id = account_id
|
124
|
+
@profile_id = profile_id
|
125
|
+
end
|
126
|
+
|
108
127
|
protected
|
109
128
|
|
110
129
|
def default_headers
|
111
130
|
{
|
112
|
-
'Content-Type' => "application/
|
113
|
-
'Accept' => "application/
|
131
|
+
'Content-Type' => "application/hal+json",
|
132
|
+
'Accept' => "application/hal+json",
|
114
133
|
'User-Agent' => "rtx-api-client-ruby/#{API::VERSION}"
|
115
134
|
}.freeze
|
116
135
|
end
|
data/lib/rtx/api/resources.rb
CHANGED
data/lib/rtx/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtx-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ReviewTrackers Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|