Sha256: 3433645ea3dc60e53c53d9bc8823276af4858cf876f31206b661509e932a3ded
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'json' require 'faraday' module ErrandBoy module Gateway class Slack def initialize(request) @request = request end def call send(@request.action) rescue NoMethodError raise NoActionError, "#{@request.action}: action not found." end def invite response = connect.post 'api/users.admin.invite', params result = JSON.parse response.body unless result['ok'] @processed = true if result['error'] == 'already_invited' raise SlackInviteMissingError, result['error'] unless processed? end end def team @request.destination['team'] end def url "https://#{team}.slack.com/" end def processed? @processed end private def connect Faraday.new(url: url) do |faraday| faraday.request :url_encoded # faraday.response :logger faraday.adapter Faraday.default_adapter end end def params { email: @request.register['email'], token: ErrandBoy.slack_access_token, set_active: true } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
errand-boy-0.1.0 | lib/errand_boy/gateway/slack.rb |