From e662a466abe0188d66e1332733d195726d970bb6 Mon Sep 17 00:00:00 2001 From: Ivan QSD Date: Mon, 28 Oct 2019 16:34:54 +0100 Subject: [PATCH] Version 4.2.1. (#104) * Update latest dependencies (#91) * Update latest dependencies - David * Update the usage of dry-validation Includes resolving rubocop warnings for that file - David * Updated usage of schema validation Fixed rules in StatusSchema - David * Use new class based schema - David * Use schema classes for events too - David * Use the lame approach with a TODO comment - David * fix schema error formatting * Add a specific PresenceSchema for OPERATION_PRESENCE - David * Bump validated Ruby versions NOTE: Includes deprecation of 2.3 since it has been EOL'd - David * Update release date and version in CHANGELOG - David * Set the minimum ruby version and bump the patch version - David * Update .pubnub.yml supported platforms Updating the supported platforms section for the 4.1.5 release * Add Signals API method and test cases. * Resolve errors in the existing presence and subscribe tests caused by changes in subscribe API response. * Resolve .rubocop.yml typo that causes RuboCop to crash in IDE. * Bump JDK version from 8 to 9 for JRuby Travis tests. * Bump version to 4.1.6. * Fix Codacy errors - David * Fix pubnub.yml indent error. * Objects API feature (#99) * Add Objects API endpoints. * Bump version to 4.2.0. * Resolve Codacy errors. * Fix line too long error. * Add Objects API integration tests (#100) * Add Objects API endpoints. * Bump version to 4.2.0. * Resolve Codacy errors. * Fix line too long error. * Add Objects API integration tests. * Resolve conflict in membership tests. * Add debug information for Travis PR tests. * Debugging nil return value of envelope in a single test. * Debugging nil return value of envelope. * Debugging nil return value of envelope. * Debugging nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Remove rspec debug code and allow all tests to run. * Update .travis.yml (#102) * Listener methods (#103) * Add Objects API endpoints. * Bump version to 4.2.0. * Resolve Codacy errors. * Fix line too long error. * Add Objects API integration tests. * Resolve conflict in membership tests. * Add debug information for Travis PR tests. * Debugging nil return value of envelope in a single test. * Debugging nil return value of envelope. * Debugging nil return value of envelope. * Debugging nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Attempting fix for nil return value of envelope. * Remove rspec debug code and allow all tests to run. * Add missing Objects API listener methods. * Version v4.2.1 * Add listener async integration tests for objects. * Make deletion tests synchronous to resolve conflict and timeout caused by create/update tests for objects. * Add missing VCR files to speed up tests. --- .pubnub.yml | 9 +- CHANGELOG.md | 3 + Gemfile.lock | 2 +- README.md | 2 +- VERSION | 2 +- .../vcr_cassettes/lib/events/create_space.yml | 40 ++++ .../vcr_cassettes/lib/events/create_user.yml | 40 ++++ .../vcr_cassettes/lib/events/delete_space.yml | 38 ++++ .../vcr_cassettes/lib/events/delete_user.yml | 38 ++++ .../vcr_cassettes/lib/events/get_members.yml | 38 ++++ .../vcr_cassettes/lib/events/get_space.yml | 38 ++++ .../lib/events/get_space_memberships.yml | 38 ++++ .../vcr_cassettes/lib/events/get_spaces.yml | 40 ++++ .../vcr_cassettes/lib/events/get_user.yml | 38 ++++ .../lib/events/manage_members_add.yml | 40 ++++ .../lib/events/manage_members_remove.yml | 83 ++++++++ .../lib/events/manage_memberships_add.yml | 40 ++++ .../lib/events/manage_memberships_remove.yml | 40 ++++ .../lib/events/subscribe-member-add-async.yml | 77 +++++++ .../events/subscribe-member-remove-async.yml | 77 +++++++ .../events/subscribe-membership-add-async.yml | 77 +++++++ .../subscribe-membership-remove-async.yml | 77 +++++++ .../events/subscribe-space-delete-async.yml | 77 +++++++ .../events/subscribe-space-update-async.yml | 77 +++++++ .../events/subscribe-user-delete-async.yml | 77 +++++++ .../events/subscribe-user-update-async.yml | 77 +++++++ .../vcr_cassettes/lib/events/update_space.yml | 40 ++++ .../vcr_cassettes/lib/events/update_user.yml | 40 ++++ lib/pubnub/subscribe_callback.rb | 5 +- lib/pubnub/subscribe_event/formatter.rb | 33 +++ lib/pubnub/subscriber.rb | 6 + lib/pubnub/version.rb | 2 +- spec/lib/events/subscribe_spec.rb | 188 ++++++++++++++++++ 33 files changed, 1493 insertions(+), 6 deletions(-) create mode 100644 fixtures/vcr_cassettes/lib/events/create_space.yml create mode 100644 fixtures/vcr_cassettes/lib/events/create_user.yml create mode 100644 fixtures/vcr_cassettes/lib/events/delete_space.yml create mode 100644 fixtures/vcr_cassettes/lib/events/delete_user.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_members.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_space.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_space_memberships.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_spaces.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_user.yml create mode 100644 fixtures/vcr_cassettes/lib/events/manage_members_add.yml create mode 100644 fixtures/vcr_cassettes/lib/events/manage_members_remove.yml create mode 100644 fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml create mode 100644 fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml create mode 100644 fixtures/vcr_cassettes/lib/events/update_space.yml create mode 100644 fixtures/vcr_cassettes/lib/events/update_user.yml diff --git a/.pubnub.yml b/.pubnub.yml index a45d9ef0e..de327f938 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,6 +1,13 @@ --- -version: "4.2.0" +version: "4.2.1" changelog: + - + changes: + - + text: "Updated listener methods" + type: feature + date: 25-10-2019 + version: "4.2.1" - changes: - diff --git a/CHANGELOG.md b/CHANGELOG.md index 90a84f83d..6015c8b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +##### 4.2.1 +* Updated listener methods + ##### 4.2.0 * Added objects feature diff --git a/Gemfile.lock b/Gemfile.lock index 2e0056039..299ab645d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pubnub (4.2.0) + pubnub (4.2.1) concurrent-ruby (~> 1.1.5) concurrent-ruby-edge (~> 0.5.0) dry-validation (~> 1.0) diff --git a/README.md b/README.md index 8ff31212d..88eaa935a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # Complete Documentation Available at https://www.pubnub.com/docs/ruby/pubnub-ruby-sdk-v4 **v4.x** -## PubNub Gem version 4.2.0 +## PubNub Gem version 4.2.1 ##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API. ##### http://www.pubnub.com/account diff --git a/VERSION b/VERSION index 6aba2b245..fae6e3d04 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.2.0 +4.2.1 diff --git a/fixtures/vcr_cassettes/lib/events/create_space.yml b/fixtures/vcr_cassettes/lib/events/create_space.yml new file mode 100644 index 000000000..d3e67a143 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/create_space.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: post + uri: http://ps.pndsn.com/v1/objects/demo/spaces?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"id":"rb_space","name":"some_name","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:54 GMT + Content-Type: + - application/json + Content-Length: + - '201' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_space","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:35:54.1512Z","updated":"2019-10-25T20:35:54.1512Z","eTag":"AZTUtcvx6NDGLQ"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:51 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/create_user.yml b/fixtures/vcr_cassettes/lib/events/create_user.yml new file mode 100644 index 000000000..b85cd8adf --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/create_user.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: post + uri: http://ps.pndsn.com/v1/objects/demo/users?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"id":"mg","name":"magnum","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:36:54 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:36:57 GMT + Content-Type: + - application/json + Content-Length: + - '227' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"mg","name":"magnum","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:36:57.254813Z","updated":"2019-10-25T20:36:57.254813Z","eTag":"Ad2eyIWXwJzBqAE"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:36:54 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/delete_space.yml b/fixtures/vcr_cassettes/lib/events/delete_space.yml new file mode 100644 index 000000000..ded8b01b3 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/delete_space.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: delete + uri: http://ps.pndsn.com/v1/objects/demo/spaces/rb_space?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:52 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:55 GMT + Content-Type: + - application/json + Content-Length: + - '26' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":null}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:52 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/delete_user.yml b/fixtures/vcr_cassettes/lib/events/delete_user.yml new file mode 100644 index 000000000..da88c5cd8 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/delete_user.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: delete + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:36:55 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:36:58 GMT + Content-Type: + - application/json + Content-Length: + - '26' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":null}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:36:55 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_members.yml b/fixtures/vcr_cassettes/lib/events/get_members.yml new file mode 100644 index 000000000..569de37e3 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_members.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v1/objects/demo/spaces/space-1/users?auth=ruby-test-auth&count=true&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:48 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + Content-Type: + - application/json + Content-Length: + - '39' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[],"totalCount":0}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:48 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_space.yml b/fixtures/vcr_cassettes/lib/events/get_space.yml new file mode 100644 index 000000000..6ceb53a59 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_space.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v1/objects/demo/spaces/rb_space?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:54 GMT + Content-Type: + - application/json + Content-Length: + - '203' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_space","name":"new_name","description":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:35:54.1512Z","updated":"2019-10-25T20:35:54.431837Z","eTag":"AYKsrdL029TZ1wE"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:51 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml b/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml new file mode 100644 index 000000000..bb4d44ec5 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?auth=ruby-test-auth&count=true&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:48 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + Content-Type: + - application/json + Content-Length: + - '39' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[],"totalCount":0}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:48 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_spaces.yml b/fixtures/vcr_cassettes/lib/events/get_spaces.yml new file mode 100644 index 000000000..4a6d13050 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_spaces.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v1/objects/demo/spaces?auth=ruby-test-auth&include=custom&limit=5&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:54 GMT + Content-Type: + - application/json + Content-Length: + - '1036' + Connection: + - keep-alive + Vary: + - Accept-Encoding + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"NMLWPOUHLV","name":"ZAGXJVHXZL","description":null,"custom":null,"created":"2019-08-18T12:10:01.873873Z","updated":"2019-08-18T12:10:01.873873Z","eTag":"AY6XzPic6t+aNg"},{"id":"YGVRVMOZIK","name":"FZJWFBWKZM","description":"GKRYWOMDRG","custom":null,"created":"2019-08-18T12:16:37.379839Z","updated":"2019-08-18T12:16:37.848793Z","eTag":"AdGc85ajmIDoXg"},{"id":"PXBRDJJWOI","name":"AOQFCTWRZF","description":null,"custom":{"info":"CJIOSKYG","text":"YWHVBDKUHF","uncd":"=!=?-+-?"},"created":"2019-08-18T12:16:40.302258Z","updated":"2019-08-18T12:16:40.609418Z","eTag":"AbzMs+nb/JmowgE"},{"id":"ZZHUEGVHWM","name":"YUUOXZEKDW","description":null,"custom":{"info":"RDZQEIYH","text":"MVCSBQVYEZ","uncd":"-=--?!=!"},"created":"2019-08-18T12:16:41.154746Z","updated":"2019-08-18T12:16:41.564938Z","eTag":"Ab79ksvrz77S6QE"},{"id":"OTCGLMCVEQ","name":"KLRDJADJSG","description":null,"custom":null,"created":"2019-08-18T12:16:42.062339Z","updated":"2019-08-18T12:16:42.062339Z","eTag":"Adbut8mspafpYw"}],"next":"NQ"}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:52 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_user.yml b/fixtures/vcr_cassettes/lib/events/get_user.yml new file mode 100644 index 000000000..2f4614448 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_user.yml @@ -0,0 +1,38 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:36:54 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:36:57 GMT + Content-Type: + - application/json + Content-Length: + - '228' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"mg","name":"magnum_1","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:36:57.254813Z","updated":"2019-10-25T20:36:57.561462Z","eTag":"AYD0rZeD55aIMA"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:36:55 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/manage_members_add.yml b/fixtures/vcr_cassettes/lib/events/manage_members_add.yml new file mode 100644 index 000000000..bd06e604c --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/manage_members_add.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/spaces/space-1/users?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"add":[{"id":"mg2"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:49 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:52 GMT + Content-Type: + - application/json + Content-Length: + - '166' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"mg2","custom":null,"created":"2019-10-25T20:35:52.562231Z","updated":"2019-10-25T20:35:52.562231Z","eTag":"AY39mJKK//C0VA"}],"next":"MQ"}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:49 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml b/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml new file mode 100644 index 000000000..44e6ca884 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml @@ -0,0 +1,83 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/presence/sub-key/demo/channel/demo/heartbeat?auth=ruby-test-auth&heartbeat=3&l_pres=0.006&pnsdk=PubNub-Ruby/4.2.0&state=%7B%22channel%22:%7B%7D,%22group%22:%7B%7D%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:49 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:52 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '55' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - OPTIONS, GET, POST + Age: + - '0' + Server: + - Pubnub Presence + Cache-Control: + - no-cache + Accept-Ranges: + - bytes + body: + encoding: UTF-8 + string: '{"status": 200, "message": "OK", "service": "Presence"}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:50 GMT +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/spaces/space-1/users?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"remove":[{"id":"mg2"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:49 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:52 GMT + Content-Type: + - application/json + Content-Length: + - '24' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:50 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml b/fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml new file mode 100644 index 000000000..d5236a70f --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"add":[{"id":"space-1"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:48 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + Content-Type: + - application/json + Content-Length: + - '168' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"space-1","custom":null,"created":"2019-10-25T20:35:51.93913Z","updated":"2019-10-25T20:35:51.93913Z","eTag":"AY39mJKK//C0VA"}],"next":"MQ"}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:49 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml b/fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml new file mode 100644 index 000000000..cf9d3fdc0 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/users/mg3/spaces?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"remove":[{"id":"space-1"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:49 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:52 GMT + Content-Type: + - application/json + Content-Length: + - '24' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:49 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml new file mode 100644 index 000000000..ca7b15bdc --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:20:13 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:20:15 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720347890178803","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:20:13 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720347890178803%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:20:13 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:20:18 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '422' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720348183193928","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720348182752121","r":2},"k":"sub-a-mock-key","c":"rb_space_4","d":{"source":"objects","version":"1.0","event":"create","type":"membership","data":{"created":"2019-10-25T20:20:18.257654837Z","custom":null,"eTag":"AY39mJKK//C0VA","spaceId":"rb_space_4","updated":"2019-10-25T20:20:18.257654837Z","userId":"user_mg4"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:20:15 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml new file mode 100644 index 000000000..ebb18bc89 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:22:50 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:22:53 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720348183193928","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:22:50 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720348183193928%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:22:50 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:22:57 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '298' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720349772458715","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720349772035051","r":2},"k":"sub-a-mock-key","c":"rb_space_4","d":{"source":"objects","version":"1.0","event":"delete","type":"membership","data":{"spaceId":"rb_space_4","userId":"user_mg4"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:22:54 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml new file mode 100644 index 000000000..4be5abfad --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:26:00 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:26:03 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720349772128587","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:26:00 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720349772128587%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:26:00 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:26:06 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '420' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720351664523185","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720351664083594","r":2},"k":"sub-a-mock-key","c":"user_mg4","d":{"source":"objects","version":"1.0","event":"create","type":"membership","data":{"created":"2019-10-25T20:26:06.392141731Z","custom":null,"eTag":"AY39mJKK//C0VA","spaceId":"rb_space_4","updated":"2019-10-25T20:26:06.392141731Z","userId":"user_mg4"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:26:03 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml new file mode 100644 index 000000000..d1ec5db7e --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:28:18 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:28:20 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720351664523185","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:28:18 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg4/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720351664523185%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:28:18 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:28:26 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '296' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720353067806096","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720353067365917","r":2},"k":"sub-a-mock-key","c":"user_mg4","d":{"source":"objects","version":"1.0","event":"delete","type":"membership","data":{"spaceId":"rb_space_4","userId":"user_mg4"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:28:24 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml new file mode 100644 index 000000000..4760866a9 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:50:12 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:50:15 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720329910471712","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:50:12 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720330183065651%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:50:15 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:50:18 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '268' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720330184481173","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720330184019633","r":2},"k":"sub-a-mock-key","c":"rb_space_3","d":{"source":"objects","version":"1.0","event":"delete","type":"space","data":{"id":"rb_space_3"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:50:15 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml new file mode 100644 index 000000000..e56ceb9b5 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:41:06 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:41:09 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720324693401333","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:41:06 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/rb_space_3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720324693401333%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:41:06 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:43:04 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '358' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720325841044329","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720325840630385","r":2},"k":"sub-a-mock-key","c":"rb_space_3","d":{"source":"objects","version":"1.0","event":"update","type":"space","data":{"eTag":"AZmU8+zbjLGOoAE","id":"rb_space_3","name":"name_1572032581","updated":"2019-10-25T19:43:03.976039Z"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:43:01 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml new file mode 100644 index 000000000..46255d14e --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:23:55 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:23:58 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720312144082905","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:23:55 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720312144082905%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:23:55 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:24:07 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '263' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720314473053590","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720314472596946","r":2},"k":"sub-a-mock-key","c":"user_mg3","d":{"source":"objects","version":"1.0","event":"delete","type":"user","data":{"id":"user_mg3"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:24:04 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml b/fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml new file mode 100644 index 000000000..45e93e7f2 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml @@ -0,0 +1,77 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:0,%22t%22:0%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:20:08 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:20:10 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '45' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720307124752724","r":12},"m":[]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:20:08 GMT +- request: + method: get + uri: http://ps.pndsn.com/v2/subscribe/sub-a-mock-key/user_mg3/0?auth=ruby-test-auth&pnsdk=PubNub-Ruby/4.2.0&t=%7B%22r%22:12,%22t%22:%2215720307124752724%22%7D&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 19:20:08 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 19:20:14 GMT + Content-Type: + - text/javascript; charset="UTF-8" + Content-Length: + - '353' + Connection: + - keep-alive + Cache-Control: + - no-cache + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + body: + encoding: UTF-8 + string: '{"t":{"t":"15720312144082905","r":12},"m":[{"a":"3","f":0,"e":2,"p":{"t":"15720312143594394","r":2},"k":"sub-a-mock-key","c":"user_mg3","d":{"source":"objects","version":"1.0","event":"update","type":"user","data":{"eTag":"Ab+suYTYtJ2yjQE","id":"user_mg3","name":"name_1572031211","updated":"2019-10-25T19:20:14.283963Z"}}}]}' + http_version: + recorded_at: Fri, 25 Oct 2019 19:20:11 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/update_space.yml b/fixtures/vcr_cassettes/lib/events/update_space.yml new file mode 100644 index 000000000..b55f1b66d --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/update_space.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/spaces/rb_space?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"id":"rb_space","name":"new_name","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:35:51 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:35:54 GMT + Content-Type: + - application/json + Content-Length: + - '203' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_space","name":"new_name","description":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:35:54.1512Z","updated":"2019-10-25T20:35:54.431837Z","eTag":"AYKsrdL029TZ1wE"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:35:51 GMT +recorded_with: VCR 5.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/update_user.yml b/fixtures/vcr_cassettes/lib/events/update_user.yml new file mode 100644 index 000000000..46ed6ec86 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/update_user.yml @@ -0,0 +1,40 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v1/objects/demo/users/mg?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"id":"mg","name":"magnum_1","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Fri, 25 Oct 2019 20:36:54 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 25 Oct 2019 20:36:57 GMT + Content-Type: + - application/json + Content-Length: + - '228' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"mg","name":"magnum_1","externalId":null,"profileUrl":null,"email":null,"custom":{"XXX":"YYYY"},"created":"2019-10-25T20:36:57.254813Z","updated":"2019-10-25T20:36:57.561462Z","eTag":"AYD0rZeD55aIMA"}}' + http_version: + recorded_at: Fri, 25 Oct 2019 20:36:54 GMT +recorded_with: VCR 5.0.0 diff --git a/lib/pubnub/subscribe_callback.rb b/lib/pubnub/subscribe_callback.rb index 19d1f7b22..8dc0ad337 100644 --- a/lib/pubnub/subscribe_callback.rb +++ b/lib/pubnub/subscribe_callback.rb @@ -9,7 +9,10 @@ def initialize(options) message: options[:message], status: options[:status], presence: options[:presence], - signal: options[:signal] + signal: options[:signal], + user: options[:user], + space: options[:space], + membership: options[:membership] } validate! end diff --git a/lib/pubnub/subscribe_event/formatter.rb b/lib/pubnub/subscribe_event/formatter.rb index 962a1f113..727b251cd 100644 --- a/lib/pubnub/subscribe_event/formatter.rb +++ b/lib/pubnub/subscribe_event/formatter.rb @@ -166,6 +166,39 @@ def get_operation(message = nil) Pubnub::Constants::OPERATION_PRESENCE elsif message[:type] == 1 Pubnub::Constants::OPERATION_SIGNAL + elsif message[:type] == 2 + case message[:payload]['type'] + when 'user' + case message[:payload]['event'] + when 'create' + Pubnub::Constants::OPERATION_CREATE_USER + when 'update' + Pubnub::Constants::OPERATION_UPDATE_USER + when 'delete' + Pubnub::Constants::OPERATION_DELETE_USER + else + Pubnub.logger.error('Pubnub::SubscribeEvent::Formatter') { "Invalid event #{message[:payload]['event']}." } + raise Exception, "Invalid event #{message[:payload]['event']}." + end + when 'space' + case message[:payload]['event'] + when 'create' + Pubnub::Constants::OPERATION_CREATE_SPACE + when 'update' + Pubnub::Constants::OPERATION_UPDATE_SPACE + when 'delete' + Pubnub::Constants::OPERATION_DELETE_SPACE + else + Pubnub.logger.error('Pubnub::SubscribeEvent::Formatter') { "Invalid event #{message[:payload]['event']}." } + raise Exception, "Invalid event #{message[:payload]['event']}." + end + when 'membership' + Pubnub::Constants::OPERATION_MANAGE_MEMBERSHIPS + else + Pubnub.logger.error('Pubnub::SubscribeEvent::Formatter') { "Invalid operation type #{message[:payload]['type']}." } + raise Exception, "Invalid operation type #{message[:payload]['type']}." + end + else Pubnub::Constants::OPERATION_SUBSCRIBE end diff --git a/lib/pubnub/subscriber.rb b/lib/pubnub/subscriber.rb index 4f77b7106..a3d849fd3 100644 --- a/lib/pubnub/subscriber.rb +++ b/lib/pubnub/subscriber.rb @@ -75,6 +75,12 @@ def fire_async_callbacks(envelopes) secure_call callbacks.callbacks[:signal], envelope when Pubnub::Constants::OPERATION_PRESENCE secure_call callbacks.callbacks[:presence], envelope + when Pubnub::Constants::OPERATION_CREATE_USER, Pubnub::Constants::OPERATION_UPDATE_USER, Pubnub::Constants::OPERATION_DELETE_USER + secure_call callbacks.callbacks[:user], envelope + when Pubnub::Constants::OPERATION_CREATE_SPACE, Pubnub::Constants::OPERATION_UPDATE_SPACE, Pubnub::Constants::OPERATION_DELETE_SPACE + secure_call callbacks.callbacks[:space], envelope + when Pubnub::Constants::OPERATION_MANAGE_MEMBERS, Pubnub::Constants::OPERATION_MANAGE_MEMBERSHIPS + secure_call callbacks.callbacks[:membership], envelope else secure_call callbacks.callbacks[:status], envelope end diff --git a/lib/pubnub/version.rb b/lib/pubnub/version.rb index d97a363bb..8e9fc842d 100644 --- a/lib/pubnub/version.rb +++ b/lib/pubnub/version.rb @@ -1,4 +1,4 @@ # Toplevel Pubnub module. module Pubnub - VERSION = '4.2.0'.freeze + VERSION = '4.2.1'.freeze end diff --git a/spec/lib/events/subscribe_spec.rb b/spec/lib/events/subscribe_spec.rb index 983c4b67c..7756c2543 100644 --- a/spec/lib/events/subscribe_spec.rb +++ b/spec/lib/events/subscribe_spec.rb @@ -12,11 +12,19 @@ before :each do @messages = [] @statuses = [] + @signals = [] + @user_events = [] + @space_events = [] + @membership_events = [] @callbacks = Pubnub::SubscribeCallback.new( message: -> (envelope) { @messages << envelope }, presence: -> (_envelope) { }, status: -> (envelope) { @statuses << envelope }, + signal: -> (envelope) { @signals << envelope }, + user: -> (envelope) { @user_events << envelope }, + space: -> (envelope) { @space_events << envelope }, + membership: -> (envelope) { @membership_events << envelope } ) end @@ -98,6 +106,102 @@ end end end + + it "user update works" do + VCR.use_cassette("lib/events/subscribe-user-update-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.add_listener(callback: @callbacks) + + @pubnub.subscribe(channel: :user_mg3) + + eventually do + envelope = @user_events.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'update' + expect(envelope.result[:data][:message]['type']).to eq 'user' + end + end + end + + it "space update works" do + VCR.use_cassette("lib/events/subscribe-space-update-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.add_listener(callback: @callbacks) + + @pubnub.subscribe(channel: :rb_space_3) + + eventually do + envelope = @space_events.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'update' + expect(envelope.result[:data][:message]['type']).to eq 'space' + end + end + end + + it "member add works" do + VCR.use_cassette("lib/events/subscribe-member-add-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.add_listener(callback: @callbacks) + + @pubnub.subscribe(channel: :rb_space_4) + + eventually do + envelope = @membership_events.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'create' + expect(envelope.result[:data][:message]['type']).to eq 'membership' + expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4' + end + end + end + + it "membership add works" do + VCR.use_cassette("lib/events/subscribe-membership-add-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.add_listener(callback: @callbacks) + + @pubnub.subscribe(channel: :user_mg4) + + eventually do + envelope = @membership_events.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'create' + expect(envelope.result[:data][:message]['type']).to eq 'membership' + expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4' + end + end + end + + end end context "sync" do @@ -153,6 +257,89 @@ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new end end + + it "user delete works" do + VCR.use_cassette("lib/events/subscribe-user-delete-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.subscribe(channel: :user_mg3, http_sync: true) + envelopes = @pubnub.subscribe(channel: :user_mg3, http_sync: true) + + envelope = envelopes.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'delete' + expect(envelope.result[:data][:message]['type']).to eq 'user' + end + end + + it "space delete works" do + VCR.use_cassette("lib/events/subscribe-space-delete-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.subscribe(channel: :rb_space_3, http_sync: true) + envelopes = @pubnub.subscribe(channel: :rb_space_3, http_sync: true) + + envelope = envelopes.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'delete' + expect(envelope.result[:data][:message]['type']).to eq 'space' + expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_space_3' + end + end + + it "member remove works" do + VCR.use_cassette("lib/events/subscribe-member-remove-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.subscribe(channel: :rb_space_4, http_sync: true) + envelopes = @pubnub.subscribe(channel: :rb_space_4, http_sync: true) + + envelope = envelopes.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'delete' + expect(envelope.result[:data][:message]['type']).to eq 'membership' + expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4' + end + end + + it "membership remove works" do + VCR.use_cassette("lib/events/subscribe-membership-remove-async", record: :once) do + @pubnub = Pubnub::Client.new( + subscribe_key: "sub-a-mock-key", + publish_key: "pub-a-mock-key", + auth_key: "ruby-test-auth", + uuid: "ruby-test-uuid" + ) + + @pubnub.subscribe(channel: :user_mg4, http_sync: true) + envelopes = @pubnub.subscribe(channel: :user_mg4, http_sync: true) + + envelope = envelopes.first + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.result[:data][:message]['event']).to eq 'delete' + expect(envelope.result[:data][:message]['type']).to eq 'membership' + expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4' + end + end context "aliases" do @@ -212,5 +399,6 @@ end end end + end end