prontoforms 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/prontoforms.rb +6 -0
- data/lib/prontoforms/client.rb +41 -0
- data/lib/prontoforms/form_space.rb +10 -0
- data/lib/prontoforms/form_submission.rb +36 -0
- data/lib/prontoforms/resource.rb +34 -0
- data/lib/prontoforms/resource_list.rb +25 -0
- data/lib/prontoforms/version.rb +3 -0
- data/prontoforms.gemspec +35 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1aa48580fd863fe9681a3ba6f901415e0775c082929532bd63e8c93de86bf121
|
4
|
+
data.tar.gz: 5a21dd84aef6f4da5d285fa1587aebf79fec6d279aa10048efa0f1c6a29a1f48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80299aa7c0a311c26467325e425b6f9ec39c5eda4692a9d613b40a07fe267b7751a88ecdca714071292a6f827520c35781bba0202023e9fd877dd3d6e851e0d4
|
7
|
+
data.tar.gz: '08f2da72649027dee6103e24b7d932047069d9e9ebabd36b1688928ec6f2359100d4d2d6a2e22eeef4e17e1b5941752b306b9351c37a86f65dc980adf1c0c15a'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
prontoforms (0.1.0)
|
5
|
+
faraday (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
faraday (1.0.1)
|
12
|
+
multipart-post (>= 1.2, < 3)
|
13
|
+
multipart-post (2.1.1)
|
14
|
+
rake (10.5.0)
|
15
|
+
rspec (3.9.0)
|
16
|
+
rspec-core (~> 3.9.0)
|
17
|
+
rspec-expectations (~> 3.9.0)
|
18
|
+
rspec-mocks (~> 3.9.0)
|
19
|
+
rspec-core (3.9.2)
|
20
|
+
rspec-support (~> 3.9.3)
|
21
|
+
rspec-expectations (3.9.2)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.9.0)
|
24
|
+
rspec-mocks (3.9.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.9.0)
|
27
|
+
rspec-support (3.9.3)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 2.0)
|
34
|
+
prontoforms!
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec (~> 3.0)
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Paul Holden
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# ProntoForms
|
2
|
+
|
3
|
+
A library for interacting with the ProntoForms REST API in Ruby applications.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'prontoforms'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install prontoforms
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Check back later
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
28
|
+
run `rake spec` to run the tests. You can also run `bin/console` for an
|
29
|
+
interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/paulholden2/prontoforms.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "prontoforms"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/prontoforms.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require 'prontoforms/resource_list'
|
4
|
+
require 'prontoforms/form_space'
|
5
|
+
require 'prontoforms/form_submission'
|
6
|
+
|
7
|
+
module ProntoForms
|
8
|
+
class Client
|
9
|
+
attr_reader :api_key_id, :api_key_secret
|
10
|
+
|
11
|
+
def initialize(api_key_id, api_key_secret)
|
12
|
+
@api_key_id = api_key_id
|
13
|
+
@api_key_secret = api_key_secret
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.resource(method, verb: :get, resource:, url: resource.resource_name)
|
17
|
+
# TODO: Raise error if verb is invalid
|
18
|
+
|
19
|
+
define_method(method) do |query: {}|
|
20
|
+
res = connection.send(verb) do |req|
|
21
|
+
req.url url
|
22
|
+
query.each { |k, v| req.params[k] = v }
|
23
|
+
end
|
24
|
+
if res.success?
|
25
|
+
ResourceList.new(JSON.parse(res.body), 0, 20, method, resource, self)
|
26
|
+
else
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
resource :form_spaces, resource: FormSpace
|
33
|
+
resource :form_submissions, resource: FormSubmission
|
34
|
+
|
35
|
+
def connection
|
36
|
+
Faraday.new(url: 'https://api.prontoforms.com/api/1.1') do |conn|
|
37
|
+
conn.basic_auth(api_key_id, api_key_secret)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'prontoforms/resource'
|
2
|
+
|
3
|
+
module ProntoForms
|
4
|
+
class FormSpace < Resource
|
5
|
+
property :id, key: 'identifier'
|
6
|
+
property :name, key: 'name'
|
7
|
+
property :problem_contact_email, key: 'problemContactEmail'
|
8
|
+
property :push_updates_to_device, key: 'pushUpdatesToDevice'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'prontoforms/resource'
|
3
|
+
|
4
|
+
module ProntoForms
|
5
|
+
class FormSubmission < Resource
|
6
|
+
def self.resource_name() 'data'; end
|
7
|
+
|
8
|
+
property :id, key: 'identifier'
|
9
|
+
property :reference_number, key: 'referenceNumber'
|
10
|
+
property :state, key: 'state'
|
11
|
+
property :data_state, key: 'dataState'
|
12
|
+
property :data_persisted, key: 'dataPersisted'
|
13
|
+
property :form_version_id, key: 'formVersionId'
|
14
|
+
property :form_id, key: 'formId'
|
15
|
+
property :user_id, key: 'userId'
|
16
|
+
property :username, key: 'username'
|
17
|
+
# Aliases
|
18
|
+
property :data_persisted?, key: 'dataPersisted'
|
19
|
+
property :submitter_id, key: 'userId'
|
20
|
+
property :submitter_username, key: 'username'
|
21
|
+
|
22
|
+
property :server_receive_date do
|
23
|
+
str = data.fetch('serverReceiveDate')
|
24
|
+
str.nil? ? nil : DateTime.strptime(str)
|
25
|
+
end
|
26
|
+
|
27
|
+
def pages
|
28
|
+
res = client.connection.get do |req|
|
29
|
+
req.url "#{resource_name}/#{id}/document.json"
|
30
|
+
end
|
31
|
+
if res.success?
|
32
|
+
JSON.parse(res.body).fetch('pages')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module ProntoForms
|
4
|
+
class Resource
|
5
|
+
attr_reader :data, :client, :parent
|
6
|
+
|
7
|
+
def self.property(name, key: nil, &block)
|
8
|
+
define_method(name) {
|
9
|
+
if block_given?
|
10
|
+
instance_eval(&block)
|
11
|
+
elsif !key.nil?
|
12
|
+
data.fetch(key)
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(data, client, parent = nil)
|
20
|
+
@data = data
|
21
|
+
@client = client
|
22
|
+
@parent = parent
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.resource_name
|
26
|
+
name = self.to_s.split("::").last
|
27
|
+
"#{name.downcase}s"
|
28
|
+
end
|
29
|
+
|
30
|
+
def resource_name
|
31
|
+
self.class.resource_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'prontoforms/resource'
|
2
|
+
|
3
|
+
module ProntoForms
|
4
|
+
class ResourceList < Resource
|
5
|
+
attr_reader :limit, :offset, :method, :resource, :client, :parent
|
6
|
+
|
7
|
+
def initialize(data, offset, limit, method, resource, client, parent = nil)
|
8
|
+
super(data, client)
|
9
|
+
@limit = limit
|
10
|
+
@offset = offset
|
11
|
+
@method = method
|
12
|
+
@resource = resource
|
13
|
+
end
|
14
|
+
|
15
|
+
def next
|
16
|
+
client.send(method, limit: limit, offset: offset + limit)
|
17
|
+
end
|
18
|
+
|
19
|
+
def items
|
20
|
+
@data.fetch('pageData').map { |item|
|
21
|
+
resource.new(item, client, parent)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/prontoforms.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'lib/prontoforms/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'prontoforms'
|
5
|
+
spec.version = ProntoForms::VERSION
|
6
|
+
spec.authors = ['Paul Holden']
|
7
|
+
spec.email = ['paul@holdensoftware.com']
|
8
|
+
|
9
|
+
spec.summary = 'A library for using the ProntoForms REST API in Ruby applications.'
|
10
|
+
spec.description = 'A library for using the ProntoForms REST API in Ruby applications.'
|
11
|
+
spec.homepage = 'https://github.com/paulholden2/prontoforms'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
|
+
|
15
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/paulholden2/prontoforms'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/paulholden2/prontoforms/blog/master/CHANGELOG.md'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'faraday', '~> 1.0'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prontoforms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Holden
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: A library for using the ProntoForms REST API in Ruby applications.
|
70
|
+
email:
|
71
|
+
- paul@holdensoftware.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/prontoforms.rb
|
88
|
+
- lib/prontoforms/client.rb
|
89
|
+
- lib/prontoforms/form_space.rb
|
90
|
+
- lib/prontoforms/form_submission.rb
|
91
|
+
- lib/prontoforms/resource.rb
|
92
|
+
- lib/prontoforms/resource_list.rb
|
93
|
+
- lib/prontoforms/version.rb
|
94
|
+
- prontoforms.gemspec
|
95
|
+
homepage: https://github.com/paulholden2/prontoforms
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata:
|
99
|
+
allowed_push_host: https://rubygems.org
|
100
|
+
homepage_uri: https://github.com/paulholden2/prontoforms
|
101
|
+
source_code_uri: https://github.com/paulholden2/prontoforms
|
102
|
+
changelog_uri: https://github.com/paulholden2/prontoforms/blog/master/CHANGELOG.md
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.3.0
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubygems_version: 3.0.8
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: A library for using the ProntoForms REST API in Ruby applications.
|
122
|
+
test_files: []
|