paperform-ruby 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d483735478590697492be1a869f9536ef36275642a1ae95922cc94d65bc8caf8
4
+ data.tar.gz: 4c605b376aff5dd81ad32d21f63dc96436db4bb2b1ca19a090c6339af6c88ef6
5
+ SHA512:
6
+ metadata.gz: 5f7f619a11e75537b0c858e0714f65f0ba5bd7b55c46e887bb12c3d838f2309907737c7b1b92535c48ed36280d28adba657ead24055bc97e34b8343a40f4f152
7
+ data.tar.gz: 482dd37a6075cfbf8c5e661015bf7e897e64b8a82510d8f7c187464bf5657801c96a7c99eb363fe113723fec4e731725b30474123530a0a2fb436a5d7be48945
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.2.6
7
+ before_install: gem install bundler -v 1.16.6
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in paperform-ruby.gemspec
6
+ gemspec
7
+
8
+ gem 'curb'
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ paperform-ruby (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ curb (0.9.10)
10
+ diff-lcs (1.3)
11
+ rake (10.5.0)
12
+ rspec (3.8.0)
13
+ rspec-core (~> 3.8.0)
14
+ rspec-expectations (~> 3.8.0)
15
+ rspec-mocks (~> 3.8.0)
16
+ rspec-core (3.8.2)
17
+ rspec-support (~> 3.8.0)
18
+ rspec-expectations (3.8.4)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-mocks (3.8.1)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-support (3.8.2)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.16)
31
+ curb
32
+ paperform-ruby!
33
+ rake (~> 10.0)
34
+ rspec (~> 3.0)
35
+
36
+ BUNDLED WITH
37
+ 1.16.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Neeraj Kapoor
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,63 @@
1
+ # Paperform-Ruby
2
+
3
+ This gem is a VERY basic wrapper around the very new Paperform API. I love Paperform and use it a lot in a lot of my projects. The API will help a lot and this wrapper should (hopefully!) make things easier as well.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'paperform-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install paperform-ruby
20
+
21
+ ## Usage
22
+
23
+ Head to the [developer documentation page](https://paperform.co/developer/api-v1-documentation/) on the paperform website for general info about the api. To get started, you'll need to generate a token. This will serve as the bearer token passed with every request you send to Paperform. Visit [this page](https://paperform.co/account/developer) in your paperform account to generate one. Note that you'll need to have a Pro or Agency account in order to use the API. Store this somewhere in your rails app (like a .env file or something). From there, you can use the gem like this:
24
+
25
+ ### Submissions
26
+
27
+ ```ruby
28
+ require 'paperform'
29
+
30
+ submission = Paperform::Submission.new(ENV['PAPERFORM_TOKEN']) # assuming I stored my paperform token in the env variable PAPERFORM_TOKEN
31
+
32
+ submission.list('sample-form') # this is the slug prefix in your paperform url. Ie, sample-form.paperform.co.
33
+
34
+ submission.list('<uuid>') # this is the uuid of the submission. You can find this value for a given submission in your paperform account
35
+
36
+ ```
37
+
38
+ This will return a list of submitted forms. You can also pass an options hash as a second parameter. Check the developer documentation link above for attributes you can send in this options hash.
39
+
40
+
41
+ ### Partial Submissions
42
+
43
+ ```ruby
44
+ require 'paperform'
45
+
46
+ partial_sub = Paperform::PartialSubmission.new(ENV['PAPERFORM_TOKEN']) # assuming I stored my paperform token in the env variable PAPERFORM_TOKEN
47
+
48
+ partial_sub.list('sample-form') # this is the slug prefix in your paperform url. Ie, sample-form.paperform.co.
49
+
50
+ partial_sub.list('<uuid>') # this is the uuid of the submission. You can find this value for a given submission in your paperform account
51
+
52
+ ```
53
+
54
+ This will return a list of partially submitted forms. You can also pass an options hash as a second parameter. Check the developer documentation link above for attributes you can send in this options hash.
55
+
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nekapoor/paperform-ruby.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "paperform"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/paperform.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'paperform/partial_submission'
2
+ require 'paperform/submission'
@@ -0,0 +1,32 @@
1
+ module Paperform
2
+ class PartialSubmission
3
+ attr_reader :token
4
+
5
+ BASE_URL = 'https://api.paperform.co/v1/partial-submissions'
6
+
7
+ def initialize(token)
8
+ @token = token
9
+ end
10
+
11
+ def find(id)
12
+ params = { id: id }
13
+
14
+ response = Curl.get(BASE_URL, params) do |http|
15
+ http.headers['Authorization'] = "Bearer #{token}"
16
+ end
17
+
18
+ response.body
19
+ end
20
+
21
+ def list(form_id, options = nil)
22
+ params = { form: form_id }
23
+ params.merge!(options) if options
24
+
25
+ response = Curl.get(BASE_URL, params) do |http|
26
+ http.headers['Authorization'] = "Bearer #{token}"
27
+ end
28
+
29
+ response.body
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module Paperform
2
+ class Submission
3
+ attr_reader :token
4
+
5
+ BASE_URL = 'https://api.paperform.co/v1/submissions'
6
+
7
+ def initialize(token)
8
+ @token = token
9
+ end
10
+
11
+ def find(id)
12
+ params = { id: id }
13
+
14
+ response = Curl.get(BASE_URL, params) do |http|
15
+ http.headers['Authorization'] = "Bearer #{token}"
16
+ end
17
+
18
+ response.body
19
+ end
20
+
21
+ def list(form_id, options = nil)
22
+ params = { form: form_id }
23
+ params.merge!(options) if options
24
+
25
+ response = Curl.get(BASE_URL, params) do |http|
26
+ http.headers['Authorization'] = "Bearer #{token}"
27
+ end
28
+
29
+ response.body
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "paperform-ruby"
7
+ spec.version = "1.0.0"
8
+ spec.authors = ["Neeraj Kapoor"]
9
+ spec.email = ["neeraj.kapoor@learntobe.org"]
10
+
11
+ spec.summary = %q{A wrapper around the paperform api.}
12
+ spec.description = %q{A wrapper around the paperform api.}
13
+ spec.homepage = "https://github.com/nekapoor/paperform-ruby"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paperform-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Neeraj Kapoor
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A wrapper around the paperform api.
56
+ email:
57
+ - neeraj.kapoor@learntobe.org
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/paperform.rb
73
+ - lib/paperform/partial_submission.rb
74
+ - lib/paperform/submission.rb
75
+ - paperform-ruby.gemspec
76
+ homepage: https://github.com/nekapoor/paperform-ruby
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: A wrapper around the paperform api.
100
+ test_files: []