davetron5000-gliffy 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,72 +0,0 @@
1
- require 'rexml/document'
2
- require 'array_has_response'
3
- require 'gliffy/rest'
4
-
5
- include REXML
6
-
7
- module Gliffy
8
-
9
- # A user token
10
- class UserToken < Response
11
- attr_reader :expiration
12
- attr_reader :token
13
- def self.from_xml(element)
14
- expiration = Time.at(element.attributes['expiration'].to_i / 1000)
15
- token = element.text
16
- UserToken.new(expiration,token)
17
- end
18
-
19
- def expired?
20
- Time.now > expiration
21
- end
22
-
23
- def initialize(expiration,token)
24
- super()
25
- @expiration = expiration
26
- @token = token
27
- end
28
-
29
- end
30
-
31
- class Users < ArrayResponseParser; end
32
-
33
- # A user of Gliffy and the main entry point to using the API (see #initiate_session)
34
- class User < Response
35
-
36
- # The user's username, which is their identifier within an account
37
- attr_reader :username
38
- # The user's email, which is unique to them in the entire Gliffy system.
39
- # Note that this isn't guaranteed to be a real email, nor is
40
- # it guaranteed to be the user's actual email. This is
41
- # assigned by the system unless overridden by the API.
42
- attr_reader :email
43
- attr_reader :id
44
-
45
- def self.from_xml(element)
46
- id = element.attributes['id'].to_i
47
- is_admin = false
48
- is_admin = element.attributes['is-admin'] == 'true' if element.attributes['is-admin']
49
- username = element.elements['username'] ? element.elements['username'].text : nil
50
- email = element.elements['email'] ? element.elements['email'].text : nil
51
-
52
- User.new(id,is_admin,username,email)
53
- end
54
-
55
- # Returns true if this user is an admin of the account in which they live
56
- def is_admin?
57
- @is_admin
58
- end
59
-
60
- protected
61
-
62
- def initialize(id,is_admin,username,email)
63
- super()
64
- @id = id
65
- @is_admin = is_admin
66
- @username = username
67
- @email = email
68
- end
69
-
70
- end
71
-
72
- end