Class: PushbulletRuby::Client

Inherits:
Object
  • Object
show all
Includes:
API, Request
Defined in:
lib/pushbullet_ruby/client.rb

Constant Summary collapse

URL =
'https://api.pushbullet.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API::Chats

#chats, #create_chat, #delete_chat, #update_chat

Methods included from API::Subscriptions

#channel_info, #create_subscription, #delete_subscription, #recent_pushes, #subscriptions, #update_subscription

Methods included from API::Contacts

#contacts

Methods included from API::Ephemerals

#push_notification, #send_sms

Methods included from API::Pushes

#delete_all_pushes, #delete_push, #push_file, #push_link, #push_note, #pushes, #update_push

Methods included from API::Devices

#create_device, #delete_device, #devices, #update_device

Methods included from API::Me

#me

Methods included from Request

#delete, #get, #post, #request

Constructor Details

#initialize(key) ⇒ Client

Returns a new instance of Client.



19
20
21
# File 'lib/pushbullet_ruby/client.rb', line 19

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



15
16
17
# File 'lib/pushbullet_ruby/client.rb', line 15

def key
  @key
end

Instance Method Details

#connectionObject



23
24
25
# File 'lib/pushbullet_ruby/client.rb', line 23

def connection
  @connection ||= Faraday.new(URL, connection_options)
end

#connection_optionsObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pushbullet_ruby/client.rb', line 27

def connection_options
  @connection_options ||= {
      builder: middleware,
      headers: {
          accept: 'application/json',
          user_agent: 'pushbullet_ruby Gem'
      },
      ssl: {
          verify: false
      }
  }
end

#middlewareObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/pushbullet_ruby/client.rb', line 40

def middleware
  @middleware ||= Faraday::RackBuilder.new do |f|
    f.request :multipart
    f.request :url_encoded
    f.use PushbulletRuby::Authorization, 'Bearer', key
    f.use PushbulletRuby::ParseJSON
    f.use PushbulletRuby::HttpException
    f.adapter :net_http
  end
end