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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80f0966c8e6948c4b8b6851f6e1634459937f877
4
- data.tar.gz: fa52bfd441df395be58433d2ea126a5807a23f8b
3
+ metadata.gz: 613cfa73e7e6b284c60d28ed6bea39d648d214e2
4
+ data.tar.gz: ebc690b26339813ae3cff561d8ca8ac6118cf266
5
5
  SHA512:
6
- metadata.gz: 538d71f7c9f5461c80244e6a807022a7dfe446f1e1311b4b4ed860f193a6a0e770d38a9e4a3fb7841ae13b0d838d0270c8f94a092e51acbbf94274b1fd9cae36
7
- data.tar.gz: 86697414d766576aca6b5e211c2465f2916ca2302fb5f13f6701c3c2265b453ebb603526e57317ad35ca1957381d0dd47a769a40eaffa6b80f931419f58a62cc
6
+ metadata.gz: d5ad4a2861faca1aca62b4ee5ac8ef0f16c08175861de7e75214dedc440f6cc83de347620461031fa63141b5ec8469012155988b4a9816b112936f6ab2afbe8e
7
+ data.tar.gz: 53c0fb31bb8bba37af47d8a2adbfbea37697d598d501599f51b57236341c7d07e982a0f365e8462d3bad3e2d1519fd22899c81e93960b1b3d712c282ee7a5320
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniqush-rb (0.0.2)
4
+ uniqush-rb (0.0.4)
5
5
  rest-client (~> 1.7.2)
6
6
 
7
7
  GEM
@@ -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 |params = {}, extras = {}|
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[url].send(http_method, *args)
43
+ @client[uri].send(http_method, *args)
27
44
  end
28
45
  end
29
46
 
@@ -1,3 +1,3 @@
1
1
  module Uniqush
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.3
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: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client