bas 0.1.0 → 0.3.0

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile +6 -0
  4. data/README.md +27 -24
  5. data/lib/bas/domain/issue.rb +22 -0
  6. data/lib/bas/domain/pto.rb +45 -4
  7. data/lib/bas/formatter/base.rb +2 -2
  8. data/lib/bas/formatter/birthday.rb +8 -4
  9. data/lib/bas/formatter/pto.rb +27 -26
  10. data/lib/bas/formatter/support_emails.rb +7 -3
  11. data/lib/bas/formatter/types/response.rb +16 -0
  12. data/lib/bas/formatter/work_items_limit.rb +8 -4
  13. data/lib/bas/process/base.rb +39 -0
  14. data/lib/bas/{dispatcher → process}/discord/exceptions/invalid_webhook_token.rb +1 -1
  15. data/lib/bas/process/discord/implementation.rb +71 -0
  16. data/lib/bas/{dispatcher → process}/discord/types/response.rb +1 -1
  17. data/lib/bas/{dispatcher → process}/slack/exceptions/invalid_webhook_token.rb +1 -1
  18. data/lib/bas/process/slack/implementation.rb +70 -0
  19. data/lib/bas/{dispatcher → process}/slack/types/response.rb +1 -1
  20. data/lib/bas/process/types/response.rb +16 -0
  21. data/lib/bas/{fetcher → read}/base.rb +8 -8
  22. data/lib/bas/read/github/base.rb +57 -0
  23. data/lib/bas/read/github/types/response.rb +27 -0
  24. data/lib/bas/read/github/use_case/repo_issues.rb +17 -0
  25. data/lib/bas/{fetcher → read}/imap/base.rb +7 -7
  26. data/lib/bas/{fetcher → read}/imap/types/response.rb +1 -1
  27. data/lib/bas/read/imap/use_case/support_emails.rb +26 -0
  28. data/lib/bas/{fetcher → read}/notion/base.rb +8 -8
  29. data/lib/bas/{fetcher → read}/notion/helper.rb +1 -1
  30. data/lib/bas/{fetcher → read}/notion/types/response.rb +1 -1
  31. data/lib/bas/{fetcher → read}/notion/use_case/birthday_next_week.rb +6 -6
  32. data/lib/bas/{fetcher → read}/notion/use_case/birthday_today.rb +6 -6
  33. data/lib/bas/{fetcher → read}/notion/use_case/pto_next_week.rb +6 -6
  34. data/lib/bas/{fetcher → read}/notion/use_case/pto_today.rb +6 -6
  35. data/lib/bas/{fetcher → read}/notion/use_case/work_items_limit.rb +5 -5
  36. data/lib/bas/{fetcher → read}/postgres/base.rb +8 -8
  37. data/lib/bas/{fetcher → read}/postgres/helper.rb +1 -1
  38. data/lib/bas/{fetcher → read}/postgres/types/response.rb +1 -1
  39. data/lib/bas/{fetcher → read}/postgres/use_case/pto_today.rb +6 -6
  40. data/lib/bas/{mapper → serialize}/base.rb +7 -7
  41. data/lib/bas/serialize/github/issues.rb +57 -0
  42. data/lib/bas/{mapper → serialize}/imap/support_emails.rb +7 -7
  43. data/lib/bas/{mapper → serialize}/notion/birthday_today.rb +7 -7
  44. data/lib/bas/serialize/notion/pto_today.rb +75 -0
  45. data/lib/bas/{mapper → serialize}/notion/work_items_limit.rb +7 -7
  46. data/lib/bas/{mapper → serialize}/postgres/pto_today.rb +9 -9
  47. data/lib/bas/use_cases/types/config.rb +6 -5
  48. data/lib/bas/use_cases/use_case.rb +13 -10
  49. data/lib/bas/use_cases/use_cases.rb +71 -59
  50. data/lib/bas/version.rb +1 -1
  51. data/lib/bas/write/base.rb +36 -0
  52. data/lib/bas/write/logs/base.rb +33 -0
  53. data/lib/bas/write/logs/use_case/console_log.rb +22 -0
  54. metadata +43 -33
  55. data/lib/bas/dispatcher/base.rb +0 -31
  56. data/lib/bas/dispatcher/discord/implementation.rb +0 -51
  57. data/lib/bas/dispatcher/slack/implementation.rb +0 -51
  58. data/lib/bas/fetcher/imap/use_case/support_emails.rb +0 -26
  59. data/lib/bas/mapper/notion/pto_today.rb +0 -70
  60. /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_api_key.rb +0 -0
  61. /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_database_id.rb +0 -0
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../domain/issue"
4
+ require_relative "../base"
5
+
6
+ module Serialize
7
+ module Github
8
+ ##
9
+ # This class implements the methods of the Serialize::Base module, specifically designed for
10
+ # preparing or shaping Github issues data coming from a Read::Base implementation.
11
+ class Issues
12
+ include Base
13
+
14
+ # Implements the logic for shaping the results from a reader response.
15
+ #
16
+ # <br>
17
+ # <b>Params:</b>
18
+ # * <tt>Read::Github::Types::Response</tt> github_response: Array of github issues data.
19
+ #
20
+ # <br>
21
+ # <b>return</b> <tt>List<Domain::Issue></tt> serialized github issues to be used by a
22
+ # Formatter::Base implementation.
23
+ #
24
+ def execute(github_response)
25
+ return [] if github_response.results.empty?
26
+
27
+ normalized_github_data = normalize_response(github_response.results)
28
+
29
+ normalized_github_data.map do |issue|
30
+ Domain::Issue.new(
31
+ issue["title"], issue["state"], issue["assignees"], issue["body"], issue["url"]
32
+ )
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def normalize_response(results)
39
+ return [] if results.nil?
40
+
41
+ results.map do |value|
42
+ {
43
+ "title" => value[:title],
44
+ "state" => value[:state],
45
+ "assignees" => extract_assignees(value[:assignees]),
46
+ "body" => value[:body],
47
+ "url" => value[:url]
48
+ }
49
+ end
50
+ end
51
+
52
+ def extract_assignees(assignees)
53
+ assignees.map { |assignee| assignee[:login] }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -3,25 +3,25 @@
3
3
  require_relative "../../domain/email"
4
4
  require_relative "../base"
5
5
 
6
- module Mapper
6
+ module Serialize
7
7
  module Imap
8
8
  ##
9
- # This class implementats the methods of the Mapper::Base module, specifically designed for
10
- # preparing or shaping support emails data coming from a Fetcher::Base implementation.
9
+ # This class implements the methods of the Serialize::Base module, specifically designed for
10
+ # preparing or shaping support emails data coming from a Read::Base implementation.
11
11
  class SupportEmails
12
12
  include Base
13
13
 
14
- # Implements the logic for shaping the results from a fetcher response.
14
+ # Implements the logic for shaping the results from a reader response.
15
15
  #
16
16
  # <br>
17
17
  # <b>Params:</b>
18
- # * <tt>Fetcher::Imap::Types::Response</tt> imap_response: Array of imap emails data.
18
+ # * <tt>Read::Imap::Types::Response</tt> imap_response: Array of imap emails data.
19
19
  #
20
20
  # <br>
21
- # <b>return</b> <tt>List<Domain::Email></tt> support_emails_list, mapped support emails to be used by a
21
+ # <b>return</b> <tt>List<Domain::Email></tt> support_emails_list, serialized support emails to be used by a
22
22
  # Formatter::Base implementation.
23
23
  #
24
- def map(imap_response)
24
+ def execute(imap_response)
25
25
  return [] if imap_response.results.empty?
26
26
 
27
27
  normalized_email_data = normalize_response(imap_response.results)
@@ -3,27 +3,27 @@
3
3
  require_relative "../../domain/birthday"
4
4
  require_relative "../base"
5
5
 
6
- module Mapper
6
+ module Serialize
7
7
  module Notion
8
8
  ##
9
- # This class implementats the methods of the Mapper::Base module, specifically designed for preparing or
10
- # shaping birthdays data coming from a Fetcher::Base implementation.
9
+ # This class implements the methods of the Serialize::Base module, specifically designed for preparing or
10
+ # shaping birthdays data coming from a Read::Base implementation.
11
11
  class BirthdayToday
12
12
  include Base
13
13
 
14
14
  BIRTHDAY_PARAMS = ["Complete Name", "BD_this_year"].freeze
15
15
 
16
- # Implements the logic for shaping the results from a fetcher response.
16
+ # Implements the logic for shaping the results from a reader response.
17
17
  #
18
18
  # <br>
19
19
  # <b>Params:</b>
20
- # * <tt>Fetcher::Notion::Types::Response</tt> notion_response: Notion response object.
20
+ # * <tt>Read::Notion::Types::Response</tt> notion_response: Notion response object.
21
21
  #
22
22
  # <br>
23
- # <b>return</b> <tt>List<Domain::Birthday></tt> birthdays_list, mapped birthdays to be used by a
23
+ # <b>return</b> <tt>List<Domain::Birthday></tt> birthdays_list, serialized birthdays to be used by a
24
24
  # Formatter::Base implementation.
25
25
  #
26
- def map(notion_response)
26
+ def execute(notion_response)
27
27
  return [] if notion_response.results.empty?
28
28
 
29
29
  normalized_notion_data = normalize_response(notion_response.results)
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../domain/pto"
4
+ require_relative "../base"
5
+
6
+ module Serialize
7
+ module Notion
8
+ ##
9
+ # This class implements the methods of the Serialize::Base module, specifically designed for preparing or
10
+ # shaping PTO's data coming from a Read::Base implementation.
11
+ #
12
+ class PtoToday
13
+ include Base
14
+
15
+ PTO_PARAMS = ["Description", "Desde?", "Hasta?"].freeze
16
+
17
+ # Implements the logic for shaping the results from a reader response.
18
+ #
19
+ # <br>
20
+ # <b>Params:</b>
21
+ # * <tt>Read::Notion::Types::Response</tt> notion_response: Notion response object.
22
+ #
23
+ # <br>
24
+ # <b>returns</b> <tt>List<Domain::Pto></tt> ptos_list, serialized PTO's to be used by a Formatter::Base
25
+ # implementation.
26
+ #
27
+ def execute(notion_response)
28
+ return [] if notion_response.results.empty?
29
+
30
+ normalized_notion_data = normalize_response(notion_response.results)
31
+
32
+ normalized_notion_data.map do |pto|
33
+ Domain::Pto.new(pto["Description"], pto["Desde?"], pto["Hasta?"])
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def normalize_response(response)
40
+ return [] if response.nil?
41
+
42
+ response.map do |value|
43
+ pto_fields = value["properties"].slice(*PTO_PARAMS)
44
+
45
+ {
46
+ "Description" => extract_description_field_value(pto_fields["Description"]),
47
+ "Desde?" => extract_date_field_value(pto_fields["Desde?"]),
48
+ "Hasta?" => extract_date_field_value(pto_fields["Hasta?"])
49
+ }
50
+ end
51
+ end
52
+
53
+ def extract_description_field_value(data)
54
+ names = data["title"].map { |name| name["plain_text"] }
55
+
56
+ names.join(" ")
57
+ end
58
+
59
+ def extract_date_field_value(date)
60
+ {
61
+ from: extract_start_date(date),
62
+ to: extract_end_date(date)
63
+ }
64
+ end
65
+
66
+ def extract_start_date(data)
67
+ data["date"]["start"]
68
+ end
69
+
70
+ def extract_end_date(data)
71
+ data["date"]["end"]
72
+ end
73
+ end
74
+ end
75
+ end
@@ -3,27 +3,27 @@
3
3
  require_relative "../../domain/work_items_limit"
4
4
  require_relative "../base"
5
5
 
6
- module Mapper
6
+ module Serialize
7
7
  module Notion
8
8
  ##
9
- # This class implementats the methods of the Mapper::Base module, specifically designed
10
- # for preparing or shaping work items data coming from a Fetcher::Base implementation.
9
+ # This class implements the methods of the Serialize::Base module, specifically designed
10
+ # for preparing or shaping work items data coming from a Read::Base implementation.
11
11
  class WorkItemsLimit
12
12
  include Base
13
13
 
14
14
  WORK_ITEM_PARAMS = ["Responsible domain"].freeze
15
15
 
16
- # Implements the logic for shaping the results from a fetcher response.
16
+ # Implements the logic for shaping the results from a reader response.
17
17
  #
18
18
  # <br>
19
19
  # <b>Params:</b>
20
- # * <tt>Fetcher::Notion::Types::Response</tt> notion_response: Notion response object.
20
+ # * <tt>Read::Notion::Types::Response</tt> notion_response: Notion response object.
21
21
  #
22
22
  # <br>
23
- # <b>return</b> <tt>List<Domain::WorkItem></tt> work_items_list, mapped work items to be used by a
23
+ # <b>return</b> <tt>List<Domain::WorkItem></tt> work_items_list, serialized work items to be used by a
24
24
  # Formatter::Base implementation.
25
25
  #
26
- def map(notion_response)
26
+ def execute(notion_response)
27
27
  return [] if notion_response.results.empty?
28
28
 
29
29
  normalized_notion_data = normalize_response(notion_response.results)
@@ -3,32 +3,32 @@
3
3
  require_relative "../../domain/pto"
4
4
  require_relative "../base"
5
5
 
6
- module Mapper
6
+ module Serialize
7
7
  module Postgres
8
8
  ##
9
- # This class implementats the methods of the Mapper::Base module, specifically designed for preparing or
10
- # shaping PTO's data coming from the Fetcher::Postgres::Pto class.
9
+ # This class implements the methods of the Serialize::Base module, specifically designed for preparing or
10
+ # shaping PTO's data coming from the Read::Postgres::Pto class.
11
11
  #
12
12
  class PtoToday
13
- # Implements the logic for shaping the results from a fetcher response.
13
+ # Implements the logic for shaping the results from a reader response.
14
14
  #
15
15
  # <br>
16
16
  # <b>Params:</b>
17
- # * <tt>Fetcher::Postgres::Types::Response</tt> pg_response: Postgres response object.
17
+ # * <tt>Read::Postgres::Types::Response</tt> pg_response: Postgres response object.
18
18
  #
19
19
  # <br>
20
- # <b>returns</b> <tt>List<Domain::Pto></tt> ptos_list, mapped PTO's to be used by a Formatter::Base
20
+ # <b>returns</b> <tt>List<Domain::Pto></tt> ptos_list, serialized PTO's to be used by a Formatter::Base
21
21
  # implementation.
22
22
  #
23
- def map(pg_response)
23
+ def execute(pg_response)
24
24
  return [] if pg_response.records.empty?
25
25
 
26
26
  ptos = build_map(pg_response)
27
27
 
28
28
  ptos.map do |pto|
29
29
  name = pto["name"]
30
- start_date = pto["start_date"]
31
- end_date = pto["end_date"]
30
+ start_date = { from: pto["start_date"], to: nil }
31
+ end_date = { from: pto["end_date"], to: nil }
32
32
 
33
33
  Domain::Pto.new(name, start_date, end_date)
34
34
  end
@@ -6,13 +6,14 @@ module UseCases
6
6
  # Represents a the configuration composing the initial components required by a UseCases::UseCase implementation.
7
7
  #
8
8
  class Config
9
- attr_reader :fetcher, :mapper, :formatter, :dispatcher
9
+ attr_reader :read, :serialize, :formatter, :process, :write
10
10
 
11
- def initialize(fetcher, mapper, formatter, dispatcher)
12
- @fetcher = fetcher
13
- @mapper = mapper
11
+ def initialize(read, serialize, formatter, process, write)
12
+ @read = read
13
+ @serialize = serialize
14
14
  @formatter = formatter
15
- @dispatcher = dispatcher
15
+ @process = process
16
+ @write = write
16
17
  end
17
18
  end
18
19
  end
@@ -6,7 +6,7 @@ module UseCases
6
6
  # logic flow by coordinating the execution of its components to fulfill a specific use case.
7
7
  #
8
8
  class UseCase
9
- attr_reader :fetcher, :mapper, :formatter, :dispatcher
9
+ attr_reader :read, :serialize, :formatter, :process, :write
10
10
 
11
11
  # Initializes the use case with the necessary components.
12
12
  #
@@ -15,25 +15,28 @@ module UseCases
15
15
  # * <tt>Usecases::Types::Config</tt> config, The components required to instantiate a use case.
16
16
  #
17
17
  def initialize(config)
18
- @fetcher = config.fetcher
19
- @mapper = config.mapper
18
+ @read = config.read
19
+ @serialize = config.serialize
20
20
  @formatter = config.formatter
21
- @dispatcher = config.dispatcher
21
+ @process = config.process
22
+ @write = config.write
22
23
  end
23
24
 
24
- # Executes the use case by orchestrating the sequential execution of the fetcher, mapper, formatter, and dispatcher.
25
+ # Executes the use case by orchestrating the sequential execution of the read, serialize, formatter, and process.
25
26
  #
26
27
  # <br>
27
- # <b>returns</b> <tt>Dispatcher::Discord::Types::Response</tt>
28
+ # <b>returns</b> <tt>Process::Discord::Types::Response</tt>
28
29
  #
29
30
  def perform
30
- response = fetcher.fetch
31
+ response = read.execute
31
32
 
32
- mappings = mapper.map(response)
33
+ serialization = serialize.execute(response)
33
34
 
34
- formatted_payload = formatter.format(mappings)
35
+ format_response = valid_format_response(serialization)
35
36
 
36
- dispatcher.dispatch(formatted_payload)
37
+ process_response = process.execute(format_response)
38
+
39
+ write.execute(process_response)
37
40
  end
38
41
  end
39
42
  end
@@ -1,20 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # fetcher
4
- require_relative "../fetcher/notion/use_case/birthday_today"
5
- require_relative "../fetcher/notion/use_case/birthday_next_week"
6
- require_relative "../fetcher/notion/use_case/pto_today"
7
- require_relative "../fetcher/notion/use_case/pto_next_week"
8
- require_relative "../fetcher/notion/use_case/work_items_limit"
9
- require_relative "../fetcher/postgres/use_case/pto_today"
10
- require_relative "../fetcher/imap/use_case/support_emails"
3
+ # read
4
+ require_relative "../read/notion/use_case/birthday_today"
5
+ require_relative "../read/notion/use_case/birthday_next_week"
6
+ require_relative "../read/notion/use_case/pto_today"
7
+ require_relative "../read/notion/use_case/pto_next_week"
8
+ require_relative "../read/notion/use_case/work_items_limit"
9
+ require_relative "../read/postgres/use_case/pto_today"
10
+ require_relative "../read/imap/use_case/support_emails"
11
+ require_relative "../read/github/use_case/repo_issues"
11
12
 
12
- # mapper
13
- require_relative "../mapper/notion/birthday_today"
14
- require_relative "../mapper/notion/pto_today"
15
- require_relative "../mapper/notion/work_items_limit"
16
- require_relative "../mapper/postgres/pto_today"
17
- require_relative "../mapper/imap/support_emails"
13
+ # serialize
14
+ require_relative "../serialize/notion/birthday_today"
15
+ require_relative "../serialize/notion/pto_today"
16
+ require_relative "../serialize/notion/work_items_limit"
17
+ require_relative "../serialize/postgres/pto_today"
18
+ require_relative "../serialize/imap/support_emails"
19
+ require_relative "../serialize/github/issues"
18
20
 
19
21
  # formatter
20
22
  require_relative "../formatter/birthday"
@@ -22,9 +24,12 @@ require_relative "../formatter/pto"
22
24
  require_relative "../formatter/work_items_limit"
23
25
  require_relative "../formatter/support_emails"
24
26
 
25
- # dispatcher
26
- require_relative "../dispatcher/discord/implementation"
27
- require_relative "../dispatcher/slack/implementation"
27
+ # process
28
+ require_relative "../process/discord/implementation"
29
+ require_relative "../process/slack/implementation"
30
+
31
+ # write
32
+ require_relative "../write/logs/use_case/console_log"
28
33
 
29
34
  require_relative "use_case"
30
35
  require_relative "./types/config"
@@ -39,11 +44,11 @@ module UseCases
39
44
  # <b>Example</b>
40
45
  #
41
46
  # options = {
42
- # fetch_options: {
47
+ # read_options: {
43
48
  # database_id: NOTION_DATABASE_ID,
44
49
  # secret: NOTION_API_INTEGRATION_SECRET,
45
50
  # },
46
- # dispatch_options: {
51
+ # process_options: {
47
52
  # webhook: "https://discord.com/api/webhooks/1199213527672565760/KmpoIzBet9xYG16oFh8W1RWHbpIqT7UtTBRrhfLcvWZdNiVZCTM-gpil2Qoy4eYEgpdf",
48
53
  # name: "Birthday Bot"
49
54
  # }
@@ -73,11 +78,12 @@ module UseCases
73
78
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
74
79
  #
75
80
  def self.notify_birthday_from_notion_to_discord(options)
76
- fetcher = Fetcher::Notion::BirthdayToday.new(options[:fetch_options])
77
- mapper = Mapper::Notion::BirthdayToday.new
81
+ read = Read::Notion::BirthdayToday.new(options[:read_options])
82
+ serialize = Serialize::Notion::BirthdayToday.new
78
83
  formatter = Formatter::Birthday.new(options[:format_options])
79
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
80
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
84
+ process = Process::Discord::Implementation.new(options[:process_options])
85
+ write = Write::Logs::ConsoleLog.new
86
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
81
87
 
82
88
  UseCases::UseCase.new(use_case_config)
83
89
  end
@@ -87,11 +93,11 @@ module UseCases
87
93
  # <b>Example</b>
88
94
  #
89
95
  # options = {
90
- # fetch_options: {
96
+ # read_options: {
91
97
  # database_id: NOTION_DATABASE_ID,
92
98
  # secret: NOTION_API_INTEGRATION_SECRET,
93
99
  # },
94
- # dispatch_options: {
100
+ # process_options: {
95
101
  # webhook: "https://discord.com/api/webhooks/1199213527672565760/KmpoIzBet9xYG16oFh8W1RWHbpIqT7UtTBRrhfLcvWZdNiVZCTM-gpil2Qoy4eYEgpdf",
96
102
  # name: "Birthday Bot"
97
103
  # },
@@ -125,11 +131,12 @@ module UseCases
125
131
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
126
132
  #
127
133
  def self.notify_next_week_birthday_from_notion_to_discord(options)
128
- fetcher = Fetcher::Notion::BirthdayNextWeek.new(options[:fetch_options])
129
- mapper = Mapper::Notion::BirthdayToday.new
134
+ read = Read::Notion::BirthdayNextWeek.new(options[:read_options])
135
+ serialize = Serialize::Notion::BirthdayToday.new
130
136
  formatter = Formatter::Birthday.new(options[:format_options])
131
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
132
- use_case_cofig = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
137
+ process = Process::Discord::Implementation.new(options[:process_options])
138
+ write = Write::Logs::ConsoleLog.new
139
+ use_case_cofig = UseCases::Types::Config.new(read, serialize, formatter, process, write)
133
140
 
134
141
  UseCases::UseCase.new(use_case_cofig)
135
142
  end
@@ -140,11 +147,11 @@ module UseCases
140
147
  # <b>Example</b>
141
148
  #
142
149
  # options = {
143
- # fetch_options: {
150
+ # read_options: {
144
151
  # database_id: NOTION_DATABASE_ID,
145
152
  # secret: NOTION_API_INTEGRATION_SECRET,
146
153
  # },
147
- # dispatch_options: {
154
+ # process_options: {
148
155
  # webhook: "https://discord.com/api/webhooks/1199213527672565760/KmpoIzBet9xYG16oFh8W1RWHbpIqT7UtTBRrhfLcvWZdNiVZCTM-gpil2Qoy4eYEgpdf",
149
156
  # name: "Pto Bot"
150
157
  # }
@@ -172,11 +179,12 @@ module UseCases
172
179
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
173
180
  #
174
181
  def self.notify_pto_from_notion_to_discord(options)
175
- fetcher = Fetcher::Notion::PtoToday.new(options[:fetch_options])
176
- mapper = Mapper::Notion::PtoToday.new
182
+ read = Read::Notion::PtoToday.new(options[:read_options])
183
+ serialize = Serialize::Notion::PtoToday.new
177
184
  formatter = Formatter::Pto.new(options[:format_options])
178
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
179
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
185
+ process = Process::Discord::Implementation.new(options[:process_options])
186
+ write = Write::Logs::ConsoleLog.new
187
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
180
188
 
181
189
  UseCases::UseCase.new(use_case_config)
182
190
  end
@@ -187,11 +195,11 @@ module UseCases
187
195
  # <b>Example</b>
188
196
  #
189
197
  # options = {
190
- # fetch_options: {
198
+ # read_options: {
191
199
  # database_id: NOTION_DATABASE_ID,
192
200
  # secret: NOTION_API_INTEGRATION_SECRET,
193
201
  # },
194
- # dispatch_options: {
202
+ # process_options: {
195
203
  # webhook: "https://discord.com/api/webhooks/1199213527672565760/KmpoIzBet9xYG16oFh8W1RWHbpIqT7UtTBRrhfLcvWZdNiVZCTM-gpil2Qoy4eYEgpdf",
196
204
  # name: "Pto Bot"
197
205
  # },
@@ -223,11 +231,12 @@ module UseCases
223
231
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
224
232
  #
225
233
  def self.notify_next_week_pto_from_notion_to_discord(options)
226
- fetcher = Fetcher::Notion::PtoNextWeek.new(options[:fetch_options])
227
- mapper = Mapper::Notion::PtoToday.new
234
+ read = Read::Notion::PtoNextWeek.new(options[:read_options])
235
+ serialize = Serialize::Notion::PtoToday.new
228
236
  formatter = Formatter::Pto.new(options[:format_options])
229
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
230
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
237
+ process = Process::Discord::Implementation.new(options[:process_options])
238
+ write = Write::Logs::ConsoleLog.new
239
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
231
240
 
232
241
  UseCases::UseCase.new(use_case_config)
233
242
  end
@@ -238,7 +247,7 @@ module UseCases
238
247
  # <b>Example</b>
239
248
  #
240
249
  # options = {
241
- # fetch_options: {
250
+ # read_options: {
242
251
  # connection: {
243
252
  # host: "localhost",
244
253
  # port: 5432,
@@ -247,7 +256,7 @@ module UseCases
247
256
  # password: "postgres"
248
257
  # }
249
258
  # },
250
- # dispatch_options:{
259
+ # process_options:{
251
260
  # webhook: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
252
261
  # name: "Pto Bot"
253
262
  # },
@@ -277,11 +286,12 @@ module UseCases
277
286
  # https://api.slack.com/messaging/webhooks#create_a_webhook
278
287
  #
279
288
  def self.notify_pto_from_postgres_to_slack(options)
280
- fetcher = Fetcher::Postgres::PtoToday.new(options[:fetch_options])
281
- mapper = Mapper::Postgres::PtoToday.new
289
+ read = Read::Postgres::PtoToday.new(options[:read_options])
290
+ serialize = Serialize::Postgres::PtoToday.new
282
291
  formatter = Formatter::Pto.new(options[:format_options])
283
- dispatcher = Dispatcher::Slack::Implementation.new(options[:dispatch_options])
284
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
292
+ process = Process::Slack::Implementation.new(options[:process_options])
293
+ write = Write::Logs::ConsoleLog.new
294
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
285
295
 
286
296
  UseCases::UseCase.new(use_case_config)
287
297
  end
@@ -292,11 +302,11 @@ module UseCases
292
302
  # <b>Example</b>
293
303
  #
294
304
  # options = {
295
- # fetch_options: {
305
+ # read_options: {
296
306
  # database_id: NOTION_DATABASE_ID,
297
307
  # secret: NOTION_API_INTEGRATION_SECRET
298
308
  # },
299
- # dispatch_options: {
309
+ # process_options: {
300
310
  # webhook: "https://discord.com/api/webhooks/1199213527672565760/KmpoIzBet9xYG16oFh8W1RWHbpIqT7UtTBRrhfLcvWZdNiVZCTM-gpil2Qoy4eYEgpdf",
301
311
  # name: "wipLimit"
302
312
  # }
@@ -324,11 +334,12 @@ module UseCases
324
334
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
325
335
  #
326
336
  def self.notify_wip_limit_from_notion_to_discord(options)
327
- fetcher = Fetcher::Notion::WorkItemsLimit.new(options[:fetch_options])
328
- mapper = Mapper::Notion::WorkItemsLimit.new
337
+ read = Read::Notion::WorkItemsLimit.new(options[:read_options])
338
+ serialize = Serialize::Notion::WorkItemsLimit.new
329
339
  formatter = Formatter::WorkItemsLimit.new(options[:format_options])
330
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
331
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
340
+ process = Process::Discord::Implementation.new(options[:process_options])
341
+ write = Write::Logs::ConsoleLog.new
342
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
332
343
 
333
344
  UseCases::UseCase.new(use_case_config)
334
345
  end
@@ -339,7 +350,7 @@ module UseCases
339
350
  # <b>Example</b>
340
351
  #
341
352
  # options = {
342
- # fetch_options: {
353
+ # read_options: {
343
354
  # user: 'info@email.co',
344
355
  # refresh_token: REFRESH_TOKEN,
345
356
  # client_id: CLIENT_ID,
@@ -347,7 +358,7 @@ module UseCases
347
358
  # inbox: 'INBOX',
348
359
  # search_email: 'support@email.co'
349
360
  # },
350
- # dispatch_options: {
361
+ # process_options: {
351
362
  # webhook: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
352
363
  # name: "emailSupport"
353
364
  # }
@@ -366,11 +377,12 @@ module UseCases
366
377
  # https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
367
378
  #
368
379
  def self.notify_support_email_from_imap_to_discord(options)
369
- fetcher = Fetcher::Imap::SupportEmails.new(options[:fetch_options])
370
- mapper = Mapper::Imap::SupportEmails.new
380
+ read = Read::Imap::SupportEmails.new(options[:read_options])
381
+ serialize = Serialize::Imap::SupportEmails.new
371
382
  formatter = Formatter::SupportEmails.new(options[:format_options])
372
- dispatcher = Dispatcher::Discord::Implementation.new(options[:dispatch_options])
373
- use_case_config = UseCases::Types::Config.new(fetcher, mapper, formatter, dispatcher)
383
+ process = Process::Discord::Implementation.new(options[:process_options])
384
+ write = Write::Logs::ConsoleLog.new
385
+ use_case_config = UseCases::Types::Config.new(read, serialize, formatter, process, write)
374
386
 
375
387
  UseCases::UseCase.new(use_case_config)
376
388
  end
data/lib/bas/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bas
4
4
  # Gem version
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end