slack_msgr 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/config/constants.rb +1 -1
- data/lib/config/initializer.rb +1 -0
- data/lib/slack_msgr.rb +4 -0
- data/lib/slack_msgr/conversations.rb +47 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8ddbcbfbd549eb2c4ab898505896bf2d99ad950b1dda24167c4c7b0af2274f
|
4
|
+
data.tar.gz: 2d9f90f36aa0cc306ddf6b968b89cdf2280a41ef72b222ac00356c3fe685562b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ee2351b8481befbd89f910b0f48855d5dfde409ac4611f7121de5311f2e7021b2553813f280539bdec5c17a208631f0e50c667766e443168ebb4475d72882b
|
7
|
+
data.tar.gz: 83810c251a1b51364de4d0f51ac216e3ceba00ee5f4a47a1a4d33dc35d88facc61826243212d11f9959acf12e099a20f686c1af6354aa6b43c12c9280459b570
|
data/Gemfile.lock
CHANGED
data/lib/config/constants.rb
CHANGED
data/lib/config/initializer.rb
CHANGED
@@ -11,5 +11,6 @@ require "#{path}/../slack_msgr/slack_method"
|
|
11
11
|
require "#{path}/../slack_msgr/authenticate"
|
12
12
|
require "#{path}/../slack_msgr/chat"
|
13
13
|
require "#{path}/../slack_msgr/configuration"
|
14
|
+
require "#{path}/../slack_msgr/conversations"
|
14
15
|
require "#{path}/../slack_msgr/users"
|
15
16
|
require "#{path}/../utils/error_handling"
|
data/lib/slack_msgr.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlackMsgr
|
4
|
+
# Handles all conversations functionality and methods corresponding with Slack API
|
5
|
+
class Conversations < SlackMethod
|
6
|
+
CONVERSATIONS_METHODS = { open: 'open' }.freeze
|
7
|
+
|
8
|
+
REQUIRED_ARGUMENTS = %i[token users].freeze
|
9
|
+
|
10
|
+
PERMITTED_ARGUMENTS = %i[token channel return_im users].freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def call(method, opts = {})
|
14
|
+
chat = new(method, opts)
|
15
|
+
send_post_request_to_slack(chat)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :method,
|
20
|
+
:opts,
|
21
|
+
:body
|
22
|
+
|
23
|
+
def initialize(method, opts)
|
24
|
+
conversations_method = CONVERSATIONS_METHODS[method]
|
25
|
+
ErrorHandling.raise(:unknown_method, method: method) unless conversations_method
|
26
|
+
|
27
|
+
@method = "conversations.#{conversations_method}"
|
28
|
+
@opts = opts
|
29
|
+
@body = sanitize_body
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def sanitize_body
|
35
|
+
ErrorHandling.raise(:req_args_missing, req_args: REQUIRED_ARGUMENTS, method: method) if req_args_missing?
|
36
|
+
|
37
|
+
opts.keys.each_with_object({}) do |key, body|
|
38
|
+
body[key] ||= opts[key] if PERMITTED_ARGUMENTS.include?(key)
|
39
|
+
body
|
40
|
+
end.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
def req_args_missing?
|
44
|
+
!(REQUIRED_ARGUMENTS - opts.keys).empty?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_msgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Workman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/slack_msgr/authenticate.rb
|
150
150
|
- lib/slack_msgr/chat.rb
|
151
151
|
- lib/slack_msgr/configuration.rb
|
152
|
+
- lib/slack_msgr/conversations.rb
|
152
153
|
- lib/slack_msgr/slack_method.rb
|
153
154
|
- lib/slack_msgr/users.rb
|
154
155
|
- lib/utils/error_handling.rb
|