Sha256: c579f126864bb868a55e42674b54025ac66fcc86d678bf591d218ecc99a2ced8

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

module FinApps
  module REST

    class Users < FinApps::REST::Resources
      include FinApps::Logging
      include FinApps::REST::Defaults

      # @param [Hash] params
      # @return [FinApps::REST::User, Array<String>]
      def create(params = {})
        logger.debug "##{__method__.to_s} => Started"
        user, error_messages = @client.post(END_POINTS[:users_create], params) { |r| User.new(r.body) }
        logger.debug "##{__method__.to_s} => Completed"

        return user, error_messages
      end

      # @param [Hash] params
      # @return [FinApps::REST::User, Array<String>]
      def login(params = {})
        logger.debug "##{__method__.to_s} => Started"
        user, error_messages = @client.post(END_POINTS[:users_login], params) { |r| User.new(r.body) }
        logger.debug "##{__method__.to_s} => Completed"

        return user, error_messages
      end

      # @param [String] public_id
      # @return [Array<String>]
      def delete(public_id)
        logger.debug "##{__method__.to_s} => Started"
        raise MissingArgumentsError.new 'Missing argument: public_id.' if public_id.blank?
        _, error_messages = @client.delete(END_POINTS[:users_delete].sub! ':public_id', public_id.to_s)
        logger.debug "##{__method__.to_s} => Completed"

        error_messages
      end

    end

    class User < FinApps::REST::Resource
      attr_accessor :public_id, :token, :email, :first_name, :last_name, :postal_code
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
finapps-0.0.21.pre lib/finapps/rest/users.rb
finapps-0.0.20.pre lib/finapps/rest/users.rb
finapps-0.0.19.pre lib/finapps/rest/users.rb
finapps-0.0.18.pre lib/finapps/rest/users.rb
finapps-0.0.17.pre lib/finapps/rest/users.rb