Sha256: 5380c0eb7f99f68005879f372fb7a317da3bee191b50a1d727d8217d22eec8d4

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents


module Todoist
  module Sync
    class Filters < Todoist::Service
        include Todoist::Util  

        # Return a Hash of filters where key is the id of a filter and value is a filter
        def collection
          return @client.api_helper.collection("filters")
        end

        # 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.
        def add(args)
          return @client.api_helper.add(args, "filter_add")
        end

        # Update a filter given a hash of attributes
        def update(args)
          return @client.api_helper.command(args, "filter_update")
        end

        # Delete filter given an array of filters
        def delete(filter)
          args = {id: filter.id}
          return @client.api_helper.command(args, "filter_delete")
        end
  
        # Update orders for an array of filters
        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


    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
todoist-ruby-0.2.7 lib/todoist/sync/filters.rb
todoist-ruby-0.2.6 lib/todoist/sync/filters.rb
todoist-ruby-0.2.5 lib/todoist/sync/filters.rb
todoist-ruby-0.2.4 lib/todoist/sync/filters.rb
todoist-ruby-0.2.3 lib/todoist/sync/filters.rb
todoist-ruby-0.2.2 lib/todoist/sync/filters.rb
todoist-ruby-0.2.1 lib/todoist/sync/filters.rb