From 439fef431ddd618f5c660daca8bbd5e2bc8e8f1c Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 18 Oct 2016 11:45:59 -0400 Subject: [PATCH] Added users_setPhoto and users_deletePhoto to Web API. --- .gitmodules | 2 +- CHANGELOG.md | 2 ++ bin/commands/users.rb | 20 +++++++++++++++ bin/commands/users_profile.rb | 2 +- lib/slack/web/api/endpoints/users.rb | 27 ++++++++++++++++++++ lib/slack/web/api/endpoints/users_profile.rb | 2 +- lib/slack/web/api/slack-api-ref | 2 +- 7 files changed, 53 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index db2ae52d..0a624af5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lib/slack/web/api/slack-api-ref"] path = lib/slack/web/api/slack-api-ref - url = git@github.com:dblock/slack-api-ref.git + url = git@github.com:slack-ruby/slack-api-ref.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d35649..2ba4a798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/bin/commands/users.rb b/bin/commands/users.rb index 4db6a7c3..e03252f4 100644 --- a/bin/commands/users.rb +++ b/bin/commands/users.rb @@ -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| @@ -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| diff --git a/bin/commands/users_profile.rb b/bin/commands/users_profile.rb index 14ea8730..a2769aa5 100644 --- a/bin/commands/users_profile.rb +++ b/bin/commands/users_profile.rb @@ -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.' diff --git a/lib/slack/web/api/endpoints/users.rb b/lib/slack/web/api/endpoints/users.rb index c67a0681..96989ee0 100644 --- a/lib/slack/web/api/endpoints/users.rb +++ b/lib/slack/web/api/endpoints/users.rb @@ -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. @@ -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. diff --git a/lib/slack/web/api/endpoints/users_profile.rb b/lib/slack/web/api/endpoints/users_profile.rb index 498112d3..6f2c46e8 100644 --- a/lib/slack/web/api/endpoints/users_profile.rb +++ b/lib/slack/web/api/endpoints/users_profile.rb @@ -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 diff --git a/lib/slack/web/api/slack-api-ref b/lib/slack/web/api/slack-api-ref index 58ffde63..3e5600db 160000 --- a/lib/slack/web/api/slack-api-ref +++ b/lib/slack/web/api/slack-api-ref @@ -1 +1 @@ -Subproject commit 58ffde63cd6940c1b49aff50ad494e042692588b +Subproject commit 3e5600db5cfa171c6743c8b3cf540dd4d6e6d02f