class SardonyxRing::Services::SlackAppClient
Constants
- SLACK_API_ORIGIN
Public Class Methods
new(options = {})
click to toggle source
# File lib/sardonyx_ring/services/slack_app_client.rb, line 8 def initialize(options = {}) @app_token = options[:token] end
Public Instance Methods
request(path, params = {})
click to toggle source
# File lib/sardonyx_ring/services/slack_app_client.rb, line 12 def request(path, params = {}) res = create_http_client.post( "/api/#{path}", params.to_json, 'Content-Type': 'application/json', Authorization: "Bearer #{@app_token}" ) parse_response(res.body) end
Private Instance Methods
create_http_client()
click to toggle source
# File lib/sardonyx_ring/services/slack_app_client.rb, line 23 def create_http_client uri = URI.parse(SLACK_API_ORIGIN) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http end
parse_response(response_body)
click to toggle source
# File lib/sardonyx_ring/services/slack_app_client.rb, line 30 def parse_response(response_body) JSON.parse(response_body, object_class: OpenStruct) end