pushradar 3.0.0.pre.alpha.1 → 3.0.0

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
  SHA256:
3
- metadata.gz: fea818e1295502c3c3361557ab50c818d6820c836283f3966efa3d6d78e7e6e3
4
- data.tar.gz: 15fdd2749967ad5aa968aba4991c27940c36032e93ed2b429f7fc063f67f8252
3
+ metadata.gz: 9edffa9f99b71bf60f915bfc6a4d91be7481491a29e84214fa36aa68e2e669cc
4
+ data.tar.gz: a3e47791e64cd2796ce5cb0820c0af3d5dc2c4b0282f693f256264e5a22015e9
5
5
  SHA512:
6
- metadata.gz: f07920a98b154a8fbb5b322caed9447bf61f231a258b6b6775208a7e98360bd45b11758de3902c419c7349fde0d37294756b54bc2181b33c4cd11ae327a00d16
7
- data.tar.gz: d8e53e91270839a55509cf8e88c5a04600c7b51a133cde5d5c37e17875005331277f11d3c93238aab26f4d844667dd2ccd8d17c04b81dfec546ed5132bba1ae5
6
+ metadata.gz: e8b05a7441edc5070490c0a909b0800105fe361a99a7f34965d94d4e0253be4bab21c2b18c8128e3a8d24a35468555c691d0a2f0c1eebbe9df1a988c3f7eec4d
7
+ data.tar.gz: e6c32fc1588940ff1ea0f8cd991dcbc4256b47befa4c92cacadd316eda1df46b00efd36284d842ef5e09c238893bd73525405100d80cc1502711335df463c1fb
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.6.3-p62" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/pushradar-server-ruby.iml" filepath="$PROJECT_DIR$/.idea/pushradar-server-ruby.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.2, ruby-2.6.3-p62) [gem]" level="application" />
15
+ </component>
16
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.0.0 (2021-02-18)
2
+
3
+ [NEW] Updated for release of PushRadar v3
4
+
1
5
  ## 3.0.0-alpha.1 (2021-02-08)
2
6
 
3
7
  [NEW] Work on base code of package, compatible with the next release of PushRadar
data/README.md CHANGED
@@ -42,7 +42,7 @@ Alterntively, install manually by running `$ gem install pushradar`
42
42
  require 'pushradar'
43
43
 
44
44
  radar = PushRadar::Client.new('your-secret-key')
45
- radar.broadcast('channel-1', {message: 'Hello world!'})
45
+ radar.broadcast('channel-1', { message: 'Hello world!' })
46
46
  ```
47
47
 
48
48
  ## Receiving Messages
@@ -64,11 +64,12 @@ Private channels require authentication and start with the prefix **private-**.
64
64
  You will need to set up an authentication endpoint that returns a token using the `auth(...)` method if the user is allowed to subscribe to the channel. For example:
65
65
 
66
66
  ```ruby
67
- radar = PushRadar::Client.new('sk_fdcaf6a6-bf6f-4dea-9406-16320cca95e6')
67
+ radar = PushRadar::Client.new('your-secret-key')
68
68
  channel_name = params[:channelName]
69
+ socket_id = params[:socketID]
69
70
  # is user allowed to access channel?
70
71
  if true
71
-     return {'token': radar.auth(channel_name)}.to_json
72
+ return { 'token': radar.auth(channel_name, socket_id) }.to_json
72
73
  end
73
74
  ```
74
75
 
@@ -84,5 +85,5 @@ Complete documentation for PushRadar's Ruby server library can be found at: <htt
84
85
 
85
86
  ## License
86
87
 
87
- Copyright 2021, PushRadar. PushRadar's Ruby server library is licensed under the MIT license:
88
- http://www.opensource.org/licenses/mit-license.php
88
+ Copyright © 2021, PushRadar. PushRadar's Ruby server library is licensed under the MIT license:
89
+ <https://opensource.org/licenses/mit-license.php>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
@@ -5,7 +5,11 @@ require 'cgi'
5
5
  module PushRadar
6
6
  class Client
7
7
  def initialize(secret_key)
8
- unless secret_key.is_a?(String) && secret_key.start_with?('sk_')
8
+ unless secret_key.is_a?(String)
9
+ raise PushRadar::Error, 'Secret key must be a string.'
10
+ end
11
+
12
+ unless secret_key.start_with?('sk_')
9
13
  raise PushRadar::Error, 'Please provide your PushRadar secret key. You can find it on the API page of your dashboard.'
10
14
  end
11
15
 
@@ -22,21 +26,29 @@ module PushRadar
22
26
  end
23
27
 
24
28
  def broadcast(channel_name, data)
29
+ unless channel_name.is_a?(String)
30
+ raise PushRadar::Error, 'Channel name must be a string.'
31
+ end
32
+
25
33
  if channel_name.nil? || channel_name.strip.empty?
26
34
  raise PushRadar::Error, 'Channel name empty. Please provide a channel name.'
27
35
  end
28
36
 
29
37
  validate_channel_name(channel_name)
30
- response = do_http_request('POST', @api_endpoint + "/broadcasts", { channel: channel_name.strip, data: data })
38
+ response = do_http_request('POST', @api_endpoint + "/broadcasts", { channel: channel_name, data: data.to_json })
31
39
 
32
40
  if response[:status] === 200
33
41
  true
34
42
  else
35
- raise PushRadar::Error, 'An error occurred while calling the API. Server returned: ' + response[:body].to_json
43
+ raise PushRadar::Error, 'An error occurred while calling the API. Server returned: ' + response[:body]
36
44
  end
37
45
  end
38
46
 
39
- def auth(channel_name)
47
+ def auth(channel_name, socket_id)
48
+ unless channel_name.is_a?(String)
49
+ raise PushRadar::Error, 'Channel name must be a string.'
50
+ end
51
+
40
52
  if channel_name.nil? || channel_name.strip.empty?
41
53
  raise PushRadar::Error, 'Channel name empty. Please provide a channel name.'
42
54
  end
@@ -45,11 +57,19 @@ module PushRadar
45
57
  raise PushRadar::Error, 'Channel authentication can only be used with private channels.'
46
58
  end
47
59
 
48
- response = do_http_request('GET', @api_endpoint + "/channels/auth?channel=" + CGI.escape(channel_name), {})
60
+ unless socket_id.is_a?(String)
61
+ raise PushRadar::Error, 'Socket ID must be a string.'
62
+ end
63
+
64
+ if socket_id.nil? || socket_id.strip.empty?
65
+ raise PushRadar::Error, 'Socket ID empty. Please pass through a socket ID.'
66
+ end
67
+
68
+ response = do_http_request('GET', @api_endpoint + "/channels/auth?channel=" + CGI.escape(channel_name) + "&socketID=" + CGI.escape(socket_id), {})
49
69
  if response[:status] === 200
50
70
  JSON(response[:body])['token']
51
71
  else
52
- raise PushRadar::Error, 'There was a problem receiving a channel authentication token. Server returned: ' + response[:body].to_json
72
+ raise PushRadar::Error, 'There was a problem receiving a channel authentication token. Server returned: ' + response[:body]
53
73
  end
54
74
  end
55
75
 
@@ -1,3 +1,3 @@
1
1
  module PushRadar
2
- VERSION = '3.0.0-alpha.1'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushradar
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre.alpha.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PushRadar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-08 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -76,11 +76,18 @@ files:
76
76
  - ".document"
77
77
  - ".gemtest"
78
78
  - ".gitignore"
79
+ - ".idea/.gitignore"
80
+ - ".idea/inspectionProfiles/Project_Default.xml"
81
+ - ".idea/misc.xml"
82
+ - ".idea/modules.xml"
83
+ - ".idea/pushradar-server-ruby.iml"
84
+ - ".idea/vcs.xml"
79
85
  - CHANGELOG.md
80
86
  - Gemfile
81
87
  - LICENSE
82
88
  - README.md
83
89
  - Rakefile
90
+ - VERSION
84
91
  - lib/pushradar.rb
85
92
  - lib/pushradar/client.rb
86
93
  - lib/pushradar/version.rb
@@ -100,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
107
  version: '0'
101
108
  required_rubygems_version: !ruby/object:Gem::Requirement
102
109
  requirements:
103
- - - ">"
110
+ - - ">="
104
111
  - !ruby/object:Gem::Version
105
- version: 1.3.1
112
+ version: '0'
106
113
  requirements: []
107
114
  rubygems_version: 3.0.3
108
115
  signing_key: