egree 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -41
- data/lib/egree/api_mappers/case_options_mapper.rb +36 -0
- data/lib/egree/client.rb +2 -2
- data/lib/egree/serializers/case_serializer.rb +4 -2
- data/lib/egree/version.rb +1 -1
- data/spec/egree/api_mappers/case_options_mapper_spec.rb +51 -0
- data/spec/egree/api_mappers/reference_id_mapper_spec.rb +0 -1
- data/spec/egree/client/create_case_spec.rb +3 -2
- data/spec/egree/serializers/case_serializer_spec.rb +12 -0
- data/spec/egree_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3309501f588e8dacabdf2efe9bfe4dc04cb18fbd
|
4
|
+
data.tar.gz: d0ea6cb7fe2cc29187ccf7d7218f5523be2fd540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bae1e3739e8f9971d0a4fab40bd03cc09ac91c89582ca60e73478b06718c967bf0a5235a186d0a1493d1339e97bb628c94ff47a97f83de0b50d6217c14edf03
|
7
|
+
data.tar.gz: 320d11f49ac518c460e3c61517198cc5c2110ae4d1bc66a8512498bd7433d7c0768db2b218bdeb44b9f4bfcc878edf5f394656912c625e99f7805fcb40ff07c7
|
data/README.md
CHANGED
@@ -1,73 +1,78 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/joeljunstrom/egree-ruby.svg?branch=master)](https://travis-ci.org/joeljunstrom/egree-ruby)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/joeljunstrom/egree-ruby/badges/gpa.svg)](https://codeclimate.com/github/joeljunstrom/egree-ruby)
|
3
3
|
[![Test Coverage](https://codeclimate.com/github/joeljunstrom/egree-ruby/badges/coverage.svg)](https://codeclimate.com/github/joeljunstrom/egree-ruby)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/egree.svg)](http://badge.fury.io/rb/egree)
|
4
5
|
|
5
6
|
# Egree
|
6
7
|
|
7
8
|
Ruby client for the [Egree API](https://app.egree.com/apiv1).
|
8
9
|
|
9
|
-
Currently the only supported
|
10
|
+
Currently the only supported api calls is `createcasecommand` and `getviewcaseurlquery`.
|
10
11
|
|
11
12
|
## Usage
|
12
13
|
|
13
14
|
### Creating a case
|
14
15
|
|
15
|
-
```
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
16
|
+
```ruby
|
17
|
+
egree = Egree.client username, password
|
18
|
+
|
19
|
+
signature_case = Egree::Case.new "Agreement", ["touch"]
|
20
|
+
signature_case.add_party Egree::Party.new_with_attributes({
|
21
|
+
name: "First Last",
|
22
|
+
email: "name@example.com",
|
23
|
+
social_security_number: "1234567890"
|
24
|
+
})
|
25
|
+
signature_case.add_document Egree::Document.new "/some/path/file.pdf"
|
26
|
+
|
27
|
+
result = egree.create_case(signature_case, {
|
28
|
+
postback_url: "https://example.com/my-endpoint",
|
29
|
+
continue: {
|
30
|
+
url: "http://example.com/user-endpoint",
|
31
|
+
auto: true
|
32
|
+
}
|
33
|
+
})
|
34
|
+
|
35
|
+
if result.success?
|
36
|
+
puts "#{signature_case.reference_id} was created."
|
37
|
+
else
|
38
|
+
puts "There was some issues with the case"
|
39
|
+
result.errors.each do |error|
|
40
|
+
puts error
|
35
41
|
end
|
42
|
+
end
|
36
43
|
```
|
37
44
|
|
38
45
|
### Getting the signature url for a case
|
39
46
|
|
40
|
-
```
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
47
|
+
```ruby
|
48
|
+
egree = Egree.client username, password
|
49
|
+
result = egree.get_case_url "98d08cf5-d35d-403b-ac31-fa1ac85037a1"
|
50
|
+
|
51
|
+
if result.success?
|
52
|
+
puts "The url is: #{result.response}"
|
53
|
+
else
|
54
|
+
puts "Could not get signature url"
|
55
|
+
result.errors.each do |error|
|
56
|
+
puts error
|
51
57
|
end
|
58
|
+
end
|
52
59
|
```
|
53
60
|
|
54
61
|
|
55
62
|
|
56
63
|
## Contributing
|
57
64
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
65
|
+
Contributions is more than welcome!
|
66
|
+
|
67
|
+
Just create a fork and submit a pull request.
|
68
|
+
|
69
|
+
Please adhere to the coding standards used in the project and add tests.
|
63
70
|
|
64
71
|
### Local development
|
65
72
|
|
66
|
-
Create a .env file in the root directory.
|
73
|
+
Create a .env file in the root directory to run the integration tests against your Egree environment.
|
67
74
|
|
68
|
-
```
|
75
|
+
```yaml
|
69
76
|
EGREE_USERNAME=your-username
|
70
77
|
EGREE_PASSWORD=your-password
|
71
78
|
```
|
72
|
-
|
73
|
-
This is used for the integration tests.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Egree
|
2
|
+
module ApiMappers
|
3
|
+
module CaseOptionsMapper
|
4
|
+
def self.to_api options = {}, mappers = self.mappers
|
5
|
+
options.reduce({}) do |api_hash, (client_key, value)|
|
6
|
+
if mappers.key?(client_key)
|
7
|
+
api_hash.merge(self.map(client_key, value, mappers))
|
8
|
+
else
|
9
|
+
api_hash
|
10
|
+
end
|
11
|
+
end || {}
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.map client_key, value, mappers = self.mappers
|
17
|
+
mapper = mappers[client_key]
|
18
|
+
|
19
|
+
if mapper.respond_to?(:call)
|
20
|
+
mapper.call value
|
21
|
+
else
|
22
|
+
{ mapper => value }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.mappers
|
27
|
+
{
|
28
|
+
postback_url: "CaseFinishedCallbackUrl",
|
29
|
+
continue: ->(options) {
|
30
|
+
CaseOptionsMapper.to_api options, name: "ContinueName", url: "ContinueUrl", auto: "ContinueAuto"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/egree/client.rb
CHANGED
@@ -16,8 +16,8 @@ module Egree
|
|
16
16
|
self.environment = environment
|
17
17
|
end
|
18
18
|
|
19
|
-
def create_case signature_case
|
20
|
-
signature_case_json = Egree::Serializers::CaseSerializer.serialize signature_case
|
19
|
+
def create_case signature_case, options = {}
|
20
|
+
signature_case_json = Egree::Serializers::CaseSerializer.serialize signature_case, options
|
21
21
|
post "/apiv1/createcasecommand", signature_case_json
|
22
22
|
end
|
23
23
|
|
@@ -4,8 +4,10 @@ require "egree/api_mappers/case_mapper"
|
|
4
4
|
module Egree
|
5
5
|
module Serializers
|
6
6
|
module CaseSerializer
|
7
|
-
def self.serialize signature_case
|
8
|
-
|
7
|
+
def self.serialize signature_case, options = {}
|
8
|
+
signature_case_api_hash = Egree::ApiMappers::CaseMapper.to_api signature_case
|
9
|
+
options_api_hash = Egree::ApiMappers::CaseOptionsMapper.to_api options
|
10
|
+
JSON.pretty_generate signature_case_api_hash.merge(options_api_hash)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/egree/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "egree/api_mappers/case_options_mapper"
|
3
|
+
|
4
|
+
module Egree
|
5
|
+
module ApiMappers
|
6
|
+
RSpec.describe CaseOptionsMapper do
|
7
|
+
describe "#to_api" do
|
8
|
+
it "translates postback_url to CaseFinishedCallbackUrl" do
|
9
|
+
expect(CaseOptionsMapper.to_api(postback_url: "http://example.com")).to eq({
|
10
|
+
"CaseFinishedCallbackUrl" => "http://example.com"
|
11
|
+
})
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "continue" do
|
15
|
+
it "translates name" do
|
16
|
+
options = { continue: { name: "The label" } }
|
17
|
+
|
18
|
+
expect(CaseOptionsMapper.to_api(options)).to eq({
|
19
|
+
"ContinueName" => "The label"
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "translates url" do
|
24
|
+
options = { continue: { url: "http://example.com/where-to-go" } }
|
25
|
+
|
26
|
+
expect(CaseOptionsMapper.to_api(options)).to eq({
|
27
|
+
"ContinueUrl" => "http://example.com/where-to-go"
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
it "translates auto" do
|
32
|
+
options = { continue: { auto: true } }
|
33
|
+
|
34
|
+
expect(CaseOptionsMapper.to_api(options)).to eq({
|
35
|
+
"ContinueAuto" => true
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "ignores unknown keys" do
|
41
|
+
expect(CaseOptionsMapper.to_api({
|
42
|
+
postback_url: "http://example.com",
|
43
|
+
unknown: "Some value"
|
44
|
+
})).to eq({
|
45
|
+
"CaseFinishedCallbackUrl" => "http://example.com"
|
46
|
+
})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -17,10 +17,11 @@ module Egree
|
|
17
17
|
allow(client).to receive :post
|
18
18
|
|
19
19
|
signature_case = double "Case"
|
20
|
+
options = { postback_url: "http://example.com/postback" }
|
20
21
|
|
21
|
-
expect(Egree::Serializers::CaseSerializer).to receive(:serialize).with(signature_case).and_return "case-json"
|
22
|
+
expect(Egree::Serializers::CaseSerializer).to receive(:serialize).with(signature_case, options).and_return "case-json"
|
22
23
|
|
23
|
-
client.create_case signature_case
|
24
|
+
client.create_case signature_case, options
|
24
25
|
|
25
26
|
expect(client).to have_received(:post).with "/apiv1/createcasecommand", "case-json"
|
26
27
|
end
|
@@ -15,6 +15,18 @@ module Egree
|
|
15
15
|
|
16
16
|
expect(CaseSerializer.serialize(signature_case)).to eq JSON.pretty_generate(api_hash)
|
17
17
|
end
|
18
|
+
|
19
|
+
it "takes options for how to handle the user" do
|
20
|
+
signature_case = double "Egree::Case"
|
21
|
+
api_hash = { "The" => "Case" }
|
22
|
+
options = { postback_url: "http://example.com" }
|
23
|
+
options_hash = { "CaseFinishedCallbackUrl" => "http://example.com" }
|
24
|
+
|
25
|
+
expect(Egree::ApiMappers::CaseMapper).to receive(:to_api).with(signature_case).and_return api_hash
|
26
|
+
expect(Egree::ApiMappers::CaseOptionsMapper).to receive(:to_api).with(options).and_return options_hash
|
27
|
+
|
28
|
+
expect(CaseSerializer.serialize(signature_case, options)).to eq JSON.pretty_generate(api_hash.merge(options_hash))
|
29
|
+
end
|
18
30
|
end
|
19
31
|
end
|
20
32
|
end
|
data/spec/egree_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Junström
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- egree.gemspec
|
140
140
|
- lib/egree.rb
|
141
141
|
- lib/egree/api_mappers/case_mapper.rb
|
142
|
+
- lib/egree/api_mappers/case_options_mapper.rb
|
142
143
|
- lib/egree/api_mappers/document_mapper.rb
|
143
144
|
- lib/egree/api_mappers/form_field_mapper.rb
|
144
145
|
- lib/egree/api_mappers/party_mapper.rb
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- lib/egree/serializers/reference_id_serializer.rb
|
154
155
|
- lib/egree/version.rb
|
155
156
|
- spec/egree/api_mappers/case_mapper_spec.rb
|
157
|
+
- spec/egree/api_mappers/case_options_mapper_spec.rb
|
156
158
|
- spec/egree/api_mappers/document_mapper_spec.rb
|
157
159
|
- spec/egree/api_mappers/form_field_mapper_spec.rb
|
158
160
|
- spec/egree/api_mappers/party_mapper_spec.rb
|
@@ -201,6 +203,7 @@ specification_version: 4
|
|
201
203
|
summary: Client for the Egree API
|
202
204
|
test_files:
|
203
205
|
- spec/egree/api_mappers/case_mapper_spec.rb
|
206
|
+
- spec/egree/api_mappers/case_options_mapper_spec.rb
|
204
207
|
- spec/egree/api_mappers/document_mapper_spec.rb
|
205
208
|
- spec/egree/api_mappers/form_field_mapper_spec.rb
|
206
209
|
- spec/egree/api_mappers/party_mapper_spec.rb
|