uniqush-rb 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/uniqush/restful_client.rb +21 -4
- data/lib/uniqush/version.rb +1 -1
- data/spec/uniqush/restul_client_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613cfa73e7e6b284c60d28ed6bea39d648d214e2
|
4
|
+
data.tar.gz: ebc690b26339813ae3cff561d8ca8ac6118cf266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ad4a2861faca1aca62b4ee5ac8ef0f16c08175861de7e75214dedc440f6cc83de347620461031fa63141b5ec8469012155988b4a9816b112936f6ab2afbe8e
|
7
|
+
data.tar.gz: 53c0fb31bb8bba37af47d8a2adbfbea37697d598d501599f51b57236341c7d07e982a0f365e8462d3bad3e2d1519fd22899c81e93960b1b3d712c282ee7a5320
|
data/Gemfile.lock
CHANGED
@@ -9,21 +9,38 @@ module Uniqush
|
|
9
9
|
remove_service: [:delete, "push_service_providers"],
|
10
10
|
subscribe_device: [:post, "subscribers"],
|
11
11
|
unsubscribe_device: [:delete, "subscribers"],
|
12
|
-
push: [:post, "push_notifications"]
|
12
|
+
push: [:post, "push_notifications"],
|
13
|
+
delete_schedule: [:delete, "push_notifications/schedule/:alias", [:alias]]
|
13
14
|
}.freeze
|
14
15
|
|
15
16
|
def initialize(base_url)
|
16
17
|
@client = rest_client(base_url)
|
17
18
|
end
|
18
19
|
|
19
|
-
ENDPOINTS.each do |method, (http_method, url)|
|
20
|
-
define_method method do |
|
20
|
+
ENDPOINTS.each do |method, (http_method, url, url_args)|
|
21
|
+
define_method method do |*arguments|
|
22
|
+
uri = url.dup
|
23
|
+
if url_args.is_a?(Array)
|
24
|
+
if arguments.size < url_args.size
|
25
|
+
raise ArgumentError, "Uniqush::RestfulClient##{method} requires at least #{url_args.size} arguments for #{url_args} on the url"
|
26
|
+
end
|
27
|
+
|
28
|
+
url_params = Hash[url_args.zip(arguments)]
|
29
|
+
uri.gsub!(/\:[a-z1-9_]+/) do |match|
|
30
|
+
url_params[match[1..-1].to_sym]
|
31
|
+
end
|
32
|
+
arguments = arguments[url_args.size..arguments.size]
|
33
|
+
end
|
34
|
+
|
35
|
+
params = arguments[0] || {}
|
36
|
+
extras = arguments[1] || {}
|
37
|
+
|
21
38
|
if [:post, :put, :patch].include?(http_method)
|
22
39
|
args = [params.to_json, extras]
|
23
40
|
else
|
24
41
|
args = [{params: params}.merge(extras)]
|
25
42
|
end
|
26
|
-
@client[
|
43
|
+
@client[uri].send(http_method, *args)
|
27
44
|
end
|
28
45
|
end
|
29
46
|
|
data/lib/uniqush/version.rb
CHANGED
@@ -25,4 +25,11 @@ describe Uniqush::RestfulClient do
|
|
25
25
|
to request(:post, "#{base_url}/push_notifications").with(body: a_hash.to_json)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe "deleting schedules" do
|
30
|
+
it "deletes given schedule" do
|
31
|
+
expect { client.delete_schedule("foobarbaz") }.
|
32
|
+
to request(:delete, "#{base_url}/push_notifications/schedule/foobarbaz")
|
33
|
+
end
|
34
|
+
end
|
28
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uniqush-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Bandeira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|