Class: Pushover::MessageEncryption
- Inherits:
-
Object
- Object
- Pushover::MessageEncryption
- Defined in:
- lib/pushover/message_encryption.rb
Overview
MessageEncryption implements Pushover's end-to-end encryption wire format.
Constant Summary collapse
- FIELDS =
%i[message title url url_title].freeze
Instance Method Summary collapse
- #encrypt(params) ⇒ Object
-
#initialize(hexadecimal_key) ⇒ MessageEncryption
constructor
A new instance of MessageEncryption.
Constructor Details
#initialize(hexadecimal_key) ⇒ MessageEncryption
Returns a new instance of MessageEncryption.
12 13 14 |
# File 'lib/pushover/message_encryption.rb', line 12 def initialize(hexadecimal_key) @key = [hexadecimal_key].pack('H*') end |
Instance Method Details
#encrypt(params) ⇒ Object
16 17 18 19 20 |
# File 'lib/pushover/message_encryption.rb', line 16 def encrypt(params) params.merge(encrypted: 1).tap do |encrypted| FIELDS.each { |field| encrypted[field] = encrypt_field(params[field]) if params.key?(field) } end end |