pubnub 4.1.6 → 4.2.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.

Potentially problematic release.


This version of pubnub might be problematic. Click here for more details.

Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.pubnub.yml +40 -6
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile.lock +1 -1
  6. data/README.md +1 -1
  7. data/VERSION +1 -1
  8. data/fixtures/vcr_cassettes/lib/events/get_users.yml +40 -0
  9. data/lib/pubnub/client.rb +14 -0
  10. data/lib/pubnub/client/events.rb +3 -1
  11. data/lib/pubnub/constants.rb +18 -1
  12. data/lib/pubnub/event.rb +12 -4
  13. data/lib/pubnub/events/create_space.rb +84 -0
  14. data/lib/pubnub/events/create_user.rb +84 -0
  15. data/lib/pubnub/events/delete_space.rb +78 -0
  16. data/lib/pubnub/events/delete_user.rb +78 -0
  17. data/lib/pubnub/events/get_members.rb +93 -0
  18. data/lib/pubnub/events/get_space.rb +74 -0
  19. data/lib/pubnub/events/get_space_memberships.rb +93 -0
  20. data/lib/pubnub/events/get_spaces.rb +90 -0
  21. data/lib/pubnub/events/get_user.rb +74 -0
  22. data/lib/pubnub/events/get_users.rb +90 -0
  23. data/lib/pubnub/events/manage_members.rb +105 -0
  24. data/lib/pubnub/events/manage_memberships.rb +105 -0
  25. data/lib/pubnub/events/update_space.rb +86 -0
  26. data/lib/pubnub/events/update_user.rb +86 -0
  27. data/lib/pubnub/validators/create_space.rb +44 -0
  28. data/lib/pubnub/validators/create_user.rb +44 -0
  29. data/lib/pubnub/validators/delete_space.rb +32 -0
  30. data/lib/pubnub/validators/delete_user.rb +32 -0
  31. data/lib/pubnub/validators/get_members.rb +32 -0
  32. data/lib/pubnub/validators/get_space.rb +32 -0
  33. data/lib/pubnub/validators/get_space_memberships.rb +32 -0
  34. data/lib/pubnub/validators/get_spaces.rb +16 -0
  35. data/lib/pubnub/validators/get_user.rb +32 -0
  36. data/lib/pubnub/validators/get_users.rb +16 -0
  37. data/lib/pubnub/validators/manage_members.rb +45 -0
  38. data/lib/pubnub/validators/manage_memberships.rb +45 -0
  39. data/lib/pubnub/validators/update_space.rb +45 -0
  40. data/lib/pubnub/validators/update_user.rb +45 -0
  41. data/lib/pubnub/version.rb +1 -1
  42. data/spec/lib/events/membership_spec.rb +69 -0
  43. data/spec/lib/events/space_spec.rb +75 -0
  44. data/spec/lib/events/user_spec.rb +75 -0
  45. metadata +37 -2
@@ -0,0 +1,45 @@
1
+ # Toplevel Pubnub module.
2
+ # frozen_string_literal: true
3
+
4
+ module Pubnub
5
+ # Validator module that holds all validators modules
6
+ module Validator
7
+ # Validator for UpdateUser event
8
+ module UpdateUser
9
+ include CommonValidator
10
+
11
+ def validate!
12
+ return if @skip_validate
13
+
14
+ validate_user!
15
+ validate_data!
16
+ end
17
+
18
+ private
19
+
20
+ def validate_user!
21
+ return unless @user_id.nil?
22
+
23
+ raise(
24
+ ArgumentError.new(
25
+ object: self,
26
+ message: 'data: Provide user_id.'
27
+ ),
28
+ 'data: Provide user_id.'
29
+ )
30
+ end
31
+
32
+ def validate_data!
33
+ return unless @data.nil?
34
+
35
+ raise(
36
+ ArgumentError.new(
37
+ object: self,
38
+ message: 'data: No data supplied.'
39
+ ),
40
+ 'data: No data supplied.'
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,4 +1,4 @@
1
1
  # Toplevel Pubnub module.
2
2
  module Pubnub
3
- VERSION = '4.1.6'.freeze
3
+ VERSION = '4.2.0'.freeze
4
4
  end
@@ -0,0 +1,69 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::ManageMemberships do
4
+ it_behaves_like "an event"
5
+
6
+ context "given basic parameters" do
7
+ before :each do
8
+ @pubnub = Pubnub::Client.new(
9
+ subscribe_key: "demo",
10
+ publish_key: "demo",
11
+ auth_key: "ruby-test-auth",
12
+ uuid: "ruby-test-uuid",
13
+ )
14
+ end
15
+ it "get_members_works" do
16
+ VCR.use_cassette("lib/events/get_members", record: :once) do
17
+ envelope = @pubnub.get_members(space_id: "space-1", include: "custom", count: true).value
18
+
19
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
20
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
21
+ end
22
+ end
23
+
24
+ it "get_space_memberships_works" do
25
+ VCR.use_cassette("lib/events/get_space_memberships", record: :once) do
26
+ envelope = @pubnub.get_space_memberships(user_id: "mg3", include: "custom", count: true).value
27
+
28
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
29
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
30
+ end
31
+ end
32
+
33
+ it "manage_memberships_add_works" do
34
+ VCR.use_cassette("lib/events/manage_memberships_add", record: :once) do
35
+ envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'add': [{'id': 'space-1'}]}, include: "custom").value
36
+
37
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
38
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
39
+ end
40
+ end
41
+ it "manage_memberships_remove_works" do
42
+ VCR.use_cassette("lib/events/manage_memberships_remove", record: :once) do
43
+ envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'remove': [{'id': 'space-1'}]}, include: "custom").value
44
+
45
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
46
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
47
+ end
48
+ end
49
+
50
+ it "manage_members_add_works" do
51
+ VCR.use_cassette("lib/events/manage_members_add", record: :once) do
52
+ envelope = @pubnub.manage_members(space_id: "space-1", data: {'add': [{'id': 'mg2'}]}, include: "custom").value
53
+
54
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
55
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
56
+ end
57
+ end
58
+ it "manage_members_remove_works" do
59
+ VCR.use_cassette("lib/events/manage_members_remove", record: :once) do
60
+ envelope = @pubnub.manage_members(space_id: "space-1", data: {'remove': [{'id': 'mg2'}]}, include: "custom").value
61
+
62
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
63
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::CreateSpace do
4
+ it_behaves_like "an event"
5
+
6
+ context "given basic parameters" do
7
+ before :each do
8
+ @pubnub = Pubnub::Client.new(
9
+ subscribe_key: "demo",
10
+ publish_key: "demo",
11
+ auth_key: "ruby-test-auth",
12
+ uuid: "ruby-test-uuid",
13
+ )
14
+ end
15
+ it "create_space_works" do
16
+ VCR.use_cassette("lib/events/create_space", record: :once) do
17
+ envelope = @pubnub.create_space(data:{
18
+ id: "rb_space",
19
+ name: "some_name",
20
+ custom: {
21
+ XXX: "YYYY"
22
+ }
23
+ }, include: "custom").value
24
+
25
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
26
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
27
+ end
28
+ end
29
+
30
+ it "update_space_works" do
31
+ VCR.use_cassette("lib/events/update_space", record: :once) do
32
+ envelope = @pubnub.update_space(space_id: "rb_space",
33
+ data:{
34
+ id: "rb_space",
35
+ name: "new_name",
36
+ custom: {
37
+ XXX: "YYYY"
38
+ }
39
+ }, include: "custom").value
40
+
41
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
42
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
43
+ end
44
+ end
45
+
46
+ it "get_space_works" do
47
+ VCR.use_cassette("lib/events/get_space", record: :once) do
48
+ envelope = @pubnub.get_space(space_id: "rb_space", include: "custom").value
49
+
50
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
51
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
52
+ end
53
+ end
54
+
55
+ it "get_spaces_works" do
56
+ VCR.use_cassette("lib/events/get_spaces", record: :once) do
57
+ envelope = @pubnub.get_spaces(limit: 5, include: "custom").value
58
+
59
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
60
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
61
+ end
62
+ end
63
+
64
+ it "delete_space_works" do
65
+ VCR.use_cassette("lib/events/delete_space", record: :once) do
66
+ envelope = @pubnub.delete_space(space_id: "rb_space").value
67
+
68
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
69
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::CreateUser do
4
+ it_behaves_like "an event"
5
+
6
+ context "given basic parameters" do
7
+ before :each do
8
+ @pubnub = Pubnub::Client.new(
9
+ subscribe_key: "demo",
10
+ publish_key: "demo",
11
+ auth_key: "ruby-test-auth",
12
+ uuid: "ruby-test-uuid",
13
+ )
14
+ end
15
+ it "create_user_works" do
16
+ VCR.use_cassette("lib/events/create_user", record: :once) do
17
+ envelope = @pubnub.create_user(data:{
18
+ id: "mg",
19
+ name: "magnum",
20
+ custom: {
21
+ XXX: "YYYY"
22
+ }
23
+ }, include: "custom").value
24
+
25
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
26
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
27
+ end
28
+ end
29
+
30
+ it "update_user_works" do
31
+ VCR.use_cassette("lib/events/update_user", record: :once) do
32
+ envelope = @pubnub.update_user(user_id: "mg",
33
+ data:{
34
+ id: "mg",
35
+ name: "magnum_1",
36
+ custom: {
37
+ XXX: "YYYY"
38
+ }
39
+ }, include: "custom").value
40
+
41
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
42
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
43
+ end
44
+ end
45
+
46
+ it "get_user_works" do
47
+ VCR.use_cassette("lib/events/get_user", record: :once) do
48
+ envelope = @pubnub.get_user(user_id: "mg", include: "custom").value
49
+
50
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
51
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
52
+ end
53
+ end
54
+
55
+ it "get_users_works" do
56
+ VCR.use_cassette("lib/events/get_users", record: :once) do
57
+ envelope = @pubnub.get_users(limit: 5, include: "custom").value
58
+
59
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
60
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
61
+ end
62
+ end
63
+
64
+ it "delete_user_works" do
65
+ VCR.use_cassette("lib/events/delete_user", record: :once) do
66
+ envelope = @pubnub.delete_user(user_id: "mg").value
67
+
68
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
69
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubnub
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.6
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PubNub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -10486,6 +10486,7 @@ files:
10486
10486
  - fixtures/vcr_cassettes/lib/events/channel-registration.yml
10487
10487
  - fixtures/vcr_cassettes/lib/events/delete_messages-error.yml
10488
10488
  - fixtures/vcr_cassettes/lib/events/delete_messages.yml
10489
+ - fixtures/vcr_cassettes/lib/events/get_users.yml
10489
10490
  - fixtures/vcr_cassettes/lib/events/grant-error.yml
10490
10491
  - fixtures/vcr_cassettes/lib/events/grant.yml
10491
10492
  - fixtures/vcr_cassettes/lib/events/heartbeat-error.yml
@@ -10575,13 +10576,25 @@ files:
10575
10576
  - lib/pubnub/events/add_channels_to_push.rb
10576
10577
  - lib/pubnub/events/audit.rb
10577
10578
  - lib/pubnub/events/channel_registration.rb
10579
+ - lib/pubnub/events/create_space.rb
10580
+ - lib/pubnub/events/create_user.rb
10578
10581
  - lib/pubnub/events/delete_messages.rb
10582
+ - lib/pubnub/events/delete_space.rb
10583
+ - lib/pubnub/events/delete_user.rb
10584
+ - lib/pubnub/events/get_members.rb
10585
+ - lib/pubnub/events/get_space.rb
10586
+ - lib/pubnub/events/get_space_memberships.rb
10587
+ - lib/pubnub/events/get_spaces.rb
10588
+ - lib/pubnub/events/get_user.rb
10589
+ - lib/pubnub/events/get_users.rb
10579
10590
  - lib/pubnub/events/grant.rb
10580
10591
  - lib/pubnub/events/heartbeat.rb
10581
10592
  - lib/pubnub/events/here_now.rb
10582
10593
  - lib/pubnub/events/history.rb
10583
10594
  - lib/pubnub/events/leave.rb
10584
10595
  - lib/pubnub/events/list_push_provisions.rb
10596
+ - lib/pubnub/events/manage_members.rb
10597
+ - lib/pubnub/events/manage_memberships.rb
10585
10598
  - lib/pubnub/events/message_counts.rb
10586
10599
  - lib/pubnub/events/presence.rb
10587
10600
  - lib/pubnub/events/publish.rb
@@ -10593,6 +10606,8 @@ files:
10593
10606
  - lib/pubnub/events/state.rb
10594
10607
  - lib/pubnub/events/subscribe.rb
10595
10608
  - lib/pubnub/events/time.rb
10609
+ - lib/pubnub/events/update_space.rb
10610
+ - lib/pubnub/events/update_user.rb
10596
10611
  - lib/pubnub/events/where_now.rb
10597
10612
  - lib/pubnub/format.rb
10598
10613
  - lib/pubnub/formatter.rb
@@ -10615,12 +10630,24 @@ files:
10615
10630
  - lib/pubnub/validators/channel_registration.rb
10616
10631
  - lib/pubnub/validators/client.rb
10617
10632
  - lib/pubnub/validators/common_validator.rb
10633
+ - lib/pubnub/validators/create_space.rb
10634
+ - lib/pubnub/validators/create_user.rb
10618
10635
  - lib/pubnub/validators/delete.rb
10636
+ - lib/pubnub/validators/delete_space.rb
10637
+ - lib/pubnub/validators/delete_user.rb
10638
+ - lib/pubnub/validators/get_members.rb
10639
+ - lib/pubnub/validators/get_space.rb
10640
+ - lib/pubnub/validators/get_space_memberships.rb
10641
+ - lib/pubnub/validators/get_spaces.rb
10642
+ - lib/pubnub/validators/get_user.rb
10643
+ - lib/pubnub/validators/get_users.rb
10619
10644
  - lib/pubnub/validators/grant.rb
10620
10645
  - lib/pubnub/validators/heartbeat.rb
10621
10646
  - lib/pubnub/validators/here_now.rb
10622
10647
  - lib/pubnub/validators/history.rb
10623
10648
  - lib/pubnub/validators/leave.rb
10649
+ - lib/pubnub/validators/manage_members.rb
10650
+ - lib/pubnub/validators/manage_memberships.rb
10624
10651
  - lib/pubnub/validators/message_counts.rb
10625
10652
  - lib/pubnub/validators/presence.rb
10626
10653
  - lib/pubnub/validators/publish.rb
@@ -10631,6 +10658,8 @@ files:
10631
10658
  - lib/pubnub/validators/state.rb
10632
10659
  - lib/pubnub/validators/subscribe.rb
10633
10660
  - lib/pubnub/validators/time.rb
10661
+ - lib/pubnub/validators/update_space.rb
10662
+ - lib/pubnub/validators/update_user.rb
10634
10663
  - lib/pubnub/validators/where_now.rb
10635
10664
  - lib/pubnub/version.rb
10636
10665
  - pubnub.gemspec
@@ -10664,16 +10693,19 @@ files:
10664
10693
  - spec/lib/events/here_now_spec.rb
10665
10694
  - spec/lib/events/history_spec.rb
10666
10695
  - spec/lib/events/leave_spec.rb
10696
+ - spec/lib/events/membership_spec.rb
10667
10697
  - spec/lib/events/message_counts_spec.rb
10668
10698
  - spec/lib/events/presence_delta_spec.rb
10669
10699
  - spec/lib/events/presence_spec.rb
10670
10700
  - spec/lib/events/publish_spec.rb
10671
10701
  - spec/lib/events/revoke_spec.rb
10672
10702
  - spec/lib/events/signal_spec.rb
10703
+ - spec/lib/events/space_spec.rb
10673
10704
  - spec/lib/events/state_spec.rb
10674
10705
  - spec/lib/events/subscribe_spec.rb
10675
10706
  - spec/lib/events/time_spec.rb
10676
10707
  - spec/lib/events/timeout_handling_spec.rb
10708
+ - spec/lib/events/user_spec.rb
10677
10709
  - spec/lib/events/where_now_spec.rb
10678
10710
  - spec/lib/keep_alive_spec.rb
10679
10711
  - spec/lib/multiple_ciphers_spec.rb
@@ -10738,16 +10770,19 @@ test_files:
10738
10770
  - spec/lib/events/here_now_spec.rb
10739
10771
  - spec/lib/events/history_spec.rb
10740
10772
  - spec/lib/events/leave_spec.rb
10773
+ - spec/lib/events/membership_spec.rb
10741
10774
  - spec/lib/events/message_counts_spec.rb
10742
10775
  - spec/lib/events/presence_delta_spec.rb
10743
10776
  - spec/lib/events/presence_spec.rb
10744
10777
  - spec/lib/events/publish_spec.rb
10745
10778
  - spec/lib/events/revoke_spec.rb
10746
10779
  - spec/lib/events/signal_spec.rb
10780
+ - spec/lib/events/space_spec.rb
10747
10781
  - spec/lib/events/state_spec.rb
10748
10782
  - spec/lib/events/subscribe_spec.rb
10749
10783
  - spec/lib/events/time_spec.rb
10750
10784
  - spec/lib/events/timeout_handling_spec.rb
10785
+ - spec/lib/events/user_spec.rb
10751
10786
  - spec/lib/events/where_now_spec.rb
10752
10787
  - spec/lib/keep_alive_spec.rb
10753
10788
  - spec/lib/multiple_ciphers_spec.rb