Sha256: 85622a70dddd653bca88bb1ce5630bd81d7b71839b199486d2224374052a76c9

Contents?: true

Size: 837 Bytes

Versions: 4

Compression:

Stored size: 837 Bytes

Contents

require 'pushover'

module Legion::Extensions::Pushover
  module Helpers
    module Client
      def message(**opts)
        client_hash = {}
        %i[message priority device title url url_title sound expire retry callback].each do |thing|
          client_hash[thing] = opts[thing] if opts.key?(thing) && !opts[thing].nil?
        end
        ::Pushover::Message.new(token:     token(opts),
                                user:      user(opts),
                                timestamp: Time.now.getlocal,
                                **client_hash)
      end

      def timestamp(**opts)
        opts[:timstamp] if opts.key? :timestamp
        Time.now.getutc
      end

      def token(**opts)
        find_setting('token', opts)
      end

      def user(**opts)
        find_setting('user', opts)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lex-pushover-0.1.3 lib/legion/extensions/pushover/helpers/client.rb
lex-pushover-0.1.2 lib/legion/extensions/pushover/helpers/client.rb
lex-pushover-0.1.1 lib/legion/extensions/pushover/helpers/client.rb
lex-pushover-0.1.0 lib/legion/extensions/pushover/helpers/client.rb