formstack-api 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2669b7804e8939a5c727199f0e1aa3ae2d2515cf
4
- data.tar.gz: ee47e04b29a3cca360bcd77876e4f4b135556f31
3
+ metadata.gz: d4550818e45ca4caffc11f17568f2bc56d3035f5
4
+ data.tar.gz: 61d6a9f6490535ee5fd7071651abc6064cefdd4c
5
5
  SHA512:
6
- metadata.gz: 9db243304d627a09c4bfdab0b336c21b75f0246ca5e49e17c627ba9c52d774e7ba77e9f258bb215cf4b132bd6d48ce00c9b7ce87ef6b8a5f7d27758674aec8eb
7
- data.tar.gz: 40a94809cf2643ff6dc33fd0877cff951b75c24f8e1db0a366dbfa92790311bc649785476ce17344989ebfc4faf7a906e723855f1fe1c3fac90a656c403c68c2
6
+ metadata.gz: 59af4928b5511cc03da28f1aee3107817a2baaaf57ee45cce3f105489aff5119344556bf01752f5d493dee50e417e87a26c6d18d88e5d64b3ecf151010b04629
7
+ data.tar.gz: 515b9bf68e4f112c750bc237f146bc47383354892c81ee2f9c2b9b2b32baf5a75e24dfac6d30719080d7f39ba0aee6fbb3400b746b75e16800e6e44a96c0f4b7
@@ -82,6 +82,12 @@ module Formstack
82
82
  request("form/#{form_id}", 'GET');
83
83
  end
84
84
 
85
+ def form_fields(form_id)
86
+ is_numeric?(form_id)
87
+
88
+ request("form/#{form_id}/field.json", 'GET');
89
+ end
90
+
85
91
  def copy_form(form_id)
86
92
  is_numeric?(form_id)
87
93
 
@@ -1,5 +1,5 @@
1
1
  module Formstack
2
2
  module Api
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -13,6 +13,7 @@ SUBMISSION_DETAILS_ID = 000000000
13
13
  SUBMISSION_DETAILS_FORM_ID = 0000000
14
14
  EDIT_SUBMISSION_FIELD_ID = 00000000
15
15
  EDIT_SUBMISSION_ARRAY_FIELD_ID = 00000000
16
+ FORM_FIELDS_ID = 0000000
16
17
 
17
18
  # ACCESS_TOKEN = '982cf05d56baa2f12db45bea51d68968'
18
19
  # INACCESSIBLE_FORM_ID = 1832744
@@ -26,12 +27,14 @@ EDIT_SUBMISSION_ARRAY_FIELD_ID = 00000000
26
27
  # SUBMISSION_DETAILS_FORM_ID = 1873710
27
28
  # EDIT_SUBMISSION_FIELD_ID = 28705506
28
29
  # EDIT_SUBMISSION_ARRAY_FIELD_ID = 28705506
30
+ # FORM_FIELDS_ID = 1881378
29
31
 
30
32
  VCR.configure do |c|
31
33
  c.cassette_library_dir = 'spec/vcr'
32
34
  c.hook_into :webmock # or :fakeweb
33
35
  c.filter_sensitive_data('<ACCESS_TOKEN>') { ACCESS_TOKEN }
34
36
  c.filter_sensitive_data('<FORM_ID>') { SUBMIT_FORM_ID }
37
+ c.filter_sensitive_data('<FORM_FIELDS_ID>') { FORM_FIELDS_ID }
35
38
  c.filter_sensitive_data('<INACCESSIBLE_FORM_ID>') { INACCESSIBLE_FORM_ID }
36
39
  c.filter_sensitive_data('<SUBMISSION_DETAILS_ID>') { SUBMISSION_DETAILS_ID }
37
40
  c.filter_sensitive_data('<UPLOAD_FORM_ID>') { UPLOAD_FORM_ID }
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.formstack.com/api/v2/form/<FORM_FIELDS_ID>/field.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer <ACCESS_TOKEN>
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Mon, 24 Nov 2014 13:17:26 GMT
21
+ Content-Type:
22
+ - application/json; charset=UTF-8
23
+ Content-Length:
24
+ - '234'
25
+ Connection:
26
+ - keep-alive
27
+ P3p:
28
+ - CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI
29
+ DSP COR"
30
+ Set-Cookie:
31
+ - FormstackAdmin=4ln4vl6k68mk99a528o61400t4; path=/api/; secure; HttpOnly
32
+ Cache-Control:
33
+ - no-cache
34
+ X-Robots-Tag:
35
+ - noindex, nofollow
36
+ body:
37
+ encoding: UTF-8
38
+ string: '[{"id":"28906371","label":"Short Answer","hide_label":"0","description":null,"name":"short_answer","type":"text","options":"","default":"","required":"0","uniq":"0","hidden":"0","readonly":"0","colspan":"1","sort":"0","text_size":50}]'
39
+ http_version:
40
+ recorded_at: Mon, 24 Nov 2014 13:17:25 GMT
41
+ recorded_with: VCR 2.9.3
@@ -16,6 +16,7 @@ RSpec.describe Formstack::API do
16
16
  let(:submission_details_form_id) { SUBMISSION_DETAILS_FORM_ID }
17
17
  let(:edit_submission_field_id) { EDIT_SUBMISSION_FIELD_ID }
18
18
  let(:edit_submission_array_field_id) { EDIT_SUBMISSION_ARRAY_FIELD_ID }
19
+ let(:form_fields_id) { FORM_FIELDS_ID }
19
20
 
20
21
  subject(:wrapper) { Formstack::API.new(access_token) }
21
22
 
@@ -334,6 +335,32 @@ RSpec.describe Formstack::API do
334
335
  end
335
336
  end
336
337
 
338
+ describe '#form_fields', :vcr do
339
+ let(:form_fields) { [{"id"=>"28906371",
340
+ "label"=>"Short Answer",
341
+ "hide_label"=>"0",
342
+ "description"=>nil,
343
+ "name"=>"short_answer",
344
+ "type"=>"text",
345
+ "options"=>"",
346
+ "default"=>"",
347
+ "required"=>"0",
348
+ "uniq"=>"0",
349
+ "hidden"=>"0",
350
+ "readonly"=>"0",
351
+ "colspan"=>"1",
352
+ "sort"=>"0",
353
+ "text_size"=>50}] }
354
+
355
+ it 'retrieves all the fields from a form' do
356
+ fields = wrapper.form_fields(form_fields_id)
357
+ expect(fields).to eq(form_fields)
358
+ end
359
+
360
+ it 'raises an exception if form id is not numeric' do
361
+ expect{wrapper.form_fields('fail')}.to raise_exception('Form ID must be numeric')
362
+ end
363
+ end
337
364
  # describe '#', :vcr => { :record => :all } do
338
365
 
339
366
  def get_editable_submission_id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formstack-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauro Morales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-20 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -157,6 +157,7 @@ files:
157
157
  - spec/vcr/Formstack_API/_form_details/reads_a_form_name.yml
158
158
  - spec/vcr/Formstack_API/_form_details/responds_with_an_error_if_form_id_doesnt_exist.yml
159
159
  - spec/vcr/Formstack_API/_form_details/responds_with_an_error_if_you_dont_have_access_to_form.yml
160
+ - spec/vcr/Formstack_API/_form_fields/retrieves_all_the_fields_from_a_form.yml
160
161
  - spec/vcr/Formstack_API/_form_submissions/gets_submissions_default.yml
161
162
  - spec/vcr/Formstack_API/_form_submissions/raises_an_error_if_page_number_is_not_working.yml
162
163
  - spec/vcr/Formstack_API/_form_submissions/returns_data_if_specified.yml
@@ -209,6 +210,7 @@ test_files:
209
210
  - spec/vcr/Formstack_API/_form_details/reads_a_form_name.yml
210
211
  - spec/vcr/Formstack_API/_form_details/responds_with_an_error_if_form_id_doesnt_exist.yml
211
212
  - spec/vcr/Formstack_API/_form_details/responds_with_an_error_if_you_dont_have_access_to_form.yml
213
+ - spec/vcr/Formstack_API/_form_fields/retrieves_all_the_fields_from_a_form.yml
212
214
  - spec/vcr/Formstack_API/_form_submissions/gets_submissions_default.yml
213
215
  - spec/vcr/Formstack_API/_form_submissions/raises_an_error_if_page_number_is_not_working.yml
214
216
  - spec/vcr/Formstack_API/_form_submissions/returns_data_if_specified.yml