Sha256: bffc01d0713cc01139fc7ceb082e6f3fdb897fa9bee671e75a1e5c50ce5dd2c2

Contents?: true

Size: 1.7 KB

Versions: 10

Compression:

Stored size: 1.7 KB

Contents

module FinApps
  module REST

    require 'erb'

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

      # @param [String] term
      # @return [Array<FinApps::REST::Institution>, Array<String>]
      def search(term)
        logger.debug "##{__method__.to_s} => Started"

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

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

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

        institutions, error_messages = @client.send(path, :get)

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

      # @param [Integer] site_id
      def form(site_id)
        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}"

        end_point = Defaults::END_POINTS[:institutions_form]
        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}"

        institution, error_messages = @client.send(path, :get) { |r| Institution.new(r.body) }

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

    end

    class Institution < FinApps::REST::Resource
      attr_accessor :login_form_html
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
finapps-0.3.6.pre lib/finapps/rest/institutions.rb
finapps-0.3.5.pre lib/finapps/rest/institutions.rb
finapps-0.3.4.pre lib/finapps/rest/institutions.rb
finapps-0.3.3.pre lib/finapps/rest/institutions.rb
finapps-0.3.2.pre lib/finapps/rest/institutions.rb
finapps-0.3.1.pre lib/finapps/rest/institutions.rb
finapps-0.2.14.pre lib/finapps/rest/institutions.rb
finapps-0.2.13.pre lib/finapps/rest/institutions.rb
finapps-0.2.12.pre lib/finapps/rest/institutions.rb
finapps-0.2.11.pre lib/finapps/rest/institutions.rb