Class: NotionOrbit::Interactions::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/notion_orbit/interactions/note.rb

Instance Method Summary collapse

Constructor Details

#initialize(note:, orbit_api_key:, orbit_workspace:, notion_api_key:) ⇒ Note

Returns a new instance of Note.



8
9
10
11
12
13
14
15
# File 'lib/notion_orbit/interactions/note.rb', line 8

def initialize(note:, orbit_api_key:, orbit_workspace:, notion_api_key:)
    @note = note
    @orbit_workspace = orbit_workspace
    @orbit_api_key = orbit_api_key
    @notion_api_key = notion_api_key

    after_initialize!
end

Instance Method Details

#after_initialize!Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/notion_orbit/interactions/note.rb', line 17

def after_initialize!
    orbit_service = NotionOrbit::Services::Orbit.new(orbit_workspace: @orbit_workspace, orbit_api_key: @orbit_api_key)
    notion_service = NotionOrbit::Services::Notion.new(notion_api_key: @notion_api_key)

    orbit_service.send_note(
        member_slug: @note[:member_slug],
        api_key: @orbit_api_key,
        content: @note[:content]
    )

    notion_service.mark_note_as_synced(@note[:page_id], orbit_note_url(@note[:member_slug]))
end