Class: Heft::Users

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

Class Method Summary collapse

Class Method Details

.add(opts = {}) ⇒ Object



6
7
8
9
10
# File 'lib/heft/users.rb', line 6

def add(opts={})
  reply = add_core opts

  fail "Failed => #{reply.body}" if reply.code > 299
end

.contain?(email) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
# File 'lib/heft/users.rb', line 18

def contain?(email)
  reply = add_core :email => email, :password => "******"

  json = JSON.parse reply.body

  error_message = json['message']

  reply.code === 400 and error_message.match /already a user with that email address/
end

.delete(email) ⇒ Object



12
13
14
15
16
# File 'lib/heft/users.rb', line 12

def delete(email)
  reply = hoist.delete :uri => "https://auth.hoi.io/user/#{URI.escape(email)}"

  fail "Failed to delete user. #{reply}" if reply.code > 299
end