Sha256: d221fb1d1b2f66827116276ccbadcf69409451d714416b5d0ecf8947355ba0f7

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module FinApps
  module REST

    require 'erb'

    class UserInstitutions < FinApps::REST::Resources
      include FinApps::REST::Defaults

      def add(site_id, parameters)
        logger.debug "##{__method__.to_s} => Started"

        raise MissingArgumentsError.new 'Missing argument: site_id.' if site_id.blank?
        logger.debug "##{__method__.to_s} => site_id: #{site_id}"

        raise MissingArgumentsError.new 'Missing argument: parameters.' if parameters.blank?
        logger.debug "##{__method__.to_s} => parameters: #{parameters.inspect}"

        end_point = Defaults::END_POINTS[:user_institutions_add]
        logger.debug "##{__method__.to_s} => end_point: #{end_point}"

        path = end_point.sub ':site_id', ERB::Util.url_encode(site_id)
        logger.debug "##{__method__.to_s} => path: #{path}"

        user_institution, error_messages = @client.post(path, :parameters => parameters ) do |r|
          if r.body.present?
            UserInstitution.new(r.body)
          else
            raise InternalServerError.new 'Unable to parse response.'
          end
        end

        logger.debug "##{__method__.to_s} => Completed"
        return user_institution, error_messages
      end

    end

    class UserInstitution < FinApps::REST::Resource
      attr_accessor :_id, :account_id, :user_public_id, :institution_name, :status, :status_message, :last_refreshed
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finapps-0.1.5.pre lib/finapps/rest/user_institutions.rb
finapps-0.1.4.pre lib/finapps/rest/user_institutions.rb