File tree Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,9 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
8
8
JSON = " 682c06a0-de6a-54ab-a142-c8b1cf79cde6"
9
9
10
10
[compat ]
11
+ HTTP = " 0.8.8"
12
+ JSON = " 0.21.0"
11
13
julia = " 1"
12
- JSON = " 0.21.0"
13
- HTTP = " 0.8.8"
14
14
15
15
[extras ]
16
16
Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
Original file line number Diff line number Diff line change 1
1
module Slack
2
2
3
- greet () = print (" Hello World!" )
3
+ using HTTP
4
+ using JSON
5
+
6
+ include (" send.jl" )
7
+ export
8
+ sendtoslack
4
9
5
10
end # module
Original file line number Diff line number Diff line change
1
+ using Slack
2
+
3
+ """
4
+ sendtoslack(data::String, user_endpoint::String)
5
+ Takes in a string of data and the endpoint url and returns the HTTP response.
6
+ The response will be "ok" if the request is sent successfully.
7
+ """
8
+ function sendtoslack (data:: String , user_endpoint:: String )
9
+ HTTP. setuseragent! (" HTTP.jl" )
10
+
11
+
12
+ params = Dict (" text" => " $(data) " )
13
+ base_url = " https://hooks.slack.com"
14
+
15
+ endpoint = user_endpoint
16
+ url = base_url * endpoint
17
+
18
+ r = HTTP. post (url,
19
+ [" Content-Type" => " application/json" ],
20
+ JSON. json (params))
21
+
22
+ return (String (r. body))
23
+ end
Original file line number Diff line number Diff line change 1
1
using Slack
2
2
using Test
3
3
4
- @testset " Slack.jl" begin
5
- # Write your own tests here.
6
- end
4
+ endpoint = " /services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"
5
+ data = " Hello World"
6
+
7
+ response = sendtoslack (data, endpoint)
8
+ @test response == " ok"
You can’t perform that action at this time.
0 commit comments