Class: Leash::Integration::SliteClient

Inherits:
Object
  • Object
show all
Defined in:
lib/leash/integration/slite.rb

Instance Method Summary collapse

Constructor Details

#initialize(leash) ⇒ SliteClient

Create a new Slite integration client.

Parameters:

  • leash (Leash::Client)

    the Leash SDK client



11
12
13
# File 'lib/leash/integration/slite.rb', line 11

def initialize(leash)
  @leash = leash
end

Instance Method Details

#ask_slite(question, parentnoteid: nil) ⇒ Object

Asks a question to Slite and returns an answer with sources.

Parameters:

  • question (String)

    The question to ask Slite.

  • parentnoteid (String, nil) (defaults to: nil)

    Optional filter to only search within notes under this parent note id.

Returns:

  • (Object)


43
44
45
46
47
48
49
# File 'lib/leash/integration/slite.rb', line 43

def ask_slite(question, parentnoteid: nil)
  params = {
    'question' => question,
    'parentNoteId' => parentnoteid
  }.compact
  @leash.call('slite', 'ask-slite', params)
end

#create_note(title, parentnoteid: nil, markdown: nil, html: nil) ⇒ Object

Creates a new note in Slite with the specified title and optional content.

Parameters:

  • title (String)

    The title of the note to create.

  • parentnoteid (String, nil) (defaults to: nil)

    Optional ID of the parent note. If not specified, the note will be created in your personal channel.

  • markdown (String, nil) (defaults to: nil)

    Optional markdown content for the note.

  • html (String, nil) (defaults to: nil)

    Optional HTML content for the note.

Returns:

  • (Object)


84
85
86
87
88
89
90
91
92
# File 'lib/leash/integration/slite.rb', line 84

def create_note(title, parentnoteid: nil, markdown: nil, html: nil)
  params = {
    'title' => title,
    'parentNoteId' => parentnoteid,
    'markdown' => markdown,
    'html' => html
  }.compact
  @leash.call('slite', 'create-note', params)
end

#get_note(noteid, format: nil) ⇒ Object

Retrieves a specific note from Slite by its ID.

Parameters:

  • noteid (String)

    The ID of the note to retrieve.

  • format (String, nil) (defaults to: nil)

    Format of the content to return (md for Markdown or html for HTML). Defaults to md.

Returns:

  • (Object)


56
57
58
59
60
61
62
# File 'lib/leash/integration/slite.rb', line 56

def get_note(noteid, format: nil)
  params = {
    'noteId' => noteid,
    'format' => format
  }.compact
  @leash.call('slite', 'get-note', params)
end

#get_note_children(noteid, cursor: nil) ⇒ Object

Retrieves all child notes of a specific note from Slite.

Parameters:

  • noteid (String)

    The ID of the parent note.

  • cursor (String, nil) (defaults to: nil)

    Cursor to use to continue fetching the note children (for pagination when there are more than 50 children).

Returns:

  • (Object)


69
70
71
72
73
74
75
# File 'lib/leash/integration/slite.rb', line 69

def get_note_children(noteid, cursor: nil)
  params = {
    'noteId' => noteid,
    'cursor' => cursor
  }.compact
  @leash.call('slite', 'get-note-children', params)
end

#search_notes(query, parentnoteid: nil, reviewstate: nil, page: nil, hitsperpage: nil, lasteditedafter: nil, includearchived: nil) ⇒ Object

Searches notes in Slite based on a query and returns the top search results.

Parameters:

  • query (String)

    The search query to perform.

  • parentnoteid (String, nil) (defaults to: nil)

    Optional filter to only return notes under this parent note id.

  • reviewstate (String, nil) (defaults to: nil)

    Optional filter to return notes in a special review state.

  • page (Float, nil) (defaults to: nil)

    Used to perform pagination on search.

  • hitsperpage (Float, nil) (defaults to: nil)

    Specify how many notes to return per page.

  • lasteditedafter (String, nil) (defaults to: nil)

    Optional filter to only return notes edited after a specific date (ISO 8601 format).

  • includearchived (Boolean, nil) (defaults to: nil)

    Optional filter to also include archived notes in the search results (default to false).

Returns:

  • (Object)


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/leash/integration/slite.rb', line 25

def search_notes(query, parentnoteid: nil, reviewstate: nil, page: nil, hitsperpage: nil, lasteditedafter: nil, includearchived: nil)
  params = {
    'query' => query,
    'parentNoteId' => parentnoteid,
    'reviewState' => reviewstate,
    'page' => page,
    'hitsPerPage' => hitsperpage,
    'lastEditedAfter' => lasteditedafter,
    'includeArchived' => includearchived
  }.compact
  @leash.call('slite', 'search-notes', params)
end

#update_note(noteid, title: nil, markdown: nil, html: nil) ⇒ Object

Updates an existing note in Slite. Can update the title and/or content.

Parameters:

  • noteid (String)

    The ID of the note to update.

  • title (String, nil) (defaults to: nil)

    New title for the note.

  • markdown (String, nil) (defaults to: nil)

    New markdown content for the note.

  • html (String, nil) (defaults to: nil)

    New HTML content for the note.

Returns:

  • (Object)


101
102
103
104
105
106
107
108
109
# File 'lib/leash/integration/slite.rb', line 101

def update_note(noteid, title: nil, markdown: nil, html: nil)
  params = {
    'noteId' => noteid,
    'title' => title,
    'markdown' => markdown,
    'html' => html
  }.compact
  @leash.call('slite', 'update-note', params)
end