Class: Mapper::Notion::BirthdayToday

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/bas/mapper/notion/birthday_today.rb

Overview

This class implementats the methods of the Mapper::Base module, specifically designed for preparing or shaping birthdays data coming from a Fetcher::Base implementation.

Constant Summary collapse

BIRTHDAY_PARAMS =
["Complete Name", "BD_this_year"].freeze

Instance Method Summary collapse

Instance Method Details

#map(notion_response) ⇒ Object

Implements the logic for shaping the results from a fetcher response.


Params:

  • Fetcher::Notion::Types::Response notion_response: Notion response object.


return List<Domain::Birthday> birthdays_list, mapped birthdays to be used by a Formatter::Base implementation.



26
27
28
29
30
31
32
33
34
# File 'lib/bas/mapper/notion/birthday_today.rb', line 26

def map(notion_response)
  return [] if notion_response.results.empty?

  normalized_notion_data = normalize_response(notion_response.results)

  normalized_notion_data.map do |birthday|
    Domain::Birthday.new(birthday["Complete Name"], birthday["BD_this_year"])
  end
end