Class: Todoist::Sync::Filters

Inherits:
Todoist::Service show all
Includes:
Util
Defined in:
lib/todoist/sync/filters.rb

Instance Method Summary collapse

Methods inherited from Todoist::Service

#initialize

Constructor Details

This class inherits a constructor from Todoist::Service

Instance Method Details

#add(args) ⇒ Object

Add a filter with a given hash of attributes and returns the filter id.

Please note that item_id is required as is a date as specific in the documentation. This method can be tricky to all.



16
17
18
# File 'lib/todoist/sync/filters.rb', line 16

def add(args)
  return @client.api_helper.add(args, "filter_add")
end

#collectionObject

Return a Hash of filters where key is the id of a filter and value is a filter



9
10
11
# File 'lib/todoist/sync/filters.rb', line 9

def collection
  return @client.api_helper.collection("filters")
end

#delete(filter) ⇒ Object

Delete filter given an array of filters



26
27
28
29
# File 'lib/todoist/sync/filters.rb', line 26

def delete(filter)
  args = {id: filter.id}
  return @client.api_helper.command(args, "filter_delete")
end

#update(args) ⇒ Object

Update a filter given a hash of attributes



21
22
23
# File 'lib/todoist/sync/filters.rb', line 21

def update(args)
  return @client.api_helper.command(args, "filter_update")
end

#update_multiple_orders(filters) ⇒ Object

Update orders for an array of filters



32
33
34
35
36
37
38
39
# File 'lib/todoist/sync/filters.rb', line 32

def update_multiple_orders(filters)
  args = {}
  filters.each do |filter|
    args[filter.id] = filter.item_order
  end
  args = {id_order_mapping: args.to_json}
  return @client.api_helper.command(args, "filter_update_orders")
end