@@ -145,45 +145,36 @@ Task Unfurl(
145145 Task < PermalinkResponse > GetPermalink ( string channelId , string messageTs , CancellationToken cancellationToken = default ) ;
146146}
147147
148- public class ChatApi : IChatApi
148+ public class ChatApi ( ISlackApiClient client , SlackJsonSettings jsonSettings ) : IChatApi
149149{
150- private readonly ISlackApiClient _client ;
151- private readonly SlackJsonSettings _jsonSettings ;
152-
153- public ChatApi ( ISlackApiClient client , SlackJsonSettings jsonSettings )
154- {
155- _client = client ;
156- _jsonSettings = jsonSettings ;
157- }
158-
159150 public Task < MessageTsResponse > Delete ( string ts , string channelId , bool asUser = false , CancellationToken cancellationToken = default ) =>
160- _client . Post < MessageTsResponse > ( "chat.delete" , new Args
151+ client . Post < MessageTsResponse > ( "chat.delete" , new Args
161152 {
162153 { "ts" , ts } ,
163154 { "channel" , channelId } ,
164155 { "as_user" , asUser }
165156 } , cancellationToken ) ;
166157
167158 public Task < PermalinkResponse > GetPermalink ( string channelId , string messageTs , CancellationToken cancellationToken = default ) =>
168- _client . Get < PermalinkResponse > ( "chat.getPermalink" , new Args
159+ client . Get < PermalinkResponse > ( "chat.getPermalink" , new Args
169160 {
170161 { "channel" , channelId } ,
171162 { "message_ts" , messageTs }
172163 } , cancellationToken ) ;
173164
174165 public Task < MessageTsResponse > MeMessage ( string channel , string text , CancellationToken cancellationToken = default ) =>
175- _client . Post < MessageTsResponse > ( "chat.meMessage" , new Args
166+ client . Post < MessageTsResponse > ( "chat.meMessage" , new Args
176167 {
177168 { "channel" , channel } ,
178169 { "text" , text }
179170 } , cancellationToken ) ;
180171
181172 public Task < PostMessageResponse > PostMessage ( Message message , CancellationToken cancellationToken = default ) =>
182- _client . Post < PostMessageResponse > ( "chat.postMessage" , PopulateMessageArgs ( message , new Args ( ) ) ,
173+ client . Post < PostMessageResponse > ( "chat.postMessage" , PopulateMessageArgs ( message , new Args ( ) ) ,
183174 cancellationToken ) ;
184175
185176 public Task < ScheduleMessageResponse > ScheduleMessage ( Message message , DateTime postAt , CancellationToken cancellationToken = default ) =>
186- _client . Post < ScheduleMessageResponse > ( "chat.scheduleMessage" , PopulateMessageArgs ( message , new Args
177+ client . Post < ScheduleMessageResponse > ( "chat.scheduleMessage" , PopulateMessageArgs ( message , new Args
187178 {
188179 { "post_at" , postAt . ToTimestamp ( ) }
189180 } ) ,
@@ -205,12 +196,12 @@ private Args PopulateMessageArgs(Message message, Args args)
205196 args [ "icon_emoji" ] = message . IconEmoji ;
206197 args [ "thread_ts" ] = message . ThreadTs ;
207198 args [ "reply_broadcast" ] = message . ReplyBroadcast ;
208- args [ "metadata" ] = message . MetadataJson ?? MessageMetadata . FromObject ( message . MetadataObject , _jsonSettings ) ;
199+ args [ "metadata" ] = message . MetadataJson ?? MessageMetadata . FromObject ( message . MetadataObject , jsonSettings ) ;
209200 return args ;
210201 }
211202
212203 public Task DeleteScheduledMessage ( string messageId , string channelId , bool ? asUser = null , CancellationToken cancellationToken = default ) =>
213- _client . Post ( "chat.deleteScheduledMessage" , new Args
204+ client . Post ( "chat.deleteScheduledMessage" , new Args
214205 {
215206 { "scheduled_message_id" , messageId } ,
216207 { "channel" , channelId } ,
@@ -219,7 +210,7 @@ public Task DeleteScheduledMessage(string messageId, string channelId, bool? asU
219210 cancellationToken ) ;
220211
221212 public Task < PostEphemeralResponse > PostEphemeral ( string userId , Message message , CancellationToken cancellationToken = default ) =>
222- _client . Post < PostEphemeralResponse > ( "chat.postEphemeral" , new Args
213+ client . Post < PostEphemeralResponse > ( "chat.postEphemeral" , new Args
223214 {
224215 { "channel" , message . Channel } ,
225216 { "text" , message . Text } ,
@@ -243,7 +234,7 @@ public Task Unfurl(
243234 string userAuthUrl = null ,
244235 CancellationToken cancellationToken = default
245236 ) =>
246- _client . Post ( "chat.unfurl" , new Args
237+ client . Post ( "chat.unfurl" , new Args
247238 {
248239 { "channel" , channelId } ,
249240 { "ts" , ts } ,
@@ -264,7 +255,7 @@ public Task Unfurl(
264255 string userAuthUrl = null ,
265256 CancellationToken cancellationToken = default
266257 ) =>
267- _client . Post ( "chat.unfurl" , new Args
258+ client . Post ( "chat.unfurl" , new Args
268259 {
269260 { "source" , source } ,
270261 { "unfurl_id" , unfurlId } ,
@@ -276,7 +267,7 @@ public Task Unfurl(
276267 } , cancellationToken ) ;
277268
278269 public Task < MessageUpdateResponse > Update ( MessageUpdate messageUpdate , CancellationToken cancellationToken = default ) =>
279- _client . Post < MessageUpdateResponse > ( "chat.update" , new Args
270+ client . Post < MessageUpdateResponse > ( "chat.update" , new Args
280271 {
281272 { "ts" , messageUpdate . Ts } ,
282273 { "channel" , messageUpdate . ChannelId } ,
0 commit comments