Sha256: cd385e801c2773cc9c90a86b2cd90cbdc1991ba6bc98b4da7110c3ac99879a4c

Contents?: true

Size: 1.03 KB

Versions: 45

Compression:

Stored size: 1.03 KB

Contents

module PortaText
  module Command
    module Api
      # The me/password endpoint.
      # https://github.com/PortaText/docs/wiki/REST-API#api_me_password
      #
      # Author::    Marcelo Gornstein (mailto:marcelog@portatext.com)
      # Copyright:: Copyright (c) 2015 PortaText
      # License::   Apache-2.0
      class MyPassword < Base
        def reset
          set :reset, true
        end

        def for_email(email)
          set :email, email
        end

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

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

        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
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
portatext-1.1.5 lib/portatext/command/api/my_password.rb
portatext-1.1.4 lib/portatext/command/api/my_password.rb
portatext-1.1.3 lib/portatext/command/api/my_password.rb
portatext-1.1.2 lib/portatext/command/api/my_password.rb
portatext-1.1.1 lib/portatext/command/api/my_password.rb