Sha256: 3bc3a8f61cba5f265c4ebff3fba6997fe5f20e7f6d9d8edcbe7cb16a70bdfe63

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

module Rexpense
  module Resources
    #
    # A wrapper to Rexpense pre_expenses API
    #
    # [API]
    #   Documentation: http://developers.rexpense.com/api/v1/pre_expenses/
    #
    class PreExpense < ResourceBase
      #
      # Ignore a pre_expense resource
      #
      # [API]
      #   Method: <tt>PUT /api/v1/pre_expenses/ignore</tt>
      #
      #   Documentation: http://developers.rexpense.com/api/v1/pre_expenses/#ignore
      def ignore(id)
        http.put("#{endpoint_base}/#{id}/ignore") do |response|
          respond_with_object response
        end
      end

      #
      # Restore a pre_expense resource
      #
      # [API]
      #   Method: <tt>PUT /api/v1/pre_expenses/restore</tt>
      #
      #   Documentation: http://developers.rexpense.com/api/v1/pre_expenses/#ignore
      def restore(id)
        http.put("#{endpoint_base}/#{id}/restore") do |response|
          respond_with_object response
        end
      end

      #
      # Restore a pre_expense resource
      #
      # [API]
      #   Method: <tt>POST /api/v1/pre_expenses/convert</tt>
      #
      #   Documentation: http://developers.rexpense.com/api/v1/pre_expenses/#convert
      def convert(id, params={})
        http.post("#{endpoint_base}/#{id}/convert", body: params) do |response|
          Rexpense::Entities::Expense.new response.parsed_body
        end
      end

      private

      def endpoint_base
        "/pre_expenses"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rexpense-2.1.0 lib/rexpense/resources/pre_expense.rb
rexpense-2.0.0 lib/rexpense/resources/pre_expense.rb
rexpense-1.0.0 lib/rexpense/resources/pre_expense.rb