Class: Zoomba::User

Inherits:
Base
  • Object
show all
Defined in:
lib/zoomba/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#assign, perform_request, #perform_request, process_response, resource_path_part, #resource_path_part

Class Method Details

.autocreate(args = {}) ⇒ Object



9
10
11
12
# File 'lib/zoomba/user.rb', line 9

def autocreate(args = {})
  validate_params(args, :email, :type, :password)
  new(perform_request(:autocreate, args))
end

.checkemail(args = {}) ⇒ Object



42
43
44
45
46
# File 'lib/zoomba/user.rb', line 42

def checkemail(args = {})
  validate_params(args, :email)
  response = perform_request(:checkemail, args)
  response['existed_email']
end

.checkzpk(args = {}) ⇒ Object



48
49
50
51
52
# File 'lib/zoomba/user.rb', line 48

def checkzpk(args = {})
  validate_params(args, :zpk)
  response = perform_request(:checkzpk, args)
  response['expire_in']
end

.create(args = {}) ⇒ Object



4
5
6
7
# File 'lib/zoomba/user.rb', line 4

def create(args = {})
  validate_params(args, :email, :type)
  new(perform_request(:create, args))
end

.custcreate(args = {}) ⇒ Object



14
15
16
17
# File 'lib/zoomba/user.rb', line 14

def custcreate(args = {})
  validate_params(args, :email, :type)
  new(perform_request(:custcreate, args))
end

.get(args = {}) ⇒ Object



32
33
34
35
# File 'lib/zoomba/user.rb', line 32

def get(args = {})
  validate_params(args, :id)
  new(perform_request(:get, args))
end

.getbyemail(args = {}) ⇒ Object



37
38
39
40
# File 'lib/zoomba/user.rb', line 37

def getbyemail(args = {})
  validate_params(args, :email, :login_type)
  new(perform_request(:getbyemail, args))
end

.list(args = {}) ⇒ Object



24
25
26
# File 'lib/zoomba/user.rb', line 24

def list(args = {})
  Zoomba::Collection.new(perform_request(:list, args), :users)
end

.pending(args = {}) ⇒ Object



28
29
30
# File 'lib/zoomba/user.rb', line 28

def pending(args = {})
  Zoomba::Collection.new(perform_request(:pending, args), :users)
end

.ssocreate(args = {}) ⇒ Object



19
20
21
22
# File 'lib/zoomba/user.rb', line 19

def ssocreate(args = {})
  validate_params(args, :email, :type)
  new(perform_request(:ssocreate, args))
end

.validate_params(params = {}, *expected) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/zoomba/user.rb', line 54

def validate_params(params = {}, *expected)
  missing = []
  expected.each do |param|
    missing << param if params[param].nil? || params[param].empty?
  end
  raise Zoomba::Error::RequiredParametersMissing, missing if missing.any?
end

Instance Method Details

#deactivateObject



68
69
70
71
# File 'lib/zoomba/user.rb', line 68

def deactivate
  validate_presence_of :id
  assign(perform_request(:deactivate, id: id))
end

#deleteObject



63
64
65
66
# File 'lib/zoomba/user.rb', line 63

def delete
  validate_presence_of :id
  assign(perform_request(:delete, id: id))
end

#getObject



94
95
96
97
# File 'lib/zoomba/user.rb', line 94

def get
  validate_presence_of :id
  assign(perform_request(:get, id: id))
end

#permanentdeleteObject



89
90
91
92
# File 'lib/zoomba/user.rb', line 89

def permanentdelete
  validate_presence_of :id
  assign(perform_request(:permanentdelete, id: id))
end

#revoketokenObject



84
85
86
87
# File 'lib/zoomba/user.rb', line 84

def revoketoken
  validate_presence_of :id
  assign(perform_request(:revoketoken, id: id))
end

#update(args = {}) ⇒ Object



73
74
75
76
77
# File 'lib/zoomba/user.rb', line 73

def update(args = {})
  validate_presence_of :id
  assign(args)
  assign(perform_request(:update, args.merge(id: id)))
end

#updatepassword(args = {}) ⇒ Object



79
80
81
82
# File 'lib/zoomba/user.rb', line 79

def updatepassword(args = {})
  validate_params(args.merge(id: id), :id, :password)
  assign(perform_request(:updatepassword, args.merge(id: id)))
end