bas 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +25 -22
  4. data/lib/bas/formatter/base.rb +2 -2
  5. data/lib/bas/formatter/birthday.rb +8 -4
  6. data/lib/bas/formatter/pto.rb +8 -4
  7. data/lib/bas/formatter/support_emails.rb +7 -3
  8. data/lib/bas/formatter/types/response.rb +16 -0
  9. data/lib/bas/formatter/work_items_limit.rb +8 -4
  10. data/lib/bas/process/base.rb +39 -0
  11. data/lib/bas/{dispatcher → process}/discord/exceptions/invalid_webhook_token.rb +1 -1
  12. data/lib/bas/process/discord/implementation.rb +71 -0
  13. data/lib/bas/{dispatcher → process}/discord/types/response.rb +1 -1
  14. data/lib/bas/{dispatcher → process}/slack/exceptions/invalid_webhook_token.rb +1 -1
  15. data/lib/bas/process/slack/implementation.rb +70 -0
  16. data/lib/bas/{dispatcher → process}/slack/types/response.rb +1 -1
  17. data/lib/bas/process/types/response.rb +16 -0
  18. data/lib/bas/{fetcher → read}/base.rb +8 -8
  19. data/lib/bas/{fetcher → read}/github/base.rb +7 -7
  20. data/lib/bas/{fetcher → read}/github/types/response.rb +1 -1
  21. data/lib/bas/read/github/use_case/repo_issues.rb +17 -0
  22. data/lib/bas/{fetcher → read}/imap/base.rb +7 -7
  23. data/lib/bas/{fetcher → read}/imap/types/response.rb +1 -1
  24. data/lib/bas/read/imap/use_case/support_emails.rb +26 -0
  25. data/lib/bas/{fetcher → read}/notion/base.rb +8 -8
  26. data/lib/bas/{fetcher → read}/notion/helper.rb +1 -1
  27. data/lib/bas/{fetcher → read}/notion/types/response.rb +1 -1
  28. data/lib/bas/{fetcher → read}/notion/use_case/birthday_next_week.rb +6 -6
  29. data/lib/bas/{fetcher → read}/notion/use_case/birthday_today.rb +6 -6
  30. data/lib/bas/{fetcher → read}/notion/use_case/pto_next_week.rb +6 -6
  31. data/lib/bas/{fetcher → read}/notion/use_case/pto_today.rb +6 -6
  32. data/lib/bas/{fetcher → read}/notion/use_case/work_items_limit.rb +5 -5
  33. data/lib/bas/{fetcher → read}/postgres/base.rb +8 -8
  34. data/lib/bas/{fetcher → read}/postgres/helper.rb +1 -1
  35. data/lib/bas/{fetcher → read}/postgres/types/response.rb +1 -1
  36. data/lib/bas/{fetcher → read}/postgres/use_case/pto_today.rb +6 -6
  37. data/lib/bas/{mapper → serialize}/base.rb +7 -7
  38. data/lib/bas/{mapper → serialize}/github/issues.rb +7 -7
  39. data/lib/bas/{mapper → serialize}/imap/support_emails.rb +7 -7
  40. data/lib/bas/{mapper → serialize}/notion/birthday_today.rb +7 -7
  41. data/lib/bas/{mapper → serialize}/notion/pto_today.rb +14 -12
  42. data/lib/bas/{mapper → serialize}/notion/work_items_limit.rb +7 -7
  43. data/lib/bas/{mapper → serialize}/postgres/pto_today.rb +7 -7
  44. data/lib/bas/use_cases/types/config.rb +6 -5
  45. data/lib/bas/use_cases/use_case.rb +13 -10
  46. data/lib/bas/use_cases/use_cases.rb +71 -61
  47. data/lib/bas/version.rb +1 -1
  48. data/lib/bas/write/base.rb +36 -0
  49. data/lib/bas/write/logs/base.rb +33 -0
  50. data/lib/bas/write/logs/use_case/console_log.rb +22 -0
  51. metadata +42 -37
  52. data/lib/bas/dispatcher/base.rb +0 -31
  53. data/lib/bas/dispatcher/discord/implementation.rb +0 -51
  54. data/lib/bas/dispatcher/slack/implementation.rb +0 -51
  55. data/lib/bas/fetcher/github/use_case/repo_issues.rb +0 -17
  56. data/lib/bas/fetcher/imap/use_case/support_emails.rb +0 -26
  57. /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_api_key.rb +0 -0
  58. /data/lib/bas/{fetcher → read}/notion/exceptions/invalid_database_id.rb +0 -0
@@ -7,23 +7,23 @@ require "jwt"
7
7
  require_relative "../base"
8
8
  require_relative "./types/response"
9
9
 
10
- module Fetcher
10
+ module Read
11
11
  module Github
12
12
  ##
13
- # This class is an implementation of the Fetcher::Base interface, specifically designed
14
- # for fetching data from a GitHub repository.
13
+ # This class is an implementation of the Read::Base interface, specifically designed
14
+ # for reading data from a GitHub repository.
15
15
  #
16
- class Base < Fetcher::Base
16
+ class Base < Read::Base
17
17
  protected
18
18
 
19
- # Implements the data fetching logic to get data from a Github repository.
19
+ # Implements the data reading logic to get data from a Github repository.
20
20
  # It connects to Github using the octokit gem, authenticates with a github app,
21
21
  # request the data and returns a validated response.
22
22
  #
23
- def execute(method, *filter)
23
+ def read(method, *filter)
24
24
  octokit_response = octokit.public_send(method, *filter)
25
25
 
26
- Fetcher::Github::Types::Response.new(octokit_response)
26
+ Read::Github::Types::Response.new(octokit_response)
27
27
  end
28
28
 
29
29
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Github
5
5
  module Types
6
6
  ##
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Read
6
+ module Github
7
+ ##
8
+ # This class is an implementation of the Read::Github::Base interface, specifically designed
9
+ # for reading issues from a Github repository.
10
+ #
11
+ class RepoIssues < Github::Base
12
+ def execute
13
+ read("list_issues", config[:repo])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,25 +6,25 @@ require "gmail_xoauth"
6
6
  require_relative "../base"
7
7
  require_relative "./types/response"
8
8
 
9
- module Fetcher
9
+ module Read
10
10
  module Imap
11
11
  ##
12
- # This class is an implementation of the Fetcher::Base interface, specifically designed
13
- # for fetching data from an IMAP server.
12
+ # This class is an implementation of the Read::Base interface, specifically designed
13
+ # for reading data from an IMAP server.
14
14
  #
15
- class Base < Fetcher::Base
15
+ class Base < Read::Base
16
16
  protected
17
17
 
18
- # Implements the data fetching logic for emails data from an IMAP server.
18
+ # Implements the reading logic for emails data from an IMAP server.
19
19
  # It connects to an IMAP server inbox, request emails base on a filter,
20
20
  # and returns a validated response.
21
21
  #
22
- def execute(email_domain, email_port, token_uri, query)
22
+ def read(email_domain, email_port, token_uri, query)
23
23
  access_token = refresh_token(token_uri)
24
24
 
25
25
  imap_fetch(email_domain, email_port, query, access_token)
26
26
 
27
- Fetcher::Imap::Types::Response.new(@emails)
27
+ Read::Imap::Types::Response.new(@emails)
28
28
  end
29
29
 
30
30
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Imap
5
5
  module Types
6
6
  ##
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Read
6
+ module Imap
7
+ ##
8
+ # This class is an implementation of the Read::Imap::Base interface, specifically designed
9
+ # for reading 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 reading filter for support emails from Google Gmail.
17
+ #
18
+ def execute
19
+ yesterday = (Time.now - (60 * 60 * 24)).strftime("%d-%b-%Y")
20
+ query = ["TO", config[:search_email], "SINCE", yesterday]
21
+
22
+ read(EMAIL_DOMAIN, EMAIL_PORT, TOKEN_URI, query)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,18 +8,18 @@ require_relative "./exceptions/invalid_database_id"
8
8
  require_relative "./types/response"
9
9
  require_relative "./helper"
10
10
 
11
- module Fetcher
11
+ module Read
12
12
  module Notion
13
13
  ##
14
- # This class is an implementation of the Fetcher::Base interface, specifically designed
15
- # for fetching data from Notion.
14
+ # This class is an implementation of the Read::Base interface, specifically designed
15
+ # for reading data from Notion.
16
16
  #
17
- class Base < Fetcher::Base
17
+ class Base < Read::Base
18
18
  NOTION_BASE_URL = "https://api.notion.com"
19
19
 
20
20
  protected
21
21
 
22
- # Implements the data fetching logic for data from Notion. It sends a POST
22
+ # Implements the read logic for data from Notion. It sends a POST
23
23
  # request to the Notion API to query the specified database and returns a validated response.
24
24
  #
25
25
  # <br>
@@ -28,14 +28,14 @@ module Fetcher
28
28
  # <b>raises</b> <tt>Exceptions::Notion::InvalidDatabaseId</tt> if the Database id provided is incorrect
29
29
  # or invalid.
30
30
  #
31
- def execute(filter)
31
+ def read(filter)
32
32
  url = "#{NOTION_BASE_URL}/v1/databases/#{config[:database_id]}/query"
33
33
 
34
34
  httparty_response = HTTParty.post(url, { body: filter.to_json, headers: headers })
35
35
 
36
- notion_response = Fetcher::Notion::Types::Response.new(httparty_response)
36
+ notion_response = Read::Notion::Types::Response.new(httparty_response)
37
37
 
38
- Fetcher::Notion::Helper.validate_response(notion_response)
38
+ Read::Notion::Helper.validate_response(notion_response)
39
39
  end
40
40
 
41
41
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Notion
5
5
  ##
6
6
  # Provides common fuctionalities along the Notion domain.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Notion
5
5
  module Types
6
6
  ##
@@ -2,18 +2,18 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Notion
7
7
  ##
8
- # This class is an implementation of the Fetcher::Notion::Base interface, specifically designed
9
- # for fetching next week birthdays data from Notion.
8
+ # This class is an implementation of the Read::Notion::Base interface, specifically designed
9
+ # for reading next week birthdays data from Notion.
10
10
  #
11
11
  class BirthdayNextWeek < Notion::Base
12
12
  DAYS_BEFORE_NOTIFY = 8
13
13
 
14
- # Implements the data fetching filter for next week Birthdays data from Notion.
14
+ # Implements the data reading filter for next week Birthdays data from Notion.
15
15
  #
16
- def fetch
16
+ def execute
17
17
  filter = {
18
18
  filter: {
19
19
  or: [
@@ -22,7 +22,7 @@ module Fetcher
22
22
  }
23
23
  }
24
24
 
25
- execute(filter)
25
+ read(filter)
26
26
  end
27
27
 
28
28
  private
@@ -2,16 +2,16 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Notion
7
7
  ##
8
- # This class is an implementation of the Fetcher::Notion::Base interface, specifically designed
9
- # for fetching birthday data from Notion.
8
+ # This class is an implementation of the Read::Notion::Base interface, specifically designed
9
+ # for reading birthday data from Notion.
10
10
  #
11
11
  class BirthdayToday < Notion::Base
12
- # Implements the data fetching filter for todays Birthdays data from Notion.
12
+ # Implements the reading filter for todays Birthdays data from Notion.
13
13
  #
14
- def fetch
14
+ def execute
15
15
  today = Time.now.utc.strftime("%F").to_s
16
16
 
17
17
  filter = {
@@ -22,7 +22,7 @@ module Fetcher
22
22
  }
23
23
  }
24
24
 
25
- execute(filter)
25
+ read(filter)
26
26
  end
27
27
  end
28
28
  end
@@ -2,19 +2,19 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Notion
7
7
  ##
8
- # This class is an implementation of the Fetcher::Notion::Base interface, specifically designed
9
- # for fetching next week Paid Time Off (PTO) data from Notion.
8
+ # This class is an implementation of the Read::Notion::Base interface, specifically designed
9
+ # for reading next week Paid Time Off (PTO) data from Notion.
10
10
  #
11
11
  class PtoNextWeek < Notion::Base
12
- # Implements the data fetching filter for next week PTO's data from Notion.
12
+ # Implements the reading filter for next week PTO's data from Notion.
13
13
  #
14
- def fetch
14
+ def execute
15
15
  filter = build_filter
16
16
 
17
- execute(filter)
17
+ read(filter)
18
18
  end
19
19
 
20
20
  private
@@ -2,16 +2,16 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Notion
7
7
  ##
8
- # This class is an implementation of the Fetcher::Notion::Base interface, specifically designed
9
- # for fetching Paid Time Off (PTO) data from Notion.
8
+ # This class is an implementation of the Read::Notion::Base interface, specifically designed
9
+ # for reading Paid Time Off (PTO) data from Notion.
10
10
  #
11
11
  class PtoToday < Notion::Base
12
- # Implements the data fetching filter for todays PTO's data from Notion.
12
+ # Implements the reading filter for todays PTO's data from Notion.
13
13
  #
14
- def fetch
14
+ def execute
15
15
  today = Time.now.utc.strftime("%F").to_s
16
16
 
17
17
  filter = {
@@ -23,7 +23,7 @@ module Fetcher
23
23
  }
24
24
  }
25
25
 
26
- execute(filter)
26
+ read(filter)
27
27
  end
28
28
  end
29
29
  end
@@ -2,16 +2,16 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Notion
7
7
  ##
8
- # This class is an implementation of the Fetcher::Notion::Base interface, specifically designed
8
+ # This class is an implementation of the Read::Notion::Base interface, specifically designed
9
9
  # for counting "in progress" work items from work item database in Notion.
10
10
  #
11
11
  class WorkItemsLimit < Notion::Base
12
- # Implements the data fetching count of "in progress" work items from Notion.
12
+ # Implements the data reading count of "in progress" work items from Notion.
13
13
  #
14
- def fetch
14
+ def execute
15
15
  filter = {
16
16
  filter: {
17
17
  "and": [
@@ -21,7 +21,7 @@ module Fetcher
21
21
  }
22
22
  }
23
23
 
24
- execute(filter)
24
+ read(filter)
25
25
  end
26
26
 
27
27
  private
@@ -6,28 +6,28 @@ require_relative "../base"
6
6
  require_relative "./types/response"
7
7
  require_relative "./helper"
8
8
 
9
- module Fetcher
9
+ module Read
10
10
  module Postgres
11
11
  ##
12
- # This class is an implementation of the Fetcher::Base interface, specifically designed
13
- # for fetching data from Postgres.
12
+ # This class is an implementation of the Read::Base interface, specifically designed
13
+ # for reading data from Postgres.
14
14
  #
15
- class Base < Fetcher::Base
15
+ class Base < Read::Base
16
16
  protected
17
17
 
18
- # Implements the data fetching logic from a Postgres database. It use the PG gem
18
+ # Implements the read logic from a Postgres database. It use the PG gem
19
19
  # to request data from a local or external database and returns a validated response.
20
20
  #
21
21
  # Gem: pg (https://rubygems.org/gems/pg)
22
22
  #
23
- def execute(query)
23
+ def read(query)
24
24
  pg_connection = PG::Connection.new(config[:connection])
25
25
 
26
26
  pg_result = execute_query(pg_connection, query)
27
27
 
28
- postgres_response = Fetcher::Postgres::Types::Response.new(pg_result)
28
+ postgres_response = Read::Postgres::Types::Response.new(pg_result)
29
29
 
30
- Fetcher::Postgres::Helper.validate_response(postgres_response)
30
+ Read::Postgres::Helper.validate_response(postgres_response)
31
31
  end
32
32
 
33
33
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Postgres
5
5
  ##
6
6
  # Provides common fuctionalities along the Postgres domain.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Fetcher
3
+ module Read
4
4
  module Postgres
5
5
  module Types
6
6
  ##
@@ -2,17 +2,17 @@
2
2
 
3
3
  require_relative "../base"
4
4
 
5
- module Fetcher
5
+ module Read
6
6
  module Postgres
7
7
  ##
8
- # This class is an implementation of the Fetcher::Postgres::Base interface, specifically designed
9
- # for fetching Paid Time Off (PTO) data from a Postgres Database.
8
+ # This class is an implementation of the Read::Postgres::Base interface, specifically designed
9
+ # for reading Paid Time Off (PTO) data from a Postgres Database.
10
10
  #
11
11
  class PtoToday < Base
12
- # Implements the data fetching query for todays PTO data from a Postgres database.
12
+ # Implements the data reading query for todays PTO data from a Postgres database.
13
13
  #
14
- def fetch
15
- execute(build_query)
14
+ def execute
15
+ read(build_query)
16
16
  end
17
17
 
18
18
  private
@@ -2,28 +2,28 @@
2
2
 
3
3
  require_relative "../domain/exceptions/function_not_implemented"
4
4
 
5
- module Mapper
5
+ module Serialize
6
6
  ##
7
- # The Mapper::Base module serves as the foundation for implementing specific data shaping logic within the
8
- # Mapper module. Defines essential methods, that provide a blueprint for organizing or shaping data in a manner
7
+ # The Serialize::Base module serves as the foundation for implementing specific data shaping logic within the
8
+ # Serialize module. Defines essential methods, that provide a blueprint for organizing or shaping data in a manner
9
9
  # suitable for downstream formatting processes.
10
10
  #
11
11
  module Base
12
- # An method meant to prepare or organize the data coming from an implementation of the Fetcher::Base interface.
12
+ # An method meant to prepare or organize the data coming from an implementation of the Read::Base interface.
13
13
  # Must be overridden by subclasses, with specific logic based on the use case.
14
14
  #
15
15
  # <br>
16
16
  # <b>Params:</b>
17
- # * <tt>Fetcher::Notion::Types::Response</tt> response: Response produced by a fetcher.
17
+ # * <tt>Read::Notion::Types::Response</tt> response: Response produced by a reader.
18
18
  #
19
19
  # <br>
20
20
  #
21
21
  # <b>raises</b> <tt>Domain::Exceptions::FunctionNotImplemented</tt> when missing implementation.
22
22
  # <br>
23
23
  #
24
- # <b>returns</b> <tt>List<Domain::></tt> Mapped list of data, ready to be formatted.
24
+ # <b>returns</b> <tt>List<Domain::></tt> Serialize list of data, ready to be formatted.
25
25
  #
26
- def map(_response)
26
+ def execute(_response)
27
27
  raise Domain::Exceptions::FunctionNotImplemented
28
28
  end
29
29
  end
@@ -3,25 +3,25 @@
3
3
  require_relative "../../domain/issue"
4
4
  require_relative "../base"
5
5
 
6
- module Mapper
6
+ module Serialize
7
7
  module Github
8
8
  ##
9
- # This class implementats the methods of the Mapper::Base module, specifically designed for
10
- # preparing or shaping Github issues 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 Github issues data coming from a Read::Base implementation.
11
11
  class Issues
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::Github::Types::Response</tt> github_response: Array of github issues data.
18
+ # * <tt>Read::Github::Types::Response</tt> github_response: Array of github issues data.
19
19
  #
20
20
  # <br>
21
- # <b>return</b> <tt>List<Domain::Issue></tt> mapped github issues to be used by a
21
+ # <b>return</b> <tt>List<Domain::Issue></tt> serialized github issues to be used by a
22
22
  # Formatter::Base implementation.
23
23
  #
24
- def map(github_response)
24
+ def execute(github_response)
25
25
  return [] if github_response.results.empty?
26
26
 
27
27
  normalized_github_data = normalize_response(github_response.results)
@@ -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)
@@ -3,34 +3,34 @@
3
3
  require_relative "../../domain/pto"
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 PTO's 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 PTO's data coming from a Read::Base implementation.
11
11
  #
12
12
  class PtoToday
13
13
  include Base
14
14
 
15
- PTO_PARAMS = ["Person", "Desde?", "Hasta?"].freeze
15
+ PTO_PARAMS = ["Description", "Desde?", "Hasta?"].freeze
16
16
 
17
- # Implements the logic for shaping the results from a fetcher response.
17
+ # Implements the logic for shaping the results from a reader response.
18
18
  #
19
19
  # <br>
20
20
  # <b>Params:</b>
21
- # * <tt>Fetcher::Notion::Types::Response</tt> notion_response: Notion response object.
21
+ # * <tt>Read::Notion::Types::Response</tt> notion_response: Notion response object.
22
22
  #
23
23
  # <br>
24
- # <b>returns</b> <tt>List<Domain::Pto></tt> ptos_list, mapped PTO's to be used by a Formatter::Base
24
+ # <b>returns</b> <tt>List<Domain::Pto></tt> ptos_list, serialized PTO's to be used by a Formatter::Base
25
25
  # implementation.
26
26
  #
27
- def map(notion_response)
27
+ def execute(notion_response)
28
28
  return [] if notion_response.results.empty?
29
29
 
30
30
  normalized_notion_data = normalize_response(notion_response.results)
31
31
 
32
32
  normalized_notion_data.map do |pto|
33
- Domain::Pto.new(pto["Person"], pto["Desde?"], pto["Hasta?"])
33
+ Domain::Pto.new(pto["Description"], pto["Desde?"], pto["Hasta?"])
34
34
  end
35
35
  end
36
36
 
@@ -43,15 +43,17 @@ module Mapper
43
43
  pto_fields = value["properties"].slice(*PTO_PARAMS)
44
44
 
45
45
  {
46
- "Person" => extract_person_field_value(pto_fields["Person"]),
46
+ "Description" => extract_description_field_value(pto_fields["Description"]),
47
47
  "Desde?" => extract_date_field_value(pto_fields["Desde?"]),
48
48
  "Hasta?" => extract_date_field_value(pto_fields["Hasta?"])
49
49
  }
50
50
  end
51
51
  end
52
52
 
53
- def extract_person_field_value(data)
54
- data["people"][0]["name"]
53
+ def extract_description_field_value(data)
54
+ names = data["title"].map { |name| name["plain_text"] }
55
+
56
+ names.join(" ")
55
57
  end
56
58
 
57
59
  def extract_date_field_value(date)