clicksign-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8951f7e1a735d417e2c3b1222c30d294ad1b5d7828dd58c0edc816b5f0eabce9
4
+ data.tar.gz: 0713e52399d0df6a4a3220a150c9becf036ae651842a6e6564563c082aa7cffb
5
+ SHA512:
6
+ metadata.gz: 2fbca1cbd757be3603bfc71af4fac36133fd41c2556e6f7175c3cbfca654a9a5654a655b82df919f48115cde2d60899299be24b79c8d8906c349a6d1a6ba681f
7
+ data.tar.gz: db8bb93dd9e9a0221bea7ef5c2a6f1543a95fcd3d054813d33c1562fa9d4a784c9c1006c22817d2c0485a34f9558ca6bd33fdad5517cf6c4a6926b298ce0a613
@@ -0,0 +1,162 @@
1
+ exit
2
+ json[:errors]
3
+ response.status
4
+ response.success?
5
+ response.status
6
+ raise json[:errors].join(', ')
7
+ json[:errors].join(', ')
8
+ json
9
+ json[:errors].json(', ')
10
+ json
11
+ response
12
+ OpenStruct.new(json[:errors])
13
+ OpenStruct
14
+ OpenScruct.new json[:errors]
15
+ json[:errors]
16
+ json
17
+ document = OpenStruct.new(json[:errors])
18
+ json
19
+ exit
20
+ response.success?
21
+ response.success
22
+ json
23
+ d.key
24
+ d = OpenStruct.new(json[:document])
25
+ json = JSON.parse(response.body, symbolize_names: true)
26
+ JSON.parse(response.body, symbolize_names: true)
27
+ response.body
28
+ response
29
+ exit
30
+ response
31
+ exit
32
+ response
33
+ exit
34
+ response
35
+ exit
36
+ response
37
+ exit
38
+ response
39
+ exit
40
+ response
41
+ exit
42
+ nil.nil?
43
+ nil.present?
44
+ hash
45
+ hash.merge!(foo: 'bar')
46
+ hash
47
+ hash.merge(foo: 'bar')
48
+ hash = {}
49
+ body
50
+ body.merge(deadline_at: deadline_at) if deadline_at
51
+ exit
52
+ response
53
+ respone
54
+ exit
55
+ end
56
+ req.body = body.to_json
57
+ req.headers['Content-Type'] = 'application/json'
58
+ req.url request_path
59
+ conn.post do |req|
60
+ end
61
+ req.body = body.to_json
62
+ req.headers['Content-Type'] = 'application/json'
63
+ req.url url
64
+ conn.post do |req|
65
+ body.to_json
66
+ end
67
+ req.body = body
68
+ req.headers['Content-Type'] = 'application/json'
69
+ req.url url
70
+ conn.post do |req|
71
+ end
72
+ request.body = body
73
+ request.headers['Content-Type'] = 'application/json'
74
+ request.url url
75
+ conn.post do |request|
76
+ url
77
+ exit
78
+ end
79
+ request.body = body
80
+ request.headers['Content-Type'] = 'application/json'
81
+ request.url url
82
+ conn.post do |request|
83
+ end
84
+ request.body = body
85
+ request.headers['Content-Type'] = 'application/json'
86
+ request.url url
87
+ conn.post do |request|
88
+ conn
89
+ end
90
+ request.body = body
91
+ headers['Content-Type'] = 'application/json'
92
+ request.url url
93
+ conn.post do |request|
94
+ end
95
+ request.body = body
96
+ headers['Content-Type'] = 'application/json'
97
+ request.url url
98
+ conn.post do |request|
99
+ end
100
+ request.body = body
101
+ headers['Content-Type'] = 'application/json'
102
+ request.url "/api/v1/documents?access_token=#{Clicksign::API.access_token}"
103
+ conn.post do |request|
104
+ body
105
+ exit
106
+ body
107
+ exit
108
+ }
109
+ locale: 'pt-BR',
110
+ auto_close: true,
111
+ deadline_at: '24/10/2018',
112
+ content_base64: content_base64,
113
+ path: '/teste',
114
+ }body = {
115
+ locale: 'pt-BR',
116
+ auto_close: true,
117
+ deadline_at: '24/10/2018',
118
+ content_base64: content_base64,
119
+ path: '/teste',
120
+ body = {
121
+ 1
122
+ end
123
+ }
124
+ locale: 'pt-BR',
125
+ auto_close: true,
126
+ deadline_at: '24/10/2018',
127
+ content_base64: content_base64,
128
+ path: '/teste',
129
+ request.body = {
130
+ headers['Content-Type'] = 'application/json'
131
+ request.url "/api/v1/documents?access_token=#{Clicksign::API.access_token}"
132
+ conn.post do |request|
133
+ Clicksign::API.access_token
134
+ exit
135
+ Clicksign::API.access_token
136
+ exit
137
+ Clicksign::API.access_token
138
+ conn
139
+ encoded_file
140
+ exit
141
+ Base64.decode64 encoded_file
142
+ Base64.decode64encoded_file
143
+ encoded_file
144
+ exit
145
+ Clicksign::API.url
146
+ conn ||= Faraday.new(url: Clicksign::API.url)
147
+ conn
148
+ end
149
+ @conn ||= Faraday.new(url: Clicksign::API.url)
150
+ def conn
151
+ conn
152
+ Base64.decode64(encoded)
153
+ encoded = Base64.encode64 File.read(file)conn
154
+ Base64.encode64 File.read(file)
155
+ File.exist? file
156
+ Base64.encode64 File.open(file)
157
+ Base64.encode64 File.open(path)
158
+ Base64.encode64 file.open
159
+ Base64.encode64 file
160
+ require 'base64'
161
+ block
162
+ file
@@ -0,0 +1 @@
1
+ CLICKSIGN_ACCESS_TOKEN="123"
@@ -0,0 +1,12 @@
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
12
+ .env
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ clicksign-api
@@ -0,0 +1 @@
1
+ 2.5.3
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.4
7
+ before_install: gem install bundler -v 1.16.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
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 clicksign-api.gemspec
6
+ gemspec
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ clicksign-api (0.0.1)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ byebug (10.0.2)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ docile (1.3.1)
17
+ dotenv (2.5.0)
18
+ faraday (0.12.2)
19
+ multipart-post (>= 1.2, < 3)
20
+ hashdiff (0.3.7)
21
+ json (2.1.0)
22
+ multipart-post (2.0.0)
23
+ public_suffix (3.0.3)
24
+ rake (10.5.0)
25
+ rspec (3.8.0)
26
+ rspec-core (~> 3.8.0)
27
+ rspec-expectations (~> 3.8.0)
28
+ rspec-mocks (~> 3.8.0)
29
+ rspec-core (3.8.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-expectations (3.8.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-mocks (3.8.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-support (3.8.0)
38
+ safe_yaml (1.0.4)
39
+ simplecov (0.16.1)
40
+ docile (~> 1.1)
41
+ json (>= 1.8, < 3)
42
+ simplecov-html (~> 0.10.0)
43
+ simplecov-html (0.10.2)
44
+ vcr (4.0.0)
45
+ webmock (3.4.2)
46
+ addressable (>= 2.3.6)
47
+ crack (>= 0.3.2)
48
+ hashdiff
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ bundler (~> 1.16)
55
+ byebug (~> 10.0)
56
+ clicksign-api!
57
+ dotenv (~> 2.5)
58
+ rake (~> 10.0)
59
+ rspec (~> 3.0)
60
+ simplecov (~> 0.16)
61
+ vcr (~> 4.0)
62
+ webmock (~> 3.0)
63
+
64
+ BUNDLED WITH
65
+ 1.16.6
@@ -0,0 +1,35 @@
1
+ # Clicksign::Api
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/clicksign/api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'clicksign-api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install clicksign-api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clicksign-api.
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "clicksign/api"
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__)
@@ -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
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "clicksign/api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'clicksign-api'
8
+ spec.version = Clicksign::Api::VERSION
9
+ spec.authors = ['Francisco Martins']
10
+ spec.email = ['franciscomxs@gmail.com']
11
+
12
+ spec.summary = 'Clicksign API ruby interface'
13
+ spec.homepage = 'https://github.com/NexoosBR/clicksign-api'
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_dependency 'faraday'
28
+
29
+ spec.add_development_dependency 'simplecov', '~> 0.16'
30
+ spec.add_development_dependency 'vcr', '~> 4.0'
31
+ spec.add_development_dependency 'webmock', '~> 3.0'
32
+ spec.add_development_dependency 'byebug', '~> 10.0'
33
+ spec.add_development_dependency 'dotenv', '~> 2.5'
34
+ end
@@ -0,0 +1,38 @@
1
+ require "clicksign/api/version"
2
+
3
+ require "faraday"
4
+ require "base64"
5
+
6
+ begin
7
+ require "dotenv/load"
8
+ require "byebug"
9
+ rescue LoadError
10
+ end
11
+
12
+ require "clicksign/api/requests"
13
+ require "clicksign/api/document"
14
+
15
+
16
+ module Clicksign
17
+ module API
18
+ class << self
19
+ attr_accessor :access_token, :production
20
+
21
+ def configure
22
+ yield(self)
23
+ end
24
+
25
+ def production?
26
+ production || false
27
+ end
28
+
29
+ def url
30
+ if production?
31
+ 'https://app.clicksign.com'
32
+ else
33
+ 'https://sandbox.clicksign.com'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ module Clicksign
2
+ module API
3
+ class Document
4
+ extend Requests
5
+
6
+ class << self
7
+ def create(path:, file:, signers: nil, deadline_at: nil, auto_close: nil, locale: nil)
8
+ content_base64 = Base64.encode64(File.read(file))
9
+
10
+ body = { document: {
11
+ path: path,
12
+ content_base64: "data:application/pdf;base64,#{content_base64}"
13
+ } }
14
+
15
+ body.merge!(deadline_at: deadline_at) unless deadline_at.nil?
16
+ body.merge!(auto_close: auto_close) unless auto_close.nil?
17
+ body.merge!(locale: locale) unless locale.nil?
18
+ body.merge!(signers: signers) unless signers.nil?
19
+
20
+ request_path = '/api/v1/documents'
21
+
22
+ response = post(request_path, body)
23
+
24
+ json = JSON.parse(response.body, symbolize_names: true)
25
+
26
+ if response.success?
27
+ json[:document]
28
+ else
29
+ json[:errors]
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module Clicksign
2
+ module API
3
+ module Requests
4
+ def post(request_path, body)
5
+ conn.post do |req|
6
+ req.url request_path, { access_token: Clicksign::API.access_token }
7
+ req.headers['Content-Type'] = 'application/json'
8
+ req.body = body.to_json
9
+ end
10
+ end
11
+
12
+ def conn
13
+ @conn ||= Faraday.new(url: Clicksign::API.url)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Clicksign
2
+ module Api
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clicksign-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Francisco Martins
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-24 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
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: dotenv
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.5'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.5'
139
+ description:
140
+ email:
141
+ - franciscomxs@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".byebug_history"
147
+ - ".env.example"
148
+ - ".gitignore"
149
+ - ".rspec"
150
+ - ".ruby-gemset"
151
+ - ".ruby-version"
152
+ - ".travis.yml"
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - README.md
156
+ - Rakefile
157
+ - bin/console
158
+ - bin/setup
159
+ - clicksign-api.gemspec
160
+ - lib/clicksign/api.rb
161
+ - lib/clicksign/api/document.rb
162
+ - lib/clicksign/api/requests.rb
163
+ - lib/clicksign/api/version.rb
164
+ homepage: https://github.com/NexoosBR/clicksign-api
165
+ licenses: []
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.7.7
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Clicksign API ruby interface
187
+ test_files: []