Sha256: b5587d6a15cfd0b7e5d513fa54fcc6d5897957497066bc9832c81b1c6d7a326d

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

module Pushbullet
  module API
    def devices
      get('/api/devices')
    end

    def push_note(device_id, title, body)
      push :note, device_id, title: title, body: body
    end

    def push_link(device_id, title, url)
      push :link, device_id, title: title, url: url
    end

    def push_address(device_id, title, address)
      push :address, device_id, title: title, address: address
    end

    def push_list(device_id, title, items)
      push :list, device_id, title: title, items: items
    end

    def push_file(device_id, file_path)
      mime_type = MIME::Types.type_for(file_path).first.to_s
      io        = Faraday::UploadIO.new(file_path, mime_type)

      push :file, device_id, file: io
    end

    private

    def push(type, device_id, payload)
      post '/api/pushes', payload.merge(device_id: device_id, type: type)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pushbullet-0.0.4 lib/pushbullet/api.rb
pushbullet-0.0.2 lib/pushbullet/api.rb