Class: Pushover::Messages
- Inherits:
-
Object
- Object
- Pushover::Messages
- Defined in:
- lib/pushover/messages.rb
Overview
Messages provides operations for the Message API.
Instance Method Summary collapse
-
#create(user:, message:) ⇒ Response
Create and send a message.
-
#initialize(client) ⇒ Messages
constructor
A new instance of Messages.
Constructor Details
#initialize(client) ⇒ Messages
Returns a new instance of Messages.
4 5 6 |
# File 'lib/pushover/messages.rb', line 4 def initialize(client) @client = client end |
Instance Method Details
#create(user:, message:) ⇒ Response
Create and send a message.
10 11 12 13 14 15 16 17 18 |
# File 'lib/pushover/messages.rb', line 10 def create(user:, message:, **) params = MessageValidator.new(user: user, message: , **).validate encryption_key = params.delete(:encryption_key) params = MessageEncryption.new(encryption_key).encrypt(params) if encryption_key body = { 'token' => @client.token }.merge(params.transform_keys(&:to_s)) response = @client.connection.post(path: '/1/messages.json', body: Oj.dump(body)) Response.create_from_excon_response(response) end |