Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added users_setPhoto and users_deletePhoto to Web API. #116

Merged
merged 1 commit into from
Oct 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "lib/slack/web/api/slack-api-ref"]
path = lib/slack/web/api/slack-api-ref
url = [email protected]:dblock/slack-api-ref.git
url = [email protected]:slack-ruby/slack-api-ref.git
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### 0.7.8 (Next)

* [#108](https://github.com/slack-ruby/slack-ruby-client/pull/108): Use slack-ruby-danger gem - [@dblock](https://github.com/dblock).
* [#116](https://github.com/slack-ruby/slack-ruby-client/pull/116): Use [slack-ruby/slack-api-ref](https://github.com/slack-ruby/slack-api-ref) as machine API reference - [@dblock](https://github.com/dblock).
* [#116](https://github.com/slack-ruby/slack-ruby-client/pull/116): Added `users_setPhoto` and `users_deletePhoto` to Web API - [@dblock](https://github.com/dblock).
* Your contribution here.

### 0.7.7 (8/29/2016)
Expand Down
20 changes: 20 additions & 0 deletions bin/commands/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

desc 'Get info on members of your Slack team.'
command 'users' do |g|
g.desc 'This method allows the user to delete their profile image. It will clear whatever image is currently set.'
g.long_desc %( This method allows the user to delete their profile image. It will clear whatever image is currently set. )
g.command 'deletePhoto' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_deletePhoto(options))
end
end

g.desc "This method lets you find out information about a user's presence."
g.long_desc %( This method lets you find out information about a user's presence. Consult the presence documentation for more details. )
g.command 'getPresence' do |c|
Expand Down Expand Up @@ -45,6 +53,18 @@
end
end

g.desc 'This method allows the user to set their profile image. The caller can pass image data via image.'
g.long_desc %( This method allows the user to set their profile image. The caller can pass image data via image. )
g.command 'setPhoto' do |c|
c.flag 'image', desc: 'File contents via multipart/form-data.'
c.flag 'crop_x', desc: 'X coordinate of top-left corner of crop box.'
c.flag 'crop_y', desc: 'Y coordinate of top-left corner of crop box.'
c.flag 'crop_w', desc: 'Width/height of crop box (always square).'
c.action do |_global_options, options, _args|
puts JSON.dump($client.users_setPhoto(options))
end
end

g.desc "This method lets you set the calling user's manual presence."
g.long_desc %( This method lets you set the calling user's manual presence. Consult the presence documentation for more details. )
g.command 'setPresence' do |c|
Expand Down
2 changes: 1 addition & 1 deletion bin/commands/users_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
g.desc 'This method is used to set the profile information for a user.'
g.long_desc %( This method is used to set the profile information for a user. )
g.command 'set' do |c|
c.flag 'user', desc: 'ID of user to change. This argument may only be specified by team admins.'
c.flag 'user', desc: 'ID of user to change. This argument may only be specified by team admins on paid teams.'
c.flag 'profile', desc: 'Collection of key:value pairs presented as a URL-encoded JSON hash.'
c.flag 'name', desc: 'Name of a single key to set. Usable only if profile is not passed.'
c.flag 'value', desc: 'Value to set a single key to. Usable only if profile is not passed.'
Expand Down
27 changes: 27 additions & 0 deletions lib/slack/web/api/endpoints/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ module Web
module Api
module Endpoints
module Users
#
# This method allows the user to delete their profile image. It will clear whatever image is currently set.
#
# @see https://api.slack.com/methods/users.deletePhoto
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.deletePhoto.json
def users_deletePhoto(options = {})
post('users.deletePhoto', options)
end

#
# This method lets you find out information about a user's presence.
# Consult the presence documentation for more details.
Expand Down Expand Up @@ -63,6 +72,24 @@ def users_setActive(options = {})
post('users.setActive', options)
end

#
# This method allows the user to set their profile image. The caller can pass image data via image.
#
# @option options [Object] :image
# File contents via multipart/form-data.
# @option options [Object] :crop_x
# X coordinate of top-left corner of crop box.
# @option options [Object] :crop_y
# Y coordinate of top-left corner of crop box.
# @option options [Object] :crop_w
# Width/height of crop box (always square).
# @see https://api.slack.com/methods/users.setPhoto
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/users/users.setPhoto.json
def users_setPhoto(options = {})
throw ArgumentError.new('Required arguments :image missing') if options[:image].nil?
post('users.setPhoto', options)
end

#
# This method lets you set the calling user's manual presence.
# Consult the presence documentation for more details.
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/api/endpoints/users_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def users_profile_get(options = {})
# This method is used to set the profile information for a user.
#
# @option options [user] :user
# ID of user to change. This argument may only be specified by team admins.
# ID of user to change. This argument may only be specified by team admins on paid teams.
# @option options [Object] :profile
# Collection of key:value pairs presented as a URL-encoded JSON hash.
# @option options [Object] :name
Expand Down