Class: BaseCRM::NotesService
- Inherits:
-
Object
- Object
- BaseCRM::NotesService
- Defined in:
- lib/basecrm/services/notes_service.rb
Constant Summary collapse
- OPTS_KEYS_TO_PERSIST =
Set[:content, :resource_id, :resource_type]
Instance Method Summary collapse
-
#all ⇒ Enumerable
Retrieve all notes.
-
#create(note) ⇒ Note
Create a note.
-
#destroy(id) ⇒ Boolean
Delete a note.
-
#find(id) ⇒ Note
Retrieve a single note.
-
#initialize(client) ⇒ NotesService
constructor
A new instance of NotesService.
-
#update(note) ⇒ Note
Update a note.
-
#where(options = {}) ⇒ Array<Note>
Retrieve all notes.
Constructor Details
#initialize(client) ⇒ NotesService
Returns a new instance of NotesService.
7 8 9 |
# File 'lib/basecrm/services/notes_service.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#all ⇒ Enumerable
Retrieve all notes
get ‘/notes’
If you want to use filtering or sorting (see #where).
17 18 19 |
# File 'lib/basecrm/services/notes_service.rb', line 17 def all PaginatedResource.new(self) end |
#create(note) ⇒ Note
Create a note
post ‘/notes’
Create a new note and associate it with one of the resources listed below:
-
[Leads](/docs/rest/reference/leads)
-
[Contacts](/docs/rest/reference/contacts)
-
[Deals](/docs/rest/reference/deals)
56 57 58 59 60 61 62 63 |
# File 'lib/basecrm/services/notes_service.rb', line 56 def create(note) validate_type!(note) attributes = sanitize(note) _, _, root = @client.post("/notes", attributes) Note.new(root[:data]) end |
#destroy(id) ⇒ Boolean
Delete a note
delete ‘/notes/BaseCRM#id’
Delete an existing note If the note ID does not exist, this request will return an error This operation cannot be undone
113 114 115 116 |
# File 'lib/basecrm/services/notes_service.rb', line 113 def destroy(id) status, _, _ = @client.delete("/notes/#{id}") status == 204 end |
#find(id) ⇒ Note
Retrieve a single note
get ‘/notes/BaseCRM#id’
Returns a single note available to the user, according to the unique note ID provided If the note ID does not exist, this request will return an error
75 76 77 78 79 |
# File 'lib/basecrm/services/notes_service.rb', line 75 def find(id) _, _, root = @client.get("/notes/#{id}") Note.new(root[:data]) end |
#update(note) ⇒ Note
Update a note
put ‘/notes/BaseCRM#id’
Updates note information If the note ID does not exist, this request will return an error
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/basecrm/services/notes_service.rb', line 91 def update(note) validate_type!(note) params = extract_params!(note, :id) id = params[:id] attributes = sanitize(note) _, _, root = @client.put("/notes/#{id}", attributes) Note.new(root[:data]) end |
#where(options = {}) ⇒ Array<Note>
Retrieve all notes
get ‘/notes’
Returns all notes available to the user, according to the parameters provided
38 39 40 41 42 |
# File 'lib/basecrm/services/notes_service.rb', line 38 def where( = {}) _, _, root = @client.get("/notes", ) root[:items].map{ |item| Note.new(item[:data]) } end |