forked from BlakeWilliams/Elixir-Slack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces a mix task called `update_slack_api` which fetches the Slack documentation github repo and copies the json API documentation to `lib/slack/web/docs`. The application uses these json documentation files to generates the modules necessary for working with the entire Slack web API. This change does introduce a breaking change to the bot API. Maps will no longer use atoms as their keys and will now be binaries.
- Loading branch information
1 parent
1926281
commit 488ad22
Showing
98 changed files
with
2,372 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule Mix.Tasks.UpdateSlackApi do | ||
use Mix.Task | ||
@dir System.tmp_dir | ||
|
||
def run(_) do | ||
try do | ||
System.cmd("git", ["clone", "https://github.com/slackhq/slack-api-docs", "#{@dir}/slack-api-docs"]) | ||
files | ||
|> filter_json | ||
|> copy_files | ||
after | ||
System.cmd("rm", ["-rf", "#{@dir}/slack-api-docs"]) | ||
end | ||
end | ||
|
||
defp files do | ||
File.ls!("#{@dir}slack-api-docs/methods") | ||
end | ||
|
||
defp filter_json(files) do | ||
Enum.filter(files, fn(file) -> | ||
String.ends_with?(file, "json") | ||
end) | ||
end | ||
|
||
defp copy_files(files) do | ||
File.mkdir_p!("lib/slack/web/docs") | ||
Enum.map(files, fn(file) -> | ||
origin = "#{@dir}slack-api-docs/methods/#{file}" | ||
dest = "lib/slack/web/docs/#{file}" | ||
File.cp!(origin, dest) | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"desc": "Checks API calling code.", | ||
|
||
"args": { | ||
"error": { | ||
"required" : false, | ||
"example" : "my_error", | ||
"desc" : "Error response to return" | ||
}, | ||
"foo": { | ||
"required" : false, | ||
"example" : "bar", | ||
"desc" : "example property to return" | ||
} | ||
}, | ||
|
||
"errors": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"desc": "Checks authentication & identity.", | ||
|
||
"args": { | ||
}, | ||
|
||
"errors": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"desc": "Archives a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to archive" | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"already_archived" : "Channel has already been archived.", | ||
"cant_archive_general" : "You cannot archive the general channel", | ||
"last_ra_channel" : "You cannot archive the last channel for a restricted account", | ||
"restricted_action" : "A team preference prevents the authenticated user from archiving." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"desc": "Creates a channel.", | ||
|
||
"args": { | ||
"name": { | ||
"required" : true, | ||
"desc" : "Name of channel to create", | ||
"example" : "mychannel" | ||
} | ||
}, | ||
|
||
"errors": { | ||
"name_taken" : "A channel cannot be created with the given name.", | ||
"restricted_action": "A team preference prevents the authenticated user from creating channels.", | ||
"no_channel" : "Value passed for `name` was empty." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"desc": "Fetches history of messages and events from a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to fetch history for." | ||
}, | ||
|
||
"latest": { | ||
"type" : "timestamp", | ||
"required" : false, | ||
"default" : "now", | ||
"desc" : "End of time range of messages to include in results." | ||
}, | ||
|
||
"oldest": { | ||
"type" : "timestamp", | ||
"required" : false, | ||
"default" : "0", | ||
"desc" : "Start of time range of messages to include in results." | ||
}, | ||
|
||
"inclusive": { | ||
"example" : 1, | ||
"default" : 0, | ||
"desc" : "Include messages with latest or oldest timestamp in results." | ||
}, | ||
|
||
"count": { | ||
"required" : false, | ||
"default" : "100", | ||
"example" : "100", | ||
"desc" : "Number of messages to return, between 1 and 1000." | ||
}, | ||
|
||
"unreads": { | ||
"required" : false, | ||
"default" : 0, | ||
"example" : 1, | ||
"desc" : "Include `unread_count_display` in the output?" | ||
} | ||
}, | ||
|
||
"errors": { | ||
|
||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"invalid_ts_latest" : "Value passed for `latest` was invalid", | ||
"invalid_ts_oldest" : "Value passed for `oldest` was invalid" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"desc": "Gets information about a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to get info on" | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"desc": "Invites a user to a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to invite user to." | ||
}, | ||
"user": { | ||
"type" : "user", | ||
"required" : true, | ||
"desc" : "User to invite to channel." | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"user_not_found": "Value passed for `user` was invalid.", | ||
"cant_invite_self" : "Authenticated user cannot invite themselves to a channel.", | ||
"not_in_channel": "Authenticated user is not in the channel.", | ||
"already_in_channel": "Invited user is already in the channel.", | ||
"is_archived" : "Channel has been archived.", | ||
"cant_invite" : "User cannot be invited to this channel." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"desc": "Joins a channel, creating it if needed.", | ||
|
||
"args": { | ||
"name": { | ||
"required" : true, | ||
"desc" : "Name of channel to join" | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"name_taken" : "A channel cannot be created with the given name.", | ||
"restricted_action": "A team preference prevents the authenticated user from creating channels.", | ||
"no_channel" : "Value passed for `name` was empty.", | ||
"is_archived" : "Channel has been archived." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"desc": "Removes a user from a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to remove user from." | ||
}, | ||
"user": { | ||
"type" : "user", | ||
"required" : true, | ||
"desc" : "User to remove from channel." | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"user_not_found" : "Value passed for `user` was invalid.", | ||
"cant_kick_self" : "Authenticated user can't kick themselves from a channel.", | ||
"not_in_channel" : "User was not in the channel.", | ||
"cant_kick_from_general": "User cannot be removed from #general.", | ||
"cant_kick_from_last_channel": "User cannot be removed from the last channel they're in.", | ||
"restricted_action" : "A team preference prevents the authenticated user from kicking." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"desc": "Leaves a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to leave" | ||
} | ||
}, | ||
|
||
"errors": { | ||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"is_archived" : "Channel has been archived.", | ||
"cant_leave_general" : "Authenticated user cannot leave the general channel" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"desc": "Lists all channels in a Slack team.", | ||
|
||
"args": { | ||
"exclude_archived": { | ||
"example" : 1, | ||
"default" : 0, | ||
"desc" : "Don't return archived channels." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"desc": "Sets the read cursor in a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to set reading cursor in." | ||
}, | ||
|
||
"ts": { | ||
"type" : "timestamp", | ||
"required" : true, | ||
"desc" : "Timestamp of the most recently seen message." | ||
} | ||
}, | ||
|
||
"errors": { | ||
|
||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"invalid_timestamp" : "Value passed for `timestamp` was invalid.", | ||
"not_in_channel" : "Caller is not a member of the channel." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"desc": "Renames a channel.", | ||
|
||
"args": { | ||
"channel": { | ||
"type" : "channel", | ||
"required" : true, | ||
"desc" : "Channel to rename" | ||
}, | ||
|
||
"name": { | ||
"required" : true, | ||
"desc" : "New name for channel." | ||
} | ||
}, | ||
|
||
"errors": { | ||
|
||
"channel_not_found" : "Value passed for `channel` was invalid.", | ||
"not_in_channel" : "Caller is not a member of the channel.", | ||
"not_authorized" : "Caller cannot rename this channel", | ||
"invalid_name" : "New name is invalid", | ||
"name_taken" : "New channel name is taken" | ||
} | ||
} |
Oops, something went wrong.