Sha256: 2755e6f27e3c9ab23e0bfd4d70a733cbc7661eab69093a957bb7d9f9e8c9880f

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

# Toplevel Pubnub module.
# frozen_string_literal: true

module Pubnub
  # Holds RemoveUuidMetadata functionality
  class RemoveUuidMetadata < SingleEvent
    include Concurrent::Async
    include Pubnub::Validator::RemoveUuidMetadata

    def initialize(options, app)
      @event = current_operation
      @telemetry_name = :l_obj
      @uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
      super
    end

    def fire
      Pubnub.logger.debug('Pubnub::RemoveUuidMetadata') { "Fired event #{self.class}" }

      body = Formatter.format_message(@data, "", @random_iv, false)
      response = send_request(body)

      envelopes = fire_callbacks(handle(response, uri))
      finalize_event(envelopes)
      envelopes
    end

    private

    def current_operation
      Pubnub::Constants::OPERATION_REMOVE_UUID_METADATA
    end

    def path
      '/' + [
        'v2',
        'objects',
        @subscribe_key,
        'uuids',
        Formatter.encode(@uuid)
      ].join('/')
    end

    def valid_envelope(parsed_response, req_res_objects)
      Pubnub::Envelope.new(
        event: @event,
        event_options: @given_options,
        timetoken: nil,

        result: {
          code: req_res_objects[:response].code,
          operation: current_operation,
          client_request: req_res_objects[:request],
          server_response: req_res_objects[:response],
          data: parsed_response
        },

        status: {
          code: req_res_objects[:response].code,
          operation: current_operation,
          client_request: req_res_objects[:request],
          server_response: req_res_objects[:response],
          data: nil,
          category: Pubnub::Constants::STATUS_ACK,
          error: false,
          auto_retried: false,

          current_timetoken: nil,
          last_timetoken: nil,
          subscribed_channels: nil,
          subscribed_channel_groups: nil,

          config: get_config
        }
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pubnub-5.2.2 lib/pubnub/events/remove_uuid_metadata.rb
pubnub-5.2.1 lib/pubnub/events/remove_uuid_metadata.rb
pubnub-5.2.0 lib/pubnub/events/remove_uuid_metadata.rb
pubnub-5.1.2 lib/pubnub/events/remove_uuid_metadata.rb
pubnub-5.1.1 lib/pubnub/events/remove_uuid_metadata.rb
pubnub-5.1.0 lib/pubnub/events/remove_uuid_metadata.rb