pushpad 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 67f4863ab766c1ca89b1682f5844e3ff14052485
4
- data.tar.gz: 848e06f99b504eac246cc94d970de15dde652ca3
2
+ SHA256:
3
+ metadata.gz: 859e8674ef09ee84c2bb6ab00a837aef0d48b2039774625974aae32f2ca3a2ee
4
+ data.tar.gz: 71086f6109284229c8c02d01d48ca0980a4621065d43875a4131bc867b7c002a
5
5
  SHA512:
6
- metadata.gz: 9bde5c69aebcbbf6f8a7ede29ce2b7c75c0a46f835f32eb806bb88a827b91b0b801cdde87cdb3fd12efb34679f18bdb4eb93be709b3de01b8fed04b84465e767
7
- data.tar.gz: 5c7666ab8ca1c40e183ce6bc15d16834e00a0df84da63969120ba894ea72b455d5888b09c647d0d2520d73d217c05de6a6d8d4b4059e8a49a0be03508aa10b78
6
+ metadata.gz: 2cd5ae106f55214c5c16a7fc2eae7d33ecb4e6fb0c9b2917d44c643a754b5a6b124630b356969d9a230a25ed89fe0726b900d001452c777dba677f629c52ce6d
7
+ data.tar.gz: f06eb68e6b96bbf6b6f59ab687c838fdc72a6a5f9df61a86e48772bd7f74d6990416d69ddbe8ea71855b8a42ba453e363c2fb4a1ae4b97268d437a545b9a0166
@@ -0,0 +1,22 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [ master ]
5
+ pull_request:
6
+ branches: [ master ]
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby-version: ['2.7', '3.0', '3.1']
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true
21
+ - name: Run tests
22
+ run: bundle exec rspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Pushpad (https://pushpad.xyz)
3
+ Copyright (c) 2016-2022 Pushpad (https://pushpad.xyz)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Pushpad - Web Push Notifications
2
2
 
3
- [![Build Status](https://travis-ci.org/pushpad/pushpad-ruby.svg?branch=master)](https://travis-ci.org/pushpad/pushpad-ruby)
4
3
  [![Gem Version](https://badge.fury.io/rb/pushpad.svg)](https://badge.fury.io/rb/pushpad)
4
+ ![Build Status](https://github.com/pushpad/pushpad-ruby/workflows/CI/badge.svg)
5
5
 
6
6
  [Pushpad](https://pushpad.xyz) is a service for sending push notifications from your web app. It supports the **Push API** (Chrome, Firefox, Opera, Edge) and **APNs** (Safari).
7
7
 
@@ -55,22 +55,24 @@ Pushpad.signature_for current_user.id
55
55
 
56
56
  ```ruby
57
57
  notification = Pushpad::Notification.new({
58
- body: "Hello world!", # max 120 characters
59
- title: "Website Name", # optional, defaults to your project name, max 30 characters
60
- target_url: "http://example.com", # optional, defaults to your project website
61
- icon_url: "http://example.com/assets/icon.png", # optional, defaults to the project icon
62
- image_url: "http://example.com/assets/image.png", # optional, an image to display in the notification content
58
+ body: "Hello world!",
59
+ title: "Website Name", # optional, defaults to your project name
60
+ target_url: "https://example.com", # optional, defaults to your project website
61
+ icon_url: "https://example.com/assets/icon.png", # optional, defaults to the project icon
62
+ badge_url: "https://example.com/assets/badge.png" # optional, defaults to the project badge
63
+ image_url: "https://example.com/assets/image.png", # optional, an image to display in the notification content
63
64
  ttl: 604800, # optional, drop the notification after this number of seconds if a device is offline
64
65
  require_interaction: true, # optional, prevent Chrome on desktop from automatically closing the notification after a few seconds
66
+ silent: false, # optional, enable this option if you want a mute notification without any sound
65
67
  urgent: false, # optional, enable this option only for time-sensitive alerts (e.g. incoming phone call)
66
68
  custom_data: "123", # optional, a string that is passed as an argument to action button callbacks
67
69
  # optional, add some action buttons to the notification
68
70
  # see https://pushpad.xyz/docs/action_buttons
69
71
  actions: [
70
72
  {
71
- title: "My Button 1", # max length is 20 characters
72
- target_url: "http://example.com/button-link", # optional
73
- icon: "http://example.com/assets/button-icon.png", # optional
73
+ title: "My Button 1",
74
+ target_url: "https://example.com/button-link", # optional
75
+ icon: "https://example.com/assets/button-icon.png", # optional
74
76
  action: "myActionName" # optional
75
77
  }
76
78
  ],
@@ -114,7 +116,7 @@ The methods above return an hash:
114
116
 
115
117
  - `"id"` is the id of the notification on Pushpad
116
118
  - `"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)
117
- - `"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).
119
+ - `"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](https://blog.pushpad.xyz/2016/05/the-push-api-and-its-wild-unsubscription-mechanism/) the W3C Push API works).
118
120
  - `"send_at"` is present only for scheduled notifications. The fields `"scheduled"` and `"uids"` are not available in this case.
119
121
 
120
122
  The `id` and `scheduled_count` attribute are also stored on the notification object:
@@ -138,11 +140,13 @@ notification = Pushpad::Notification.find(42)
138
140
  notification.id # => 42
139
141
  notification.title # => "Foo Bar",
140
142
  notification.body # => "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
141
- notification.target_url # => "http://example.com",
143
+ notification.target_url # => "https://example.com",
142
144
  notification.ttl # => 604800,
143
145
  notification.require_interaction # => false,
146
+ notification.silent # => false,
144
147
  notification.urgent # => false,
145
- notification.icon_url # => "http://example.com/assets/icon.png",
148
+ notification.icon_url # => "https://example.com/assets/icon.png",
149
+ notification.badge_url # => "https://example.com/assets/badge.png",
146
150
 
147
151
  # `created_at` is a `Time` instance
148
152
  notification.created_at.utc.to_s # => "2016-07-06 10:09:14 UTC",
@@ -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, :urgent, :custom_data, :custom_metrics, :actions, :starred, :send_at
15
+ attr_accessor :body, :title, :target_url, :icon_url, :badge_url, :image_url, :ttl, :require_interaction, :silent, :urgent, :custom_data, :custom_metrics, :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)
@@ -26,9 +26,11 @@ module Pushpad
26
26
  @title = options[:title]
27
27
  @target_url = options[:target_url]
28
28
  @icon_url = options[:icon_url]
29
+ @badge_url = options[:badge_url]
29
30
  @image_url = options[:image_url]
30
31
  @ttl = options[:ttl]
31
32
  @require_interaction = options[:require_interaction]
33
+ @silent = options[:silent]
32
34
  @urgent = options[:urgent]
33
35
  @custom_data = options[:custom_data]
34
36
  @custom_metrics = options[:custom_metrics]
@@ -38,7 +40,7 @@ module Pushpad
38
40
  end
39
41
 
40
42
  def self.find(id)
41
- response = Request.get("https://pushpad.xyz/notifications/#{id}")
43
+ response = Request.get("https://pushpad.xyz/api/v1/notifications/#{id}")
42
44
 
43
45
  unless response.code == "200"
44
46
  raise FindError, "Response #{response.code} #{response.message}: #{response.body}"
@@ -54,7 +56,7 @@ module Pushpad
54
56
  query_parameters = {}
55
57
  query_parameters[:page] = options[:page] if options.key?(:page)
56
58
 
57
- response = Request.get("https://pushpad.xyz/projects/#{project_id}/notifications",
59
+ response = Request.get("https://pushpad.xyz/api/v1/projects/#{project_id}/notifications",
58
60
  query_parameters: query_parameters)
59
61
 
60
62
  unless response.code == "200"
@@ -97,7 +99,7 @@ module Pushpad
97
99
  project_id = options[:project_id] || Pushpad.project_id
98
100
  raise "You must set project_id" unless project_id
99
101
 
100
- endpoint = "https://pushpad.xyz/projects/#{project_id}/notifications"
102
+ endpoint = "https://pushpad.xyz/api/v1/projects/#{project_id}/notifications"
101
103
  response = Request.post(endpoint, req_body)
102
104
 
103
105
  unless response.code == "201"
@@ -115,9 +117,11 @@ module Pushpad
115
117
  notification_params["title"] = self.title if self.title
116
118
  notification_params["target_url"] = self.target_url if self.target_url
117
119
  notification_params["icon_url"] = self.icon_url if self.icon_url
120
+ notification_params["badge_url"] = self.badge_url if self.badge_url
118
121
  notification_params["image_url"] = self.image_url if self.image_url
119
122
  notification_params["ttl"] = self.ttl if self.ttl
120
123
  notification_params["require_interaction"] = self.require_interaction unless self.require_interaction.nil?
124
+ notification_params["silent"] = self.silent unless self.silent.nil?
121
125
  notification_params["urgent"] = self.urgent unless self.urgent.nil?
122
126
  notification_params["custom_data"] = self.custom_data if self.custom_data
123
127
  notification_params["custom_metrics"] = self.custom_metrics if self.custom_metrics
@@ -18,7 +18,7 @@ module Pushpad
18
18
  project_id = options[:project_id] || Pushpad.project_id
19
19
  raise "You must set project_id" unless project_id
20
20
 
21
- endpoint = "https://pushpad.xyz/projects/#{project_id}/subscriptions"
21
+ endpoint = "https://pushpad.xyz/api/v1/projects/#{project_id}/subscriptions"
22
22
  response = Request.head(endpoint, query_parameters: query_parameters)
23
23
 
24
24
  unless response.code == "200"
data/pushpad.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pushpad"
3
- spec.version = '0.11.0'
3
+ spec.version = '0.13.0'
4
4
  spec.authors = ["Pushpad"]
5
5
  spec.email = ["support@pushpad.xyz"]
6
6
  spec.summary = "Web push notifications for Chrome, Firefox, Opera, Edge and Safari using Pushpad."
@@ -7,35 +7,35 @@ module Pushpad
7
7
  let(:notification) { Pushpad::Notification.new body: "Example message" }
8
8
 
9
9
  def stub_notification_get(attributes)
10
- stub_request(:get, "https://pushpad.xyz/notifications/#{attributes[:id]}").
10
+ stub_request(:get, "https://pushpad.xyz/api/v1/notifications/#{attributes[:id]}").
11
11
  to_return(status: 200, body: attributes.to_json)
12
12
  end
13
13
 
14
14
  def stub_failing_notification_get(notification_id)
15
- stub_request(:get, "https://pushpad.xyz/notifications/#{notification_id}").
15
+ stub_request(:get, "https://pushpad.xyz/api/v1/notifications/#{notification_id}").
16
16
  to_return(status: 404)
17
17
  end
18
18
 
19
19
  def stub_notifications_get(options)
20
- stub_request(:get, "https://pushpad.xyz/projects/#{options[:project_id]}/notifications").
20
+ stub_request(:get, "https://pushpad.xyz/api/v1/projects/#{options[:project_id]}/notifications").
21
21
  with(query: hash_including(options.fetch(:query, {}))).
22
22
  to_return(status: 200, body: options[:list].to_json)
23
23
  end
24
24
 
25
25
  def stub_failing_notifications_get(options)
26
- stub_request(:get, "https://pushpad.xyz/projects/#{options[:project_id]}/notifications").
26
+ stub_request(:get, "https://pushpad.xyz/api/v1/projects/#{options[:project_id]}/notifications").
27
27
  to_return(status: 403)
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
+ stub_request(:post, "https://pushpad.xyz/api/v1/projects/#{project_id}/notifications").
33
33
  with(body: hash_including(params)).
34
34
  to_return(status: 201, body: response_body)
35
35
  end
36
36
 
37
37
  def stub_failing_notification_post(project_id)
38
- stub_request(:post, "https://pushpad.xyz/projects/#{project_id}/notifications").
38
+ stub_request(:post, "https://pushpad.xyz/api/v1/projects/#{project_id}/notifications").
39
39
  to_return(status: 403)
40
40
  end
41
41
 
@@ -55,12 +55,14 @@ module Pushpad
55
55
  id: 5,
56
56
  title: "Foo Bar",
57
57
  body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
58
- target_url: "http://example.com",
58
+ target_url: "https://example.com",
59
59
  created_at: "2016-07-06T10:09:14.835Z",
60
60
  ttl: 604800,
61
61
  require_interaction: false,
62
+ silent: false,
62
63
  urgent: false,
63
64
  icon_url: "https://example.com/assets/icon.png",
65
+ badge_url: "https://example.com/assets/badge.png",
64
66
  scheduled_count: 2,
65
67
  successfully_sent_count: 4,
66
68
  opened_count: 1
@@ -109,12 +111,14 @@ module Pushpad
109
111
  id: 5,
110
112
  title: "Foo Bar",
111
113
  body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
112
- target_url: "http://example.com",
114
+ target_url: "https://example.com",
113
115
  created_at: "2016-07-06T10:09:14.835Z",
114
116
  ttl: 604800,
115
117
  require_interaction: false,
118
+ silent: false,
116
119
  urgent: false,
117
120
  icon_url: "https://example.com/assets/icon.png",
121
+ badge_url: "https://example.com/assets/badge.png",
118
122
  scheduled_count: 2,
119
123
  successfully_sent_count: 4,
120
124
  opened_count: 1
@@ -274,19 +278,21 @@ module Pushpad
274
278
  {
275
279
  body: "Example message",
276
280
  title: "Website Name",
277
- target_url: "http://example.com",
278
- icon_url: "http://example.com/assets/icon.png",
279
- image_url: "http://example.com/assets/image.png",
281
+ target_url: "https://example.com",
282
+ icon_url: "https://example.com/assets/icon.png",
283
+ badge_url: "https://example.com/assets/badge.png",
284
+ image_url: "https://example.com/assets/image.png",
280
285
  ttl: 604800,
281
286
  require_interaction: true,
287
+ silent: true,
282
288
  urgent: true,
283
289
  custom_data: "123",
284
290
  custom_metrics: ["examples", "another_metric"],
285
291
  actions: [
286
292
  {
287
293
  title: "My Button 1",
288
- target_url: "http://example.com/button-link",
289
- icon: "http://example.com/assets/button-icon.png",
294
+ target_url: "https://example.com/button-link",
295
+ icon: "https://example.com/assets/button-icon.png",
290
296
  action: "myActionName"
291
297
  }
292
298
  ],
@@ -356,19 +362,21 @@ module Pushpad
356
362
  {
357
363
  body: "Example message",
358
364
  title: "Website Name",
359
- target_url: "http://example.com",
360
- icon_url: "http://example.com/assets/icon.png",
361
- image_url: "http://example.com/assets/image.png",
365
+ target_url: "https://example.com",
366
+ icon_url: "https://example.com/assets/icon.png",
367
+ badge_url: "https://example.com/assets/badge.png",
368
+ image_url: "https://example.com/assets/image.png",
362
369
  ttl: 604800,
363
370
  require_interaction: true,
371
+ silent: true,
364
372
  urgent: true,
365
373
  custom_data: "123",
366
374
  custom_metrics: ["examples", "another_metric"],
367
375
  actions: [
368
376
  {
369
377
  title: "My Button 1",
370
- target_url: "http://example.com/button-link",
371
- icon: "http://example.com/assets/button-icon.png",
378
+ target_url: "https://example.com/button-link",
379
+ icon: "https://example.com/assets/button-icon.png",
372
380
  action: "myActionName"
373
381
  }
374
382
  ],
@@ -3,14 +3,14 @@ require "spec_helper"
3
3
  module Pushpad
4
4
  describe Subscription do
5
5
  def stub_subscriptions_head(options)
6
- stub_request(:head, "https://pushpad.xyz/projects/#{options[:project_id]}/subscriptions").
6
+ stub_request(:head, "https://pushpad.xyz/api/v1/projects/#{options[:project_id]}/subscriptions").
7
7
  with(query: hash_including(options.fetch(:query, {}))).
8
8
  to_return(status: 200,
9
9
  headers: { "X-Total-Count" => options.fetch(:total_count, 10) })
10
10
  end
11
11
 
12
12
  def stub_failing_subscriptions_head(options)
13
- stub_request(:head, "https://pushpad.xyz/projects/#{options[:project_id]}/subscriptions").
13
+ stub_request(:head, "https://pushpad.xyz/api/v1/projects/#{options[:project_id]}/subscriptions").
14
14
  to_return(status: 503)
15
15
  end
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushpad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pushpad
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-26 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,16 +38,16 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - support@pushpad.xyz
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/ci.yml"
48
49
  - ".gitignore"
49
50
  - ".rspec"
50
- - ".travis.yml"
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -66,7 +66,7 @@ homepage: https://pushpad.xyz
66
66
  licenses:
67
67
  - MIT
68
68
  metadata: {}
69
- post_install_message:
69
+ post_install_message:
70
70
  rdoc_options: []
71
71
  require_paths:
72
72
  - lib
@@ -81,9 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.4.5
86
- signing_key:
84
+ rubygems_version: 3.2.32
85
+ signing_key:
87
86
  specification_version: 4
88
87
  summary: Web push notifications for Chrome, Firefox, Opera, Edge and Safari using
89
88
  Pushpad.
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.2