Sha256: 4c9c59ad882650deae3f27a34a4267d252ea70d2d2d74d4f289bbe900bd6ee91

Contents?: true

Size: 1.43 KB

Versions: 47

Compression:

Stored size: 1.43 KB

Contents

module FinApps
  module REST

    require 'erb'

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

      # @return [Array<Hash>, Array<String>]
      def list
        logger.debug "##{__method__.to_s} => Started"

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

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

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

      # @param [Integer] budget_model_id
      def show(budget_model_id)
        logger.debug "##{__method__.to_s} => Started"

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

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

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

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

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

    end

    class BudgetModel < FinApps::REST::Resource
      attr_accessor :_id, :name, :desc
    end

  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
finapps-0.22.2.pre lib/finapps/rest/budget_models.rb
finapps-0.22.1.pre lib/finapps/rest/budget_models.rb
finapps-0.22.0.pre lib/finapps/rest/budget_models.rb
finapps-0.21.6.pre lib/finapps/rest/budget_models.rb
finapps-0.21.5.pre lib/finapps/rest/budget_models.rb
finapps-0.21.4.pre lib/finapps/rest/budget_models.rb
finapps-0.21.3.pre lib/finapps/rest/budget_models.rb
finapps-0.21.2.pre lib/finapps/rest/budget_models.rb
finapps-0.21.0.pre lib/finapps/rest/budget_models.rb
finapps-0.20.0.pre lib/finapps/rest/budget_models.rb
finapps-0.19.1.pre lib/finapps/rest/budget_models.rb
finapps-0.19.0.pre lib/finapps/rest/budget_models.rb
finapps-0.18.4.pre lib/finapps/rest/budget_models.rb
finapps-0.18.3.pre lib/finapps/rest/budget_models.rb
finapps-0.18.2.pre lib/finapps/rest/budget_models.rb
finapps-0.18.1.pre lib/finapps/rest/budget_models.rb
finapps-0.18.0.pre lib/finapps/rest/budget_models.rb
finapps-0.17.1.pre lib/finapps/rest/budget_models.rb
finapps-0.17.0.pre lib/finapps/rest/budget_models.rb
finapps-0.16.6.pre lib/finapps/rest/budget_models.rb