Sha256: 6545bd5a9a03e46516c109815ae52df711c367c016663d33de0b2dcb744b0124
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
# Toplevel Pubnub module. # frozen_string_literal: true module Pubnub # Validator module that holds all validators modules module Validator # Validator for SetUuidMetadata event module SetUuidMetadata include CommonValidator def validate! return if @skip_validate validate_subscribe_key! validate_uuid! validate_metadata! end private def validate_subscribe_key! return unless @subscribe_key.nil? raise( ArgumentError.new(object: self, message: ':subscribe_key is required for set uuid metadata event.'), ':subscribe_key is required for set uuid metadata event.' ) end def validate_uuid! return unless @uuid.nil? || @uuid.empty? raise( ArgumentError.new(object: self, message: ':uuid is required for set uuid metadata event.'), ':uuid is required for set uuid metadata event.' ) end def validate_metadata! 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 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 type status custom] @metadata.each_key do |field_name| 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pubnub-5.5.0 | lib/pubnub/validators/set_uuid_metadata.rb |