azure-push 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +18 -0
- data/azure-push.gemspec +2 -0
- data/lib/azure/push/message.rb +7 -5
- data/lib/azure/push/sas.rb +1 -1
- data/lib/azure/push/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb25adcfaa24ae53c7c40de69225341ac9dc402f
|
4
|
+
data.tar.gz: 03697355380b07c9165f0dd6e8b51e1fdd8287cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ed2e102d25e4a3f79ea94ae50b537a0e611334905ba9bd697ed185348c889b2415ab9b46ff609d62050b24f5f08dd250f17db70a36f10c493c6d6fd68760dd
|
7
|
+
data.tar.gz: a704d12094bf54ef5361cf2b2315bf2608ad4524bd42d201d2314162506043a39a63bfed33efd2e0ce6720ac402cdd4cd47e98ab96d96392daeda8a3a0d5d07a
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ This is a very simple Azure notification-hub implementation for sending push not
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
This gem is available on Rubygems: (https://rubygems.org/gems/azure-push)
|
8
|
+
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
11
|
gem 'azure-push'
|
@@ -21,6 +23,16 @@ Or install it yourself as:
|
|
21
23
|
ap = Azure::Push::Message.new(namespace, hub, access_key)
|
22
24
|
ap.send({aps: {alert: message, sound: true}, 'my_tag')
|
23
25
|
|
26
|
+
The default Message format is 'apple'. Since v0.0.2 all available formats are supported.
|
27
|
+
|
28
|
+
Formats: 'apple', 'gcm', 'template', 'windows', 'windowsphone'
|
29
|
+
|
30
|
+
ap.send(xml_string, 'my_tag', format: 'windows')
|
31
|
+
|
32
|
+
You can also add additional headers:
|
33
|
+
|
34
|
+
ap.send(xml_string, 'my_tag', format: 'windows', additional_headers: {'X-Special-Windows-Header' => 'value'})
|
35
|
+
|
24
36
|
## Contributing
|
25
37
|
|
26
38
|
1. Fork it ( https://github.com/christian-s/azure-push/fork )
|
@@ -28,3 +40,9 @@ Or install it yourself as:
|
|
28
40
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
41
|
4. Push to the branch (`git push origin my-new-feature`)
|
30
42
|
5. Create a new Pull Request
|
43
|
+
|
44
|
+
## Roadmap / Upcoming Features
|
45
|
+
|
46
|
+
- Read & Delete Registrations / Tags
|
47
|
+
- Create, Update Registrations
|
48
|
+
- Notification Hub management
|
data/azure-push.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
20
22
|
spec.add_runtime_dependency('json', '~> 1.8')
|
21
23
|
|
22
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
data/lib/azure/push/message.rb
CHANGED
@@ -18,18 +18,20 @@ module Azure
|
|
18
18
|
@sig_lifetime = sig_lifetime
|
19
19
|
end
|
20
20
|
|
21
|
-
def send(payload, tags, format: 'apple')
|
22
|
-
raise ArgumentError unless ['apple', 'gcm', 'template'].include? format
|
21
|
+
def send(payload, tags, format: 'apple', additional_headers: {})
|
22
|
+
raise ArgumentError unless ['apple', 'gcm', 'template', 'windows', 'windowsphone'].include? format
|
23
|
+
raise ArgumentError unless additional_headers.instance_of?(Hash)
|
23
24
|
if tags.instance_of?(Array)
|
24
25
|
tags = tags.join(' || ')
|
25
26
|
end
|
26
27
|
uri = URI(url)
|
28
|
+
content_type = ['apple', 'gcm', 'template'].include?(format) ? 'application/json' : 'application/xml;charset=utf-8'
|
27
29
|
headers = {
|
28
|
-
'Content-Type' =>
|
29
|
-
'Authorization' => sas_token(url, @key_name, @access_key, lifetime: @sig_lifetime),
|
30
|
+
'Content-Type' => content_type,
|
31
|
+
'Authorization' => Azure::Push::Sas.sas_token(url, @key_name, @access_key, lifetime: @sig_lifetime),
|
30
32
|
'ServiceBusNotification-Format' => format,
|
31
33
|
'ServiceBusNotification-Tags' => tags
|
32
|
-
}
|
34
|
+
}.merge(additional_headers)
|
33
35
|
http = Net::HTTP.new(uri.host,uri.port)
|
34
36
|
http.use_ssl = true
|
35
37
|
req = Net::HTTP::Post.new(uri.path, initheader = headers)
|
data/lib/azure/push/sas.rb
CHANGED
@@ -5,7 +5,7 @@ require 'digest'
|
|
5
5
|
module Azure
|
6
6
|
module Push
|
7
7
|
module Sas
|
8
|
-
def sas_token(url, key_name, access_key, lifetime:
|
8
|
+
def self.sas_token(url, key_name, access_key, lifetime: 10)
|
9
9
|
target_uri = CGI.escape(url.downcase).gsub('+', '%20').downcase
|
10
10
|
expires = Time.now.to_i + lifetime
|
11
11
|
to_sign = "#{target_uri}\n#{expires}"
|
data/lib/azure/push/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Sädtler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements:
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: 2.0.0
|
85
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|