message_franking.rb 605 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class MessageFranking
  3. attr_reader :hmac, :source_account_id, :target_account_id,
  4. :timestamp, :original_franking
  5. def initialize(attributes = {})
  6. @hmac = attributes[:hmac]
  7. @source_account_id = attributes[:source_account_id]
  8. @target_account_id = attributes[:target_account_id]
  9. @timestamp = attributes[:timestamp]
  10. @original_franking = attributes[:original_franking]
  11. end
  12. def to_token
  13. crypt = ActiveSupport::MessageEncryptor.new(SystemKey.current_key, serializer: Oj)
  14. crypt.encrypt_and_sign(self)
  15. end
  16. end