diff --git a/CHANGELOG.md b/CHANGELOG.md index 1936d20..36bc001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## [Unreleased] +## [0.1.1] - 2021-12-16 +- Expose get_entry method ## [0.1.0] - 2021-11-18 - Initial release diff --git a/hws-tansactions.gemspec b/hws-transactions.gemspec similarity index 98% rename from hws-tansactions.gemspec rename to hws-transactions.gemspec index 181b3f9..700f432 100644 --- a/hws-tansactions.gemspec +++ b/hws-transactions.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = 'hws-transactions' - spec.version = '0.1.0' + spec.version = '0.1.1' spec.authors = ['Hypto Engineering Team'] spec.email = ['engineering@hypto.in'] diff --git a/lib/hws-transactions.rb b/lib/hws-transactions.rb index e3c9785..aa230d4 100644 --- a/lib/hws-transactions.rb +++ b/lib/hws-transactions.rb @@ -47,10 +47,16 @@ def self.update_entry(transaction_group_id, entry_id, mutable_tags) # 'last_entry': '', # 'page_size': 10 # } - def self.list_entries(transaction_group_id, filters, page_context) + def self.list_entries(transaction_group_id, filters = {}, page_context = {}) self.get_group(transaction_group_id).try(:list_entries, filters.with_indifferent_access, page_context.with_indifferent_access) end + def self.get_entry(entry_id) + entry = ::Hws::Transactions::Models::TransactionEntry.find_by(id: entry_id) + { id: entry.id, transaction_group_id: entry.transaction_group_id, value: entry.value, txn_time: entry.txn_time, + tags: { immutable_tags: entry.immutable_tags, mutable_tags: entry.mutable_tags } } + end + module Models # :nodoc: end end diff --git a/lib/hws-transactions/models/base.rb b/lib/hws-transactions/models/base.rb index da81707..ed6f086 100644 --- a/lib/hws-transactions/models/base.rb +++ b/lib/hws-transactions/models/base.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true -module Hws::Transactions::Models - class Base < ActiveRecord::Base # :nodoc: - self.abstract_class = true +class Hws::Transactions::Models::Base < ActiveRecord::Base # :nodoc: + self.abstract_class = true - before_create :set_uuid + before_create :set_uuid - def set_uuid - self.id = LSUUID.generate if self.id.blank? - end + def set_uuid + self.id = LSUUID.generate if self.id.blank? end end diff --git a/lib/hws-transactions/models/transaction_group.rb b/lib/hws-transactions/models/transaction_group.rb index 575a6e6..10c9945 100644 --- a/lib/hws-transactions/models/transaction_group.rb +++ b/lib/hws-transactions/models/transaction_group.rb @@ -81,11 +81,11 @@ def validate_and_sanitize_tags(tags) tags['immutable_tags'] = {} unless tags.key? 'immutable_tags' unless tags['mutable_tags'].keys.all? { |key| self.mutable_tags.include?(key) } - raise 'Invalid mutable tags present in add_entry request.' + raise "Invalid mutable tags present in add_entry request. Given keys: #{tags['mutable_tags'].keys} | Allowed keys: #{self.mutable_tags}" end unless tags['immutable_tags'].keys.all? { |key| self.immutable_tags.include?(key) } - raise 'Invalid immutable_tags tags present in add_entry request.' + raise "Invalid immutable_tags tags present in add_entry request. Given keys: #{tags['immutable_tags'].keys} | Allowed keys: #{self.immutable_tags}" end tags