wufoo_party 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/wufoo_party.rb +18 -6
- data/test/wufoo_party_test.rb +3 -3
- metadata +2 -2
data/lib/wufoo_party.rb
CHANGED
@@ -8,6 +8,7 @@ class WufooParty
|
|
8
8
|
SUBMIT_ENDPOINT = 'http://%s.wufoo.com/api/insert/'
|
9
9
|
API_VERSION = '2.0'
|
10
10
|
|
11
|
+
# Create a new WufooParty object
|
11
12
|
def initialize(account, api_key)
|
12
13
|
@account = account
|
13
14
|
@api_key = api_key
|
@@ -36,14 +37,25 @@ class WufooParty
|
|
36
37
|
}.merge(data)
|
37
38
|
self.class.post(SUBMIT_ENDPOINT % @account, :body => args)
|
38
39
|
end
|
39
|
-
|
40
|
-
#
|
41
|
-
def
|
40
|
+
|
41
|
+
# Queries a form to get its field details
|
42
|
+
def field_details(form_id)
|
43
|
+
query(form_id)['form']['Fields']
|
44
|
+
end
|
45
|
+
|
46
|
+
# Queries a form to get its field numbers and names and types
|
47
|
+
def field_numbers_and_names_and_types(form_id)
|
48
|
+
get_field_numbers(field_details(form_id))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Converts an array of field specs (returned by Wufoo) into a simple hash of <tt>{FIELDNUM => [FIELDNAME, FIELDTYPE]}</tt>
|
52
|
+
def get_field_numbers(field_data, is_sub_fields=false, typeof=nil)
|
42
53
|
field_data.inject({}) do |hash, field|
|
43
54
|
if field['SubFields']
|
44
|
-
hash.merge!(get_field_numbers(field['SubFields']))
|
45
|
-
|
46
|
-
|
55
|
+
hash.merge!(get_field_numbers(field['SubFields'], :is_sub_fields, field['Typeof']))
|
56
|
+
elsif field['ColumnId'] =~ /^\d+$/
|
57
|
+
title = is_sub_fields && field['ChoicesText'] ? field['ChoicesText'] : field['Title']
|
58
|
+
hash[field['ColumnId']] = [title, field['Typeof'] || typeof]
|
47
59
|
end
|
48
60
|
hash
|
49
61
|
end
|
data/test/wufoo_party_test.rb
CHANGED
@@ -27,13 +27,13 @@ class WufooPartyTest < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
def test_get_field_numbers
|
29
29
|
assert_equal(
|
30
|
-
{'1' => 'Name', '2' => 'Last', '3' => 'Foo'},
|
30
|
+
{'1' => ['Name', 'shortname'], '2' => ['Last', 'shortname'], '3' => ['Foo', 'date']},
|
31
31
|
@wufoo.get_field_numbers([
|
32
|
-
{"Title" => "Name", "SubFields" => [
|
32
|
+
{"Title" => "Name", "Typeof" => "shortname", "SubFields" => [
|
33
33
|
{"Title" => "Name", "ColumnId" => "1"},
|
34
34
|
{"Title" => "Last", "ColumnId" => "2"}
|
35
35
|
]},
|
36
|
-
{"Title" => "Foo", "ColumnId" => "3"}
|
36
|
+
{"Title" => "Foo", "ColumnId" => "3", "Typeof" => "date"}
|
37
37
|
])
|
38
38
|
)
|
39
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wufoo_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Morgan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-15 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|