Sha256: abf325309d1d5cf428ba4d2addf861e39faa54f28c4f65e864edbac91fb61c79

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "json"

module NotionOrbit
    module Interactions
        class Note
            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

            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

            private

            def orbit_note_url(member_slug)
                "https://app.orbit.love/#{@orbit_workspace}/members/#{member_slug}?type=notes"
            end
        end
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
notion_orbit-0.0.7 lib/notion_orbit/interactions/note.rb
notion_orbit-0.0.6 lib/notion_orbit/interactions/note.rb
notion_orbit-0.0.5 lib/notion_orbit/interactions/note.rb
notion_orbit-0.0.4 lib/notion_orbit/interactions/note.rb
notion_orbit-0.0.3 lib/notion_orbit/interactions/note.rb