active_forms 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -19
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE +3 -1
- data/README.md +31 -0
- data/Rakefile +3 -49
- data/active_forms.gemspec +16 -81
- data/lib/active_forms.rb +41 -15
- data/lib/active_forms/application.rb +3 -1
- data/lib/active_forms/application_print.rb +2 -0
- data/lib/active_forms/configuration.rb +3 -1
- data/lib/active_forms/entry.rb +51 -0
- data/lib/active_forms/entry_printout.rb +22 -0
- data/lib/active_forms/form.rb +3 -1
- data/lib/active_forms/form_version.rb +19 -0
- data/lib/active_forms/mapper.rb +2 -0
- data/lib/active_forms/request.rb +27 -8
- data/lib/active_forms/token.rb +18 -0
- data/lib/active_forms/version.rb +3 -0
- data/test/active_forms/application_print_test.rb +2 -0
- data/test/active_forms/application_test.rb +2 -0
- data/test/active_forms/entry_printout_test.rb +60 -0
- data/test/active_forms/entry_test.rb +125 -0
- data/test/active_forms/form_test.rb +2 -0
- data/test/active_forms/form_version_test.rb +37 -0
- data/test/active_forms/mapper_test.rb +2 -0
- data/test/active_forms/request_test.rb +14 -12
- data/test/active_forms/token_test.rb +33 -0
- data/test/active_forms_test.rb +2 -0
- data/test/fixtures/get_entries.xml +22 -0
- data/test/fixtures/get_entries_single.xml +14 -0
- data/test/fixtures/get_entrydata.xml +38 -0
- data/test/fixtures/get_entryprintout.xml +15 -0
- data/test/fixtures/get_formaccesstokens.xml +12 -0
- data/test/fixtures/get_forminfo.xml +21 -0
- data/test/fixtures/post_entrydata.xml +12 -0
- data/test/test_helper.rb +5 -4
- metadata +99 -32
- data/.document +0 -5
- data/README.rdoc +0 -7
- data/VERSION +0 -1
data/.gitignore
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
17
9
|
coverage
|
18
|
-
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
19
12
|
pkg
|
20
|
-
|
21
|
-
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/monterail/active_forms.png?branch=master)](http://travis-ci.org/monterail/active_forms)
|
2
|
+
|
3
|
+
# ActiveForms
|
4
|
+
|
5
|
+
ActiveForms API wrapper.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'active_forms'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install active_forms
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create new Pull Request
|
28
|
+
|
29
|
+
## Copyright
|
30
|
+
|
31
|
+
Copyright (c) 2009 Monterail.com. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,55 +1,9 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "active_forms"
|
8
|
-
gem.summary = %Q{Active Forms API wrapper}
|
9
|
-
gem.email = "michal.szajbe@gmail.com"
|
10
|
-
gem.authors = ["Michał Szajbe"]
|
11
|
-
gem.homepage = "http://github.com/monterail/active_forms"
|
12
|
-
gem.add_dependency "activesupport", ">= 0"
|
13
|
-
gem.add_dependency "httparty", ">= 0.5.2"
|
14
|
-
gem.add_development_dependency "thoughtbot-shoulda", ">= 2.10.2"
|
15
|
-
gem.add_development_dependency "fakeweb", ">= 1.2.8"
|
16
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
22
3
|
|
23
4
|
require 'rake/testtask'
|
24
5
|
Rake::TestTask.new(:test) do |test|
|
25
6
|
test.libs << 'lib' << 'test'
|
26
|
-
test.
|
7
|
+
test.test_files = Dir.glob("test/**/*_test.rb")
|
27
8
|
test.verbose = true
|
28
9
|
end
|
29
|
-
|
30
|
-
begin
|
31
|
-
require 'rcov/rcovtask'
|
32
|
-
Rcov::RcovTask.new do |test|
|
33
|
-
test.libs << 'test'
|
34
|
-
test.pattern = 'test/**/*_test.rb'
|
35
|
-
test.verbose = true
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
task :rcov do
|
39
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
task :test => :check_dependencies
|
44
|
-
|
45
|
-
task :default => :test
|
46
|
-
|
47
|
-
require 'rake/rdoctask'
|
48
|
-
Rake::RDocTask.new do |rdoc|
|
49
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
-
|
51
|
-
rdoc.rdoc_dir = 'rdoc'
|
52
|
-
rdoc.title = "active_forms #{version}"
|
53
|
-
rdoc.rdoc_files.include('README*')
|
54
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
-
end
|
data/active_forms.gemspec
CHANGED
@@ -1,86 +1,21 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/active_forms/version', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Micha\xC5\x82 Szajbe"]
|
6
|
+
gem.email = ["michal.szajbe@gmail.com"]
|
7
|
+
gem.summary = %q{Active Forms API wrapper}
|
8
|
+
gem.homepage = "http://github.com/monterail/active_forms"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"README.rdoc"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".document",
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"active_forms.gemspec",
|
26
|
-
"lib/active_forms.rb",
|
27
|
-
"lib/active_forms/application.rb",
|
28
|
-
"lib/active_forms/application_print.rb",
|
29
|
-
"lib/active_forms/configuration.rb",
|
30
|
-
"lib/active_forms/form.rb",
|
31
|
-
"lib/active_forms/mapper.rb",
|
32
|
-
"lib/active_forms/request.rb",
|
33
|
-
"test/active_forms/application_print_test.rb",
|
34
|
-
"test/active_forms/application_test.rb",
|
35
|
-
"test/active_forms/form_test.rb",
|
36
|
-
"test/active_forms/mapper_test.rb",
|
37
|
-
"test/active_forms/request_test.rb",
|
38
|
-
"test/active_forms_test.rb",
|
39
|
-
"test/fixtures/error.xml",
|
40
|
-
"test/fixtures/get_applicationdata.xml",
|
41
|
-
"test/fixtures/get_applicationprint.xml",
|
42
|
-
"test/fixtures/get_applications.xml",
|
43
|
-
"test/fixtures/get_applications_single.xml",
|
44
|
-
"test/fixtures/get_forms.xml",
|
45
|
-
"test/fixtures/get_forms_single.xml",
|
46
|
-
"test/fixtures/success.xml",
|
47
|
-
"test/test_helper.rb"
|
48
|
-
]
|
49
|
-
s.homepage = %q{http://github.com/monterail/active_forms}
|
50
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
51
|
-
s.require_paths = ["lib"]
|
52
|
-
s.rubygems_version = %q{1.3.5}
|
53
|
-
s.summary = %q{Active Forms API wrapper}
|
54
|
-
s.test_files = [
|
55
|
-
"test/active_forms/application_print_test.rb",
|
56
|
-
"test/active_forms/application_test.rb",
|
57
|
-
"test/active_forms/form_test.rb",
|
58
|
-
"test/active_forms/mapper_test.rb",
|
59
|
-
"test/active_forms/request_test.rb",
|
60
|
-
"test/active_forms_test.rb",
|
61
|
-
"test/test_helper.rb"
|
62
|
-
]
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "active_forms"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = ActiveForms::VERSION
|
63
16
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
69
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
70
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
|
71
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 2.10.2"])
|
72
|
-
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
73
|
-
else
|
74
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
75
|
-
s.add_dependency(%q<httparty>, [">= 0.5.2"])
|
76
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 2.10.2"])
|
77
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
78
|
-
end
|
79
|
-
else
|
80
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
81
|
-
s.add_dependency(%q<httparty>, [">= 0.5.2"])
|
82
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 2.10.2"])
|
83
|
-
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
84
|
-
end
|
17
|
+
gem.add_runtime_dependency "activesupport", ">= 0"
|
18
|
+
gem.add_runtime_dependency "httparty", ">= 0.5.2"
|
19
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 2.10.2"
|
20
|
+
gem.add_development_dependency "fakeweb", ">= 1.2.8"
|
85
21
|
end
|
86
|
-
|
data/lib/active_forms.rb
CHANGED
@@ -1,12 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'active_support'
|
4
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
5
|
+
require 'active_support/core_ext/string/inflections'
|
6
|
+
require 'active_support/core_ext/string/starts_ends_with'
|
2
7
|
|
3
8
|
require 'active_forms/configuration'
|
4
9
|
require 'active_forms/mapper'
|
5
10
|
require 'active_forms/request'
|
11
|
+
require 'active_forms/version'
|
6
12
|
|
7
13
|
require 'active_forms/application'
|
8
14
|
require 'active_forms/application_print'
|
15
|
+
require 'active_forms/entry'
|
16
|
+
require 'active_forms/entry_printout'
|
9
17
|
require 'active_forms/form'
|
18
|
+
require 'active_forms/form_version'
|
19
|
+
require 'active_forms/token'
|
10
20
|
|
11
21
|
module ActiveForms
|
12
22
|
class << self
|
@@ -16,21 +26,37 @@ module ActiveForms
|
|
16
26
|
self.configuration ||= Configuration.new
|
17
27
|
yield(configuration)
|
18
28
|
end
|
29
|
+
|
30
|
+
def log(msg)
|
31
|
+
if configuration.logger
|
32
|
+
configuration.logger.info(msg)
|
33
|
+
end
|
34
|
+
end
|
19
35
|
end
|
20
36
|
|
21
|
-
class Error
|
22
|
-
|
23
|
-
class
|
24
|
-
class
|
25
|
-
class
|
26
|
-
class
|
27
|
-
class
|
28
|
-
class
|
29
|
-
class
|
30
|
-
class
|
31
|
-
class
|
32
|
-
class
|
33
|
-
class
|
34
|
-
class
|
35
|
-
class
|
37
|
+
class Error < StandardError; end
|
38
|
+
|
39
|
+
class ApiKeyInvalid < Error; end
|
40
|
+
class ApiSigInvalid < Error; end
|
41
|
+
class ApiTimestampInvalid < Error; end
|
42
|
+
class ApiVersionNotSupported < Error; end
|
43
|
+
class ApplicationNotFound < Error; end
|
44
|
+
class ApplicationNotSent < Error; end
|
45
|
+
class BadParameterFormat < Error; end
|
46
|
+
class FieldNotFound < Error; end
|
47
|
+
class FieldNotMultiple < Error; end
|
48
|
+
class Forbidden < Error; end
|
49
|
+
class FormActiveVersionNotFound < Error; end
|
50
|
+
class FormNotFound < Error; end
|
51
|
+
class FormVersionNotFound < Error; end
|
52
|
+
class InternalServerError < Error; end
|
53
|
+
class MethodNotAllowed < Error; end
|
54
|
+
class MissingParameter < Error; end
|
55
|
+
class MissingResource < Error; end
|
56
|
+
class MissingVendor < Error; end
|
57
|
+
class NullResponse < Error; end
|
58
|
+
class OptionNotFound < Error; end
|
59
|
+
class ResourceNotSupported < Error; end
|
60
|
+
class TemplateNotFound < Error; end
|
61
|
+
class Unauthorized < Error; end
|
36
62
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
class ActiveForms::Application < ActiveForms::Mapper
|
2
4
|
columns :number, :formCode, :formVersion, :date, :status, :isPrintable, :fieldData
|
3
5
|
|
@@ -10,7 +12,7 @@ class ActiveForms::Application < ActiveForms::Mapper
|
|
10
12
|
hashes = response["applications"]["application"]
|
11
13
|
hashes = [hashes] if hashes.is_a?(Hash)
|
12
14
|
|
13
|
-
objects = hashes.map { |attributes| new(attributes) }
|
15
|
+
objects = hashes.nil? ? [] : hashes.map { |attributes| new(attributes) }
|
14
16
|
end
|
15
17
|
|
16
18
|
# required params:
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
module ActiveForms
|
2
4
|
class Configuration
|
3
|
-
attr_accessor :api_url, :url, :base_url, :api_key, :secret_key
|
5
|
+
attr_accessor :api_url, :url, :base_url, :api_key, :secret_key, :logger
|
4
6
|
|
5
7
|
def initialize
|
6
8
|
@api_url = { :protocol => "https", :host => 'api.activeforms.com' }
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class ActiveForms::Entry < ActiveForms::Mapper
|
4
|
+
columns :number, :formCode, :formVersionCode, :date, :status, :isPrintable, :fieldData, :accessToken
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def all(params = {})
|
9
|
+
response = ActiveForms::Request.get("entries", params)
|
10
|
+
|
11
|
+
hashes = response["entries"]["entry"]
|
12
|
+
hashes = [hashes] if hashes.is_a?(Hash)
|
13
|
+
|
14
|
+
objects = hashes.nil? ? [] : hashes.map { |attributes| new(attributes) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# required params:
|
18
|
+
# apiFormCode - form's code
|
19
|
+
# apiNumber or apiEntryToken - entry's number or token
|
20
|
+
def find(params = {})
|
21
|
+
response = ActiveForms::Request.get("entrydata", params)
|
22
|
+
|
23
|
+
attributes = response["entryData"]
|
24
|
+
|
25
|
+
new(attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
# required params:
|
29
|
+
# apiFormCode
|
30
|
+
# field id
|
31
|
+
def create(params = {})
|
32
|
+
response = ActiveForms::Request.post("entrydata", params)
|
33
|
+
|
34
|
+
attributes = response["entryPutConfirmation"]
|
35
|
+
|
36
|
+
new(attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
# required params:
|
40
|
+
# apiFormCode
|
41
|
+
# apiNumber or apiEntryToken
|
42
|
+
def delete(params = {})
|
43
|
+
response = ActiveForms::Request.delete("entrydata", params)
|
44
|
+
response && response.code.to_i == 204
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
ActiveForms::Entry.delete :apiFormCode => self.formCode, :apiNumber => self.number
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class ActiveForms::EntryPrintout < ActiveForms::Mapper
|
4
|
+
columns :formCode, :formVersionCode, :number, :date, :status, :contentType, :identifier, :printoutContent
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# required params:
|
8
|
+
# apiFormCode - Form's code
|
9
|
+
# apiNumber - Application's number
|
10
|
+
def find(params = {})
|
11
|
+
response = ActiveForms::Request.get("entryprintout", params)
|
12
|
+
|
13
|
+
attributes = response["entryPrintout"]
|
14
|
+
|
15
|
+
new(attributes)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def printoutContent=(value)
|
20
|
+
@attributes["printoutContent"] = value.is_a?(String) ? value.strip : super
|
21
|
+
end
|
22
|
+
end
|