auth-lh 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25846ed903ad93193b5a1b12db490c18436456d8
4
- data.tar.gz: 2561e4786c7f090ab0d2a2066285c144fe67921f
3
+ metadata.gz: dc1e3adcd34051edf7cc9bc3875417a37a851589
4
+ data.tar.gz: 22a41cf358bfe8ded9d7c4c86c238d8adc7cb39b
5
5
  SHA512:
6
- metadata.gz: 0987b288d526a43409d8fdcb7d5f7879ca6b95c5524491b307b9e7a7d3bbac5492e766e4eef89d3cbea77f82b426ed564359a82511a9d1f2a899dd37b27d20ea
7
- data.tar.gz: 245ba3dd8c658ae32dcd3b480cd2ae3379f1ba3b41f8fd4bdd725d442a3084a173c3000c50ac40a30815d805353f80ae0e4a0f380a42e4a842aedf8a18ebb1b2
6
+ metadata.gz: 3ef5f6f956b44c1775e35c50e71ea7aa150e8cf107bd534c34ca0baf6774baf2761b52bc48441c5a5e11ddadd513d7a86a99d054c9b6cb024221cc62432b0423
7
+ data.tar.gz: e6b4c723e0b384661a13648c36dcac79f5df3d299c78c831f28ea0f0fe2300ecca8377fb102fe360da493dd8994b243612813ee6b54db60b9af623918bee4ab5
data/CHANGELOG.md CHANGED
@@ -9,3 +9,7 @@
9
9
  ## v0.0.3
10
10
 
11
11
  * Bugfix: namespace bad typed
12
+
13
+ ## v0.0.4
14
+
15
+ * Implemented method to get users from api
data/lib/auth/lh/api.rb CHANGED
@@ -30,6 +30,15 @@ module Auth
30
30
  "#{@endpoint}/logout?return=#{CGI::escape(@return_url)}"
31
31
  end
32
32
 
33
+ def get_user(code_or_login)
34
+ User.new(get_request("/api/user/#{code_or_login}"))
35
+ end
36
+
37
+ def get_users(filters={})
38
+ results = get_request("/api/users", filters)
39
+ results.map { |r| User.new(r) }
40
+ end
41
+
33
42
  protected
34
43
 
35
44
  def create_login_attempt
@@ -42,11 +51,16 @@ module Auth
42
51
  end
43
52
 
44
53
  def get_request(action, params={})
45
- JSON.parse(RestClient.get("#{@endpoint}#{action}", {params: params}))
54
+ response = RestClient.get("#{@endpoint}#{action}", {params: params}.merge(auth_headers))
55
+ JSON.parse(response.body)
46
56
  end
47
57
 
48
58
  def post_request(action, params={})
49
- JSON.parse(RestClient.post("#{@endpoint}#{action}", params))
59
+ JSON.parse(RestClient.post("#{@endpoint}#{action}", params, auth_headers))
60
+ end
61
+
62
+ def auth_headers
63
+ { authorization: "Token token=\"#{@access_token}\"" }
50
64
  end
51
65
  end
52
66
  end
data/lib/auth/lh/user.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Auth
2
2
  module Lh
3
3
  class User
4
- attr_accessor :code, :email, :jabber, :name, :login,
5
- :shop_code, :allowed_application_codes
4
+ attr_accessor :code, :email, :jabber, :name, :login, :shop_code,
5
+ :is_admin, :allow_remote_access, :last_activity
6
6
 
7
7
  def initialize(attributes={})
8
8
  attributes.each do |k,v|
@@ -1,5 +1,5 @@
1
1
  module Auth
2
2
  module Lh
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth-lh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick