Sha256: 91667bed1006a32ccf649b06ca1849c250c90dca35b24102d82385e7aae6ffb0

Contents?: true

Size: 916 Bytes

Versions: 14

Compression:

Stored size: 916 Bytes

Contents

require 'pushbullet_ruby/ephemeral'

module PushbulletRuby
  class Ephemerable
    class MissingParameter < StandardError; end

    attr_reader :client, :user_identifier, :device_identifier, :params

    def self.push(client, user_identifier, device_identifier, params)
      Ephemeral.new(new(client, user_identifier, device_identifier, params).push.body)
    end

    def initialize(client, user_identifier, device_identifier, params)
      @client = client
      @user_identifier = user_identifier
      @device_identifier = device_identifier
      @params = params
    end

    def push
      raise MissingParameter unless required_parameters.all? { |e| params.keys.include?(e) }

      payload = {
          type: type,
          push: params.merge(construct_payload(user_identifier, device_identifier))
      }
      client.post('/v2/ephemerals', payload.to_json)
    end
  end
end

Version data entries

14 entries across 13 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/pushbullet_ruby-1.1.4/lib/pushbullet_ruby/ephemerable.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/pushbullet_ruby-1.1.4/lib/pushbullet_ruby/ephemerable.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/pushbullet_ruby-1.1.4/lib/pushbullet_ruby/ephemerable.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/pushbullet_ruby-1.1.4/lib/pushbullet_ruby/ephemerable.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/pushbullet_ruby-1.1.4/lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.1.4 lib/pushbullet_ruby/ephemerable.rb
tdiary-5.0.8 vendor/bundle/gems/pushbullet_ruby-1.1.3/lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.1.3 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.1.2 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.1.1 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.1.0 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.0.4.1 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.0.4 lib/pushbullet_ruby/ephemerable.rb
pushbullet_ruby-1.0.3 lib/pushbullet_ruby/ephemerable.rb