44
55namespace SlackPhp \BlockKit \Surfaces ;
66
7+ use SlackPhp \BlockKit \{FauxProperty ,
8+ Property ,
9+ Surfaces \MessageDirective \DeleteOriginal ,
10+ Surfaces \MessageDirective \ReplaceOriginal ,
11+ Surfaces \MessageDirective \ResponseType };
712use SlackPhp \BlockKit \Blocks \Block ;
813use SlackPhp \BlockKit \Collections \{AttachmentCollection , BlockCollection };
9- use SlackPhp \BlockKit \{FauxProperty , Property };
1014use SlackPhp \BlockKit \Hydration \OmitType ;
1115use SlackPhp \BlockKit \Validation \{RequiresAnyOf , UniqueIds , ValidCollection , ValidString };
1216
@@ -19,8 +23,14 @@ class Message extends Surface
1923 #[Property, ValidCollection(50 , 0 ), UniqueIds]
2024 public BlockCollection $ blocks ;
2125
22- #[FauxProperty('response_type ' , 'replace_original ' , 'delete_original ' )]
23- public ?MessageDirective $ directive ;
26+ #[FauxProperty('response_type ' )]
27+ public ?ResponseType $ responseType ;
28+
29+ #[FauxProperty('replace_original ' )]
30+ public ?ReplaceOriginal $ replaceOriginal ;
31+
32+ #[FauxProperty('delete_original ' )]
33+ public ?DeleteOriginal $ deleteOriginal ;
2434
2535 #[Property, ValidString]
2636 public ?string $ text ;
@@ -40,19 +50,23 @@ class Message extends Surface
4050 */
4151 public function __construct (
4252 BlockCollection |array |null $ blocks = null ,
43- ?MessageDirective $ directive = null ,
53+ ?ResponseType $ directive = null ,
4454 ?string $ text = null ,
4555 AttachmentCollection |array |null $ attachments = null ,
4656 ?bool $ mrkdwn = null ,
4757 ?string $ threadTs = null ,
4858 ?bool $ ephemeral = null ,
59+ ?bool $ replaceOriginal = null ,
60+ ?bool $ deleteOriginal = null ,
4961 ) {
5062 parent ::__construct ($ blocks );
5163 $ this ->attachments = AttachmentCollection::wrap ($ attachments );
52- $ this ->directive ($ directive ?? ($ ephemeral ? MessageDirective ::EPHEMERAL : null ));
64+ $ this ->responseType ($ directive ?? ($ ephemeral ? ResponseType ::EPHEMERAL : null ));
5365 $ this ->text ($ text );
5466 $ this ->mrkdwn ($ mrkdwn );
5567 $ this ->threadTs ($ threadTs );
68+ $ this ->replaceOriginal ($ replaceOriginal );
69+ $ this ->deleteOriginal ($ deleteOriginal );
5670 }
5771
5872 /**
@@ -62,36 +76,40 @@ public function __construct(
6276 */
6377 public function ephemeral (): static
6478 {
65- return $ this ->directive (MessageDirective ::EPHEMERAL );
79+ return $ this ->responseType (ResponseType ::EPHEMERAL );
6680 }
6781
6882 /**
6983 * Configures message to send to the entire channel.
7084 */
7185 public function inChannel (): static
7286 {
73- return $ this ->directive (MessageDirective ::IN_CHANNEL );
87+ return $ this ->responseType (ResponseType ::IN_CHANNEL );
7488 }
7589
7690 /**
7791 * Configures message to "replace_original" mode.
7892 */
79- public function replaceOriginal (): static
93+ public function replaceOriginal (ReplaceOriginal | array | bool | null $ replaceOriginal = true ): static
8094 {
81- return $ this ->directive (MessageDirective::REPLACE_ORIGINAL );
95+ $ this ->replaceOriginal = ReplaceOriginal::fromValue ($ replaceOriginal );
96+
97+ return $ this ;
8298 }
8399
84100 /**
85101 * Configures message to "delete_original" mode.
86102 */
87- public function deleteOriginal (): static
103+ public function deleteOriginal (DeleteOriginal | array | bool | null $ deleteOriginal = true ): static
88104 {
89- return $ this ->directive (MessageDirective::DELETE_ORIGINAL );
105+ $ this ->deleteOriginal = DeleteOriginal::fromValue ($ deleteOriginal );
106+
107+ return $ this ;
90108 }
91109
92- public function directive ( MessageDirective |array |null $ directive ): static
110+ public function responseType ( ResponseType |array |null $ responseType ): static
93111 {
94- $ this ->directive = MessageDirective ::fromValue ($ directive );
112+ $ this ->responseType = ResponseType ::fromValue ($ responseType );
95113
96114 return $ this ;
97115 }
0 commit comments