wuparty 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +35 -6
- data/lib/wuparty.rb +51 -20
- metadata +42 -77
data/README.rdoc
CHANGED
@@ -15,7 +15,6 @@ Make sure you have latest version installed (1.0.0 or higher).
|
|
15
15
|
|
16
16
|
== Source & Download
|
17
17
|
|
18
|
-
* {Homepage & Demo}[http://wuparty.71m.us]
|
19
18
|
* {Source Code}[http://github.com/seven1m/wuparty]
|
20
19
|
* {RDoc Documentation}[http://seven1m.github.com/wuparty]
|
21
20
|
|
@@ -25,6 +24,8 @@ Make sure you have latest version installed (1.0.0 or higher).
|
|
25
24
|
|
26
25
|
== Usage
|
27
26
|
|
27
|
+
=== Setup
|
28
|
+
|
28
29
|
require 'wuparty'
|
29
30
|
|
30
31
|
ACCOUNT = 'accountname'
|
@@ -33,24 +34,52 @@ Make sure you have latest version installed (1.0.0 or higher).
|
|
33
34
|
|
34
35
|
wufoo = WuParty.new(ACCOUNT, API_KEY)
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
=== Login
|
38
|
+
|
39
|
+
result = WuParty.login(myIntegrationKey, users_email, users_password)
|
40
|
+
api_key = result['LoginResult']['ApiKey']
|
41
|
+
|
42
|
+
=== Get Form Info
|
43
|
+
|
44
|
+
wufoo.forms
|
45
|
+
form = wufoo.form(FORM_ID)
|
46
|
+
|
47
|
+
=== Get Entries
|
38
48
|
|
39
|
-
# query all entries
|
40
49
|
form.entries
|
41
50
|
|
42
51
|
# ...or filter entries (see http://wufoo.com/docs/api/v3/entries/get/#filter)
|
43
52
|
form.entries([['Field1', 'Is_equal_to', 'Tim']])
|
44
53
|
|
54
|
+
=== Submit
|
55
|
+
|
45
56
|
# To submit, use field numbers shown on the 'API Information' page in Wufoo
|
46
|
-
result =
|
57
|
+
result = form.submit({
|
47
58
|
'Field1' => 'Tim',
|
48
59
|
'Field2' => 'Morgan'
|
49
60
|
})
|
50
61
|
if result['Success'] == 0
|
51
62
|
puts result['ErrorText']
|
52
63
|
end
|
53
|
-
|
64
|
+
|
65
|
+
=== Web Hooks
|
66
|
+
|
67
|
+
# Any submission to this form will now post to the given url.
|
68
|
+
result = form.add_webhook('http://www.postbin.org/zh9iy1')
|
69
|
+
|
70
|
+
# Tell the webhook to include metadata in its postback
|
71
|
+
result = form.add_webhook('http://www.postbin.org/zh9iy1', true)
|
72
|
+
|
73
|
+
result = form.delete_webhook(result["WebHookPutResult"]["Hash"])
|
74
|
+
|
75
|
+
# Or, directly through wufoo:
|
76
|
+
result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1')
|
77
|
+
|
78
|
+
# Tell the webhook to include metadata in its postback
|
79
|
+
result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1', true)
|
80
|
+
|
81
|
+
wufoo.delete_webhook(FORM_ID, result["WebHookPutResult"]["Hash"])
|
82
|
+
|
54
83
|
== Feedback
|
55
84
|
|
56
85
|
I’d love to hear from you if you have suggestions for improvement, bug fixes, or whatever.
|
data/lib/wuparty.rb
CHANGED
@@ -93,6 +93,18 @@ class WuParty
|
|
93
93
|
ENDPOINT = 'https://%s.wufoo.com/api/v3'
|
94
94
|
API_VERSION = '3.0'
|
95
95
|
|
96
|
+
# uses the Login API to fetch a user's API key
|
97
|
+
def self.login(integration_key, email, password, account = nil)
|
98
|
+
result = self.post("https://wufoo.com/api/v3/login.json", { :body => { :integrationKey => integration_key, :email => email, :password => password, :subdomain => account }})
|
99
|
+
if result.is_a?(String)
|
100
|
+
raise ConnectionError, result
|
101
|
+
elsif result['HTTPCode']
|
102
|
+
raise HTTPError.new(result['HTTPCode'], result['Text'])
|
103
|
+
else
|
104
|
+
result
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
96
108
|
# Create a new WuParty object
|
97
109
|
def initialize(account, api_key)
|
98
110
|
@account = account
|
@@ -128,6 +140,14 @@ class WuParty
|
|
128
140
|
end
|
129
141
|
end
|
130
142
|
|
143
|
+
def add_webhook(form_id, url, metadata = false)
|
144
|
+
put("forms/#{form_id}/webhooks", :body => {'url' => url, 'metadata' => metadata})
|
145
|
+
end
|
146
|
+
|
147
|
+
def delete_webhook(form_id, webhook_hash)
|
148
|
+
delete("forms/#{form_id}/webhooks/#{webhook_hash}")
|
149
|
+
end
|
150
|
+
|
131
151
|
# Returns details about the specified report.
|
132
152
|
def report(report_id)
|
133
153
|
if r = get("reports/#{report_id}")['Reports']
|
@@ -136,29 +156,19 @@ class WuParty
|
|
136
156
|
end
|
137
157
|
|
138
158
|
def get(method, options={}) # :nodoc:
|
139
|
-
|
140
|
-
url = "#{base_url}/#{method}.json"
|
141
|
-
result = self.class.get(url, options)
|
142
|
-
if result.is_a?(String)
|
143
|
-
raise ConnectionError, result
|
144
|
-
elsif result['HTTPCode']
|
145
|
-
raise HTTPError.new(result['HTTPCode'], result['Text'])
|
146
|
-
else
|
147
|
-
result
|
148
|
-
end
|
159
|
+
handle_http_verb(:get, method, options)
|
149
160
|
end
|
150
161
|
|
151
162
|
def post(method, options={}) # :nodoc:
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
163
|
+
handle_http_verb(:post, method, options)
|
164
|
+
end
|
165
|
+
|
166
|
+
def put(method, options={}) # :nodoc:
|
167
|
+
handle_http_verb(:put, method, options)
|
168
|
+
end
|
169
|
+
|
170
|
+
def delete(method, options={}) # :nodoc:
|
171
|
+
handle_http_verb(:delete, method, options)
|
162
172
|
end
|
163
173
|
|
164
174
|
private
|
@@ -167,6 +177,19 @@ class WuParty
|
|
167
177
|
ENDPOINT % @account
|
168
178
|
end
|
169
179
|
|
180
|
+
def handle_http_verb(verb, action, options={})
|
181
|
+
options.merge!(:basic_auth => {:username => @api_key})
|
182
|
+
url = "#{base_url}/#{action}.json"
|
183
|
+
result = self.class.send(verb, url, options)
|
184
|
+
if result.is_a?(String)
|
185
|
+
raise ConnectionError, result
|
186
|
+
elsif result['HTTPCode']
|
187
|
+
raise HTTPError.new(result['HTTPCode'], result['Text'])
|
188
|
+
else
|
189
|
+
result
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
170
193
|
public
|
171
194
|
|
172
195
|
# ----------
|
@@ -217,6 +240,14 @@ class WuParty
|
|
217
240
|
@details[id]
|
218
241
|
end
|
219
242
|
|
243
|
+
def add_webhook(url, metadata = false)
|
244
|
+
@party.add_webhook(@details["Hash"], url, metadata)
|
245
|
+
end
|
246
|
+
|
247
|
+
def delete_webhook(webhook_id)
|
248
|
+
@party.delete_webhook(@details["Hash"], webhook_id)
|
249
|
+
end
|
250
|
+
|
220
251
|
# Returns fields and subfields, as a flattened array, e.g.
|
221
252
|
# [{'ID' => 'Field1', 'Title' => 'Name - First', 'Type' => 'shortname', 'Required' => true }, # (subfield)
|
222
253
|
# {'ID' => 'Field2', 'Title' => 'Name - Last', 'Type' => 'shortname', 'Required' => true }, # (subfield)
|
metadata
CHANGED
@@ -1,115 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wuparty
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Tim Morgan
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: httparty
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &18787920 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 6
|
33
|
-
- 1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.6.1
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: multipart-post
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *18787920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multipart-post
|
27
|
+
requirement: &18787120 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 21
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 0
|
49
|
-
- 1
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
50
32
|
version: 1.0.1
|
51
33
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: mime-types
|
55
34
|
prerelease: false
|
56
|
-
|
35
|
+
version_requirements: *18787120
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mime-types
|
38
|
+
requirement: &18786460 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 1
|
64
|
-
- 16
|
65
|
-
version: "1.16"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.16'
|
66
44
|
type: :runtime
|
67
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *18786460
|
68
47
|
description:
|
69
48
|
email: tim@timmorgan.org
|
70
49
|
executables: []
|
71
|
-
|
72
50
|
extensions: []
|
73
|
-
|
74
51
|
extra_rdoc_files: []
|
75
|
-
|
76
|
-
files:
|
52
|
+
files:
|
77
53
|
- README.rdoc
|
78
54
|
- lib/wuparty.rb
|
79
55
|
- test/wuparty_test.rb
|
80
|
-
has_rdoc: true
|
81
56
|
homepage: http://seven1m.github.com/wuparty
|
82
57
|
licenses: []
|
83
|
-
|
84
58
|
post_install_message:
|
85
59
|
rdoc_options: []
|
86
|
-
|
87
|
-
require_paths:
|
60
|
+
require_paths:
|
88
61
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
63
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
|
96
|
-
- 0
|
97
|
-
version: "0"
|
98
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
69
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
107
74
|
requirements: []
|
108
|
-
|
109
75
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.10
|
111
77
|
signing_key:
|
112
78
|
specification_version: 3
|
113
79
|
summary: Ruby wrapper for Wufoo's REST API v3.
|
114
80
|
test_files: []
|
115
|
-
|