Class: Users

Inherits:
Base show all
Defined in:
lib/zapix/proxies/users.rb

Defined Under Namespace

Classes: NonExistingUser

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#create(options) ⇒ Object



4
5
6
# File 'lib/zapix/proxies/users.rb', line 4

def create(options)
  client.user_create(options) unless exists?(options)
end

#delete(user_ids) ⇒ Object



21
22
23
# File 'lib/zapix/proxies/users.rb', line 21

def delete(user_ids)
  client.user_delete(user_ids)
end

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/zapix/proxies/users.rb', line 8

def exists?(options)
  result = client.user_get('filter' => { 'alias' => options['alias'] })
  result.empty? ? false : true
end

#get_id(options) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/zapix/proxies/users.rb', line 13

def get_id(options)
  if exists?(options)
    client.user_get('filter' => { 'alias' => options['alias'] }).first['userid']
  else
    raise NonExistingUser, "User #{options['alias']} does not exist !"
  end
end