urbanairship 4.0.0 → 4.1.0

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: 692d6774c618680475e856b748d6565f38278c2a
4
- data.tar.gz: 44cbb4e3aa1adf9382a9616fc540b675591e71a1
3
+ metadata.gz: f7bc6156e0fc21c9020bd23086bcc3b66932ec8e
4
+ data.tar.gz: 64dad835fae994e277ca6e423b678847247c7ec3
5
5
  SHA512:
6
- metadata.gz: e354ef63c9665715631ec9647692c8148aea180dedb43159afdd041da68e5e1a206158fee15ac4ba589f1c0e90cbf389f3270e4b94ddd3710fb3f01bd276116c
7
- data.tar.gz: 1d77961f636470f64cc8372d08b56adaeab8b4ffa5607e1825e007c5ad6c3700dc48a405a923510f8cc7c3455a9db2d15f340a38dd0e8f9e48095ae6b49324e4
6
+ metadata.gz: 23e996f15107e84770fe1f8bb5d072412d8da757101003b4ddf36feb3e3fb87f297b58154f05c7760584e16604504966734b19ed1619e3375612c3b97f5f035c
7
+ data.tar.gz: f889a58b38c495265507e9c0c430a30e4683c32666a365c4d3d41f1e4e33aa257f1ccb2a27750aa7676671b7e367ff9c46e2897c1e53818917293c796d457760
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ --------------------
2
+ 4.1.0
3
+ --------------------
4
+ - Added support for Open Channels
5
+
6
+
1
7
  --------------------
2
8
  4.0.0
3
9
  --------------------
data/lib/urbanairship.rb CHANGED
@@ -13,6 +13,7 @@ require 'urbanairship/version'
13
13
  require 'urbanairship/devices/devicelist'
14
14
  require 'urbanairship/devices/channel_tags'
15
15
  require 'urbanairship/devices/named_user'
16
+ require 'urbanairship/devices/open_channel'
16
17
  require 'urbanairship/reports/response_statistics'
17
18
  require 'urbanairship/devices/static_lists'
18
19
  require 'urbanairship/push/location'
@@ -7,6 +7,7 @@ module Urbanairship
7
7
  SERVER = 'go.urbanairship.com'
8
8
  BASE_URL = 'https://go.urbanairship.com/api'
9
9
  CHANNEL_URL = BASE_URL + '/channels/'
10
+ OPEN_CHANNEL_URL = BASE_URL + '/channels/open/'
10
11
  DEVICE_TOKEN_URL = BASE_URL + '/device_tokens/'
11
12
  APID_URL = BASE_URL + '/apids/'
12
13
  PUSH_URL = BASE_URL + '/push/'
@@ -31,5 +31,35 @@ module Urbanairship
31
31
  response
32
32
  end
33
33
  end
34
+
35
+
36
+ class OpenChannelUninstall
37
+ include Urbanairship::Common
38
+ include Urbanairship::Loggable
39
+ attr_reader :client
40
+
41
+ def initialize(client: required('client'))
42
+ @client = client
43
+ end
44
+
45
+ def uninstall(address: required('address'),
46
+ open_platform: required('open_platform'))
47
+
48
+ body = {
49
+ address: address,
50
+ open_platform_name: open_platform
51
+ }
52
+
53
+ response = @client.send_request(
54
+ method: 'POST',
55
+ body: JSON.dump(body),
56
+ url: OPEN_CHANNEL_URL + 'uninstall/',
57
+ content_type: 'application/json'
58
+ )
59
+
60
+ logger.info { "Successfully unintalled open channel with address: #{address}"}
61
+ response
62
+ end
63
+ end
34
64
  end
35
65
  end
@@ -0,0 +1,105 @@
1
+ require 'urbanairship'
2
+
3
+ module Urbanairship
4
+ module Devices
5
+ class OpenChannel
6
+ include Urbanairship::Common
7
+ include Urbanairship::Loggable
8
+ attr_accessor :channel_id, :open_platform, :opt_in, :address,
9
+ :tags, :identifiers
10
+
11
+ def initialize(client: required('client'))
12
+ @client = client
13
+ @channel_id = nil
14
+ @open_platform = nil
15
+ @opt_in = nil
16
+ @address = nil
17
+ @tags = nil
18
+ @identifiers = nil
19
+ end
20
+
21
+ def create()
22
+ fail TypeError, 'address must be set to create open channel' unless @address.is_a? String
23
+ fail TypeError, 'open_platform must be set to create open channel' unless @open_platform.is_a? String
24
+ fail TypeError, 'opt_in must be boolean' unless [true, false].include? @opt_in
25
+
26
+ channel_data = {
27
+ 'type': 'open',
28
+ 'open': {:open_platform_name => @open_platform},
29
+ 'opt_in': @opt_in,
30
+ 'address': @address
31
+ }
32
+
33
+ if @tags
34
+ channel_data['tags'] = @tags
35
+ end
36
+ if @identifiers
37
+ channel_data[:open][:identifiers] = @identifiers
38
+ end
39
+
40
+ body = {'channel': channel_data}
41
+
42
+ response = @client.send_request(
43
+ method: 'POST',
44
+ url: OPEN_CHANNEL_URL,
45
+ body: JSON.dump(body),
46
+ content_type: 'application/json'
47
+ )
48
+ logger.info("Registering open channel with address: #{@address}")
49
+ response
50
+ end
51
+
52
+ def update(set_tags: required('set_tags'))
53
+ fail ArgumentError, 'set_tags must be boolean' unless [true, false].include? set_tags
54
+ fail ArgumentError, 'set_tags cannot be true when tags are not set' unless set_tags == true && @tags != nil
55
+ fail TypeError, 'opt_in must be boolean' unless [true, false].include? @opt_in
56
+ fail TypeError, 'address or channel_id must not be nil' unless @address.is_a? String || @channel_id.is_a?(String)
57
+ fail TypeError, 'open_platform cannot be nil' unless @open_platform.is_a? String
58
+ fail TypeErorr, 'address must not be nil if opt_in is true' unless @opt_in.is_a? TrueClass
59
+
60
+ channel_data = {
61
+ 'type': 'open',
62
+ 'open': {'open_platform_name': @open_platform},
63
+ 'opt_in': @opt_in,
64
+ 'set_tags': set_tags
65
+ }
66
+
67
+ if @channel_id
68
+ channel_data['channel_id'] = @channel_id
69
+ end
70
+ if @address
71
+ channel_data['address'] = @address
72
+ end
73
+ if @tags
74
+ channel_data['tags'] = @tags
75
+ end
76
+ if @identifiers
77
+ channel_data['open']['identifiers'] = @identifiers
78
+ end
79
+
80
+ body = {'channel': channel_data}
81
+
82
+ response = @client.send_request(
83
+ method: 'POST',
84
+ url: OPEN_CHANNEL_URL,
85
+ body: JSON.dump(body),
86
+ content_type: 'application/json'
87
+ )
88
+ logger.info("Updating open channel with address #{@address}")
89
+ response
90
+ end
91
+
92
+ def lookup(channel_id: required('channel_id'))
93
+ fail ArgumentError, 'channel_id needs to be a string' unless channel_id.is_a? String
94
+
95
+ response = @client.send_request(
96
+ method: 'GET',
97
+ url: CHANNEL_URL + channel_id
98
+ )
99
+ logger.info("Looking up info on device token #{channel_id}")
100
+ response
101
+ end
102
+ end
103
+ end
104
+ end
105
+
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '4.0.0'
2
+ VERSION = '4.1.0'
3
3
  end
metadata CHANGED
@@ -1,117 +1,117 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanairship
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urban Airship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2018-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
- - - "<"
20
+ - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.4'
30
- - - "<"
30
+ - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ~>
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ~>
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: pry
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ~>
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ~>
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ~>
80
80
  - !ruby/object:Gem::Version
81
81
  version: '10.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ~>
87
87
  - !ruby/object:Gem::Version
88
88
  version: '10.0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: rspec
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ~>
94
94
  - !ruby/object:Gem::Version
95
95
  version: '3'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ~>
101
101
  - !ruby/object:Gem::Version
102
102
  version: '3'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: terminal-notifier-guard
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: '1'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: '1'
117
117
  description: A Ruby Library for using the Urban Airship web service API for push notifications
@@ -122,13 +122,13 @@ executables: []
122
122
  extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
- - ".github/CONTRIBUTING.md"
126
- - ".github/ISSUE_TEMPLATE.md"
127
- - ".github/PULL_REQUEST_TEMPLATE.md"
128
- - ".github/SUPPORT.md"
129
- - ".gitignore"
130
- - ".rspec"
131
- - ".travis.yml"
125
+ - .github/CONTRIBUTING.md
126
+ - .github/ISSUE_TEMPLATE.md
127
+ - .github/PULL_REQUEST_TEMPLATE.md
128
+ - .github/SUPPORT.md
129
+ - .gitignore
130
+ - .rspec
131
+ - .travis.yml
132
132
  - CHANGELOG
133
133
  - Gemfile
134
134
  - Guardfile
@@ -160,6 +160,7 @@ files:
160
160
  - lib/urbanairship/devices/channel_uninstall.rb
161
161
  - lib/urbanairship/devices/devicelist.rb
162
162
  - lib/urbanairship/devices/named_user.rb
163
+ - lib/urbanairship/devices/open_channel.rb
163
164
  - lib/urbanairship/devices/segment.rb
164
165
  - lib/urbanairship/devices/static_lists.rb
165
166
  - lib/urbanairship/loggable.rb
@@ -183,17 +184,17 @@ require_paths:
183
184
  - lib
184
185
  required_ruby_version: !ruby/object:Gem::Requirement
185
186
  requirements:
186
- - - ">="
187
+ - - '>='
187
188
  - !ruby/object:Gem::Version
188
189
  version: 2.0.0
189
190
  required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  requirements:
191
- - - ">="
192
+ - - '>='
192
193
  - !ruby/object:Gem::Version
193
194
  version: '0'
194
195
  requirements: []
195
196
  rubyforge_project:
196
- rubygems_version: 2.5.2.1
197
+ rubygems_version: 2.0.14.1
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: Ruby Gem for using the Urban Airship API