pushpad 0.7.0 → 0.8.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: 62b82eeebcf3b9611c204c4752dd44a0beb6b45c
4
- data.tar.gz: cf789a7d62f9a8aae45cdb7d5fd758594ad3dd7f
3
+ metadata.gz: 523d9efb23303960dd6479a1488ddbf0c6a4acfa
4
+ data.tar.gz: 1170dd487dcaee2ebe4cc45177e32ff75174241d
5
5
  SHA512:
6
- metadata.gz: cfa24ded993111cf8d193336f29e1be39372cf3e9b95a25166b67c9bc142699311fa5c7c35ff75df12a988d526a8345d1825e110f317bd1f40ebc2fd6337285e
7
- data.tar.gz: 2a690c2bce05779cf56c5a475853292e0c637ab4dfbeb753513a67d69544fa1ea35ac829b52a63d5b0fb3290ad164bbcdfaccc91288b0d5e15df562945f86729
6
+ metadata.gz: 93f7b3c1c25d3a37d4dcf277055329f1e4e8874817a8f8291b1d4a9d8033dcb547b93c7093de3048b3e8fbe727b24ca9c0bd4a196c716726046b65ff849eb766
7
+ data.tar.gz: 5ce9742333e169945e3084b8b377e48fe8a186af589f26841b7f4f9844f5e984b1fe30363d0ee39c85d1aaec038a41809b0af3204558229159660eaaad024e2e
data/README.md CHANGED
@@ -87,8 +87,8 @@ notification = Pushpad::Notification.new({
87
87
  ttl: 604800, # optional, drop the notification after this number of seconds if a device is offline
88
88
  require_interaction: true, # optional, prevent Chrome on desktop from automatically closing the notification after a few seconds
89
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
90
+ # optional, add some action buttons to the notification
91
+ # see https://pushpad.xyz/docs/action_buttons
92
92
  actions: [
93
93
  {
94
94
  title: "My Button 1", # max length is 20 characters
@@ -97,7 +97,10 @@ notification = Pushpad::Notification.new({
97
97
  action: "myActionName" # optional
98
98
  }
99
99
  ],
100
- starred: true # optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)
100
+ starred: true, # optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)
101
+ # optional, use this option only if you need to create scheduled notifications (max 5 days)
102
+ # see https://pushpad.xyz/docs/schedule_notifications
103
+ send_at: Time.utc(2016, 7, 25, 10, 9)
101
104
  })
102
105
 
103
106
  # deliver to a user
@@ -132,6 +135,7 @@ The methods above return an hash:
132
135
  - `"id"` is the id of the notification on Pushpad
133
136
  - `"scheduled"` is the estimated reach of the notification (i.e. the number of devices to which the notification will be sent, which can be different from the number of users, since a user may receive notifications on multiple devices)
134
137
  - `"uids"` (`deliver_to` only) are the user IDs that will be actually reached by the notification because they are subscribed to your notifications. For example if you send a notification to `['uid1', 'uid2', 'uid3']`, but only `'uid1'` is subscribed, you will get `['uid1']` in response. Note that if a user has unsubscribed after the last notification sent to him, he may still be reported for one time as subscribed (this is due to [the way](http://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/) the W3C Push API works).
138
+ - `"send_at"` is present only for scheduled notifications. The fields `"scheduled"` and `"uids"` are not available in this case.
135
139
 
136
140
  The `id` and `scheduled_count` attribute are also stored on the notification object:
137
141
 
@@ -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, :image_url, :ttl, :require_interaction, :custom_data, :actions, :starred
15
+ attr_accessor :body, :title, :target_url, :icon_url, :image_url, :ttl, :require_interaction, :custom_data, :actions, :starred, :send_at
16
16
  attr_reader :id, :created_at, :scheduled_count, :successfully_sent_count, :opened_count
17
17
 
18
18
  def initialize(options)
@@ -32,6 +32,7 @@ module Pushpad
32
32
  @custom_data = options[:custom_data]
33
33
  @actions = options[:actions]
34
34
  @starred = options[:starred]
35
+ @send_at = options[:send_at]
35
36
  end
36
37
 
37
38
  def self.find(id)
@@ -118,6 +119,7 @@ module Pushpad
118
119
  notification_params["custom_data"] = self.custom_data if self.custom_data
119
120
  notification_params["actions"] = self.actions if self.actions
120
121
  notification_params["starred"] = self.starred unless self.starred.nil?
122
+ notification_params["send_at"] = self.send_at.utc.strftime("%Y-%m-%dT%R") if self.send_at
121
123
 
122
124
  body = { "notification" => notification_params }
123
125
  body["uids"] = uids if uids
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pushpad"
3
- spec.version = '0.7.0'
3
+ spec.version = '0.8.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."
@@ -28,6 +28,7 @@ module Pushpad
28
28
  end
29
29
 
30
30
  def stub_notification_post(project_id, params = {}, response_body = "{}")
31
+
31
32
  stub_request(:post, "https://pushpad.xyz/projects/#{project_id}/notifications").
32
33
  with(body: hash_including(params)).
33
34
  to_return(status: 201, body: response_body)
@@ -248,9 +249,11 @@ module Pushpad
248
249
  notification.deliver_to(100)
249
250
  }
250
251
 
252
+ let(:notification_params_to_json) { {} }
253
+
251
254
  shared_examples "notification params" do
252
255
  it "includes the params in the request" do
253
- req = stub_notification_post project_id, notification: notification_params
256
+ req = stub_notification_post project_id, notification: notification_params.merge(notification_params_to_json)
254
257
  notification.deliver_to [123, 456]
255
258
  expect(req).to have_been_made.once
256
259
  end
@@ -283,7 +286,13 @@ module Pushpad
283
286
  action: "myActionName"
284
287
  }
285
288
  ],
286
- starred: true
289
+ starred: true,
290
+ send_at: Time.utc(2016, 7, 25, 10, 9)
291
+ }
292
+ end
293
+ let(:notification_params_to_json) do
294
+ {
295
+ send_at: "2016-07-25T10:09"
287
296
  }
288
297
  end
289
298
  let(:notification) { Pushpad::Notification.new notification_params }
@@ -320,9 +329,11 @@ module Pushpad
320
329
  notification.broadcast
321
330
  }
322
331
 
332
+ let(:notification_params_to_json) { {} }
333
+
323
334
  shared_examples "notification params" do
324
335
  it "includes the params in the request" do
325
- req = stub_notification_post project_id, notification: notification_params
336
+ req = stub_notification_post project_id, notification: notification_params.merge(notification_params_to_json)
326
337
  notification.broadcast
327
338
  expect(req).to have_been_made.once
328
339
  end
@@ -355,7 +366,13 @@ module Pushpad
355
366
  action: "myActionName"
356
367
  }
357
368
  ],
358
- starred: true
369
+ starred: true,
370
+ send_at: Time.utc(2016, 7, 25, 10, 9)
371
+ }
372
+ end
373
+ let(:notification_params_to_json) do
374
+ {
375
+ send_at: "2016-07-25T10:09"
359
376
  }
360
377
  end
361
378
  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.7.0
4
+ version: 0.8.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-05-30 00:00:00.000000000 Z
11
+ date: 2017-10-26 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.4.5
85
+ rubygems_version: 2.0.14.1
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Web push notifications for Chrome, Firefox and Safari using Pushpad.