Class: Washbullet::Pushable
- Inherits:
-
Object
- Object
- Washbullet::Pushable
- Defined in:
- lib/washbullet/pushable.rb,
lib/washbullet/pushable/file.rb,
lib/washbullet/pushable/link.rb,
lib/washbullet/pushable/note.rb
Defined Under Namespace
Classes: File, Link, MissingParameter, Note
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, receiver, identifier, params) ⇒ Pushable
constructor
A new instance of Pushable.
- #push ⇒ Object
- #receiver_type ⇒ Object
- #required_parameters ⇒ Object
- #specify_receiver(payload) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(client, receiver, identifier, params) ⇒ Pushable
Returns a new instance of Pushable.
15 16 17 18 19 20 |
# File 'lib/washbullet/pushable.rb', line 15 def initialize(client, receiver, identifier, params) @client = client @receiver = receiver @identifier = identifier @params = params end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/washbullet/pushable.rb', line 7 def client @client end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
7 8 9 |
# File 'lib/washbullet/pushable.rb', line 7 def identifier @identifier end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/washbullet/pushable.rb', line 7 def params @params end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
7 8 9 |
# File 'lib/washbullet/pushable.rb', line 7 def receiver @receiver end |
Class Method Details
Instance Method Details
#push ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/washbullet/pushable.rb', line 22 def push raise MissingParameter unless params.keys == required_parameters payload = params.merge(type: type) payload = specify_receiver(payload) client.post('/v2/pushes', payload) end |
#receiver_type ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/washbullet/pushable.rb', line 48 def receiver_type case receiver when :device then :device_iden when :email then receiver when :channel then :channel_tag when :client then :client_iden else raise NotImplementedError end end |
#required_parameters ⇒ Object
36 37 38 |
# File 'lib/washbullet/pushable.rb', line 36 def required_parameters raise NotImplementedError end |
#specify_receiver(payload) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/washbullet/pushable.rb', line 40 def specify_receiver(payload) if receiver && identifier payload.merge(receiver_type => identifier) else payload end end |
#type ⇒ Object
32 33 34 |
# File 'lib/washbullet/pushable.rb', line 32 def type raise NotImplementedError end |