|
|
@@ -20,7 +20,13 @@ module Agents
|
20
|
20
|
|
21
|
21
|
Put one of the retured `iden` strings into the `device_id` field.
|
22
|
22
|
|
23
|
|
- You can provide a `title` and a `body`.
|
|
23
|
+ You have to provide a message `type` which has to be `note`, `link`, or `address`. The message types `checklist`, and `file` are not supported at the moment.
|
|
24
|
+
|
|
25
|
+ Depending on the message `type` you can use additional fields:
|
|
26
|
+
|
|
27
|
+ * note: `title` and `body`
|
|
28
|
+ * link: `title`, `body`, and `url`
|
|
29
|
+ * address: `name`, and `address`
|
24
|
30
|
|
25
|
31
|
In every value of the options hash you can use the liquid templating, learn more about it at the [Wiki](https://github.com/cantino/huginn/wiki/Formatting-Events-using-Liquid).
|
26
|
32
|
MD
|
|
|
@@ -29,14 +35,16 @@ module Agents
|
29
|
35
|
{
|
30
|
36
|
'api_key' => '',
|
31
|
37
|
'device_id' => '',
|
32
|
|
- 'title' => "Hello from Huginn!",
|
|
38
|
+ 'title' => "{{title}}",
|
33
|
39
|
'body' => '{{body}}',
|
|
40
|
+ 'type' => 'note',
|
34
|
41
|
}
|
35
|
42
|
end
|
36
|
43
|
|
37
|
44
|
def validate_options
|
38
|
45
|
errors.add(:base, "you need to specify a pushbullet api_key") unless options['api_key'].present?
|
39
|
46
|
errors.add(:base, "you need to specify a device_id") if options['device_id'].blank?
|
|
47
|
+ errors.add(:base, "you need to specify a valid message type") if options['type'].blank? or not ['note', 'link', 'address'].include?(options['type'])
|
40
|
48
|
end
|
41
|
49
|
|
42
|
50
|
def working?
|
|
|
@@ -54,9 +62,21 @@ module Agents
|
54
|
62
|
|
55
|
63
|
def query_options(event)
|
56
|
64
|
mo = interpolated(event)
|
|
65
|
+ body = {:device_iden => mo[:device_id], :type => mo[:type]}
|
|
66
|
+ if mo[:type] == "note"
|
|
67
|
+ body[:title] = mo[:title]
|
|
68
|
+ body[:body] = mo[:body]
|
|
69
|
+ elsif mo[:type] == "link"
|
|
70
|
+ body[:title] = mo[:title]
|
|
71
|
+ body[:body] = mo[:body]
|
|
72
|
+ body[:url] = mo[:url]
|
|
73
|
+ elsif mo[:type] == "address"
|
|
74
|
+ body[:name] = mo[:name]
|
|
75
|
+ body[:address] = mo[:address]
|
|
76
|
+ end
|
57
|
77
|
{
|
58
|
78
|
:basic_auth => {:username => mo[:api_key], :password => ''},
|
59
|
|
- :body => {:device_iden => mo[:device_id], :title => mo[:title], :body => mo[:body], :type => 'note'}
|
|
79
|
+ :body => body
|
60
|
80
|
}
|
61
|
81
|
end
|
62
|
82
|
end
|