factor-connector-slack 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| @@ -2,7 +2,7 @@ require 'factor-connector-api' | |
| 2 2 | 
             
            require 'rest_client'
         | 
| 3 3 |  | 
| 4 4 | 
             
            Factor::Connector.service 'slack_channel' do
         | 
| 5 | 
            -
              action  | 
| 5 | 
            +
              action 'list' do |params|
         | 
| 6 6 |  | 
| 7 7 | 
             
                token = params['token']
         | 
| 8 8 |  | 
| @@ -12,13 +12,18 @@ Factor::Connector.service 'slack_channel' do | |
| 12 12 | 
             
                  token: token
         | 
| 13 13 | 
             
                }
         | 
| 14 14 |  | 
| 15 | 
            -
                info  | 
| 15 | 
            +
                info 'Getting all Channels'
         | 
| 16 16 | 
             
                begin
         | 
| 17 17 | 
             
                  uri          = 'https://slack.com/api/channels.list'
         | 
| 18 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 18 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 19 | 
            +
                                                      url: uri,
         | 
| 20 | 
            +
                                                      method: 'POST',
         | 
| 21 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 22 | 
            +
                                                      payload: payload
         | 
| 23 | 
            +
                                                    )
         | 
| 19 24 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 20 25 | 
             
                rescue
         | 
| 21 | 
            -
                   | 
| 26 | 
            +
                  raise 'failed to connect to Slack API, check your credentials'
         | 
| 22 27 | 
             
                end
         | 
| 23 28 |  | 
| 24 29 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -26,114 +31,139 @@ Factor::Connector.service 'slack_channel' do | |
| 26 31 | 
             
                action_callback response
         | 
| 27 32 | 
             
              end
         | 
| 28 33 |  | 
| 29 | 
            -
              action  | 
| 30 | 
            -
                token | 
| 31 | 
            -
                 | 
| 32 | 
            -
                 | 
| 34 | 
            +
              action 'invite' do |params|
         | 
| 35 | 
            +
                token        = params['token']
         | 
| 36 | 
            +
                channel_name = params['channel']
         | 
| 37 | 
            +
                user_name    = params['user']
         | 
| 33 38 |  | 
| 34 39 | 
             
                fail 'Token is required' unless token
         | 
| 35 | 
            -
                fail 'Channel is required' unless  | 
| 36 | 
            -
                fail 'Username is required' unless  | 
| 40 | 
            +
                fail 'Channel is required' unless channel_name
         | 
| 41 | 
            +
                fail 'Username is required' unless user_name
         | 
| 37 42 |  | 
| 38 43 | 
             
                payload = {
         | 
| 39 44 | 
             
                  token: token
         | 
| 40 45 | 
             
                }
         | 
| 41 46 |  | 
| 42 | 
            -
                info  | 
| 47 | 
            +
                info 'Getting all Channels'
         | 
| 43 48 | 
             
                begin
         | 
| 44 49 | 
             
                  uri          = 'https://slack.com/api/channels.list'
         | 
| 45 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 50 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 51 | 
            +
                                                      url: uri,
         | 
| 52 | 
            +
                                                      method: 'POST',
         | 
| 53 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 54 | 
            +
                                                      payload: payload
         | 
| 55 | 
            +
                                                    )
         | 
| 46 56 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 47 57 | 
             
                rescue
         | 
| 48 | 
            -
                  fail  | 
| 58 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 49 59 | 
             
                end
         | 
| 50 60 |  | 
| 51 61 | 
             
                fail response['error'] unless response['ok']
         | 
| 52 62 |  | 
| 53 | 
            -
                response['channels']. | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
                  end
         | 
| 57 | 
            -
                end
         | 
| 63 | 
            +
                channel = response['channels'].find { |c| c['name'] || c['id'] == channel_name }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                fail "Channel '#{channel_name}' wasn't found" unless channel
         | 
| 58 66 |  | 
| 59 | 
            -
                 | 
| 67 | 
            +
                channel_id = channel['id']
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                info 'Getting Users'
         | 
| 60 70 | 
             
                begin
         | 
| 61 71 | 
             
                  uri          = 'https://slack.com/api/users.list'
         | 
| 62 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 72 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 73 | 
            +
                                                      url: uri,
         | 
| 74 | 
            +
                                                      method: 'POST',
         | 
| 75 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 76 | 
            +
                                                      payload: payload
         | 
| 77 | 
            +
                                                    )
         | 
| 63 78 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 64 79 | 
             
                rescue
         | 
| 65 | 
            -
                  fail  | 
| 80 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 66 81 | 
             
                end
         | 
| 67 82 |  | 
| 68 83 | 
             
                fail response['error'] unless response['ok']
         | 
| 69 84 |  | 
| 70 | 
            -
                response['members']. | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
                 | 
| 85 | 
            +
                user = response['members'].find { |m| m['name'] || m['id'] == user_name }
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                fail "User '#{user_name}' was not found" unless user
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                user_id = user['id']
         | 
| 75 90 |  | 
| 76 91 | 
             
                payload = {
         | 
| 77 92 | 
             
                  token:   token,
         | 
| 78 | 
            -
                  channel:  | 
| 79 | 
            -
                  user:     | 
| 93 | 
            +
                  channel: channel_id,
         | 
| 94 | 
            +
                  user:    user_id
         | 
| 80 95 | 
             
                }
         | 
| 81 96 |  | 
| 82 97 | 
             
                info "Inviting #{user} to #{channel}"
         | 
| 83 98 | 
             
                begin
         | 
| 84 99 | 
             
                  uri          = 'https://slack.com/api/channels.invite'
         | 
| 85 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 100 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 101 | 
            +
                                                      url: uri,
         | 
| 102 | 
            +
                                                      method: 'POST',
         | 
| 103 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 104 | 
            +
                                                      payload: payload
         | 
| 105 | 
            +
                                                    )
         | 
| 86 106 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 87 107 | 
             
                rescue
         | 
| 88 | 
            -
                  fail  | 
| 108 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 89 109 | 
             
                end
         | 
| 90 110 |  | 
| 91 | 
            -
                 | 
| 111 | 
            +
                warn response['error'] unless response['ok']
         | 
| 92 112 |  | 
| 93 113 | 
             
                action_callback response
         | 
| 94 114 | 
             
              end
         | 
| 95 115 |  | 
| 96 | 
            -
              action  | 
| 116 | 
            +
              action 'history' do |params|
         | 
| 97 117 |  | 
| 98 | 
            -
                token | 
| 99 | 
            -
                 | 
| 118 | 
            +
                token        = params['token']
         | 
| 119 | 
            +
                channel_name = params['channel']
         | 
| 100 120 |  | 
| 101 121 | 
             
                fail 'Token is required' unless token
         | 
| 102 | 
            -
                fail 'Channel is required' unless  | 
| 122 | 
            +
                fail 'Channel is required' unless channel_name
         | 
| 103 123 |  | 
| 104 124 | 
             
                payload = {
         | 
| 105 125 | 
             
                  token: token
         | 
| 106 126 | 
             
                }
         | 
| 107 127 |  | 
| 108 | 
            -
                info  | 
| 128 | 
            +
                info 'Getting all Channels'
         | 
| 109 129 | 
             
                begin
         | 
| 110 130 | 
             
                  uri          = 'https://slack.com/api/channels.list'
         | 
| 111 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 131 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 132 | 
            +
                                                      url: uri,
         | 
| 133 | 
            +
                                                      method: 'POST',
         | 
| 134 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 135 | 
            +
                                                      payload: payload
         | 
| 136 | 
            +
                                                    )
         | 
| 112 137 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 113 138 | 
             
                rescue
         | 
| 114 | 
            -
                  fail  | 
| 139 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 115 140 | 
             
                end
         | 
| 116 141 |  | 
| 117 142 | 
             
                fail response['error'] unless response['ok']
         | 
| 118 143 |  | 
| 119 | 
            -
                response['channels']. | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
                 | 
| 144 | 
            +
                channel = response['channels'].find { |c| c['name'] || c['id'] == channel_name }
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                fail "Channel '#{channel_name}' wasn't found" unless channel
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                channel_id = channel['id']
         | 
| 124 149 |  | 
| 125 150 | 
             
                payload = {
         | 
| 126 151 | 
             
                  token: token,
         | 
| 127 | 
            -
                  channel:  | 
| 152 | 
            +
                  channel: channel_id
         | 
| 128 153 | 
             
                }
         | 
| 129 154 |  | 
| 130 155 | 
             
                info "Getting History for #{channel}"
         | 
| 131 156 | 
             
                begin
         | 
| 132 157 | 
             
                  uri = 'https://slack.com/api/channels.history'
         | 
| 133 | 
            -
                   | 
| 134 | 
            -
             | 
| 158 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 159 | 
            +
                                                      url: uri,
         | 
| 160 | 
            +
                                                      method: 'POST',
         | 
| 161 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 162 | 
            +
                                                      payload: payload
         | 
| 163 | 
            +
                                                    )
         | 
| 164 | 
            +
                  response     = JSON.parse(raw_response)
         | 
| 135 165 | 
             
                rescue
         | 
| 136 | 
            -
                  fail  | 
| 166 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 137 167 | 
             
                end
         | 
| 138 168 |  | 
| 139 169 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -141,50 +171,60 @@ Factor::Connector.service 'slack_channel' do | |
| 141 171 | 
             
                action_callback response
         | 
| 142 172 | 
             
              end
         | 
| 143 173 |  | 
| 144 | 
            -
              action  | 
| 174 | 
            +
              action 'topic' do |params|
         | 
| 145 175 |  | 
| 146 | 
            -
                token | 
| 147 | 
            -
                 | 
| 148 | 
            -
                topic | 
| 176 | 
            +
                token        = params['token']
         | 
| 177 | 
            +
                channel_name = params['channel']
         | 
| 178 | 
            +
                topic        = params['topic']
         | 
| 149 179 |  | 
| 150 180 | 
             
                fail 'Token is required' unless token
         | 
| 151 | 
            -
                fail 'Channel is required' unless  | 
| 181 | 
            +
                fail 'Channel is required' unless channel_name
         | 
| 152 182 | 
             
                fail 'Topic is required' unless topic
         | 
| 153 183 |  | 
| 154 184 | 
             
                payload = {
         | 
| 155 185 | 
             
                  token: token
         | 
| 156 186 | 
             
                }
         | 
| 157 187 |  | 
| 158 | 
            -
                info  | 
| 188 | 
            +
                info 'Getting all Channels'
         | 
| 159 189 | 
             
                begin
         | 
| 160 190 | 
             
                  uri          = 'https://slack.com/api/channels.list'
         | 
| 161 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 191 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 192 | 
            +
                                                      url: uri,
         | 
| 193 | 
            +
                                                      method: 'POST',
         | 
| 194 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 195 | 
            +
                                                      payload: payload
         | 
| 196 | 
            +
                                                    )
         | 
| 162 197 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 163 198 | 
             
                rescue
         | 
| 164 | 
            -
                  fail  | 
| 199 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 165 200 | 
             
                end
         | 
| 166 201 |  | 
| 167 202 | 
             
                fail response['error'] unless response['ok']
         | 
| 168 203 |  | 
| 169 | 
            -
                response['channels']. | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
                 | 
| 204 | 
            +
                channel = response['channels'].find { |c| c['name'] || c['id'] == channel_name }
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                fail "Channel '#{channel_name}' wasn't found" unless channel
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                channel_id = channel['id']
         | 
| 174 209 |  | 
| 175 210 | 
             
                payload = {
         | 
| 176 211 | 
             
                  token: token,
         | 
| 177 | 
            -
                  channel:  | 
| 212 | 
            +
                  channel: channel_id,
         | 
| 178 213 | 
             
                  topic: topic
         | 
| 179 214 | 
             
                }
         | 
| 180 215 |  | 
| 181 | 
            -
                info  | 
| 216 | 
            +
                info 'Setting Topic'
         | 
| 182 217 | 
             
                begin
         | 
| 183 218 | 
             
                  uri = 'https://slack.com/api/channels.setTopic'
         | 
| 184 | 
            -
                   | 
| 185 | 
            -
             | 
| 219 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 220 | 
            +
                                                      url: uri,
         | 
| 221 | 
            +
                                                      method: 'POST',
         | 
| 222 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 223 | 
            +
                                                      payload: payload
         | 
| 224 | 
            +
                                                    )
         | 
| 225 | 
            +
                  response     = JSON.parse(raw_response)
         | 
| 186 226 | 
             
                rescue
         | 
| 187 | 
            -
                  fail  | 
| 227 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 188 228 | 
             
                end
         | 
| 189 229 |  | 
| 190 230 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -2,7 +2,7 @@ require 'factor-connector-api' | |
| 2 2 | 
             
            require 'rest_client'
         | 
| 3 3 |  | 
| 4 4 | 
             
            Factor::Connector.service 'slack_chat' do
         | 
| 5 | 
            -
              action  | 
| 5 | 
            +
              action 'send' do |params|
         | 
| 6 6 |  | 
| 7 7 | 
             
                token   = params['token']
         | 
| 8 8 | 
             
                channel = params['channel']
         | 
| @@ -18,13 +18,18 @@ Factor::Connector.service 'slack_chat' do | |
| 18 18 | 
             
                  text:    text
         | 
| 19 19 | 
             
                }
         | 
| 20 20 |  | 
| 21 | 
            -
                info  | 
| 21 | 
            +
                info 'Posting Message'
         | 
| 22 22 | 
             
                begin
         | 
| 23 23 | 
             
                  uri          = 'https://slack.com/api/chat.postMessage'
         | 
| 24 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 24 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 25 | 
            +
                                                      url: uri,
         | 
| 26 | 
            +
                                                      method: 'POST',
         | 
| 27 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 28 | 
            +
                                                      payload: payload
         | 
| 29 | 
            +
                                                    )
         | 
| 25 30 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 26 31 | 
             
                rescue
         | 
| 27 | 
            -
                  fail  | 
| 32 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 28 33 | 
             
                end
         | 
| 29 34 |  | 
| 30 35 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -2,7 +2,7 @@ require 'factor-connector-api' | |
| 2 2 | 
             
            require 'rest_client'
         | 
| 3 3 |  | 
| 4 4 | 
             
            Factor::Connector.service 'slack_group' do
         | 
| 5 | 
            -
              action  | 
| 5 | 
            +
              action 'create' do |params|
         | 
| 6 6 |  | 
| 7 7 | 
             
                token = params['token']
         | 
| 8 8 | 
             
                name  = params['name']
         | 
| @@ -12,16 +12,21 @@ Factor::Connector.service 'slack_group' do | |
| 12 12 |  | 
| 13 13 | 
             
                payload = {
         | 
| 14 14 | 
             
                  token: token,
         | 
| 15 | 
            -
                  name:  name | 
| 15 | 
            +
                  name:  name
         | 
| 16 16 | 
             
                }
         | 
| 17 17 |  | 
| 18 | 
            -
                info  | 
| 18 | 
            +
                info 'Creating Group'
         | 
| 19 19 | 
             
                begin
         | 
| 20 20 | 
             
                  uri          = 'https://slack.com/api/groups.create'
         | 
| 21 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 21 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 22 | 
            +
                                                      url: uri,
         | 
| 23 | 
            +
                                                      method: 'POST',
         | 
| 24 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 25 | 
            +
                                                      payload: payload
         | 
| 26 | 
            +
                                                    )
         | 
| 22 27 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 23 28 | 
             
                rescue
         | 
| 24 | 
            -
                  fail  | 
| 29 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 25 30 | 
             
                end
         | 
| 26 31 |  | 
| 27 32 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -29,29 +34,82 @@ Factor::Connector.service 'slack_group' do | |
| 29 34 | 
             
                action_callback response
         | 
| 30 35 | 
             
              end
         | 
| 31 36 |  | 
| 32 | 
            -
              action  | 
| 37 | 
            +
              action 'invite' do |params|
         | 
| 33 38 |  | 
| 34 | 
            -
                token | 
| 35 | 
            -
                 | 
| 36 | 
            -
                 | 
| 39 | 
            +
                token        = params['token']
         | 
| 40 | 
            +
                channel_name = params['channel']
         | 
| 41 | 
            +
                user_name    = params['user']
         | 
| 37 42 |  | 
| 38 43 | 
             
                fail 'Token is required' unless token
         | 
| 39 | 
            -
                fail 'Channel is required' unless  | 
| 40 | 
            -
                fail 'Username is required' unless  | 
| 44 | 
            +
                fail 'Channel is required' unless channel_name
         | 
| 45 | 
            +
                fail 'Username is required' unless user_name
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                payload = {
         | 
| 48 | 
            +
                  token: token
         | 
| 49 | 
            +
                }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                info 'Getting all Channels'
         | 
| 52 | 
            +
                begin
         | 
| 53 | 
            +
                  uri          = 'https://slack.com/api/groups.list'
         | 
| 54 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 55 | 
            +
                                                      url: uri,
         | 
| 56 | 
            +
                                                      method: 'POST',
         | 
| 57 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 58 | 
            +
                                                      payload: payload
         | 
| 59 | 
            +
                                                    )
         | 
| 60 | 
            +
                  response     = JSON.parse(raw_response)
         | 
| 61 | 
            +
                rescue
         | 
| 62 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                fail response['error'] unless response['ok']
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                channel = response['groups'].find { |c| c['name'] == channel_name }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                fail "Channel '#{channel_name}' wasn't found" unless channel
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                channel_id = channel['id']
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                info 'Getting Users'
         | 
| 74 | 
            +
                begin
         | 
| 75 | 
            +
                  uri          = 'https://slack.com/api/users.list'
         | 
| 76 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 77 | 
            +
                                                      url: uri,
         | 
| 78 | 
            +
                                                      method: 'POST',
         | 
| 79 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 80 | 
            +
                                                      payload: payload
         | 
| 81 | 
            +
                                                    )
         | 
| 82 | 
            +
                  response     = JSON.parse(raw_response)
         | 
| 83 | 
            +
                rescue
         | 
| 84 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                fail response['error'] unless response['ok']
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                user = response['members'].find { |m|  m['name'] == user_name }
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                fail "User '#{user_name}' was not found" unless user
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                user_id = user['id']
         | 
| 41 94 |  | 
| 42 95 | 
             
                payload = {
         | 
| 43 96 | 
             
                  token:   token,
         | 
| 44 | 
            -
                  channel:  | 
| 45 | 
            -
                  user:     | 
| 97 | 
            +
                  channel: channel_id,
         | 
| 98 | 
            +
                  user:    user_id
         | 
| 46 99 | 
             
                }
         | 
| 47 100 |  | 
| 48 | 
            -
                info  | 
| 101 | 
            +
                info 'Inviting User'
         | 
| 49 102 | 
             
                begin
         | 
| 50 103 | 
             
                  uri          = 'https://slack.com/api/groups.invite'
         | 
| 51 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 104 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 105 | 
            +
                                                      url: uri,
         | 
| 106 | 
            +
                                                      method: 'POST',
         | 
| 107 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 108 | 
            +
                                                      payload: payload
         | 
| 109 | 
            +
                                                    )
         | 
| 52 110 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 53 111 | 
             
                rescue
         | 
| 54 | 
            -
                  fail  | 
| 112 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 55 113 | 
             
                end
         | 
| 56 114 |  | 
| 57 115 | 
             
                fail response['error'] unless response['ok']
         | 
| @@ -6,19 +6,24 @@ Factor::Connector.service 'slack_user' do | |
| 6 6 |  | 
| 7 7 | 
             
                token = params['token']
         | 
| 8 8 |  | 
| 9 | 
            -
                fail  | 
| 9 | 
            +
                fail 'Token is required' unless token
         | 
| 10 10 |  | 
| 11 11 | 
             
                payload = {
         | 
| 12 12 | 
             
                  token: token
         | 
| 13 13 | 
             
                }
         | 
| 14 14 |  | 
| 15 | 
            -
             | 
| 15 | 
            +
                info 'Listing Users'
         | 
| 16 16 | 
             
                begin
         | 
| 17 17 | 
             
                  uri          = 'https://slack.com/api/users.list'
         | 
| 18 | 
            -
                  raw_response = RestClient::Request.execute( | 
| 18 | 
            +
                  raw_response = RestClient::Request.execute(
         | 
| 19 | 
            +
                                                      url: uri,
         | 
| 20 | 
            +
                                                      method: 'POST',
         | 
| 21 | 
            +
                                                      ssl_version: 'SSLv23',
         | 
| 22 | 
            +
                                                      payload: payload
         | 
| 23 | 
            +
                                                    )
         | 
| 19 24 | 
             
                  response     = JSON.parse(raw_response)
         | 
| 20 25 | 
             
                rescue
         | 
| 21 | 
            -
                  fail  | 
| 26 | 
            +
                  fail 'failed to connect to Slack API, check your credentials'
         | 
| 22 27 | 
             
                end
         | 
| 23 28 |  | 
| 24 29 | 
             
                fail response['error'] unless response['ok']
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: factor-connector-slack
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -32,17 +32,17 @@ dependencies: | |
| 32 32 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 33 | 
             
                none: false
         | 
| 34 34 | 
             
                requirements:
         | 
| 35 | 
            -
                - -  | 
| 35 | 
            +
                - - ~>
         | 
| 36 36 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version:  | 
| 37 | 
            +
                    version: 1.7.3
         | 
| 38 38 | 
             
              type: :runtime
         | 
| 39 39 | 
             
              prerelease: false
         | 
| 40 40 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 41 | 
             
                none: false
         | 
| 42 42 | 
             
                requirements:
         | 
| 43 | 
            -
                - -  | 
| 43 | 
            +
                - - ~>
         | 
| 44 44 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version:  | 
| 45 | 
            +
                    version: 1.7.3
         | 
| 46 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 47 | 
             
              name: codeclimate-test-reporter
         | 
| 48 48 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -107,6 +107,22 @@ dependencies: | |
| 107 107 | 
             
                - - ~>
         | 
| 108 108 | 
             
                  - !ruby/object:Gem::Version
         | 
| 109 109 | 
             
                    version: 0.7.1
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              name: rubocop
         | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                none: false
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ~>
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: 0.26.1
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                none: false
         | 
| 122 | 
            +
                requirements:
         | 
| 123 | 
            +
                - - ~>
         | 
| 124 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                    version: 0.26.1
         | 
| 110 126 | 
             
            description: 
         | 
| 111 127 | 
             
            email:
         | 
| 112 128 | 
             
            - andrewrdakers@gmail.com
         |