Permalink
Browse files

Added the ability to count.

  • Loading branch information...
1 parent 918b42f commit 84135491a15f74e2b77dbc53732725d31f46f445 @delianides delianides committed with Mar 17, 2013
Showing with 22 additions and 2 deletions.
  1. +1 −1 .rvmrc
  2. +21 −1 lib/wuparty.rb
View
2 .rvmrc
@@ -1 +1 @@
-rvm gemset use wuparty
+rvm --create gemset use wuparty
View
@@ -308,10 +308,30 @@ def entries(options={})
query[:sort] = field
query[:sortDirection] = direction || 'ASC'
end
-
+
@party.get("forms/#{@id}/entries", :query => query)['Entries']
end
+ # Return entries already submitted to the form.
+ #
+ # Supports:
+ # Same as Entries above with filtering.
+ # form.count(:filters => [['Field1', 'Is_equal_to', 'Tim']])
+ #
+ # See http://wufoo.com/docs/api/v3/entries/get/#filter for details
+ def count(options={})
+ query = {}
+
+ if options[:filters]
+ query['match'] = options[:filter_match] || 'AND'
+ options[:filters].each_with_index do |filter, index|
+ query["Filter#{ index + 1 }"] = filter.join(' ')
+ end
+ end
+ @party.get("forms/#{@id}/entries/count", :query => query)['EntryCount']
+ end
+
+
# Submit form data to the form.
# Pass data as a hash, with field ids as the hash keys, e.g.
# submit('Field1' => 'Tim', 'Field2' => 'Morgan')

0 comments on commit 8413549

Please sign in to comment.