bas 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +25 -22
- data/lib/bas/formatter/base.rb +2 -2
- data/lib/bas/formatter/birthday.rb +8 -4
- data/lib/bas/formatter/pto.rb +8 -4
- data/lib/bas/formatter/support_emails.rb +7 -3
- data/lib/bas/formatter/types/response.rb +16 -0
- data/lib/bas/formatter/work_items_limit.rb +8 -4
- data/lib/bas/process/base.rb +39 -0
- data/lib/bas/{dispatcher → process}/discord/exceptions/invalid_webhook_token.rb +1 -1
- data/lib/bas/process/discord/implementation.rb +71 -0
- data/lib/bas/{dispatcher → process}/discord/types/response.rb +1 -1
- data/lib/bas/{dispatcher → process}/slack/exceptions/invalid_webhook_token.rb +1 -1
- data/lib/bas/process/slack/implementation.rb +70 -0
- data/lib/bas/{dispatcher → process}/slack/types/response.rb +1 -1
- data/lib/bas/process/types/response.rb +16 -0
- data/lib/bas/{fetcher → read}/base.rb +8 -8
- data/lib/bas/{fetcher → read}/github/base.rb +7 -7
- data/lib/bas/{fetcher → read}/github/types/response.rb +1 -1
- data/lib/bas/read/github/use_case/repo_issues.rb +17 -0
- data/lib/bas/{fetcher → read}/imap/base.rb +7 -7
- data/lib/bas/{fetcher → read}/imap/types/response.rb +1 -1
- data/lib/bas/read/imap/use_case/support_emails.rb +26 -0
- data/lib/bas/{fetcher → read}/notion/base.rb +8 -8
- data/lib/bas/{fetcher → read}/notion/helper.rb +1 -1
- data/lib/bas/{fetcher → read}/notion/types/response.rb +1 -1
- data/lib/bas/{fetcher → read}/notion/use_case/birthday_next_week.rb +6 -6
- data/lib/bas/{fetcher → read}/notion/use_case/birthday_today.rb +6 -6
- data/lib/bas/{fetcher → read}/notion/use_case/pto_next_week.rb +6 -6
- data/lib/bas/{fetcher → read}/notion/use_case/pto_today.rb +6 -6
- data/lib/bas/{fetcher → read}/notion/use_case/work_items_limit.rb +5 -5
- data/lib/bas/{fetcher → read}/postgres/base.rb +8 -8
- data/lib/bas/{fetcher → read}/postgres/helper.rb +1 -1
- data/lib/bas/{fetcher → read}/postgres/types/response.rb +1 -1
- data/lib/bas/{fetcher → read}/postgres/use_case/pto_today.rb +6 -6
- data/lib/bas/{mapper → serialize}/base.rb +7 -7
- data/lib/bas/{mapper → serialize}/github/issues.rb +7 -7
- data/lib/bas/{mapper → serialize}/imap/support_emails.rb +7 -7
- data/lib/bas/{mapper → serialize}/notion/birthday_today.rb +7 -7
- data/lib/bas/{mapper → serialize}/notion/pto_today.rb +14 -12
- data/lib/bas/{mapper → serialize}/notion/work_items_limit.rb +7 -7
- data/lib/bas/{mapper → serialize}/postgres/pto_today.rb +7 -7
- data/lib/bas/use_cases/types/config.rb +6 -5
- data/lib/bas/use_cases/use_case.rb +13 -10
- data/lib/bas/use_cases/use_cases.rb +71 -61
- data/lib/bas/version.rb +1 -1
- data/lib/bas/write/base.rb +36 -0
- data/lib/bas/write/logs/base.rb +33 -0
- data/lib/bas/write/logs/use_case/console_log.rb +22 -0
- metadata +42 -37
- data/lib/bas/dispatcher/base.rb +0 -31
- data/lib/bas/dispatcher/discord/implementation.rb +0 -51
- data/lib/bas/dispatcher/slack/implementation.rb +0 -51
- data/lib/bas/fetcher/github/use_case/repo_issues.rb +0 -17
- data/lib/bas/fetcher/imap/use_case/support_emails.rb +0 -26
- /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_api_key.rb +0 -0
- /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_database_id.rb +0 -0
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../base"
|
4
|
-
require_relative "./exceptions/invalid_webhook_token"
|
5
|
-
require_relative "./types/response"
|
6
|
-
|
7
|
-
module Dispatcher
|
8
|
-
module Discord
|
9
|
-
##
|
10
|
-
# This class is an implementation of the Dispatcher::Base interface, specifically designed
|
11
|
-
# for dispatching messages to Discord.
|
12
|
-
#
|
13
|
-
class Implementation < Base
|
14
|
-
# Implements the dispatching logic for the Discord use case. It sends a POST request to
|
15
|
-
# the Discord webhook with the specified payload.
|
16
|
-
#
|
17
|
-
# <br>
|
18
|
-
# <b>Params:</b>
|
19
|
-
# * <tt>String</tt> payload: Payload to be dispatched to discord.
|
20
|
-
# <br>
|
21
|
-
# <b>raises</b> <tt>Exceptions::Discord::InvalidWebookToken</tt> if the provided webhook token is invalid.
|
22
|
-
#
|
23
|
-
# <br>
|
24
|
-
# <b>returns</b> <tt>Dispatcher::Discord::Types::Response</tt>
|
25
|
-
#
|
26
|
-
def dispatch(payload)
|
27
|
-
body = {
|
28
|
-
username: name,
|
29
|
-
avatar_url: "",
|
30
|
-
content: payload
|
31
|
-
}.to_json
|
32
|
-
response = HTTParty.post(webhook, { body: body, headers: { "Content-Type" => "application/json" } })
|
33
|
-
|
34
|
-
discord_response = Dispatcher::Discord::Types::Response.new(response)
|
35
|
-
|
36
|
-
validate_response(discord_response)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def validate_response(response)
|
42
|
-
case response.code
|
43
|
-
when 50_027
|
44
|
-
raise Discord::Exceptions::InvalidWebookToken, response.message
|
45
|
-
else
|
46
|
-
response
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../base"
|
4
|
-
require_relative "./exceptions/invalid_webhook_token"
|
5
|
-
require_relative "./types/response"
|
6
|
-
|
7
|
-
module Dispatcher
|
8
|
-
module Slack
|
9
|
-
##
|
10
|
-
# This class is an implementation of the Dispatcher::Base interface, specifically designed
|
11
|
-
# for dispatching messages to Slack.
|
12
|
-
#
|
13
|
-
class Implementation < Base
|
14
|
-
# Implements the dispatching logic for the Slack use case. It sends a POST request to
|
15
|
-
# the Slack webhook with the specified payload.
|
16
|
-
#
|
17
|
-
# <br>
|
18
|
-
# <b>Params:</b>
|
19
|
-
# * <tt>String</tt> payload: Payload to be dispatched to slack.
|
20
|
-
# <br>
|
21
|
-
# <b>raises</b> <tt>Exceptions::Slack::InvalidWebookToken</tt> if the provided webhook token is invalid.
|
22
|
-
#
|
23
|
-
# <br>
|
24
|
-
# <b>returns</b> <tt>Dispatcher::Slack::Types::Response</tt>
|
25
|
-
#
|
26
|
-
def dispatch(payload)
|
27
|
-
body = {
|
28
|
-
username: name,
|
29
|
-
text: payload
|
30
|
-
}.to_json
|
31
|
-
|
32
|
-
response = HTTParty.post(webhook, { body: body, headers: { "Content-Type" => "application/json" } })
|
33
|
-
|
34
|
-
slack_response = Dispatcher::Discord::Types::Response.new(response)
|
35
|
-
|
36
|
-
validate_response(slack_response)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def validate_response(response)
|
42
|
-
case response.http_code
|
43
|
-
when 403
|
44
|
-
raise Dispatcher::Slack::Exceptions::InvalidWebookToken, response.message
|
45
|
-
else
|
46
|
-
response
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../base"
|
4
|
-
|
5
|
-
module Fetcher
|
6
|
-
module Github
|
7
|
-
##
|
8
|
-
# This class is an implementation of the Fetcher::Github::Base interface, specifically designed
|
9
|
-
# for fetching issues from a Github repository.
|
10
|
-
#
|
11
|
-
class RepoIssues < Github::Base
|
12
|
-
def fetch
|
13
|
-
execute("list_issues", config[:repo])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "../base"
|
4
|
-
|
5
|
-
module Fetcher
|
6
|
-
module Imap
|
7
|
-
##
|
8
|
-
# This class is an implementation of the Fetcher::Imap::Base interface, specifically designed
|
9
|
-
# for fetching support email from a Google Gmail account.
|
10
|
-
#
|
11
|
-
class SupportEmails < Imap::Base
|
12
|
-
TOKEN_URI = "https://oauth2.googleapis.com/token"
|
13
|
-
EMAIL_DOMAIN = "imap.gmail.com"
|
14
|
-
EMAIL_PORT = 993
|
15
|
-
|
16
|
-
# Implements the data fetching filter for support emails from Google Gmail.
|
17
|
-
#
|
18
|
-
def fetch
|
19
|
-
yesterday = (Time.now - (60 * 60 * 24)).strftime("%e-%b-%Y")
|
20
|
-
query = ["TO", config[:search_email], "SINCE", yesterday]
|
21
|
-
|
22
|
-
execute(EMAIL_DOMAIN, EMAIL_PORT, TOKEN_URI, query)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
File without changes
|
File without changes
|