Module: Simplewoo::Client::User

Included in:
Simplewoo::Client
Defined in:
lib/simplewoo/client/user.rb

Instance Method Summary collapse

Instance Method Details

#create_user(email, password, password_confirmation, birthday, first_name, last_name, options = {}) ⇒ Hashie::Mash

Create a user on the core api

Examples:

Create a user

Simplewoo.create_user({
  :email => "[email protected]",
  :password => "password",
  :password_confirmation => "password",
  :birthday => "1988-01-01",
  :first_name => "Johnny",
  :last_name => "Test"
})

Parameters:

  • email (String)
    • the email of the user

  • password (String)
    • the password of the user

  • password_confirmation (String)
    • the password_confirmation of the user

  • birthday (String)
    • the birthday of the user

  • first_name (String)
    • the first name of the user

  • last_name (String)
    • the first name of the user

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • bio (String)
    • The users bio

  • image (String)
    • The users image

Returns:

  • (Hashie::Mash)

    user the user created by the request



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/simplewoo/client/user.rb', line 27

def create_user(email, password, password_confirmation, birthday, first_name, last_name, options = {})
  options.merge!({
    :email                 => email,
    :password              => password,
    :password_confirmation => password_confirmation,
    :birthday              => birthday,
    :first_name            => first_name,
    :last_name             => last_name
  })

  result = post("/users", { :user => options })
  # TODO we should really make this core method return an api_token as well and use that instead
  authenticate({:email => email, :password => password })
  result
end

#meObject

Note:

This method requires an authenticated user via email + password or api_token

Returns the currently authenticated user

Examples:

Return the user

Simplewoo.me


77
78
79
80
81
82
83
# File 'lib/simplewoo/client/user.rb', line 77

def me
  if authenticated?
    get("/users/me")
  else
    raise "No authorized user."
  end
end

#update_user(options = {}) ⇒ Hashie::Mash Also known as: reset_password

Note:

This method requires an authenticated user via email + password or api_token

Update a user on the core api

Examples:

Update a user

Simplewoo.update_user({
  :email => "[email protected]"
})

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • email (String)
    • the email of the user

  • password (String)
    • the password of the user

  • password_confirmation (String)
    • the password_confirmation of the user

  • birthday (String)
    • the birthday of the user

  • first_name (String)
    • the first name of the user

  • last_name (String)
    • the first name of the user

  • bio (String)
    • The users bio

  • image (String)
    • The users image

Returns:

  • (Hashie::Mash)

    user the user updated by the request



62
63
64
65
66
67
68
# File 'lib/simplewoo/client/user.rb', line 62

def update_user(options = {})
  if authenticated?
    put("/users/me", { :user => options })
  else
    raise "No authorized user."
  end
end