Class: PortaText::Command::Api::MyPassword

Inherits:
Base
  • Object
show all
Defined in:
lib/portatext/command/api/my_password.rb

Overview

The me/password endpoint. github.com/PortaText/docs/wiki/REST-API#api_me_password

Author

Marcelo Gornstein ([email protected])

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#accept_content_type, #body, #content_type, #delete, #get, #initialize, #patch, #post, #put, #set

Constructor Details

This class inherits a constructor from PortaText::Command::Base

Instance Method Details

#change(old_password, new_password) ⇒ Object



24
25
26
27
# File 'lib/portatext/command/api/my_password.rb', line 24

def change(old_password, new_password)
  set :old_password, old_password
  set :new_password, new_password
end

#endpoint(_method) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/portatext/command/api/my_password.rb', line 29

def endpoint(_method)
  return 'me/password' if @args[:reset].nil?
  @args.delete :reset
  return 'me/password/reset' if @args[:nonce].nil?
  nonce = @args[:nonce]
  @args.delete :nonce
  "me/password/reset/#{nonce}"
end

#for_email(email) ⇒ Object



15
16
17
# File 'lib/portatext/command/api/my_password.rb', line 15

def for_email(email)
  set :email, email
end

#resetObject



11
12
13
# File 'lib/portatext/command/api/my_password.rb', line 11

def reset
  set :reset, true
end

#with_nonce(nonce, new_password) ⇒ Object



19
20
21
22
# File 'lib/portatext/command/api/my_password.rb', line 19

def with_nonce(nonce, new_password)
  set :nonce, nonce
  set :new_password, new_password
end