dirigible 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dirigible.gemspec +1 -1
- data/lib/dirigible/device_information.rb +39 -6
- data/lib/dirigible/device_registration.rb +2 -2
- data/lib/dirigible/push.rb +1 -1
- data/lib/dirigible/request.rb +1 -1
- data/lib/dirigible/utils.rb +9 -1
- data/lib/dirigible/version.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b36b3346e8c2514e6726e129f10a6d2525afd203
|
4
|
+
data.tar.gz: fc4b117b7004ac49010feb6c8e1896138fea24e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a2ffb0992991d31abc166565cbab34c7a57a848c958248a453e1b9deed080e8833f0b33c51bfa384a3265dac4dc0e5b41feb92caedbe165c7da230845f7b95e
|
7
|
+
data.tar.gz: 4f66cd85d0e7743b175c94e9419af128bf949e72bb4f98cec083d1f9f3ced2f73b98370f2cdcb60ea9ddfbae2c0fabf4da5d229a447a77be1d17be4756dff65c
|
data/dirigible.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# Runtime dependencies
|
22
|
-
spec.add_dependency "faraday", "~> 0.8"
|
22
|
+
spec.add_dependency "faraday", "~> 0.8.0"
|
23
23
|
spec.add_dependency "faraday_middleware", "~> 0.9"
|
24
24
|
spec.add_dependency "hashie", "~> 2.0"
|
25
25
|
spec.add_dependency "multi_json", "~> 1.8"
|
@@ -37,9 +37,13 @@ class Dirigible::DeviceInformation
|
|
37
37
|
# @example Example request:
|
38
38
|
# Dirigible::DeviceInformation.list_device_tokens
|
39
39
|
#
|
40
|
+
# @example Request next page:
|
41
|
+
# device_tokens = Dirigible::DeviceInformation.list_device_tokens
|
42
|
+
# more_device_tokens = device_tokens.next_page
|
43
|
+
#
|
40
44
|
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
|
41
|
-
def self.list_device_tokens
|
42
|
-
Dirigible.get('/device_tokens')
|
45
|
+
def self.list_device_tokens(options = {})
|
46
|
+
List.new(Dirigible.get('/device_tokens', params))
|
43
47
|
end
|
44
48
|
|
45
49
|
# Fetch Android APIDs registered to this application and
|
@@ -48,9 +52,13 @@ class Dirigible::DeviceInformation
|
|
48
52
|
# @example Example request:
|
49
53
|
# Dirigible::DeviceInformation.list_apids
|
50
54
|
#
|
55
|
+
# @example Request next page:
|
56
|
+
# apids = Dirigible::DeviceInformation.list_apids
|
57
|
+
# more_apids = apids.next_page
|
58
|
+
#
|
51
59
|
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
|
52
|
-
def self.list_apids
|
53
|
-
Dirigible.get('/apids')
|
60
|
+
def self.list_apids(options = {})
|
61
|
+
List.new(Dirigible.get('/apids', params))
|
54
62
|
end
|
55
63
|
|
56
64
|
# Fetch BlackBerry PINs registered to this application and
|
@@ -59,9 +67,13 @@ class Dirigible::DeviceInformation
|
|
59
67
|
# @example Example request:
|
60
68
|
# Dirigible::DeviceInformation.list_device_pins
|
61
69
|
#
|
70
|
+
# @example Request next page:
|
71
|
+
# device_pins = Dirigible::DeviceInformation.list_device_pins
|
72
|
+
# more_device_pins = device_pins.next_page
|
73
|
+
#
|
62
74
|
# @see http://docs.urbanairship.com/reference/api/v3/device_information.html#device-listing
|
63
|
-
def self.list_device_pins
|
64
|
-
Dirigible.get('/device_pins')
|
75
|
+
def self.list_device_pins(options = {})
|
76
|
+
List.new(Dirigible.get('/device_pins', params))
|
65
77
|
end
|
66
78
|
|
67
79
|
# Fetch device tokens that can't recieve messages because
|
@@ -74,4 +86,25 @@ class Dirigible::DeviceInformation
|
|
74
86
|
def self.device_token_feedback(since)
|
75
87
|
Dirigible.get("/device_tokens/feedback", { since: since })
|
76
88
|
end
|
89
|
+
|
90
|
+
class List
|
91
|
+
def initialize(response)
|
92
|
+
@response = response
|
93
|
+
end
|
94
|
+
|
95
|
+
def [](value)
|
96
|
+
@response[value]
|
97
|
+
end
|
98
|
+
|
99
|
+
# Fetch the next page for this device listing. Returns
|
100
|
+
# nil if next_page is nil.
|
101
|
+
def next_page(params = {})
|
102
|
+
return nil if @response[:next_page].nil?
|
103
|
+
uri = URI.parse(@response[:next_page])
|
104
|
+
path = "/#{uri.path.gsub(/\/api|\//, '')}"
|
105
|
+
# Shew! Need to simplify this!
|
106
|
+
params = (CGI.parse(uri.query).map{ |k,v| { k => v[0] } }.reduce({}) { |h,pairs| pairs.each { |k,v| (h[k.to_sym] = v) }; h }).merge!(params)
|
107
|
+
List.new(Dirigible.get(path, params))
|
108
|
+
end
|
109
|
+
end
|
77
110
|
end
|
@@ -44,8 +44,8 @@ class Dirigible::DeviceRegistration
|
|
44
44
|
# })
|
45
45
|
#
|
46
46
|
# @see http://docs.urbanairship.com/reference/api/v3/registration.html#apid-registration
|
47
|
-
def self.register_apid(id,
|
48
|
-
Dirigible.put("/apids/#{id}",
|
47
|
+
def self.register_apid(id, options = {})
|
48
|
+
Dirigible.put("/apids/#{id}", options)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Register this PIN with this application. This will mark
|
data/lib/dirigible/push.rb
CHANGED
@@ -9,7 +9,7 @@ class Dirigible::Push
|
|
9
9
|
# @example Example request:
|
10
10
|
# Dirigible::Push.create({
|
11
11
|
# audience: { device_token: "998BAD77A8347EFE7920F5367A4811C4385D526AE42C598A629A73B94EEDBAC8" },
|
12
|
-
# notification: { alert: "Hello"
|
12
|
+
# notification: { alert: "Hello!" },
|
13
13
|
# device_types: "all"
|
14
14
|
# })
|
15
15
|
#
|
data/lib/dirigible/request.rb
CHANGED
data/lib/dirigible/utils.rb
CHANGED
@@ -2,7 +2,7 @@ module Dirigible
|
|
2
2
|
# @private
|
3
3
|
module Utils
|
4
4
|
def self.handle_api_error(response)
|
5
|
-
message =
|
5
|
+
message = parse_message(response)
|
6
6
|
|
7
7
|
klass = case response.status
|
8
8
|
when 400 then BadRequest
|
@@ -19,5 +19,13 @@ module Dirigible
|
|
19
19
|
def self.parse_json(json)
|
20
20
|
MultiJson.load(json, symbolize_keys: true)
|
21
21
|
end
|
22
|
+
|
23
|
+
def self.parse_message(response)
|
24
|
+
begin
|
25
|
+
parse_json(response.body)
|
26
|
+
rescue
|
27
|
+
response.body
|
28
|
+
end
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/dirigible/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dirigible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.9'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: multi_json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.8'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.8'
|
69
69
|
description: An Urban Airship v3 API wrapper written in Ruby
|
@@ -73,7 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
77
|
- Gemfile
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
@@ -106,17 +106,17 @@ require_paths:
|
|
106
106
|
- lib
|
107
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.0
|
119
|
+
rubygems_version: 2.2.0
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Urban Airship REST API client library for Ruby
|