From 1b3d2b059f2ef972c54c3ade1f595ebeaa25beb4 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 21 Jan 2025 13:47:59 +0200 Subject: [PATCH 1/3] feat(app-context): add `type` and `status` fields Add the ability to specify `type` and `status` fields for `channel metadata`, `uuid metadata`, `member`, and `membership`. feat(app-context): add missing `include` options support Add missing `include` options for App Context APIs: `custom`, `status`, `type`, `uuid_status`, `uuid_type`, `channel_status`, and `channel_type`. --- .../examples/channel_members/007.yml | 111 ++++++++++++++++++ .../examples/channel_metadata/007.yml | 39 ++++++ .../examples/memberships/009.yml | 111 ++++++++++++++++++ .../examples/uuid_metadata/009.yml | 39 ++++++ .../lib/events/get_all_channels_metadata.yml | 39 ------ .../lib/events/get_all_channels_metadata1.yml | 37 ++++++ .../lib/events/get_all_channels_metadata2.yml | 37 ++++++ .../lib/events/get_all_uuid_metadata.yml | 76 ------------ .../lib/events/get_all_uuid_metadata1.yml | 42 +++++++ .../lib/events/get_all_uuid_metadata2.yml | 42 +++++++ ...metadata.yml => get_channel_metadata1.yml} | 20 ++-- .../lib/events/get_channel_metadata2.yml | 37 ++++++ .../lib/events/get_uuid_metadata3.yml | 37 ++++++ ...metadata.yml => set_channel_metadata1.yml} | 22 ++-- .../lib/events/set_channel_metadata2.yml | 39 ++++++ .../lib/events/set_uuid_metadata3.yml | 39 ++++++ lib/pubnub/event.rb | 2 +- .../events/get_all_channels_metadata.rb | 22 ++-- lib/pubnub/events/get_all_uuid_metadata.rb | 22 ++-- lib/pubnub/events/get_channel_members.rb | 33 +++--- lib/pubnub/events/get_channel_metadata.rb | 14 ++- lib/pubnub/events/get_memberships.rb | 33 +++--- lib/pubnub/events/get_uuid_metadata.rb | 14 ++- lib/pubnub/events/set_channel_members.rb | 31 +++-- lib/pubnub/events/set_channel_metadata.rb | 12 +- lib/pubnub/events/set_memberships.rb | 31 +++-- lib/pubnub/events/set_uuid_metadata.rb | 12 +- lib/pubnub/validators/set_channel_metadata.rb | 30 +++-- lib/pubnub/validators/set_uuid_metadata.rb | 30 +++-- .../set_channel_members_examples_spec.rb | 47 +++++++- .../set_channel_metadata_examples_spec.rb | 29 ++++- .../examples/set_memberships_examples_spec.rb | 50 +++++++- .../set_uuid_metadata_examples_spec.rb | 31 ++++- spec/lib/events/channel_metadata_spec.rb | 41 ++++++- spec/lib/events/uuid_metadata_spec.rb | 32 ++++- 35 files changed, 1008 insertions(+), 275 deletions(-) create mode 100644 fixtures/vcr_cassettes/examples/channel_members/007.yml create mode 100644 fixtures/vcr_cassettes/examples/channel_metadata/007.yml create mode 100644 fixtures/vcr_cassettes/examples/memberships/009.yml create mode 100644 fixtures/vcr_cassettes/examples/uuid_metadata/009.yml delete mode 100644 fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_all_channels_metadata1.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_all_channels_metadata2.yml delete mode 100644 fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata1.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata2.yml rename fixtures/vcr_cassettes/lib/events/{get_channel_metadata.yml => get_channel_metadata1.yml} (63%) create mode 100644 fixtures/vcr_cassettes/lib/events/get_channel_metadata2.yml create mode 100644 fixtures/vcr_cassettes/lib/events/get_uuid_metadata3.yml rename fixtures/vcr_cassettes/lib/events/{set_channel_metadata.yml => set_channel_metadata1.yml} (52%) create mode 100644 fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml create mode 100644 fixtures/vcr_cassettes/lib/events/set_uuid_metadata3.yml diff --git a/fixtures/vcr_cassettes/examples/channel_members/007.yml b/fixtures/vcr_cassettes/examples/channel_members/007.yml new file mode 100644 index 000000000..9fbe1d16f --- /dev/null +++ b/fixtures/vcr_cassettes/examples/channel_members/007.yml @@ -0,0 +1,111 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"public":true},"type":"lobby","status":"open"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 10:51:02 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 10:51:04 GMT + Content-Type: + - application/json + Content-Length: + - '183' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"channel","name":"some_name","description":null,"custom":{"public":true},"updated":"2025-01-21T10:46:24.088899Z","eTag":"d5ec4d7bdc94bc26720727fe45e6ea78"}}' + recorded_at: Tue, 21 Jan 2025 10:51:04 GMT +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&include=custom&l_obj=2.017&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum","custom":{"announcer":true},"type":"admin","status":"away"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 10:51:04 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 10:51:05 GMT + Content-Type: + - application/json + Content-Length: + - '209' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"custom":{"announcer":true},"updated":"2025-01-21T10:46:24.429565Z","eTag":"45708f3570743e16664a7ab2929d1d71"}}' + recorded_at: Tue, 21 Jan 2025 10:51:04 GMT +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel/uuids?auth=ruby-test-auth-client-one&count=1&include=custom,status,type,uuid,uuid.custom,uuid.status,uuid.type&l_obj=0.343&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"set":[{"uuid":{"id":"bob"},"custom":{"can_write":true},"type":"info","status":"active"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 10:51:04 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 10:51:05 GMT + Content-Type: + - application/json + Content-Length: + - '403' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"uuid":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"type":"admin","status":"away","custom":{"announcer":true},"updated":"2025-01-21T10:46:24.429565Z","eTag":"45708f3570743e16664a7ab2929d1d71"},"type":"info","status":"active","custom":{"can_write":true},"updated":"2025-01-21T10:51:05.330619Z","eTag":"AeqXm5OZjaPqtQE"}],"totalCount":1,"next":"MQ"}' + recorded_at: Tue, 21 Jan 2025 10:51:05 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/examples/channel_metadata/007.yml b/fixtures/vcr_cassettes/examples/channel_metadata/007.yml new file mode 100644 index 000000000..d800f27ca --- /dev/null +++ b/fixtures/vcr_cassettes/examples/channel_metadata/007.yml @@ -0,0 +1,39 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel?auth=ruby-test-auth-client-one&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"some_name","type":"lobby","status":"open"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 10:30:54 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 10:30:55 GMT + Content-Type: + - application/json + Content-Length: + - '203' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"channel","name":"some_name","description":null,"type":"lobby","status":"open","custom":null,"updated":"2025-01-21T10:30:55.080486Z","eTag":"af4025ea32884737d00662f205d2872a"}}' + recorded_at: Tue, 21 Jan 2025 10:30:54 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/examples/memberships/009.yml b/fixtures/vcr_cassettes/examples/memberships/009.yml new file mode 100644 index 000000000..049d5a692 --- /dev/null +++ b/fixtures/vcr_cassettes/examples/memberships/009.yml @@ -0,0 +1,111 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"public":true},"type":"lobby","status":"open"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 11:12:07 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 11:12:08 GMT + Content-Type: + - application/json + Content-Length: + - '183' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"channel","name":"some_name","description":null,"custom":{"public":true},"updated":"2025-01-21T10:46:24.088899Z","eTag":"d5ec4d7bdc94bc26720727fe45e6ea78"}}' + recorded_at: Tue, 21 Jan 2025 11:12:08 GMT +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&include=custom&l_obj=0.764&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum","custom":{"announcer":true},"type":"admin","status":"away"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 11:12:08 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 11:12:09 GMT + Content-Type: + - application/json + Content-Length: + - '209' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"custom":{"announcer":true},"updated":"2025-01-21T10:46:24.429565Z","eTag":"45708f3570743e16664a7ab2929d1d71"}}' + recorded_at: Tue, 21 Jan 2025 11:12:09 GMT +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob/channels?auth=ruby-test-auth-client-one&count=1&include=channel,channel.custom,channel.status,channel.type,custom,status,type&l_obj=0.333&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"set":[{"channel":{"id":"channel"},"custom":{"read_only":false},"type":"system","status":"locked"}]}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 11:12:09 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 11:12:09 GMT + Content-Type: + - application/json + Content-Length: + - '382' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"channel":{"id":"channel","name":"some_name","description":null,"type":"lobby","status":"open","custom":{"public":true},"updated":"2025-01-21T10:46:24.088899Z","eTag":"d5ec4d7bdc94bc26720727fe45e6ea78"},"type":"system","status":"locked","custom":{"read_only":false},"updated":"2025-01-21T11:12:09.552725Z","eTag":"Ad+B0saY4+GlFw"}],"totalCount":1,"next":"MQ"}' + recorded_at: Tue, 21 Jan 2025 11:12:09 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/examples/uuid_metadata/009.yml b/fixtures/vcr_cassettes/examples/uuid_metadata/009.yml new file mode 100644 index 000000000..9fa35d1de --- /dev/null +++ b/fixtures/vcr_cassettes/examples/uuid_metadata/009.yml @@ -0,0 +1,39 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum","type":"admin","status":"away"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 11:24:10 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 11:24:11 GMT + Content-Type: + - application/json + Content-Length: + - '240' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"type":"admin","status":"away","custom":{"announcer":true},"updated":"2025-01-21T10:46:24.429565Z","eTag":"45708f3570743e16664a7ab2929d1d71"}}' + recorded_at: Tue, 21 Jan 2025 11:24:11 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml deleted file mode 100644 index d0e0b1abd..000000000 --- a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?auth=ruby-test-auth&count=1&include=custom&limit=5&pnsdk=PubNub-Ruby/4.2.7&signature=v2.cNbbuIJL6KQzXCAT_Kb1RTv5zsmRLPRacYCFFFk6Mh0×tamp=1602593069&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: - - Tue, 13 Oct 2020 12:44:29 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 12:44:30 GMT - Content-Type: - - application/json - Content-Length: - - '348' - Connection: - - keep-alive - Vary: - - Accept-Encoding - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":[{"id":"rb_channel1","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T11:43:29.824332Z","eTag":"AZTUtcvx6NDGLQ"},{"id":"rb_channel2","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T12:38:14.839088Z","eTag":"AZTUtcvx6NDGLQ"}],"totalCount":2,"next":"Mg"}' - recorded_at: Tue, 13 Oct 2020 12:44:30 GMT -recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata1.yml b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata1.yml new file mode 100644 index 000000000..ddb437396 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata1.yml @@ -0,0 +1,37 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?auth=ruby-test-auth&count=1&include=custom&limit=5&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:32:25 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:32:27 GMT + Content-Type: + - application/json + Content-Length: + - '1088' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"00a8d2e0-c640-45b1-e6de-f61e6bd9a393","name":"00a8d2e0-c640-45b1-e6de-f61e6bd9a393","description":null,"custom":null,"updated":"2024-12-13T11:03:03.457996Z","eTag":"bf29eb2bef1baa47fd954ed7010cb51b"},{"id":"03d27c15-cda9-4dc7-e276-b4d8fa6f848e","name":"03d27c15-cda9-4dc7-e276-b4d8fa6f848e","description":null,"custom":null,"updated":"2024-12-16T09:08:54.231515Z","eTag":"feb44e840fbee7da1bbc87ef51f223ba"},{"id":"04e3083e-019a-4dae-be7f-d896291ab4d9","name":"04e3083e-019a-4dae-be7f-d896291ab4d9","description":null,"custom":null,"updated":"2024-12-19T12:06:37.313275Z","eTag":"ddf8929b455b800afbf69531fc56aad8"},{"id":"05b2d402-f904-499d-b9f3-8166fbcd66d4","name":"05b2d402-f904-499d-b9f3-8166fbcd66d4","description":null,"custom":null,"updated":"2024-12-19T11:30:43.21224Z","eTag":"005f87588abf8e67aeca30340310de7d"},{"id":"06d8f3b6-32ba-479c-8300-8d7dab0ea21b","name":"06d8f3b6-32ba-479c-8300-8d7dab0ea21b","description":null,"custom":null,"updated":"2024-12-18T18:42:16.967369Z","eTag":"5911a63be62caf69fd6aaec0f3e54212"}],"totalCount":21497,"next":"NQ"}' + recorded_at: Tue, 21 Jan 2025 07:32:27 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata2.yml b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata2.yml new file mode 100644 index 000000000..6bf9a3aa9 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata2.yml @@ -0,0 +1,37 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?auth=ruby-test-auth&count=1&include=custom,status,type&limit=5&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:32:27 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:32:28 GMT + Content-Type: + - application/json + Content-Length: + - '1233' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"00a8d2e0-c640-45b1-e6de-f61e6bd9a393","name":"00a8d2e0-c640-45b1-e6de-f61e6bd9a393","description":null,"type":"group","status":null,"custom":null,"updated":"2024-12-13T11:03:03.457996Z","eTag":"bf29eb2bef1baa47fd954ed7010cb51b"},{"id":"03d27c15-cda9-4dc7-e276-b4d8fa6f848e","name":"03d27c15-cda9-4dc7-e276-b4d8fa6f848e","description":null,"type":"group","status":null,"custom":null,"updated":"2024-12-16T09:08:54.231515Z","eTag":"feb44e840fbee7da1bbc87ef51f223ba"},{"id":"04e3083e-019a-4dae-be7f-d896291ab4d9","name":"04e3083e-019a-4dae-be7f-d896291ab4d9","description":null,"type":"group","status":null,"custom":null,"updated":"2024-12-19T12:06:37.313275Z","eTag":"ddf8929b455b800afbf69531fc56aad8"},{"id":"05b2d402-f904-499d-b9f3-8166fbcd66d4","name":"05b2d402-f904-499d-b9f3-8166fbcd66d4","description":null,"type":"group","status":null,"custom":null,"updated":"2024-12-19T11:30:43.21224Z","eTag":"005f87588abf8e67aeca30340310de7d"},{"id":"06d8f3b6-32ba-479c-8300-8d7dab0ea21b","name":"06d8f3b6-32ba-479c-8300-8d7dab0ea21b","description":null,"type":"group","status":null,"custom":null,"updated":"2024-12-18T18:42:16.967369Z","eTag":"5911a63be62caf69fd6aaec0f3e54212"}],"totalCount":21497,"next":"NQ"}' + recorded_at: Tue, 21 Jan 2025 07:32:27 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml b/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml deleted file mode 100644 index fb34293ae..000000000 --- a/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-test-auth,ruby-test-auth2&g=1&j=1&m=1&pnsdk=PubNub-Ruby/4.2.7&r=1&signature=v2.vOIJQ3_z4VCBfNg-2UyoMR6Z78weFmHXpcukiFDPgD8&target-uuid=ruby-test-uuid,ruby-test-uuid2×tamp=1602594634&ttl=1440&u=1&uuid=ruby-test-uuid&w=1 - body: - encoding: UTF-8 - string: '' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) - Accept: - - "*/*" - Date: - - Tue, 13 Oct 2020 13:10:34 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:34 GMT - Content-Type: - - text/javascript; charset=UTF-8 - Content-Length: - - '475' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Methods: - - GET - Access-Control-Allow-Headers: - - Origin, X-Requested-With, Content-Type, Accept - Cache-Control: - - no-cache, no-store, must-revalidate - body: - encoding: UTF-8 - string: '{"message":"Success","payload":{"level":"uuid","subscribe_key":"sub-a-mock-key","ttl":1440,"uuids":{"ruby-test-uuid":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}},"ruby-test-uuid2":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}}}},"service":"Access - Manager","status":200}' - recorded_at: Tue, 13 Oct 2020 13:10:34 GMT -- request: - method: get - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids?auth=ruby-test-auth&count=1&include=custom&limit=5&pnsdk=PubNub-Ruby/4.2.7&signature=v2.XuCXUg1KTKOcCznFz1f3lw19jrGTG8Z3-4SBBWIA0uA×tamp=1602594634&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: - - Tue, 13 Oct 2020 13:10:34 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:35 GMT - Content-Type: - - application/json - Content-Length: - - '216' - 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"},"updated":"2020-10-13T13:10:33.333845Z","eTag":"Ad2eyIWXwJzBqAE"}],"totalCount":1,"next":"MQ"}' - recorded_at: Tue, 13 Oct 2020 13:10:35 GMT -recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata1.yml b/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata1.yml new file mode 100644 index 000000000..a60cf8caf --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata1.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids?auth=ruby-test-auth&count=1&include=custom&limit=5&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:37:32 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:37:33 GMT + Content-Type: + - application/json + Content-Length: + - '1130' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"0aeRHzYcuser_8v02LnrL","name":"0aeRHzYcTest + User","externalId":null,"profileUrl":null,"email":null,"custom":null,"updated":"2024-12-12T13:27:41.021712Z","eTag":"14e7f477ded2b6e329d1880b82ad8fb4"},{"id":"0H1VkYHguser_gHBwxZUg","name":"0H1VkYHgTest + User","externalId":null,"profileUrl":null,"email":null,"custom":null,"updated":"2024-12-12T13:23:15.790547Z","eTag":"42984e2544d629e22936bba2b820f002"},{"id":"0Y5y5LOsuser_IGYtjjI3","name":"0Y5y5LOsTest + User","externalId":null,"profileUrl":null,"email":null,"custom":null,"updated":"2024-12-12T13:23:11.860968Z","eTag":"9d09332f2f5550a555d2e00209f3d9c6"},{"id":"1h0RWArquser_4O9vvG9W","name":"1h0RWArqTest + User","externalId":null,"profileUrl":null,"email":null,"custom":null,"updated":"2024-12-12T13:26:31.925826Z","eTag":"ec86c4fada9407d1fbf253662a6cfdc5"},{"id":"2aiuiG","name":"Marian + Salazar","externalId":"5445888223","profileUrl":"https://picsum.photos/100/200","email":"marian.salazar@pubnub.com","custom":{"age":36,"city":"London"},"updated":"2025-01-03T16:24:20.549904Z","eTag":"6d50dccdbbc119aaf23af54a5bccf36a"}],"totalCount":1768,"next":"NQ"}' + recorded_at: Tue, 21 Jan 2025 07:37:33 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata2.yml b/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata2.yml new file mode 100644 index 000000000..c5e8f8540 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata2.yml @@ -0,0 +1,42 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids?auth=ruby-test-auth&count=1&include=custom,status,type&limit=5&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:37:33 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:37:34 GMT + Content-Type: + - application/json + Content-Length: + - '1268' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"0aeRHzYcuser_8v02LnrL","name":"0aeRHzYcTest + User","externalId":null,"profileUrl":null,"email":null,"type":null,"status":null,"custom":null,"updated":"2024-12-12T13:27:41.021712Z","eTag":"14e7f477ded2b6e329d1880b82ad8fb4"},{"id":"0H1VkYHguser_gHBwxZUg","name":"0H1VkYHgTest + User","externalId":null,"profileUrl":null,"email":null,"type":null,"status":null,"custom":null,"updated":"2024-12-12T13:23:15.790547Z","eTag":"42984e2544d629e22936bba2b820f002"},{"id":"0Y5y5LOsuser_IGYtjjI3","name":"0Y5y5LOsTest + User","externalId":null,"profileUrl":null,"email":null,"type":null,"status":null,"custom":null,"updated":"2024-12-12T13:23:11.860968Z","eTag":"9d09332f2f5550a555d2e00209f3d9c6"},{"id":"1h0RWArquser_4O9vvG9W","name":"1h0RWArqTest + User","externalId":null,"profileUrl":null,"email":null,"type":null,"status":null,"custom":null,"updated":"2024-12-12T13:26:31.925826Z","eTag":"ec86c4fada9407d1fbf253662a6cfdc5"},{"id":"2aiuiG","name":"Marian + Salazar","externalId":"5445888223","profileUrl":"https://picsum.photos/100/200","email":"marian.salazar@pubnub.com","type":"admin","status":"deleted","custom":{"age":36,"city":"London"},"updated":"2025-01-03T16:24:20.549904Z","eTag":"6d50dccdbbc119aaf23af54a5bccf36a"}],"totalCount":1768,"next":"NQ"}' + recorded_at: Tue, 21 Jan 2025 07:37:34 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_channel_metadata.yml b/fixtures/vcr_cassettes/lib/events/get_channel_metadata1.yml similarity index 63% rename from fixtures/vcr_cassettes/lib/events/get_channel_metadata.yml rename to fixtures/vcr_cassettes/lib/events/get_channel_metadata1.yml index f74368e67..84fc3af62 100644 --- a/fixtures/vcr_cassettes/lib/events/get_channel_metadata.yml +++ b/fixtures/vcr_cassettes/lib/events/get_channel_metadata1.yml @@ -2,36 +2,36 @@ http_interactions: - request: method: get - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.7&signature=v2.ACmKb5y3ubXTJOmsSOr9Q2f_hbX0m0Gbf52uJuLhbGM×tamp=1602592739&uuid=ruby-test-uuid + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/5.4.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)) + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) Accept: - "*/*" Date: - - Tue, 13 Oct 2020 12:38:59 GMT + - Tue, 21 Jan 2025 07:20:00 GMT response: status: code: 200 message: OK headers: Date: - - Tue, 13 Oct 2020 12:39:00 GMT + - Tue, 21 Jan 2025 07:20:01 GMT Content-Type: - application/json Content-Length: - - '167' + - '185' Connection: - keep-alive - Access-Control-Allow-Origin: - - "*" Access-Control-Allow-Credentials: - 'true' + Access-Control-Expose-Headers: + - "*" body: encoding: UTF-8 - string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T12:38:14.839088Z","eTag":"AZTUtcvx6NDGLQ"}}' - recorded_at: Tue, 13 Oct 2020 12:39:00 GMT -recorded_with: VCR 6.0.0 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' + recorded_at: Tue, 21 Jan 2025 07:20:01 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_channel_metadata2.yml b/fixtures/vcr_cassettes/lib/events/get_channel_metadata2.yml new file mode 100644 index 000000000..f2ba4199d --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_channel_metadata2.yml @@ -0,0 +1,37 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:24:49 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:24:50 GMT + Content-Type: + - application/json + Content-Length: + - '221' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"type":"event","status":"completed","custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' + recorded_at: Tue, 21 Jan 2025 07:24:50 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/get_uuid_metadata3.yml b/fixtures/vcr_cassettes/lib/events/get_uuid_metadata3.yml new file mode 100644 index 000000000..e3754351d --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/get_uuid_metadata3.yml @@ -0,0 +1,37 @@ +--- +http_interactions: +- request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid?auth=ruby-test-auth&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:36:42 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:36:42 GMT + Content-Type: + - application/json + Content-Length: + - '249' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"ruby-test-uuid","name":"magnum","externalId":null,"profileUrl":null,"email":null,"type":"admin","status":"active","custom":{"XXX":"YYYY"},"updated":"2025-01-21T07:35:49.731004Z","eTag":"5e793e98ebf25b2ed47ad51beed46e11"}}' + recorded_at: Tue, 21 Jan 2025 07:36:42 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/set_channel_metadata.yml b/fixtures/vcr_cassettes/lib/events/set_channel_metadata1.yml similarity index 52% rename from fixtures/vcr_cassettes/lib/events/set_channel_metadata.yml rename to fixtures/vcr_cassettes/lib/events/set_channel_metadata1.yml index 47747e303..cf07869d7 100644 --- a/fixtures/vcr_cassettes/lib/events/set_channel_metadata.yml +++ b/fixtures/vcr_cassettes/lib/events/set_channel_metadata1.yml @@ -2,17 +2,17 @@ http_interactions: - request: method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=1&pnsdk=PubNub-Ruby/4.2.7&signature=v2.5Qv0f9StzXIeVLlnHcm7GqlQK44CWqyk4VGRQixE3nY×tamp=1602592693&uuid=ruby-test-uuid + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid body: encoding: UTF-8 - string: '{"name":"some_name","custom":{"XXX":"YYYY"}}' + string: '{"name":"some_name","custom":{"XXX":"YYYY"},"type":"event","status":"completed"}' headers: User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) Accept: - "*/*" Date: - - Tue, 13 Oct 2020 12:38:13 GMT + - Tue, 21 Jan 2025 00:09:17 GMT Content-Type: - application/x-www-form-urlencoded response: @@ -21,19 +21,19 @@ http_interactions: message: OK headers: Date: - - Tue, 13 Oct 2020 12:38:15 GMT + - Tue, 21 Jan 2025 00:09:18 GMT Content-Type: - application/json Content-Length: - - '143' + - '185' Connection: - keep-alive - Access-Control-Allow-Origin: - - "*" Access-Control-Allow-Credentials: - 'true' + Access-Control-Expose-Headers: + - "*" body: encoding: UTF-8 - string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"updated":"2020-10-13T12:38:14.839088Z","eTag":"AZTUtcvx6NDGLQ"}}' - recorded_at: Tue, 13 Oct 2020 12:38:15 GMT -recorded_with: VCR 6.0.0 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' + recorded_at: Tue, 21 Jan 2025 00:09:18 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml b/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml new file mode 100644 index 000000000..2204dba2f --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml @@ -0,0 +1,39 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=type,status,custom&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"XXX":"YYYY"},"type":"event","status":"completed"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 00:07:40 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 00:07:40 GMT + Content-Type: + - application/json + Content-Length: + - '221' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"type":"event","status":"completed","custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' + recorded_at: Tue, 21 Jan 2025 00:07:40 GMT +recorded_with: VCR 6.3.1 diff --git a/fixtures/vcr_cassettes/lib/events/set_uuid_metadata3.yml b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata3.yml new file mode 100644 index 000000000..107037ec0 --- /dev/null +++ b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata3.yml @@ -0,0 +1,39 @@ +--- +http_interactions: +- request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid?auth=ruby-test-auth&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"magnum","custom":{"XXX":"YYYY"},"type":"admin","status":"active"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 07:35:49 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 07:35:49 GMT + Content-Type: + - application/json + Content-Length: + - '249' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"ruby-test-uuid","name":"magnum","externalId":null,"profileUrl":null,"email":null,"type":"admin","status":"active","custom":{"XXX":"YYYY"},"updated":"2025-01-21T07:35:49.731004Z","eTag":"5e793e98ebf25b2ed47ad51beed46e11"}}' + recorded_at: Tue, 21 Jan 2025 07:35:49 GMT +recorded_with: VCR 6.3.1 diff --git a/lib/pubnub/event.rb b/lib/pubnub/event.rb index 918bba778..f82b40789 100644 --- a/lib/pubnub/event.rb +++ b/lib/pubnub/event.rb @@ -178,7 +178,7 @@ def create_variables_from_options(options) include_custom_message_type include_message_actions include_message_type replicate with_presence cipher_key_selector include_meta include_uuid join update get add remove push_token push_gateway environment topic - authorized_uuid authorized_user_id token type value] + authorized_uuid authorized_user_id token type status value] options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last } diff --git a/lib/pubnub/events/get_all_channels_metadata.rb b/lib/pubnub/events/get_all_channels_metadata.rb index b1dfbd017..b9286db0f 100644 --- a/lib/pubnub/events/get_all_channels_metadata.rb +++ b/lib/pubnub/events/get_all_channels_metadata.rb @@ -11,18 +11,22 @@ def initialize(options, app) @event = current_operation @telemetry_name = :l_obj @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] - @include_count = [0, '0', false].include?(options[:include][:count]) ? "0" : "1" unless options[:include][:count].nil? - @include = "custom" unless [0, '0', false].include?(options[:include][:custom]) + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -41,7 +45,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include unless @include.to_s.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -56,12 +60,12 @@ def path end def valid_envelope(parsed_response, req_res_objects) - channels_metadata = parsed_response['data'].map { |uuid_metadata| - metadata = Hash.new - uuid_metadata.each{ |k,v| metadata[k.to_sym] = v } + channels_metadata = parsed_response['data'].map do |uuid_metadata| + metadata = {} + uuid_metadata.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? metadata - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/get_all_uuid_metadata.rb b/lib/pubnub/events/get_all_uuid_metadata.rb index ca82a1a9b..d1b397053 100644 --- a/lib/pubnub/events/get_all_uuid_metadata.rb +++ b/lib/pubnub/events/get_all_uuid_metadata.rb @@ -11,18 +11,22 @@ def initialize(options, app) @event = current_operation @telemetry_name = :l_obj @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] - @include_count = [0, '0', false].include?(options[:include][:count]) ? "0" : "1" unless options[:include][:count].nil? - @include = "custom" unless [0, '0', false].include?(options[:include][:custom]) + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -41,7 +45,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include unless @include.to_s.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -56,12 +60,12 @@ def path end def valid_envelope(parsed_response, req_res_objects) - uuids_metadata = parsed_response['data'].map { |uuid_metadata| - metadata = Hash.new - uuid_metadata.each{ |k,v| metadata[k.to_sym] = v } + uuids_metadata = parsed_response['data'].map do |uuid_metadata| + metadata = {} + uuid_metadata.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? metadata - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/get_channel_members.rb b/lib/pubnub/events/get_channel_members.rb index 3d4abc8dc..6c3505d5f 100644 --- a/lib/pubnub/events/get_channel_members.rb +++ b/lib/pubnub/events/get_channel_members.rb @@ -12,23 +12,26 @@ def initialize(options, app) @telemetry_name = :l_obj @channel = options[:channel] @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] include = options[:include] - @include_count = [0, '0', false].include?(include[:count]) ? "0" : "1" unless include[:count].nil? - @include_custom = "custom" if !include[:custom].nil? && ![0, '0', false].include?(include[:custom]) - @include_uuid_metadata = "uuid" if !include[:uuid_metadata].nil? && ![0, '0', false].include?(include[:uuid_metadata]) - @include_uuid_custom = "uuid.custom" if !include[:uuid_custom].nil? && ![0, '0', false].include?(include[:uuid_custom]) - - @include = [@include_custom, @include_uuid_metadata, @include_uuid_custom].reject { |flag| flag.to_s.empty? } + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include.push('uuid') unless include[:uuid_metadata].nil? || [0, '0', false].include?(include[:uuid_metadata]) + @include.push('uuid.type') unless include[:uuid_type].nil? || [0, '0', false].include?(include[:uuid_type]) + @include.push('uuid.status') unless include[:uuid_status].nil? || [0, '0', false].include?(include[:uuid_status]) + @include.push('uuid.custom') unless include[:uuid_custom].nil? || [0, '0', false].include?(include[:uuid_custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -47,7 +50,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include.sort.join(",") if @include && !@include.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -64,20 +67,20 @@ def path end def valid_envelope(parsed_response, req_res_objects) - members = parsed_response['data'].map { |channel_member| - member = Hash.new - channel_member.each{ |k,v| member[k.to_sym] = v } + members = parsed_response['data'].map do |channel_member| + member = {} + channel_member.each { |k, v| member[k.to_sym] = v } unless member[:uuid].nil? - uuid_metadata = Hash.new - member[:uuid].each{ |k,v| uuid_metadata[k.to_sym] = v } + uuid_metadata = {} + member[:uuid].each { |k, v| uuid_metadata[k.to_sym] = v } uuid_metadata[:updated] = Date._parse(uuid_metadata[:updated]) unless uuid_metadata[:updated].nil? member[:uuid] = uuid_metadata end member[:updated] = Date._parse(member[:updated]) unless member[:updated].nil? member - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/get_channel_metadata.rb b/lib/pubnub/events/get_channel_metadata.rb index 4b3c885fd..92f1e68b7 100644 --- a/lib/pubnub/events/get_channel_metadata.rb +++ b/lib/pubnub/events/get_channel_metadata.rb @@ -12,12 +12,16 @@ def initialize(options, app) @telemetry_name = :l_obj @channel = options[:channel] + @include = [] if options[:include] - @include = "custom" unless [0, '0', false].include?(options[:include][:custom]) + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) end # Single entity creation should return it's 'custom' field by default. - @include = "custom" if @include.nil? + @include = ['custom'] if @include.empty? super end @@ -29,7 +33,7 @@ def current_operation def parameters(signature = false) parameters = super(signature) - parameters[:include] = @include + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -46,8 +50,8 @@ def path def valid_envelope(parsed_response, req_res_objects) data = parsed_response['data'] - metadata = Hash.new - data.each{ |k,v| metadata[k.to_sym] = v } + metadata = {} + data.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? Pubnub::Envelope.new( diff --git a/lib/pubnub/events/get_memberships.rb b/lib/pubnub/events/get_memberships.rb index 1f26ec442..6811cb472 100644 --- a/lib/pubnub/events/get_memberships.rb +++ b/lib/pubnub/events/get_memberships.rb @@ -12,23 +12,26 @@ def initialize(options, app) @telemetry_name = :l_obj @uuid = options[:uuid].nil? ? app.user_id : options[:uuid] @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] include = options[:include] - @include_count = [0, '0', false].include?(include[:count]) ? "0" : "1" unless include[:count].nil? - @include_custom = "custom" if !include[:custom].nil? && ![0, '0', false].include?(include[:custom]) - @include_channel_metadata = "channel" if !include[:channel_metadata].nil? && ![0, '0', false].include?(include[:channel_metadata]) - @include_channel_custom = "channel.custom" if !include[:channel_custom].nil? && ![0, '0', false].include?(include[:channel_custom]) - - @include = [@include_custom, @include_channel_metadata, @include_channel_custom].reject { |flag| flag.to_s.empty? } + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include.push('channel') unless include[:channel_metadata].nil? || [0, '0', false].include?(include[:channel_metadata]) + @include.push('channel.type') unless include[:channel_type].nil? || [0, '0', false].include?(include[:channel_type]) + @include.push('channel.status') unless include[:channel_status].nil? || [0, '0', false].include?(include[:channel_status]) + @include.push('channel.custom') unless include[:channel_custom].nil? || [0, '0', false].include?(include[:channel_custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -47,7 +50,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include.sort.join(",") if @include && !@include.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -64,20 +67,20 @@ def path end def valid_envelope(parsed_response, req_res_objects) - memberships = parsed_response['data'].map { |uuid_membership| - membership = Hash.new - uuid_membership.each{ |k,v| membership[k.to_sym] = v } + memberships = parsed_response['data'].map do |uuid_membership| + membership = {} + uuid_membership.each { |k, v| membership[k.to_sym] = v } unless membership[:channel].nil? - channel_metadata = Hash.new - membership[:channel].each{ |k,v| channel_metadata[k.to_sym] = v } + channel_metadata = {} + membership[:channel].each { |k, v| channel_metadata[k.to_sym] = v } channel_metadata[:updated] = Date._parse(channel_metadata[:updated]) unless channel_metadata[:updated].nil? membership[:channel] = channel_metadata end membership[:updated] = Date._parse(membership[:updated]) unless membership[:updated].nil? membership - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/get_uuid_metadata.rb b/lib/pubnub/events/get_uuid_metadata.rb index aed4f0d74..5c687fa09 100644 --- a/lib/pubnub/events/get_uuid_metadata.rb +++ b/lib/pubnub/events/get_uuid_metadata.rb @@ -12,12 +12,16 @@ def initialize(options, app) @telemetry_name = :l_obj @uuid = options[:uuid].nil? ? app.user_id : options[:uuid] + @include = [] if options[:include] - @include = "custom" unless [0, '0', false].include?(options[:include][:custom]) + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) end # Single entity creation should return it's 'custom' field by default. - @include = "custom" if @include.nil? + @include = ['custom'] if @include.empty? super end @@ -29,7 +33,7 @@ def current_operation def parameters(signature = false) parameters = super(signature) - parameters[:include] = @include + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -46,8 +50,8 @@ def path def valid_envelope(parsed_response, req_res_objects) data = parsed_response['data'] - metadata = Hash.new - data.each{ |k,v| metadata[k.to_sym] = v } + metadata = {} + data.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? Pubnub::Envelope.new( diff --git a/lib/pubnub/events/set_channel_members.rb b/lib/pubnub/events/set_channel_members.rb index 8db950152..045a8aafb 100644 --- a/lib/pubnub/events/set_channel_members.rb +++ b/lib/pubnub/events/set_channel_members.rb @@ -12,25 +12,28 @@ def initialize(options, app) @telemetry_name = :l_obj @channel = options[:channel] @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] include = options[:include] - @include_count = [0, '0', false].include?(include[:count]) ? "0" : "1" unless include[:count].nil? - @include_custom = "custom" if !include[:custom].nil? && ![0, '0', false].include?(include[:custom]) - @include_uuid_metadata = "uuid" if !include[:uuid_metadata].nil? && ![0, '0', false].include?(include[:uuid_metadata]) - @include_uuid_custom = "uuid.custom" if !include[:uuid_custom].nil? && ![0, '0', false].include?(include[:uuid_custom]) - - @include = [@include_custom, @include_uuid_metadata, @include_uuid_custom].reject { |flag| flag.to_s.empty? } + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include.push('uuid') unless include[:uuid_metadata].nil? || [0, '0', false].include?(include[:uuid_metadata]) + @include.push('uuid.type') unless include[:uuid_type].nil? || [0, '0', false].include?(include[:uuid_type]) + @include.push('uuid.status') unless include[:uuid_status].nil? || [0, '0', false].include?(include[:uuid_status]) + @include.push('uuid.custom') unless include[:uuid_custom].nil? || [0, '0', false].include?(include[:uuid_custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end @uuids = options[:uuids] if options[:uuids] && !options[:uuids].empty? # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -41,6 +44,8 @@ def fire members = @uuids.map do |member| member_object = { uuid: { id: member[:uuid] } } member_object[:custom] = member[:custom] if member[:custom] && !member[:custom].empty? + member_object[:type] = member[:type] if member[:type] && !member[:type].empty? + member_object[:status] = member[:status] if member[:status] && !member[:status].empty? member_object end @@ -67,7 +72,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include.sort.join(",") if @include && !@include.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -84,12 +89,12 @@ def path end def valid_envelope(parsed_response, req_res_objects) - members = parsed_response['data'].map { |channel_member| - member = Hash.new + members = parsed_response['data'].map do |channel_member| + member = {} channel_member.each { |k, v| member[k.to_sym] = v } unless member[:uuid].nil? - uuid_metadata = Hash.new + uuid_metadata = {} member[:uuid].each { |k, v| uuid_metadata[k.to_sym] = v } uuid_metadata[:updated] = Date._parse(uuid_metadata[:updated]) unless uuid_metadata[:updated].nil? member[:uuid] = uuid_metadata @@ -97,7 +102,7 @@ def valid_envelope(parsed_response, req_res_objects) member[:updated] = Date._parse(member[:updated]) unless member[:updated].nil? member - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/set_channel_metadata.rb b/lib/pubnub/events/set_channel_metadata.rb index 7e3aba6cf..664400e57 100644 --- a/lib/pubnub/events/set_channel_metadata.rb +++ b/lib/pubnub/events/set_channel_metadata.rb @@ -15,12 +15,16 @@ def initialize(options, app) # Clean up user-provided metadata object from nils. @metadata = options[:metadata].delete_if { |_k, v| v.blank? } unless options[:metadata].nil? + @include = [] if options[:include] - @include = [0, '0', false].include?(options[:include][:custom]) ? "0" : "1" unless options[:include][:custom].nil? + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) end # Single entity creation should return it's 'custom' field by default. - @include = "custom" if @include.nil? + @include = ['custom'] if @include.empty? super end @@ -43,7 +47,7 @@ def current_operation def parameters(signature = false) parameters = super(signature) - parameters[:include] = @include + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -59,7 +63,7 @@ def path def valid_envelope(parsed_response, req_res_objects) data = parsed_response['data'] - metadata = Hash.new + metadata = {} data.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? diff --git a/lib/pubnub/events/set_memberships.rb b/lib/pubnub/events/set_memberships.rb index b582b4e34..f4e8a1ae3 100644 --- a/lib/pubnub/events/set_memberships.rb +++ b/lib/pubnub/events/set_memberships.rb @@ -12,25 +12,28 @@ def initialize(options, app) @telemetry_name = :l_obj @uuid = options[:uuid].nil? ? app.user_id : options[:uuid] @limit = [options[:limit], 100].min unless options[:limit].nil? - @sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty? + @sort = options[:sort].join(',') if options[:sort] && !options[:sort].empty? @filter = options[:filter] if options[:filter] && !options[:filter].empty? @start = options[:start] if options[:start] && !options[:start].empty? @end = options[:end] if options[:start] && !options[:end].empty? + @include = [] if options[:include] include = options[:include] - @include_count = [0, '0', false].include?(include[:count]) ? "0" : "1" unless include[:count].nil? - @include_custom = "custom" if !include[:custom].nil? && ![0, '0', false].include?(include[:custom]) - @include_channel_metadata = "channel" if !include[:channel_metadata].nil? && ![0, '0', false].include?(include[:channel_metadata]) - @include_channel_custom = "channel.custom" if !include[:channel_custom].nil? && ![0, '0', false].include?(include[:channel_custom]) - - @include = [@include_custom, @include_channel_metadata, @include_channel_custom].reject { |flag| flag.to_s.empty? } + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) + @include.push('channel') unless include[:channel_metadata].nil? || [0, '0', false].include?(include[:channel_metadata]) + @include.push('channel.type') unless include[:channel_type].nil? || [0, '0', false].include?(include[:channel_type]) + @include.push('channel.status') unless include[:channel_status].nil? || [0, '0', false].include?(include[:channel_status]) + @include.push('channel.custom') unless include[:channel_custom].nil? || [0, '0', false].include?(include[:channel_custom]) + @include_count = [0, '0', false].include?(include[:count]) ? '0' : '1' unless include[:count].nil? end @channels = options[:channels] if options[:channels] && !options[:channels].empty? # Collections by default return number of available entries. - @include_count = "1" if @include_count.nil? + @include_count = '1' if @include_count.nil? super end @@ -41,6 +44,8 @@ def fire memberships = @channels.map do |membership| membership_object = { channel: { id: membership[:channel] } } membership_object[:custom] = membership[:custom] if membership[:custom] && !membership[:custom].empty? + membership_object[:type] = membership[:type] if membership[:type] && !membership[:type].empty? + membership_object[:status] = membership[:status] if membership[:status] && !membership[:status].empty? membership_object end @@ -67,7 +72,7 @@ def parameters(signature = false) parameters[:start] = @start unless @start.nil? parameters[:end] = @end if @end && !@start parameters[:count] = @include_count unless @include_count.nil? - parameters[:include] = @include.sort.join(",") if @include && !@include.empty? + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -84,12 +89,12 @@ def path end def valid_envelope(parsed_response, req_res_objects) - memberships = parsed_response['data'].map { |uuid_membership| - membership = Hash.new + memberships = parsed_response['data'].map do |uuid_membership| + membership = {} uuid_membership.each { |k, v| membership[k.to_sym] = v } unless membership[:channel].nil? - channel_metadata = Hash.new + channel_metadata = {} membership[:channel].each { |k, v| channel_metadata[k.to_sym] = v } channel_metadata[:updated] = Date._parse(channel_metadata[:updated]) unless channel_metadata[:updated].nil? membership[:channel] = channel_metadata @@ -97,7 +102,7 @@ def valid_envelope(parsed_response, req_res_objects) membership[:updated] = Date._parse(membership[:updated]) unless membership[:updated].nil? membership - } + end Pubnub::Envelope.new( event: @event, diff --git a/lib/pubnub/events/set_uuid_metadata.rb b/lib/pubnub/events/set_uuid_metadata.rb index cefa7cd57..c26e4b231 100644 --- a/lib/pubnub/events/set_uuid_metadata.rb +++ b/lib/pubnub/events/set_uuid_metadata.rb @@ -15,12 +15,16 @@ def initialize(options, app) # Clean up user-provided metadata object from nils. @metadata = options[:metadata].delete_if { |_k, v| v.blank? } unless options[:metadata].nil? + @include = [] if options[:include] - @include = [0, '0', false].include?(options[:include][:custom]) ? "0" : "1" unless options[:include][:custom].nil? + include = options[:include] + @include.push('type') unless include[:type].nil? || [0, '0', false].include?(include[:type]) + @include.push('status') unless include[:status].nil? || [0, '0', false].include?(include[:status]) + @include.push('custom') unless include[:custom].nil? || [0, '0', false].include?(include[:custom]) end # Single entity creation should return it's 'custom' field by default. - @include = "custom" if @include.nil? + @include = ['custom'] if @include.empty? super end @@ -44,7 +48,7 @@ def current_operation def parameters(signature = false) parameters = super(signature) - parameters[:include] = @include + parameters[:include] = @include.sort.join(',') unless @include.empty? parameters end @@ -60,7 +64,7 @@ def path def valid_envelope(parsed_response, req_res_objects) data = parsed_response['data'] - metadata = Hash.new + metadata = {} data.each { |k, v| metadata[k.to_sym] = v } metadata[:updated] = Date._parse(metadata[:updated]) unless metadata[:updated].nil? diff --git a/lib/pubnub/validators/set_channel_metadata.rb b/lib/pubnub/validators/set_channel_metadata.rb index c54bfb6f3..834c14f0c 100644 --- a/lib/pubnub/validators/set_channel_metadata.rb +++ b/lib/pubnub/validators/set_channel_metadata.rb @@ -37,24 +37,28 @@ def validate_channel! end def validate_metadata! - raise( - ArgumentError.new(object: self, message: ':metadata is required for set channel metadata event.'), - ':metadata is required for set channel metadata event.' - ) if @metadata.nil? || @metadata.empty? + if @metadata.nil? || @metadata.empty? + raise( + ArgumentError.new(object: self, message: ':metadata is required for set channel metadata event.'), + ':metadata is required for set channel metadata event.' + ) + end - raise( - ArgumentError.new(object: self, message: ':metadata parameter for set channel metadata must be Hash.'), - ':metadata parameter for set channel metadata must be Hash.' - ) if @metadata.class != Hash + if @metadata.class != Hash + raise( + ArgumentError.new(object: self, message: ':metadata parameter for set channel metadata must be Hash.'), + ':metadata parameter for set channel metadata must be Hash.' + ) + end - known_channel_metadata_fields = %w[name description custom updated eTag] + known_channel_metadata_fields = %w[name description type status custom] @metadata.each_key do |field_name| - unless known_channel_metadata_fields.include?(field_name.to_s) - message = "Unknown channel metadata key: '#{field_name}'. Only following keys allowed: #{known_channel_metadata_fields.join(", ")}" + next if known_channel_metadata_fields.include?(field_name.to_s) + + message = "Unknown channel metadata key: '#{field_name}'. Only following keys allowed: #{known_channel_metadata_fields.join(', ')}" - raise(ArgumentError.new(object: self, message: message), message) - end + raise(ArgumentError.new(object: self, message: message), message) end end end diff --git a/lib/pubnub/validators/set_uuid_metadata.rb b/lib/pubnub/validators/set_uuid_metadata.rb index 25f0927f8..5fed4f9d7 100644 --- a/lib/pubnub/validators/set_uuid_metadata.rb +++ b/lib/pubnub/validators/set_uuid_metadata.rb @@ -37,24 +37,28 @@ def validate_uuid! end def validate_metadata! - raise( - ArgumentError.new(object: self, message: ':metadata is required for set uuid metadata event.'), - ':metadata is required for set uuid metadata event.' - ) if @metadata.nil? || @metadata.empty? + if @metadata.nil? || @metadata.empty? + raise( + ArgumentError.new(object: self, message: ':metadata is required for set uuid metadata event.'), + ':metadata is required for set uuid metadata event.' + ) + end - raise( - ArgumentError.new(object: self, message: ':metadata parameter for set uuid metadata must be Hash.'), - ':metadata parameter for set uuid metadata must be Hash.' - ) if @metadata.class != Hash + if @metadata.class != Hash + raise( + ArgumentError.new(object: self, message: ':metadata parameter for set uuid metadata must be Hash.'), + ':metadata parameter for set uuid metadata must be Hash.' + ) + end - known_uuid_metadata_fields = %w[name email externalId profileUrl custom updated eTag] + known_uuid_metadata_fields = %w[name email externalId profileUrl type status custom] @metadata.each_key do |field_name| - unless known_uuid_metadata_fields.include?(field_name.to_s) - message = "Unknown uuid metadata key: '#{field_name}'. Only following keys allowed: #{known_uuid_metadata_fields.join(", ")}" + next if known_uuid_metadata_fields.include?(field_name.to_s) + + message = "Unknown uuid metadata key: '#{field_name}'. Only following keys allowed: #{known_uuid_metadata_fields.join(', ')}" - raise(ArgumentError.new(object: self, message: message), message) - end + raise(ArgumentError.new(object: self, message: message), message) end end end diff --git a/spec/examples/set_channel_members_examples_spec.rb b/spec/examples/set_channel_members_examples_spec.rb index ed8a12c65..4037f405c 100644 --- a/spec/examples/set_channel_members_examples_spec.rb +++ b/spec/examples/set_channel_members_examples_spec.rb @@ -40,7 +40,7 @@ expect(envelope.status[:operation]).to eq(:set_channel_members) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -67,7 +67,7 @@ expect(envelope.status[:operation]).to eq(:set_channel_members) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -93,7 +93,48 @@ expect(envelope.status[:operation]).to eq(:set_channel_members) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) + end + end + + it "__channel__channel___uuids__uuid___include__custom_status_type_uuid_uuid_custom_uuid_status_uuid_type____http_sync__true_" do + VCR.use_cassette("examples/channel_members/007", record: :once) do + @pubnub.set_channel_metadata( + channel: 'channel', + metadata: { name: 'some_name', custom: { public: true }, type: :lobby, status: :open }, + http_sync: true + ) + @pubnub.set_uuid_metadata( + uuid: 'bob', + metadata: { name: 'magnum', custom: { announcer: true }, type: :admin, status: :away }, + http_sync: true + ) + + envelope = @pubnub.set_channel_members( + channel: 'channel', + uuids: [{ uuid: 'bob', custom: { can_write: true }, type: :info, status: :active }], + include: { + custom: true, + type: true, + status: true, + uuid_metadata: true, + uuid_custom: true, + uuid_type: true, + uuid_status: true + }, + http_sync: true) + + expect(envelope.is_a?(Pubnub::Envelope)).to eq true + expect(envelope.error?).to eq false + + expect(envelope.status[:code]).to eq(200) + expect(envelope.status[:operation]).to eq(:set_channel_members) + expect(envelope.status[:category]).to eq(:ack) + expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel") + expect(envelope.status[:client_request].query.include?("include=custom%2Cstatus%2Ctype%2Cuuid%2Cuuid.custom%2Cuuid.status%2Cuuid.type")).to eq true + expect(envelope.result[:data][:members][0][:type]).to eq("info") + expect(envelope.result[:data][:members][0][:status]).to eq("active") + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end end diff --git a/spec/examples/set_channel_metadata_examples_spec.rb b/spec/examples/set_channel_metadata_examples_spec.rb index 816dbd127..0002b5431 100644 --- a/spec/examples/set_channel_metadata_examples_spec.rb +++ b/spec/examples/set_channel_metadata_examples_spec.rb @@ -38,7 +38,7 @@ expect(envelope.status[:operation]).to eq(:set_channel_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -63,7 +63,7 @@ expect(envelope.status[:operation]).to eq(:set_channel_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -87,7 +87,30 @@ expect(envelope.status[:operation]).to eq(:set_channel_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("channel") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) + end + end + + it "__channel__channel___metadata__name_some_name_type_lobby_status_open___include__custom_type_status___http_sync__true_" do + VCR.use_cassette("examples/channel_metadata/007", record: :once) do + envelope = @pubnub.set_channel_metadata( + channel: 'channel', + metadata: { name: 'some_name', type: :lobby, status: :open }, + include: { custom: true, type: true, status: true }, + http_sync: true + ) + + expect(envelope.is_a?(Pubnub::Envelope)).to eq true + expect(envelope.error?).to eq false + + expect(envelope.status[:code]).to eq(200) + expect(envelope.status[:operation]).to eq(:set_channel_metadata) + expect(envelope.status[:category]).to eq(:ack) + expect(envelope.status[:client_request].query.include?('include=custom%2Cstatus%2Ctype')).to eq true + expect(envelope.status[:client_request].path.split('/').last).to eq("channel") + expect(envelope.result[:data][:type]).to eq("lobby") + expect(envelope.result[:data][:status]).to eq("open") + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end end diff --git a/spec/examples/set_memberships_examples_spec.rb b/spec/examples/set_memberships_examples_spec.rb index 793b4e57f..7f1639cf5 100644 --- a/spec/examples/set_memberships_examples_spec.rb +++ b/spec/examples/set_memberships_examples_spec.rb @@ -40,7 +40,7 @@ expect(envelope.status[:operation]).to eq(:set_memberships) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("ruby-test-uuid-client-one") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -63,7 +63,7 @@ expect(envelope.status[:operation]).to eq(:set_memberships) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -90,7 +90,7 @@ expect(envelope.status[:operation]).to eq(:set_memberships) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -116,7 +116,49 @@ expect(envelope.status[:operation]).to eq(:set_memberships) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) + end + end + + it "__uuid__bob___channels__channel___include__custom_status_type_channel_channel_custom_channel_status_channel_type___http_sync__true_" do + VCR.use_cassette("examples/memberships/009", record: :once) do + @pubnub.set_channel_metadata( + channel: 'channel', + metadata: { name: 'some_name', custom: { public: true }, type: :lobby, status: :open }, + http_sync: true + ) + @pubnub.set_uuid_metadata( + uuid: 'bob', + metadata: { name: 'magnum', custom: { announcer: true }, type: :admin, status: :away }, + http_sync: true + ) + + envelope = @pubnub.set_memberships( + uuid: 'bob', + channels: [{ channel: 'channel', custom: { read_only: false }, type: :system, status: :locked }], + include: { + custom: true, + type: true, + status: true, + channel_metadata: true, + channel_custom: true, + channel_type: true, + channel_status: true + }, + http_sync: true + ) + + expect(envelope.is_a?(Pubnub::Envelope)).to eq true + expect(envelope.error?).to eq false + + expect(envelope.status[:code]).to eq(200) + expect(envelope.status[:operation]).to eq(:set_memberships) + expect(envelope.status[:category]).to eq(:ack) + expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob") + expect(envelope.status[:client_request].query.include?("include=channel%2Cchannel.custom%2Cchannel.status%2Cchannel.type%2Ccustom%2Cstatus%2Ctype")).to eq true + expect(envelope.result[:data][:memberships][0][:type]).to eq("system") + expect(envelope.result[:data][:memberships][0][:status]).to eq("locked") + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end end diff --git a/spec/examples/set_uuid_metadata_examples_spec.rb b/spec/examples/set_uuid_metadata_examples_spec.rb index aad50bf4e..c99301181 100644 --- a/spec/examples/set_uuid_metadata_examples_spec.rb +++ b/spec/examples/set_uuid_metadata_examples_spec.rb @@ -38,7 +38,7 @@ expect(envelope.status[:operation]).to eq(:set_uuid_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("ruby-test-uuid-client-one") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -59,7 +59,7 @@ expect(envelope.status[:operation]).to eq(:set_uuid_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -84,7 +84,7 @@ expect(envelope.status[:operation]).to eq(:set_uuid_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end @@ -108,7 +108,30 @@ expect(envelope.status[:operation]).to eq(:set_uuid_metadata) expect(envelope.status[:category]).to eq(:ack) expect(envelope.status[:client_request].path.split('/').last).to eq("bob") - expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"}) + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) + end + end + + it "__uuid__bob___metadata__name_magnum_type_admin_status_away__include__custom_type_status___http_sync__true_" do + VCR.use_cassette("examples/uuid_metadata/009", record: :once) do + envelope = @pubnub.set_uuid_metadata( + uuid: 'bob', + metadata: { name: 'magnum', type: :admin, status: :away }, + include: { custom: true, type: true, status: true }, + http_sync: true + ) + + expect(envelope.is_a?(Pubnub::Envelope)).to eq true + expect(envelope.error?).to eq false + + expect(envelope.status[:code]).to eq(200) + expect(envelope.status[:operation]).to eq(:set_uuid_metadata) + expect(envelope.status[:category]).to eq(:ack) + expect(envelope.status[:client_request].query.include?('include=custom%2Cstatus%2Ctype')).to eq true + expect(envelope.status[:client_request].path.split('/').last).to eq("bob") + expect(envelope.result[:data][:type]).to eq("admin") + expect(envelope.result[:data][:status]).to eq("away") + expect(envelope.status[:config]).to eq({ :tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com" }) end end end diff --git a/spec/lib/events/channel_metadata_spec.rb b/spec/lib/events/channel_metadata_spec.rb index 8d41845ad..f0939f4a3 100644 --- a/spec/lib/events/channel_metadata_spec.rb +++ b/spec/lib/events/channel_metadata_spec.rb @@ -14,11 +14,24 @@ end it "set_channel_metadata_works" do - VCR.use_cassette("lib/events/set_channel_metadata", record: :once) do + VCR.use_cassette("lib/events/set_channel_metadata1", record: :once) do envelope = @pubnub.set_channel_metadata( channel: "rb_channel", - metadata: { name: "some_name", custom: { XXX: "YYYY" } }, - include: { custom: true } + metadata: { name: "some_name", custom: { XXX: "YYYY" }, type: :event, status: :completed }, + include: { custom: true }, + ).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + + it "set_channel_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/set_channel_metadata2", record: :once) do + envelope = @pubnub.set_channel_metadata( + channel: "rb_channel", + metadata: { name: "some_name", custom: { XXX: "YYYY" }, type: :event, status: :completed }, + include: { custom: true, status: true, type: true }, ).value expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new @@ -27,7 +40,7 @@ end it "get_channel_metadata_works" do - VCR.use_cassette("lib/events/get_channel_metadata", record: :once) do + VCR.use_cassette("lib/events/get_channel_metadata1", record: :once) do envelope = @pubnub.get_channel_metadata(channel: "rb_channel", include: { custom: true }).value expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new @@ -35,8 +48,17 @@ end end + it "get_channel_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/get_channel_metadata2", record: :once) do + envelope = @pubnub.get_channel_metadata(channel: "rb_channel", include: { custom: true, status: true, type: true }).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "get_all_channels_metadata_works" do - VCR.use_cassette("lib/events/get_all_channels_metadata", record: :once) do + VCR.use_cassette("lib/events/get_all_channels_metadata1", record: :once) do envelope = @pubnub.get_all_channels_metadata(limit: 5, include: { custom: true }).value expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new @@ -44,6 +66,15 @@ end end + it "get_all_channels_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/get_all_channels_metadata2", record: :once) do + envelope = @pubnub.get_all_channels_metadata(limit: 5, include: { custom: true, status: true, type: true }).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "get_all_channels_metadata_with_filter_and_secret" do VCR.use_cassette("lib/events/get_all_channels_metadata_with_filter_and_secret", record: :once) do Pubnub::GetAllChannelsMetadata.any_instance.stub(:current_time).and_return "1714133102" diff --git a/spec/lib/events/uuid_metadata_spec.rb b/spec/lib/events/uuid_metadata_spec.rb index 1170a42c8..8bb301565 100644 --- a/spec/lib/events/uuid_metadata_spec.rb +++ b/spec/lib/events/uuid_metadata_spec.rb @@ -38,6 +38,18 @@ end end + it "set_uuid_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/set_uuid_metadata3", record: :once) do + envelope = @pubnub.set_uuid_metadata( + metadata: { name: "magnum", custom: { XXX: "YYYY" }, type: :admin, status: :active }, + include: { custom: true, status: true, type: true }, + ).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "get_uuid_metadata_works_1" do VCR.use_cassette("lib/events/get_uuid_metadata1", record: :once) do envelope = @pubnub.get_uuid_metadata(uuid: "mg", include: { custom: true }).value @@ -56,8 +68,17 @@ end end + it "get_uuid_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/get_uuid_metadata3", record: :once) do + envelope = @pubnub.get_uuid_metadata(include: { custom: true, status: true, type: true }).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "get_all_uuid_metadata_works" do - VCR.use_cassette("lib/events/get_all_uuid_metadata", record: :once) do + VCR.use_cassette("lib/events/get_all_uuid_metadata1", record: :once) do envelope = @pubnub.get_all_uuid_metadata(limit: 5, include: { custom: true }).value expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new @@ -65,6 +86,15 @@ end end + it "get_all_uuid_metadata_works_with_included_status_type" do + VCR.use_cassette("lib/events/get_all_uuid_metadata2", record: :once) do + envelope = @pubnub.get_all_uuid_metadata(limit: 5, include: { custom: true, status: true, type: true }).value + + expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new + expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new + end + end + it "remove_uuid_metadata_works_1" do VCR.use_cassette("lib/events/remove_uuid_metadata1", record: :once) do envelope = @pubnub.remove_uuid_metadata(uuid: "mg").value From 6a02aa604f32ee8b849b9cb9201b2b5220916b16 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 21 Jan 2025 14:03:57 +0200 Subject: [PATCH 2/3] test(fixture): fix fixtures recorded with bug --- .../examples/channel_metadata/001.yml | 72 ++++----- .../examples/uuid_metadata/001.yml | 72 ++++----- .../examples/uuid_metadata/002.yml | 72 ++++----- .../examples/uuid_metadata/008.yml | 140 +++++++++--------- ...annels_metadata_with_filter_and_secret.yml | 140 +++++++++--------- .../lib/events/set_channel_metadata2.yml | 72 ++++----- 6 files changed, 284 insertions(+), 284 deletions(-) diff --git a/fixtures/vcr_cassettes/examples/channel_metadata/001.yml b/fixtures/vcr_cassettes/examples/channel_metadata/001.yml index d2895b99d..0bcf9f4ab 100644 --- a/fixtures/vcr_cassettes/examples/channel_metadata/001.yml +++ b/fixtures/vcr_cassettes/examples/channel_metadata/001.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel?auth=ruby-test-auth-client-one&include=1&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one - body: - encoding: UTF-8 - string: '{"name":"some_name"}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) - Accept: - - "*/*" - Date: - - Wed, 03 Mar 2021 23:14:08 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Wed, 03 Mar 2021 23:14:08 GMT - Content-Type: - - application/json - Content-Length: - - '141' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"channel","name":"some_name","description":null,"updated":"2021-03-03T23:11:02.017367Z","eTag":"Adqiu+akxbGf1wE"}}' - recorded_at: Wed, 03 Mar 2021 23:14:08 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/channel?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"some_name"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) + Accept: + - "*/*" + Date: + - Wed, 03 Mar 2021 23:14:08 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Mar 2021 23:14:08 GMT + Content-Type: + - application/json + Content-Length: + - '141' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"channel","name":"some_name","description":null,"updated":"2021-03-03T23:11:02.017367Z","eTag":"Adqiu+akxbGf1wE"}}' + recorded_at: Wed, 03 Mar 2021 23:14:08 GMT recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml b/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml index cb9522330..4bc5a5743 100644 --- a/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml +++ b/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid-client-one?auth=ruby-test-auth-client-one&include=1&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one - body: - encoding: UTF-8 - string: '{"name":"magnum"}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) - Accept: - - "*/*" - Date: - - Wed, 03 Mar 2021 23:25:23 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Wed, 03 Mar 2021 23:25:23 GMT - Content-Type: - - application/json - Content-Length: - - '185' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"ruby-test-uuid-client-one","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:13.101616Z","eTag":"AaaUxtPTpNTufg"}}' - recorded_at: Wed, 03 Mar 2021 23:25:23 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid-client-one?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) + Accept: + - "*/*" + Date: + - Wed, 03 Mar 2021 23:25:23 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Mar 2021 23:25:23 GMT + Content-Type: + - application/json + Content-Length: + - '185' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"ruby-test-uuid-client-one","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:13.101616Z","eTag":"AaaUxtPTpNTufg"}}' + recorded_at: Wed, 03 Mar 2021 23:25:23 GMT recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml b/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml index b8e812bc4..e5c06cf22 100644 --- a/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml +++ b/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&include=1&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one - body: - encoding: UTF-8 - string: '{"name":"magnum"}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) - Accept: - - "*/*" - Date: - - Wed, 03 Mar 2021 23:25:23 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Wed, 03 Mar 2021 23:25:23 GMT - Content-Type: - - application/json - Content-Length: - - '163' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:37.570828Z","eTag":"AaaUxtPTpNTufg"}}' - recorded_at: Wed, 03 Mar 2021 23:25:23 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) + Accept: + - "*/*" + Date: + - Wed, 03 Mar 2021 23:25:23 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Mar 2021 23:25:23 GMT + Content-Type: + - application/json + Content-Length: + - '163' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"bob","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:37.570828Z","eTag":"AaaUxtPTpNTufg"}}' + recorded_at: Wed, 03 Mar 2021 23:25:23 GMT recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml b/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml index d24cfd034..2d8dc5735 100644 --- a/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml +++ b/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml @@ -1,73 +1,73 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid-client-one?auth=ruby-test-auth-client-one&include=1&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one - body: - encoding: UTF-8 - string: '{"name":"magnum"}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) - Accept: - - "*/*" - Date: - - Wed, 03 Mar 2021 23:11:13 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Wed, 03 Mar 2021 23:11:13 GMT - Content-Type: - - application/json - Content-Length: - - '185' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"ruby-test-uuid-client-one","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:13.101616Z","eTag":"AaaUxtPTpNTufg"}}' - recorded_at: Wed, 03 Mar 2021 23:11:13 GMT -- request: - method: delete - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one - body: - encoding: UTF-8 - string: '' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) - Accept: - - "*/*" - Date: - - Wed, 03 Mar 2021 23:11:13 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Wed, 03 Mar 2021 23:11:13 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}' - recorded_at: Wed, 03 Mar 2021 23:11:13 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid-client-one?auth=ruby-test-auth-client-one&include=custom&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '{"name":"magnum"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) + Accept: + - "*/*" + Date: + - Wed, 03 Mar 2021 23:11:13 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Mar 2021 23:11:13 GMT + Content-Type: + - application/json + Content-Length: + - '185' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"ruby-test-uuid-client-one","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2021-03-03T23:11:13.101616Z","eTag":"AaaUxtPTpNTufg"}}' + recorded_at: Wed, 03 Mar 2021 23:11:13 GMT + - request: + method: delete + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/bob?auth=ruby-test-auth-client-one&pnsdk=PubNub-Ruby/4.5.0&uuid=ruby-test-uuid-client-one + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.5 (2019-10-01)) + Accept: + - "*/*" + Date: + - Wed, 03 Mar 2021 23:11:13 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Wed, 03 Mar 2021 23:11:13 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}' + recorded_at: Wed, 03 Mar 2021 23:11:13 GMT recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml index 099fbc0ae..08faf6f2e 100644 --- a/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml +++ b/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata_with_filter_and_secret.yml @@ -1,73 +1,73 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?include=1&pnsdk=PubNub-Ruby/5.3.3&signature=v2.YxJFOwRREFlkCGawTu7x8DVs-aBylBL0Ol5316h32Y4×tamp=1714133102&uuid=ruby-test-uuid - body: - encoding: UTF-8 - string: '{"name":"some_name","custom":{"XXX":"YYYY"}}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) - Accept: - - "*/*" - Date: - - Fri, 26 Apr 2024 12:05:02 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Fri, 26 Apr 2024 12:05:02 GMT - Content-Type: - - application/json - Content-Length: - - '161' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}}' - recorded_at: Fri, 26 Apr 2024 12:05:02 GMT -- request: - method: get - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?count=1&filter=(name==%22some_name%22)&include=custom&l_obj=0.576&limit=5&pnsdk=PubNub-Ruby/5.3.3&signature=v2.lVw9ZV0HvyHhhZ1WAU6rVFuvoZbMjuND5TwWhktrbgs×tamp=1714133102&uuid=ruby-test-uuid - body: - encoding: UTF-8 - string: '' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) - Accept: - - "*/*" - Date: - - Fri, 26 Apr 2024 12:05:02 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Fri, 26 Apr 2024 12:05:03 GMT - Content-Type: - - application/json - Content-Length: - - '366' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":[{"id":"[\"rb_channel\"]","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T11:43:29.824332Z","eTag":"AZTUtcvx6NDGLQ"},{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}],"totalCount":2,"next":"Mg"}' - recorded_at: Fri, 26 Apr 2024 12:05:03 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?include=custom&pnsdk=PubNub-Ruby/5.3.3&signature=v2.YxJFOwRREFlkCGawTu7x8DVs-aBylBL0Ol5316h32Y4×tamp=1714133102&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + Content-Type: + - application/json + Content-Length: + - '161' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}}' + recorded_at: Fri, 26 Apr 2024 12:05:02 GMT + - request: + method: get + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels?count=1&filter=(name==%22some_name%22)&include=custom&l_obj=0.576&limit=5&pnsdk=PubNub-Ruby/5.3.3&signature=v2.lVw9ZV0HvyHhhZ1WAU6rVFuvoZbMjuND5TwWhktrbgs×tamp=1714133102&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Fri, 26 Apr 2024 12:05:02 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Fri, 26 Apr 2024 12:05:03 GMT + Content-Type: + - application/json + Content-Length: + - '366' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":[{"id":"[\"rb_channel\"]","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2020-10-13T11:43:29.824332Z","eTag":"AZTUtcvx6NDGLQ"},{"id":"rb_channel","name":"some_name","description":null,"custom":{"XXX":"YYYY"},"updated":"2024-04-26T10:27:32.517008Z","eTag":"52da053241bacffd8c951390d273e7c9"}],"totalCount":2,"next":"Mg"}' + recorded_at: Fri, 26 Apr 2024 12:05:03 GMT recorded_with: VCR 6.2.0 diff --git a/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml b/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml index 2204dba2f..be7ca598b 100644 --- a/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml +++ b/fixtures/vcr_cassettes/lib/events/set_channel_metadata2.yml @@ -1,39 +1,39 @@ --- http_interactions: -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=type,status,custom&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid - body: - encoding: UTF-8 - string: '{"name":"some_name","custom":{"XXX":"YYYY"},"type":"event","status":"completed"}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) - Accept: - - "*/*" - Date: - - Tue, 21 Jan 2025 00:07:40 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 21 Jan 2025 00:07:40 GMT - Content-Type: - - application/json - Content-Length: - - '221' - Connection: - - keep-alive - Access-Control-Allow-Credentials: - - 'true' - Access-Control-Expose-Headers: - - "*" - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"type":"event","status":"completed","custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' - recorded_at: Tue, 21 Jan 2025 00:07:40 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/channels/rb_channel?auth=ruby-test-auth&include=custom,status,type&pnsdk=PubNub-Ruby/5.4.0&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"some_name","custom":{"XXX":"YYYY"},"type":"event","status":"completed"}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 3.2.2 (2023-03-30)) + Accept: + - "*/*" + Date: + - Tue, 21 Jan 2025 00:07:40 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 21 Jan 2025 00:07:40 GMT + Content-Type: + - application/json + Content-Length: + - '221' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Expose-Headers: + - "*" + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"rb_channel","name":"some_name","description":null,"type":"event","status":"completed","custom":{"XXX":"YYYY"},"updated":"2025-01-20T23:53:34.477431Z","eTag":"7c2191b2e73fd57c008b2549f7afca89"}}' + recorded_at: Tue, 21 Jan 2025 00:07:40 GMT recorded_with: VCR 6.3.1 From da3d56bd6011bd3d732d8a4a685231045d2cff2d Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 21 Jan 2025 14:12:34 +0200 Subject: [PATCH 3/3] test(fixture): fix fixtures recorded with bug --- .../lib/events/set_uuid_metadata1.yml | 148 +++++++++--------- .../lib/events/set_uuid_metadata2.yml | 148 +++++++++--------- 2 files changed, 148 insertions(+), 148 deletions(-) diff --git a/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml index 5bfa8f444..5bacab013 100644 --- a/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml +++ b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml @@ -1,78 +1,78 @@ --- http_interactions: -- request: - method: get - uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-test-auth,ruby-test-auth2&g=1&j=1&m=1&pnsdk=PubNub-Ruby/4.2.7&r=1&signature=v2.hl2CMq_6oYJtD323BI0V5I_xh84a29Pq_CAcSEPKxa8&target-uuid=ruby-test-uuid,ruby-test-uuid2×tamp=1602594632&ttl=1440&u=1&uuid=ruby-test-uuid&w=1 - body: - encoding: UTF-8 - string: '' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) - Accept: - - "*/*" - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - Content-Type: - - text/javascript; charset=UTF-8 - Content-Length: - - '475' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Methods: - - GET - Access-Control-Allow-Headers: - - Origin, X-Requested-With, Content-Type, Accept - Cache-Control: - - no-cache, no-store, must-revalidate - body: - encoding: UTF-8 - string: '{"message":"Success","payload":{"level":"uuid","subscribe_key":"sub-a-mock-key","ttl":1440,"uuids":{"ruby-test-uuid":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}},"ruby-test-uuid2":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}}}},"service":"Access + - request: + method: get + uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-test-auth,ruby-test-auth2&g=1&j=1&m=1&pnsdk=PubNub-Ruby/4.2.7&r=1&signature=v2.hl2CMq_6oYJtD323BI0V5I_xh84a29Pq_CAcSEPKxa8&target-uuid=ruby-test-uuid,ruby-test-uuid2×tamp=1602594632&ttl=1440&u=1&uuid=ruby-test-uuid&w=1 + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + Content-Type: + - text/javascript; charset=UTF-8 + Content-Length: + - '475' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + Access-Control-Allow-Headers: + - Origin, X-Requested-With, Content-Type, Accept + Cache-Control: + - no-cache, no-store, must-revalidate + body: + encoding: UTF-8 + string: '{"message":"Success","payload":{"level":"uuid","subscribe_key":"sub-a-mock-key","ttl":1440,"uuids":{"ruby-test-uuid":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}},"ruby-test-uuid2":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}}}},"service":"Access Manager","status":200}' - recorded_at: Tue, 13 Oct 2020 13:10:32 GMT -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/mg?auth=ruby-test-auth&include=1&pnsdk=PubNub-Ruby/4.2.7&signature=v2.xL1myJ1EozYQzxaQrCzfbOcAFPTctVp20mIyk_11Srw×tamp=1602594632&uuid=ruby-test-uuid - body: - encoding: UTF-8 - string: '{"name":"magnum","custom":{"XXX":"YYYY"}}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) - Accept: - - "*/*" - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:34 GMT - Content-Type: - - application/json - Content-Length: - - '163' - 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,"updated":"2020-10-13T13:10:33.333845Z","eTag":"Ad2eyIWXwJzBqAE"}}' - recorded_at: Tue, 13 Oct 2020 13:10:34 GMT + recorded_at: Tue, 13 Oct 2020 13:10:32 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/mg?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.7&signature=v2.xL1myJ1EozYQzxaQrCzfbOcAFPTctVp20mIyk_11Srw×tamp=1602594632&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"magnum","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Oct 2020 13:10:34 GMT + Content-Type: + - application/json + Content-Length: + - '163' + 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,"updated":"2020-10-13T13:10:33.333845Z","eTag":"Ad2eyIWXwJzBqAE"}}' + recorded_at: Tue, 13 Oct 2020 13:10:34 GMT recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml index 33f77ee5a..29a212cbb 100644 --- a/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml +++ b/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml @@ -1,78 +1,78 @@ --- http_interactions: -- request: - method: get - uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-test-auth,ruby-test-auth2&g=1&j=1&m=1&pnsdk=PubNub-Ruby/4.2.7&r=1&signature=v2.hl2CMq_6oYJtD323BI0V5I_xh84a29Pq_CAcSEPKxa8&target-uuid=ruby-test-uuid,ruby-test-uuid2×tamp=1602594632&ttl=1440&u=1&uuid=ruby-test-uuid&w=1 - body: - encoding: UTF-8 - string: '' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) - Accept: - - "*/*" - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - Content-Type: - - text/javascript; charset=UTF-8 - Content-Length: - - '475' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Methods: - - GET - Access-Control-Allow-Headers: - - Origin, X-Requested-With, Content-Type, Accept - Cache-Control: - - no-cache, no-store, must-revalidate - body: - encoding: UTF-8 - string: '{"message":"Success","payload":{"level":"uuid","subscribe_key":"sub-a-mock-key","ttl":1440,"uuids":{"ruby-test-uuid":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}},"ruby-test-uuid2":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}}}},"service":"Access + - request: + method: get + uri: http://ps.pndsn.com/v2/auth/grant/sub-key/sub-a-mock-key?auth=ruby-test-auth,ruby-test-auth2&g=1&j=1&m=1&pnsdk=PubNub-Ruby/4.2.7&r=1&signature=v2.hl2CMq_6oYJtD323BI0V5I_xh84a29Pq_CAcSEPKxa8&target-uuid=ruby-test-uuid,ruby-test-uuid2×tamp=1602594632&ttl=1440&u=1&uuid=ruby-test-uuid&w=1 + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + Content-Type: + - text/javascript; charset=UTF-8 + Content-Length: + - '475' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + Access-Control-Allow-Headers: + - Origin, X-Requested-With, Content-Type, Accept + Cache-Control: + - no-cache, no-store, must-revalidate + body: + encoding: UTF-8 + string: '{"message":"Success","payload":{"level":"uuid","subscribe_key":"sub-a-mock-key","ttl":1440,"uuids":{"ruby-test-uuid":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}},"ruby-test-uuid2":{"auths":{"ruby-test-auth":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1},"ruby-test-auth2":{"r":1,"w":1,"m":1,"d":0,"g":1,"u":1,"j":1}}}}},"service":"Access Manager","status":200}' - recorded_at: Tue, 13 Oct 2020 13:10:32 GMT -- request: - method: patch - uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid?auth=ruby-test-auth&include=1&pnsdk=PubNub-Ruby/4.2.7&signature=v2.xL1myJ1EozYQzxaQrCzfbOcAFPTctVp20mIyk_11Srw×tamp=1602594632&uuid=ruby-test-uuid - body: - encoding: UTF-8 - string: '{"name":"magnum","custom":{"XXX":"YYYY"}}' - headers: - User-Agent: - - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) - Accept: - - "*/*" - Date: - - Tue, 13 Oct 2020 13:10:32 GMT - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 13 Oct 2020 13:10:34 GMT - Content-Type: - - application/json - Content-Length: - - '163' - Connection: - - keep-alive - Access-Control-Allow-Origin: - - "*" - Access-Control-Allow-Credentials: - - 'true' - body: - encoding: UTF-8 - string: '{"status":200,"data":{"id":"ruby-test-uuid","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2020-10-13T13:10:33.333845Z","eTag":"Ad2eyIWXwJzBqAE"}}' - recorded_at: Tue, 13 Oct 2020 13:10:34 GMT + recorded_at: Tue, 13 Oct 2020 13:10:32 GMT + - request: + method: patch + uri: http://ps.pndsn.com/v2/objects/sub-a-mock-key/uuids/ruby-test-uuid?auth=ruby-test-auth&include=custom&pnsdk=PubNub-Ruby/4.2.7&signature=v2.xL1myJ1EozYQzxaQrCzfbOcAFPTctVp20mIyk_11Srw×tamp=1602594632&uuid=ruby-test-uuid + body: + encoding: UTF-8 + string: '{"name":"magnum","custom":{"XXX":"YYYY"}}' + headers: + User-Agent: + - HTTPClient/1.0 (2.8.3, ruby 2.6.3 (2019-04-16)) + Accept: + - "*/*" + Date: + - Tue, 13 Oct 2020 13:10:32 GMT + Content-Type: + - application/x-www-form-urlencoded + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 13 Oct 2020 13:10:34 GMT + Content-Type: + - application/json + Content-Length: + - '163' + Connection: + - keep-alive + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Credentials: + - 'true' + body: + encoding: UTF-8 + string: '{"status":200,"data":{"id":"ruby-test-uuid","name":"magnum","externalId":null,"profileUrl":null,"email":null,"updated":"2020-10-13T13:10:33.333845Z","eTag":"Ad2eyIWXwJzBqAE"}}' + recorded_at: Tue, 13 Oct 2020 13:10:34 GMT recorded_with: VCR 6.0.0