Sha256: 7a6bdbdff696c614e6563ef322d8a9bb2ac804ab9493149011811e2c6099a7ef

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
module FinApps
  module REST
    class Users < FinApps::REST::Resources # :nodoc:
      using ObjectExtensions
      using StringExtensions

      # @param [String] public_id
      # @return [FinApps::REST::User, Array<String>]
      def show(public_id)
        raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
        super public_id
      end

      # @param [Hash] params
      # @return [Array<String>]
      def update(public_id, params)
        raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
        raise MissingArgumentsError.new 'Missing argument: params.' if params.blank?

        path = "#{end_point}/#{ERB::Util.url_encode(public_id)}#{'/password' if password_update?(params)}"
        super params, path
      end

      def destroy(public_id)
        raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
        super public_id
      end

      private

      def password_update?(params)
        params.key?(:password) && params.key?(:password_confirm)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finapps-2.1.4 lib/finapps/rest/users.rb
finapps-2.1.3 lib/finapps/rest/users.rb
finapps-2.1.2 lib/finapps/rest/users.rb
finapps-2.1.1 lib/finapps/rest/users.rb
finapps-2.0.30 lib/finapps/rest/users.rb
finapps-2.0.29 lib/finapps/rest/users.rb
finapps-2.0.28 lib/finapps/rest/users.rb