pushpad 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72937e2f8f9f8340e2c8a503a413a13f5cce90cd
4
- data.tar.gz: b296e7b4007accf9d7d8729b31c1f0180fa465a1
3
+ metadata.gz: 62b82eeebcf3b9611c204c4752dd44a0beb6b45c
4
+ data.tar.gz: cf789a7d62f9a8aae45cdb7d5fd758594ad3dd7f
5
5
  SHA512:
6
- metadata.gz: 85de1abb940f431332c41280c5a47983e93b29999c25877c4eef01e913b2517f208a13804110294d904399f4f348f7899fc10817fa3e95d85436e85a908532fd
7
- data.tar.gz: 7c3230b40848571ce581498286364eee8e86388519b1cf82df37cfd54bf45074930196752021ec985b09a2072370632cc5c56c629ac7a298f17f7604fd824f2b
6
+ metadata.gz: cfa24ded993111cf8d193336f29e1be39372cf3e9b95a25166b67c9bc142699311fa5c7c35ff75df12a988d526a8345d1825e110f317bd1f40ebc2fd6337285e
7
+ data.tar.gz: 2a690c2bce05779cf56c5a475853292e0c637ab4dfbeb753513a67d69544fa1ea35ac829b52a63d5b0fb3290ad164bbcdfaccc91288b0d5e15df562945f86729
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- # Pushpad - Web Push Notifications Service
1
+ # Pushpad - Web Push Notifications
2
2
 
3
3
  [![Build Status](https://travis-ci.org/pushpad/pushpad-ruby.svg?branch=master)](https://travis-ci.org/pushpad/pushpad-ruby)
4
-
4
+ [![Gem Version](https://badge.fury.io/rb/pushpad.svg)](https://badge.fury.io/rb/pushpad)
5
+
5
6
  [Pushpad](https://pushpad.xyz) is a service for sending push notifications from your web app. It supports the **Push API** (Chrome, Firefox, Opera) and **APNs** (Safari).
6
7
 
7
8
  Features:
@@ -82,8 +83,21 @@ notification = Pushpad::Notification.new({
82
83
  title: "Website Name", # optional, defaults to your project name, max 30 characters
83
84
  target_url: "http://example.com", # optional, defaults to your project website
84
85
  icon_url: "http://example.com/assets/icon.png", # optional, defaults to the project icon
86
+ image_url: "http://example.com/assets/image.png", # optional, an image to display in the notification content
85
87
  ttl: 604800, # optional, drop the notification after this number of seconds if a device is offline
86
- require_interaction: true # optional, if true it prevents Chrome from automatically closing the notification after a few seconds
88
+ require_interaction: true, # optional, prevent Chrome on desktop from automatically closing the notification after a few seconds
89
+ custom_data: "123", # optional, a string that is passed as an argument to action button callbacks
90
+ // optional, add some action buttons to the notification
91
+ // see https://pushpad.xyz/docs/action_buttons
92
+ actions: [
93
+ {
94
+ title: "My Button 1", # max length is 20 characters
95
+ target_url: "http://example.com/button-link", # optional
96
+ icon: "http://example.com/assets/button-icon.png", # optional
97
+ action: "myActionName" # optional
98
+ }
99
+ ],
100
+ starred: true # optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)
87
101
  })
88
102
 
89
103
  # deliver to a user
@@ -109,7 +123,9 @@ notification.deliver_to users, tags: ['tag1 && tag2', 'tag3'] # equal to 'tag1 &
109
123
  notification.broadcast
110
124
  ```
111
125
 
112
- If no user with that id has subscribed to push notifications, that id is simply ignored.
126
+ You can set the default values for most fields in the project settings. See also [the docs](https://pushpad.xyz/docs/rest_api#notifications_api_docs) for more information about notification fields.
127
+
128
+ If you try to send a notification to a user ID, but that user is not subscribed, that ID is simply ignored.
113
129
 
114
130
  The methods above return an hash:
115
131
 
@@ -12,7 +12,7 @@ module Pushpad
12
12
  class ReadonlyError < RuntimeError
13
13
  end
14
14
 
15
- attr_accessor :body, :title, :target_url, :icon_url, :ttl, :require_interaction
15
+ attr_accessor :body, :title, :target_url, :icon_url, :image_url, :ttl, :require_interaction, :custom_data, :actions, :starred
16
16
  attr_reader :id, :created_at, :scheduled_count, :successfully_sent_count, :opened_count
17
17
 
18
18
  def initialize(options)
@@ -26,8 +26,12 @@ module Pushpad
26
26
  @title = options[:title]
27
27
  @target_url = options[:target_url]
28
28
  @icon_url = options[:icon_url]
29
+ @image_url = options[:image_url]
29
30
  @ttl = options[:ttl]
30
31
  @require_interaction = options[:require_interaction]
32
+ @custom_data = options[:custom_data]
33
+ @actions = options[:actions]
34
+ @starred = options[:starred]
31
35
  end
32
36
 
33
37
  def self.find(id)
@@ -108,8 +112,12 @@ module Pushpad
108
112
  notification_params["title"] = self.title if self.title
109
113
  notification_params["target_url"] = self.target_url if self.target_url
110
114
  notification_params["icon_url"] = self.icon_url if self.icon_url
115
+ notification_params["image_url"] = self.image_url if self.image_url
111
116
  notification_params["ttl"] = self.ttl if self.ttl
112
117
  notification_params["require_interaction"] = self.require_interaction unless self.require_interaction.nil?
118
+ notification_params["custom_data"] = self.custom_data if self.custom_data
119
+ notification_params["actions"] = self.actions if self.actions
120
+ notification_params["starred"] = self.starred unless self.starred.nil?
113
121
 
114
122
  body = { "notification" => notification_params }
115
123
  body["uids"] = uids if uids
data/pushpad.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pushpad"
3
- spec.version = '0.6.0'
3
+ spec.version = '0.7.0'
4
4
  spec.authors = ["Pushpad"]
5
5
  spec.email = ["support@pushpad.xyz"]
6
6
  spec.summary = "Web push notifications for Chrome, Firefox and Safari using Pushpad."
@@ -271,8 +271,19 @@ module Pushpad
271
271
  title: "Website Name",
272
272
  target_url: "http://example.com",
273
273
  icon_url: "http://example.com/assets/icon.png",
274
+ image_url: "http://example.com/assets/image.png",
274
275
  ttl: 604800,
275
- require_interaction: true
276
+ require_interaction: true,
277
+ custom_data: "123",
278
+ actions: [
279
+ {
280
+ title: "My Button 1",
281
+ target_url: "http://example.com/button-link",
282
+ icon: "http://example.com/assets/button-icon.png",
283
+ action: "myActionName"
284
+ }
285
+ ],
286
+ starred: true
276
287
  }
277
288
  end
278
289
  let(:notification) { Pushpad::Notification.new notification_params }
@@ -332,8 +343,19 @@ module Pushpad
332
343
  title: "Website Name",
333
344
  target_url: "http://example.com",
334
345
  icon_url: "http://example.com/assets/icon.png",
346
+ image_url: "http://example.com/assets/image.png",
335
347
  ttl: 604800,
336
- require_interaction: true
348
+ require_interaction: true,
349
+ custom_data: "123",
350
+ actions: [
351
+ {
352
+ title: "My Button 1",
353
+ target_url: "http://example.com/button-link",
354
+ icon: "http://example.com/assets/button-icon.png",
355
+ action: "myActionName"
356
+ }
357
+ ],
358
+ starred: true
337
359
  }
338
360
  end
339
361
  let(:notification) { Pushpad::Notification.new notification_params }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushpad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pushpad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: webmock
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -45,9 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
49
- - .rspec
50
- - .travis.yml
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".travis.yml"
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -72,17 +72,17 @@ require_paths:
72
72
  - lib
73
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.0.14.1
85
+ rubygems_version: 2.4.5
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Web push notifications for Chrome, Firefox and Safari using Pushpad.