slackened 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/slackened/block_kit/blocks/actions.rb +6 -1
- data/lib/slackened/block_kit/blocks/base.rb +3 -0
- data/lib/slackened/block_kit/blocks/context.rb +1 -1
- data/lib/slackened/block_kit/blocks/custom.rb +24 -0
- data/lib/slackened/block_kit/blocks/header.rb +1 -1
- data/lib/slackened/block_kit/blocks/section.rb +1 -1
- data/lib/slackened/block_kit/blocks/text.rb +1 -1
- data/lib/slackened/block_kit/blocks.rb +8 -3
- data/lib/slackened/block_kit/builder.rb +5 -1
- data/lib/slackened/error.rb +13 -0
- data/lib/slackened/methods.rb +1104 -0
- data/lib/slackened/response.rb +30 -0
- data/lib/slackened/surface/message.rb +19 -2
- data/lib/slackened/surface/modal.rb +93 -0
- data/lib/slackened.rb +3 -0
- data.tar.gz.sig +0 -0
- metadata +13 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bad9043ef7f4e72714275b03a7fb6fe42614d832c7140518db72606cbe2f923
|
4
|
+
data.tar.gz: bd67503ad085cd0a662ea3bfc08eb6263a2022f137fd01e0a6c06771a6548fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d546b2be2252060e8d8345a5ae56c5aa3cbdc1856f7c22bc28fb1586f04e561685cfa1763d94eabba73cd3fc6b76db1dbff2e6a8e4ba03f250938c4f40286e1f
|
7
|
+
data.tar.gz: 97727c761a96d7f0f16a7c351e13f68880e86c50e15621e9c23655ae9706d69388c024fb3aa4bd234f80962bbfadf9925b1ad07152071a452a28a0c10af51b00
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -8,6 +8,7 @@ module Slackened
|
|
8
8
|
module Blocks
|
9
9
|
class Actions < Slackened::BlockKit::Blocks::Base
|
10
10
|
MAX_LENGTH = 25
|
11
|
+
ELEMENTS = %i(button checkboxes datepicker datetimepicker email_text_input file_input image multi_static_select multi_external_select multi_users_select multi_conversations_select multi_channels_select number_input overflow plain_text_input radio_buttons rich_text_input option_groups external_select users_select conversations_select channels_select timepicker url_text_input workflow_button)
|
11
12
|
|
12
13
|
def initialize(*elements)
|
13
14
|
raise MinimumElementsError if elements.length.zero?
|
@@ -15,7 +16,11 @@ module Slackened
|
|
15
16
|
|
16
17
|
set({
|
17
18
|
type: :actions,
|
18
|
-
elements:
|
19
|
+
elements: elements.map do |element|
|
20
|
+
raise InvalidElement unless ELEMENTS.include? element.block[:type]
|
21
|
+
|
22
|
+
element
|
23
|
+
end
|
19
24
|
})
|
20
25
|
|
21
26
|
self
|
@@ -10,7 +10,7 @@ module Slackened
|
|
10
10
|
MAX_LENGTH = 10
|
11
11
|
|
12
12
|
def initialize(*elements)
|
13
|
-
raise
|
13
|
+
raise MaximumElementsError, "#{elements.count} can't be greater than #{MAX_LENGTH}" if elements.length > MAX_LENGTH
|
14
14
|
|
15
15
|
# TODO: need to allow for image
|
16
16
|
# https://api.slack.com/reference/block-kit/blocks#context
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module Slackened
|
6
|
+
module BlockKit
|
7
|
+
# proof of concept
|
8
|
+
module Blocks
|
9
|
+
class Custom < Slackened::BlockKit::Blocks::Base
|
10
|
+
def initialize(block)
|
11
|
+
raise MustBeHash unless block.is_a? Hash
|
12
|
+
|
13
|
+
set(block)
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_h
|
19
|
+
@block.to_h
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -10,7 +10,7 @@ module Slackened
|
|
10
10
|
MAX_LENGTH = 150
|
11
11
|
|
12
12
|
def initialize(plain_text)
|
13
|
-
raise
|
13
|
+
raise MaximumCharactersError, "#{plain_text} can't be greater than #{MAX_LENGTH}" if plain_text.length > MAX_LENGTH
|
14
14
|
raise MustBeString unless plain_text.is_a? String
|
15
15
|
|
16
16
|
set({
|
@@ -10,7 +10,7 @@ module Slackened
|
|
10
10
|
MAX_LENGTH = 10
|
11
11
|
|
12
12
|
def initialize(*fields) # rubocop:disable Metrics/MethodLength
|
13
|
-
raise
|
13
|
+
raise MaximumFieldsError, "#{fields.count} can't be greater than #{MAX_LENGTH}" if fields.length > MAX_LENGTH
|
14
14
|
raise MustBeString unless fields.all? { |f| f.is_a? String }
|
15
15
|
|
16
16
|
if fields.one?
|
@@ -10,7 +10,7 @@ module Slackened
|
|
10
10
|
MAX_LENGTH = 3000
|
11
11
|
|
12
12
|
def initialize(markdown)
|
13
|
-
raise
|
13
|
+
raise MaximumCharactersError, "#{markdown.length} can't be greater than #{MAX_LENGTH}" if markdown.length > MAX_LENGTH
|
14
14
|
|
15
15
|
set({
|
16
16
|
type: :mrkdwn,
|
@@ -8,9 +8,6 @@ module Slackened
|
|
8
8
|
module Blocks
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
# alphabetical
|
12
|
-
def_delegators self, :actions, :button, :context, :divider, :header, :section, :text
|
13
|
-
|
14
11
|
# alphabetical
|
15
12
|
class << self
|
16
13
|
def actions(*elements)
|
@@ -25,6 +22,10 @@ module Slackened
|
|
25
22
|
Context.new(*elements)
|
26
23
|
end
|
27
24
|
|
25
|
+
def custom(block)
|
26
|
+
Custom.new(block)
|
27
|
+
end
|
28
|
+
|
28
29
|
def divider
|
29
30
|
Divider.new
|
30
31
|
end
|
@@ -41,6 +42,10 @@ module Slackened
|
|
41
42
|
Text.new(*args)
|
42
43
|
end
|
43
44
|
end
|
45
|
+
|
46
|
+
# alphabetical
|
47
|
+
def_delegators self, :actions, :button, :context, :custom, :divider, :header, :section, :text
|
48
|
+
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slackened
|
4
|
+
class Error < StandardError
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(http_response)
|
8
|
+
@response = http_response
|
9
|
+
|
10
|
+
super("#{@response.code} #{@response.message}: #{@response.body}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|