pushover2 0.1.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 +7 -0
- data/.rubocop.yml +21 -0
- data/.ruby-version +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/lib/pushover2/client.rb +33 -0
- data/lib/pushover2/message.rb +118 -0
- data/lib/pushover2/sounds.rb +29 -0
- data/lib/pushover2/version.rb +5 -0
- data/lib/pushover2.rb +11 -0
- metadata +136 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 49568c6d155d41bf796bae5ea5fe5928f32343ece725756aac8691dbd1e0e094
|
|
4
|
+
data.tar.gz: fc1af9923a1d53734dc2596010fd2f787b7f4c2ecdbaaa931fc515490439d395
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 05bddbcaed195ce3782edd30259134728a8d344a00cc2818e0d94a56977c99c49892bca0b973dae0b05e048317758014bc3eca469df0eeb68dda94573b2f8b13
|
|
7
|
+
data.tar.gz: 626babddd33cf9e4c4f64a9ef0d57092f86a3f195a0d79c90222970aed743599c7cd931f84773626be37c8967f6e6b1795d4f81785b79b9e8965e0fc7caa75b5
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
NewCops: enable
|
|
7
|
+
|
|
8
|
+
Style/StringLiterals:
|
|
9
|
+
Enabled: false
|
|
10
|
+
|
|
11
|
+
Style/WordArray:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Style/Documentation:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
Gemspec/OrderedDependencies:
|
|
18
|
+
Enabled: false
|
|
19
|
+
|
|
20
|
+
Bundler/OrderedGems:
|
|
21
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.4.7
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Igor Zubkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Pushover2
|
|
2
|
+
|
|
3
|
+
Pushover.net Ruby API Client.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle add pushover2
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
gem install pushover2
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
require "pushover2"
|
|
23
|
+
|
|
24
|
+
# Send message
|
|
25
|
+
message = Pushover2::Message.new(token: "app-token", user: "user-token", message: "...")
|
|
26
|
+
message.push
|
|
27
|
+
|
|
28
|
+
# Send to device
|
|
29
|
+
message = Pushover2::Message.new(token: "app-token", user: "user-token", message: "...", device: "iphone")
|
|
30
|
+
message.push
|
|
31
|
+
|
|
32
|
+
# Send html message
|
|
33
|
+
message = Pushover2::Message.new(token: "app-token", user: "user-token", message: "<b>Hello</b>", html: 1)
|
|
34
|
+
message.push
|
|
35
|
+
|
|
36
|
+
# Send silent message
|
|
37
|
+
message = Pushover2::Message.new(token: "app-token", user: "user-token", message: "...", sound: "none")
|
|
38
|
+
message.push
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
44
|
+
|
|
45
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/biow0lf/pushover2.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "uri"
|
|
4
|
+
require "net/http"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module Pushover2
|
|
8
|
+
class Client
|
|
9
|
+
BASE_URI = "https://api.pushover.net"
|
|
10
|
+
|
|
11
|
+
# @param path [String]
|
|
12
|
+
def post(path, query: {}, body: {})
|
|
13
|
+
make_request(path, body: body)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def make_request(path, body: {})
|
|
17
|
+
uri = URI("#{BASE_URI}#{path}")
|
|
18
|
+
|
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
20
|
+
http.use_ssl = true
|
|
21
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
22
|
+
|
|
23
|
+
request = Net::HTTP::Post.new(uri.request_uri, {
|
|
24
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
25
|
+
})
|
|
26
|
+
request.set_form_data(body)
|
|
27
|
+
|
|
28
|
+
response = http.request(request)
|
|
29
|
+
|
|
30
|
+
puts JSON.parse(response.body)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pushover2
|
|
4
|
+
class Message
|
|
5
|
+
MESSAGE_PATH = "/1/messages.json"
|
|
6
|
+
|
|
7
|
+
# Instance of Pushover2::Client
|
|
8
|
+
attr_reader :client
|
|
9
|
+
|
|
10
|
+
# Application Token (how is sending message)
|
|
11
|
+
attr_reader :token
|
|
12
|
+
|
|
13
|
+
# User Token (how is receiving message)
|
|
14
|
+
attr_reader :user
|
|
15
|
+
|
|
16
|
+
# String to send
|
|
17
|
+
attr_reader :message
|
|
18
|
+
|
|
19
|
+
attr_reader :attachment
|
|
20
|
+
attr_reader :attachment_base64
|
|
21
|
+
attr_reader :attachment_type
|
|
22
|
+
attr_reader :device
|
|
23
|
+
attr_reader :html
|
|
24
|
+
attr_reader :priority
|
|
25
|
+
attr_reader :sound
|
|
26
|
+
attr_reader :timestamp
|
|
27
|
+
attr_reader :title
|
|
28
|
+
attr_reader :ttl
|
|
29
|
+
attr_reader :url
|
|
30
|
+
attr_reader :url_title
|
|
31
|
+
|
|
32
|
+
# @param token [String] Application Token (how is sending message). Required.
|
|
33
|
+
# @param user [String] User Token (how is receiving message). Required.
|
|
34
|
+
# @param message [String] String to send. Required.
|
|
35
|
+
# @param attachment [] Optional.
|
|
36
|
+
# @param attachment_base64 [] Optional.
|
|
37
|
+
# @param attachment_type [] Optional.
|
|
38
|
+
# @param device [String, nil] Device name to send notification. Optional.
|
|
39
|
+
# @param html [Integer, nil] If set to 1, send html formatted message. Optional.
|
|
40
|
+
# @param priority [Integer, nil] One from: -2, -1, 0, 1, 2. Default: 0. Optional.
|
|
41
|
+
# @param sound [String, nil] Sound to play. Default: "pushover". Optional.
|
|
42
|
+
# @param timestamp [] Optional.
|
|
43
|
+
# @param title [String, nil] Title for notification. Optional.
|
|
44
|
+
# @param ttl [Integer, nil] TTL for notification in seconds. Optional.
|
|
45
|
+
# @param url [String, nil] URL for notification. Optional.
|
|
46
|
+
# @param url_title [String, nil] Title for notification URL. Optional.
|
|
47
|
+
def initialize(token:, user:, message:,
|
|
48
|
+
attachment: nil,
|
|
49
|
+
attachment_base64: nil,
|
|
50
|
+
attachment_type: nil,
|
|
51
|
+
device: nil,
|
|
52
|
+
html: nil,
|
|
53
|
+
priority: nil,
|
|
54
|
+
sound: nil,
|
|
55
|
+
timestamp: nil,
|
|
56
|
+
title: nil,
|
|
57
|
+
ttl: nil,
|
|
58
|
+
url: nil,
|
|
59
|
+
url_title: nil)
|
|
60
|
+
@client = Client.new
|
|
61
|
+
@token = token
|
|
62
|
+
@user = user
|
|
63
|
+
@message = message
|
|
64
|
+
@attachment = attachment
|
|
65
|
+
@attachment_base64 = attachment_base64
|
|
66
|
+
@attachment_type = attachment_type
|
|
67
|
+
@device = device
|
|
68
|
+
@html = html
|
|
69
|
+
@priority = priority
|
|
70
|
+
@sound = sound
|
|
71
|
+
@timestamp = timestamp
|
|
72
|
+
@title = title
|
|
73
|
+
@ttl = ttl
|
|
74
|
+
@url = url
|
|
75
|
+
@url_title = url_title
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def push
|
|
79
|
+
client.post(MESSAGE_PATH, body: body)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
def body
|
|
85
|
+
payload = {
|
|
86
|
+
token: token,
|
|
87
|
+
user: user,
|
|
88
|
+
message: message,
|
|
89
|
+
attachment: attachment,
|
|
90
|
+
attachment_base64: attachment_base64,
|
|
91
|
+
attachment_type: attachment_type,
|
|
92
|
+
device: device,
|
|
93
|
+
html: html,
|
|
94
|
+
priority: priority,
|
|
95
|
+
sound: sound,
|
|
96
|
+
timestamp: timestamp,
|
|
97
|
+
title: title,
|
|
98
|
+
ttl: ttl,
|
|
99
|
+
url: url,
|
|
100
|
+
url_title: url_title
|
|
101
|
+
}.compact
|
|
102
|
+
|
|
103
|
+
if payload[:token].nil?
|
|
104
|
+
raise "Missing required :token field"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if payload[:user].nil?
|
|
108
|
+
raise "Missing required :user field"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if payload[:message].nil?
|
|
112
|
+
raise "Missing required :message field"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
payload
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pushover2
|
|
4
|
+
SOUNDS = [
|
|
5
|
+
"pushover",
|
|
6
|
+
"bike",
|
|
7
|
+
"bugle",
|
|
8
|
+
"cashregister",
|
|
9
|
+
"classical",
|
|
10
|
+
"cosmic",
|
|
11
|
+
"falling",
|
|
12
|
+
"gamelan",
|
|
13
|
+
"incoming",
|
|
14
|
+
"intermission",
|
|
15
|
+
"magic",
|
|
16
|
+
"mechanical",
|
|
17
|
+
"pianobar",
|
|
18
|
+
"siren",
|
|
19
|
+
"spacealarm",
|
|
20
|
+
"tugboat",
|
|
21
|
+
"alien",
|
|
22
|
+
"climb",
|
|
23
|
+
"persistent",
|
|
24
|
+
"echo",
|
|
25
|
+
"updown",
|
|
26
|
+
"vibrate",
|
|
27
|
+
"none"
|
|
28
|
+
].freeze
|
|
29
|
+
end
|
data/lib/pushover2.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "pushover2/version"
|
|
4
|
+
require_relative "pushover2/sounds"
|
|
5
|
+
require_relative "pushover2/client"
|
|
6
|
+
require_relative "pushover2/message"
|
|
7
|
+
|
|
8
|
+
module Pushover2
|
|
9
|
+
class Error < StandardError; end
|
|
10
|
+
# Your code goes here...
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pushover2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ihor Zubkov
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: json
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: uri
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: net-http
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: webmock
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: vcr
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
description: Ruby API for pushover.net.
|
|
97
|
+
email:
|
|
98
|
+
- igor.zubkov@gmail.com
|
|
99
|
+
executables: []
|
|
100
|
+
extensions: []
|
|
101
|
+
extra_rdoc_files: []
|
|
102
|
+
files:
|
|
103
|
+
- ".rubocop.yml"
|
|
104
|
+
- ".ruby-version"
|
|
105
|
+
- LICENSE.txt
|
|
106
|
+
- README.md
|
|
107
|
+
- Rakefile
|
|
108
|
+
- lib/pushover2.rb
|
|
109
|
+
- lib/pushover2/client.rb
|
|
110
|
+
- lib/pushover2/message.rb
|
|
111
|
+
- lib/pushover2/sounds.rb
|
|
112
|
+
- lib/pushover2/version.rb
|
|
113
|
+
homepage: https://github.com/biow0lf/pushover2
|
|
114
|
+
licenses:
|
|
115
|
+
- MIT
|
|
116
|
+
metadata:
|
|
117
|
+
homepage_uri: https://github.com/biow0lf/pushover2
|
|
118
|
+
source_code_uri: https://github.com/biow0lf/pushover2
|
|
119
|
+
rdoc_options: []
|
|
120
|
+
require_paths:
|
|
121
|
+
- lib
|
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: 3.4.0
|
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
requirements: []
|
|
133
|
+
rubygems_version: 4.0.0
|
|
134
|
+
specification_version: 4
|
|
135
|
+
summary: Ruby API for pushover.net
|
|
136
|
+
test_files: []
|