Class: MustardClient::UsersClient

Inherits:
Client
  • Object
show all
Defined in:
lib/MustardClient/users.rb

Instance Method Summary collapse

Methods inherited from Client

#execute, #initialize

Constructor Details

This class inherits a constructor from MustardClient::Client

Instance Method Details

#add(user_params) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/MustardClient/users.rb', line 38

def add user_params

  command = {}
  command[:method] = :post
  command[:route] = @mustard_url + "/users"
  command[:params] = {user: user_params}
  command[:headers] = {'User-Token' => @user_token}

  execute(command)

end

#allObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/MustardClient/users.rb', line 5

def all

  command = {}
  command[:method] = :get
  command[:route] = @mustard_url + '/users'
  command[:headers] = {'User-Token' => @user_token}

  execute(command)

end

#delete(user_id) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/MustardClient/users.rb', line 50

def delete user_id

  command = {}
  command[:method] = :delete
  command[:route] = @mustard_url + "/users/#{user_id}"
  command[:headers] = {'User-Token' => @user_token}

  execute(command)

end

#find(user_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/MustardClient/users.rb', line 16

def find user_id

  command = {}
  command[:method] = :get
  command[:route] = @mustard_url + "/users/#{user_id}"
  command[:headers] = {'User-Token' => @user_token}

  execute(command)

end

#find_by_username(username) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/MustardClient/users.rb', line 27

def find_by_username username

  command = {}
  command[:method] = :get
  command[:route] = @mustard_url + "/users/find/#{ username}"
  command[:headers] = {'User-Token' => @user_token}

  execute(command)

end

#reset_password(user_id, password_token, new_password) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/MustardClient/users.rb', line 84

def reset_password user_id, password_token, new_password

  command = {}
  command[:method] = :post
  command[:route] = @mustard_url + "/users/#{user_id}/reset-password/#{password_token}"
  command[:params] = {user: {'password' => new_password}}

  execute(command)

end

#trigger_password_reset(username, redirect_url) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/MustardClient/users.rb', line 73

def trigger_password_reset username, redirect_url

  command = {}
  command[:method] = :post
  command[:route] = @mustard_url + "/users/reset-password"
  command[:params] = {user: {email: username}, 'redirect-to' => redirect_url, }

  execute(command)

end

#update(user_id, user_params) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/MustardClient/users.rb', line 61

def update user_id, user_params

  command = {}
  command[:method] = :put
  command[:route] = @mustard_url + "/users/#{user_id}"
  command[:headers] = {'User-Token' => @user_token}
  command[:params] = {user: user_params}

  execute(command)

end