class Zzlink::Users

The zzUser service.

Public Instance Methods

create_session(attributes) click to toggle source

Create or reset a session. @param attributes [Hash] attributes of the new session. If the combination of user_id and client_id confilicts, the existing session will be reset. @return [Session] the created or updated session. @raise [Error] in case of failure.

# File lib/zzlink/users.rb, line 83
def create_session(attributes)
  session = Session.new(attributes)
  resp = post('/sessions', session.to_hash)
  session.from_hash(JSON.parse(resp))
  session
end
create_user(attributes) click to toggle source

Create a user. If :oauth_provider and :oauth_id already exist, the existing user will be updated. @param attributes [Hash] attributes of the new user. @return [User] the created user. @raise [Error] in case of failure.

# File lib/zzlink/users.rb, line 72
def create_user(attributes)
  user = User.new(attributes)
  resp = post('/users', user.to_hash)
  user.from_hash(JSON.parse(resp))
  user
end
delete_session_by_token(token) click to toggle source

Delete a session by its token. @param token [String] the token. @return [Boolean] the found session or nil.

# File lib/zzlink/users.rb, line 105
def delete_session_by_token(token)
  begin
    delete("/sessions/#{token}")
    true
  rescue
    false
  end
end
find_session_by_token(token) click to toggle source

Find a session by its token. @param token [String] the token. @return [Session, nil] the found session or nil.

# File lib/zzlink/users.rb, line 93
def find_session_by_token(token)
  begin
    resp = get("/sessions/#{token}")
    Session.new(JSON.parse(resp))
  rescue
    nil
  end
end
name() click to toggle source
# File lib/zzlink/users.rb, line 60
def name
  'zzUsers'
end
version() click to toggle source
# File lib/zzlink/users.rb, line 64
def version
  'v1.0'
end