Class: Pushover::Message
- Inherits:
-
Object
- Object
- Pushover::Message
- Defined in:
- lib/pushover/message.rb
Overview
Deprecated compatibility interface for sending messages.
Instance Method Summary collapse
-
#initialize(attributes = {}, **keywords) ⇒ Message
constructor
A new instance of Message.
-
#push ⇒ Response
Send the configured message through the shared client.
Constructor Details
#initialize(attributes = {}, **keywords) ⇒ Message
Returns a new instance of Message.
11 12 13 14 15 16 17 18 19 |
# File 'lib/pushover/message.rb', line 11 def initialize(attributes = {}, **keywords) raise ArgumentError, 'attributes must be supplied as a Hash' unless attributes.is_a?(Hash) values = attributes.merge(keywords).transform_keys(&:to_sym) unknown = values.keys - ATTRIBUTES raise ArgumentError, "unknown keywords: #{unknown.join(', ')}" unless unknown.empty? values.each { |attribute, value| public_send("#{attribute}=", value) } end |
Instance Method Details
#push ⇒ Response
Send the configured message through the shared client.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pushover/message.rb', line 23 def push require 'pushover' unless defined?(Pushover::Excon) warn 'Pushover::Message#push is deprecated; use Pushover::Client.new(token: ...).messages.create(...)', uplevel: 1 %i[token user message].each { |param| raise "#{param} must be supplied" unless public_send(param) } raise ArgumentError, 'raw attachment is unsupported; use attachment_base64 and attachment_type with Pushover::Client#messages.create' unless .nil? params = ATTRIBUTES.to_h { |attribute| [attribute, public_send(attribute)] } .except(:token, :attachment) .compact Client.new(token: token)..create(**params) end |