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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e145e55bb48f4842b4f4784fc1780d2c7de1dde
4
- data.tar.gz: d5f4742156e3612b7f91515f786bb1a4340b621c
3
+ metadata.gz: cb25adcfaa24ae53c7c40de69225341ac9dc402f
4
+ data.tar.gz: 03697355380b07c9165f0dd6e8b51e1fdd8287cc
5
5
  SHA512:
6
- metadata.gz: cccbfe66d20ae3c182716d574a1bf3cf5a2fee5f1555aa1432c64f2766285c00d859dec1fc0d073f2fca9a5ba42d088a6700c9f148a14f79d4257ea51ac94f1f
7
- data.tar.gz: 777207f91370b7191231d064f27a4942de588eed9466d418b4abdc947c2d7ad226a1d90cf33b4faecbc876cc8c70df0f302b84f6cb4ce2309be4729910211eaf
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
@@ -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"
@@ -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' => 'application/json',
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)
@@ -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: 60)
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}"
@@ -1,5 +1,5 @@
1
1
  module Azure
2
2
  module Push
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
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.1
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-12 00:00:00.000000000 Z
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: '0'
84
+ version: 2.0.0
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="