Sha256: 42783c88ba53d02a5202dd9d897c75b4b685e18cfe0fee079443abab111c44e8

Contents?: true

Size: 960 Bytes

Versions: 5

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

require "json_schematize"
require "json_schematize/generator"

require "slack_bot/events/schemas/data_payload"

module SlackBot
  module Events
    module Schemas
      class SocketPayload < JsonSchematize::Generator
        schema_default option: :dig_type, value: :string

        add_field name: :envelope_id, type: String

        add_field name: :payload, type: SlackBot::Events::Schemas::DataPayload

        add_field name: :type, type: String
        add_field name: :accepts_response_payload, type: JsonSchematize::Boolean
        add_field name: :retry_attempt, type: Integer
        add_field name: :retry_reason, type: String


        def type
          payload.event.type
        end

        def tldr
          retry_language = "#{retry_attempt}"
          retry_language += ":#{retry_reason}" if retry_attempt > 0
          "#{payload.event.tldr}; retry:#{retry_language}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack_bot-events-0.4.4 lib/slack_bot/events/schemas/socket_payload.rb
slack_bot-events-0.4.2 lib/slack_bot/events/schemas/socket_payload.rb
slack_bot-events-0.4.1 lib/slack_bot/events/schemas/socket_payload.rb
slack_bot-events-0.4.0 lib/slack_bot/events/schemas/socket_payload.rb
slack_bot-events-0.3.0 lib/slack_bot/events/schemas/socket_payload.rb