Class: Pushover::Receipt

Inherits:
Object
  • Object
show all
Defined in:
lib/pushover/receipt.rb

Overview

Deprecated compatibility interface for retrieving receipts.

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, **keywords) ⇒ Receipt

Returns a new instance of Receipt.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
# File 'lib/pushover/receipt.rb', line 9

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

#getResponse

Retrieve the configured receipt through the shared client.

Returns:

  • (Response)

    the Pushover API response



21
22
23
24
25
26
27
# File 'lib/pushover/receipt.rb', line 21

def get
  require 'pushover' unless defined?(Pushover::Excon)
  warn 'Pushover::Receipt#get is deprecated; use Pushover::Client.new(token: ...).receipts.get(receipt: ...)', uplevel: 1
  %i[receipt token].each { |param| raise "#{param} must be supplied" unless public_send(param) }

  Client.new(token: token).receipts.get(receipt: receipt)
end