lib/finapps/rest/transactions.rb in finapps-0.7.0.pre vs lib/finapps/rest/transactions.rb in finapps-0.7.1.pre

- old
+ new

@@ -2,12 +2,41 @@ module REST class Transactions < FinApps::REST::Resources include FinApps::REST::Defaults + # @transaction_id [String] + # # @return [Hash, Array<String>] + def search_by_id(transaction_id) + logger.debug "##{__method__.to_s} => Started" + + transactions, error_messages = search_by_ids([transaction_id]) + + # get one + transaction = transactions.present? ? transactions.first : nil + + logger.debug "##{__method__.to_s} => Completed" + return transaction, error_messages + end + + # @transaction_ids [Array<String>] + # # @return [Array<Hash>, Array<String>] + def search_by_ids(transaction_ids) + logger.debug "##{__method__.to_s} => Started" + + transactions, error_messages = search + + # filter by given ids + transactions = transactions.present? ? transactions.select { |t| transaction_ids.include?(t[:_id]) } : nil + + logger.debug "##{__method__.to_s} => Completed" + return transactions, error_messages + end + + # @param [Hash] params - # @return [Array<FinApps::REST::Transaction>, Array<String>] + # @return [Array<Hash>, Array<String>] def search(params={}) logger.debug "##{__method__.to_s} => Started" path = Defaults::END_POINTS[:transactions_list] @@ -18,9 +47,10 @@ logger.debug "##{__method__.to_s} => Completed" return transactions, error_messages end # @param [Hash] params + # @return [Array<Hash>, Array<String>] def edit(params={}) logger.debug "##{__method__.to_s} => Started" path = Defaults::END_POINTS[:transactions_list] \ No newline at end of file