Skip to content

Commit

Permalink
Expose get_entry API
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-vinod committed Dec 16, 2021
1 parent 72f8596 commit 3d08d88
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]
## [0.1.1] - 2021-12-16

- Expose get_entry method
## [0.1.0] - 2021-11-18

- Initial release
2 changes: 1 addition & 1 deletion hws-tansactions.gemspec → hws-transactions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
8 changes: 7 additions & 1 deletion lib/hws-transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions lib/hws-transactions/models/base.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions lib/hws-transactions/models/transaction_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d08d88

Please sign in to comment.