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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f44e74f96bec3baf31f333e3cc965aedcfccd2bf9373eb4ee8d43e89ec2c5f9f
4
- data.tar.gz: 7f43e04b3900ec50c3c0e223bf2b9df11760145ca39398b1ed8bd24dd012a2a0
3
+ metadata.gz: 4e8ddbcbfbd549eb2c4ab898505896bf2d99ad950b1dda24167c4c7b0af2274f
4
+ data.tar.gz: 2d9f90f36aa0cc306ddf6b968b89cdf2280a41ef72b222ac00356c3fe685562b
5
5
  SHA512:
6
- metadata.gz: 67b61a9469da611a81dec53fc613e679df13fcffbd51f51ae6436059e48172ab947379fd2a0282cd58ffa220e08914a3eac1f4fe2de586d7deddb13f9d5738f0
7
- data.tar.gz: e6aa49addf640888d861f5b90cb1c8030dbbe6d99d130bde8ebb4ffec15c4c839212ffee1e91e1a88d6326be3b6b924bb22698d63e505a03abe1e7f6df0c192a
6
+ metadata.gz: e8ee2351b8481befbd89f910b0f48855d5dfde409ac4611f7121de5311f2e7021b2553813f280539bdec5c17a208631f0e50c667766e443168ebb4475d72882b
7
+ data.tar.gz: 83810c251a1b51364de4d0f51ac216e3ceba00ee5f4a47a1a4d33dc35d88facc61826243212d11f9959acf12e099a20f686c1af6354aa6b43c12c9280459b570
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack_msgr (0.0.6)
4
+ slack_msgr (0.0.7)
5
5
  faraday (~> 0.15.4)
6
6
 
7
7
  GEM
@@ -5,5 +5,5 @@ module SlackMsgr
5
5
 
6
6
  SLACK_URL = 'https://slack.com'
7
7
 
8
- VERSION = '0.0.6'
8
+ VERSION = '0.0.7'
9
9
  end
@@ -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"
@@ -21,5 +21,9 @@ module SlackMsgr
21
21
  def users(*methods, **opts)
22
22
  Users.call(methods, opts)
23
23
  end
24
+
25
+ def conversations(method, **opts)
26
+ Conversations.call(method, opts)
27
+ end
24
28
  end
25
29
  end
@@ -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.6
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-28 00:00:00.000000000 Z
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