egree 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/egree/api_mappers/case_mapper.rb +23 -0
- data/lib/egree/{serializers/document.rb → api_mappers/document_mapper.rb} +7 -9
- data/lib/egree/api_mappers/form_field_mapper.rb +12 -0
- data/lib/egree/{serializers/party.rb → api_mappers/party_mapper.rb} +3 -7
- data/lib/egree/api_mappers/reference_id_mapper.rb +9 -0
- data/lib/egree/case.rb +0 -5
- data/lib/egree/client.rb +10 -3
- data/lib/egree/reference_id.rb +0 -9
- data/lib/egree/serializers/case_serializer.rb +12 -0
- data/lib/egree/serializers/reference_id_serializer.rb +13 -0
- data/lib/egree/version.rb +1 -1
- data/spec/egree/api_mappers/case_mapper_spec.rb +34 -0
- data/spec/egree/{serializers/document_spec.rb → api_mappers/document_mapper_spec.rb} +6 -16
- data/spec/egree/api_mappers/form_field_mapper_spec.rb +19 -0
- data/spec/egree/api_mappers/party_mapper_spec.rb +24 -0
- data/spec/egree/api_mappers/reference_id_mapper_spec.rb +19 -0
- data/spec/egree/case_spec.rb +0 -6
- data/spec/egree/client/create_case_spec.rb +3 -1
- data/spec/egree/client/get_case_url_spec.rb +24 -5
- data/spec/egree/reference_id_spec.rb +0 -16
- data/spec/egree/serializers/case_serializer_spec.rb +21 -0
- data/spec/egree/serializers/reference_id_serializer_spec.rb +20 -0
- metadata +23 -17
- data/lib/egree/serializers/case.rb +0 -22
- data/lib/egree/serializers/form_field.rb +0 -16
- data/lib/egree/serializers/reference_id.rb +0 -18
- data/spec/egree/serializers/case_spec.rb +0 -30
- data/spec/egree/serializers/form_field_spec.rb +0 -29
- data/spec/egree/serializers/party_spec.rb +0 -34
- data/spec/egree/serializers/reference_id_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d312dc980ab9ce2ef80fc6dd3ff8cfe1b18ff149
|
4
|
+
data.tar.gz: 76b01dd7a7d5f556dc6917df58c6dd56df7ee29a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bf175c5c2d84ede2932be4238a83c98a0e7b21af52e3e5f14f7c760078aa2f35d6b3a69dfac6ccd25b27b4d906c2c021d7308451fc2aadc3858b6a5a6c4e131
|
7
|
+
data.tar.gz: f63183fa1383fd85b77c1159f53ad8cdeb8f8bc3ce87aac0cffc4100c3db738156b8810054d4a4b9aa7680905bded9cdab21dd712cb4a2facc90383b517cb90e
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
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
|
+
[![Test Coverage](https://codeclimate.com/github/joeljunstrom/egree-ruby/badges/coverage.svg)](https://codeclimate.com/github/joeljunstrom/egree-ruby)
|
3
4
|
|
4
5
|
# Egree
|
5
6
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "json"
|
2
|
+
require "egree/api_mappers/party_mapper"
|
3
|
+
require "egree/api_mappers/document_mapper"
|
4
|
+
require "egree/api_mappers/reference_id_mapper"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module ApiMappers
|
8
|
+
module CaseMapper
|
9
|
+
def self.to_api signature_case
|
10
|
+
{
|
11
|
+
"Name" => signature_case.name,
|
12
|
+
"Documents" => signature_case.documents.map { |document|
|
13
|
+
Egree::ApiMappers::DocumentMapper.to_api(document)
|
14
|
+
},
|
15
|
+
"Parties" => signature_case.parties.map { |party|
|
16
|
+
Egree::ApiMappers::PartyMapper.to_api(party)
|
17
|
+
},
|
18
|
+
"AllowedSignatureTypes" => signature_case.signature_types
|
19
|
+
}.merge(Egree::ApiMappers::ReferenceIdMapper.to_api(signature_case.reference_id))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
require "egree/
|
1
|
+
require "egree/api_mappers/form_field_mapper"
|
2
2
|
|
3
3
|
module Egree
|
4
|
-
module
|
5
|
-
module
|
6
|
-
def self.
|
7
|
-
JSON.pretty_generate to_api_hash(document)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.to_api_hash document
|
4
|
+
module ApiMappers
|
5
|
+
module DocumentMapper
|
6
|
+
def self.to_api document
|
11
7
|
{
|
12
8
|
"Filename" => document.filename,
|
13
9
|
"Data" => document.data,
|
14
10
|
"ContentType" => document.content_type,
|
15
11
|
"Size" => document.size,
|
16
|
-
"FormFields" => document.form_fields.map { |form_field|
|
12
|
+
"FormFields" => document.form_fields.map { |form_field|
|
13
|
+
Egree::ApiMappers::FormFieldMapper.to_api(form_field)
|
14
|
+
}
|
17
15
|
}
|
18
16
|
end
|
19
17
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module Egree
|
2
|
-
module
|
3
|
-
module
|
4
|
-
def self.
|
5
|
-
JSON.pretty_generate to_api_hash(party)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.to_api_hash party
|
2
|
+
module ApiMappers
|
3
|
+
module PartyMapper
|
4
|
+
def self.to_api party
|
9
5
|
{
|
10
6
|
"Name" => party.name,
|
11
7
|
"EmailAddress" => party.email,
|
data/lib/egree/case.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "egree/reference_id"
|
2
|
-
require "egree/serializers/case"
|
3
2
|
|
4
3
|
module Egree
|
5
4
|
class Case
|
@@ -51,10 +50,6 @@ module Egree
|
|
51
50
|
@documents ||= []
|
52
51
|
end
|
53
52
|
|
54
|
-
def to_json
|
55
|
-
Serializers::Case.serialize self
|
56
|
-
end
|
57
|
-
|
58
53
|
private
|
59
54
|
|
60
55
|
def unknown_signature_type_error types
|
data/lib/egree/client.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "json"
|
2
2
|
require "faraday"
|
3
3
|
|
4
|
+
require "egree/serializers/case_serializer"
|
5
|
+
require "egree/serializers/reference_id_serializer"
|
6
|
+
|
4
7
|
module Egree
|
5
8
|
class Client
|
6
9
|
attr_reader :username, :password
|
@@ -14,11 +17,15 @@ module Egree
|
|
14
17
|
end
|
15
18
|
|
16
19
|
def create_case signature_case
|
17
|
-
|
20
|
+
signature_case_json = Egree::Serializers::CaseSerializer.serialize signature_case
|
21
|
+
post "/apiv1/createcasecommand", signature_case_json
|
18
22
|
end
|
19
23
|
|
20
|
-
def get_case_url
|
21
|
-
|
24
|
+
def get_case_url signature_case
|
25
|
+
reference_id = signature_case.respond_to?(:reference_id) ? signature_case.reference_id : signature_case.to_s
|
26
|
+
reference_id_json = Egree::Serializers::ReferenceIdSerializer.serialize reference_id
|
27
|
+
|
28
|
+
post "/apiv1/getviewcaseurlquery", reference_id_json
|
22
29
|
end
|
23
30
|
|
24
31
|
def post api_command, body = nil
|
data/lib/egree/reference_id.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "securerandom"
|
2
|
-
require "egree/serializers/reference_id"
|
3
2
|
|
4
3
|
module Egree
|
5
4
|
class ReferenceId
|
@@ -19,14 +18,6 @@ module Egree
|
|
19
18
|
id.to_s
|
20
19
|
end
|
21
20
|
|
22
|
-
def to_json
|
23
|
-
Serializers::ReferenceId.serialize self
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_api_hash
|
27
|
-
Serializers::ReferenceId.to_api_hash self
|
28
|
-
end
|
29
|
-
|
30
21
|
def <=> other
|
31
22
|
other.is_a?(self.class) && self.id <=> other.id
|
32
23
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "json"
|
2
|
+
require "egree/api_mappers/case_mapper"
|
3
|
+
|
4
|
+
module Egree
|
5
|
+
module Serializers
|
6
|
+
module CaseSerializer
|
7
|
+
def self.serialize signature_case
|
8
|
+
JSON.pretty_generate Egree::ApiMappers::CaseMapper.to_api(signature_case)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "json"
|
2
|
+
require "egree/api_mappers/reference_id_mapper"
|
3
|
+
|
4
|
+
module Egree
|
5
|
+
module Serializers
|
6
|
+
module ReferenceIdSerializer
|
7
|
+
def self.serialize reference_id
|
8
|
+
JSON.pretty_generate Egree::ApiMappers::ReferenceIdMapper.to_api(reference_id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/lib/egree/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "egree/case"
|
4
|
+
require "egree/api_mappers/case_mapper"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module ApiMappers
|
8
|
+
RSpec.describe CaseMapper do
|
9
|
+
describe "#to_api" do
|
10
|
+
it "maps the case into an has that complies with the expected format" do
|
11
|
+
party = double "Party"
|
12
|
+
document = double "Document"
|
13
|
+
|
14
|
+
signature_case = Egree::Case.new "Agreement", ["electronicId"]
|
15
|
+
signature_case.add_party party
|
16
|
+
signature_case.add_document document
|
17
|
+
|
18
|
+
expect(Egree::ApiMappers::PartyMapper).to receive(:to_api).with(party).and_return(party: "on")
|
19
|
+
expect(Egree::ApiMappers::DocumentMapper).to receive(:to_api).with(document).and_return(document: "on")
|
20
|
+
|
21
|
+
api_hash = CaseMapper.to_api signature_case
|
22
|
+
|
23
|
+
expect(api_hash).to eq({
|
24
|
+
"CaseReferenceId" => signature_case.reference_id.to_s,
|
25
|
+
"Name" => "Agreement",
|
26
|
+
"Documents" => [{ document: "on" }],
|
27
|
+
"Parties" => [{ party: "on" }],
|
28
|
+
"AllowedSignatureTypes" => ["electronicId"]
|
29
|
+
})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,20 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "egree/
|
2
|
+
require "egree/api_mappers/document_mapper"
|
3
3
|
|
4
4
|
module Egree
|
5
|
-
module
|
6
|
-
RSpec.describe
|
7
|
-
describe ".
|
8
|
-
it "returns a json string of the api hash" do
|
9
|
-
document = double "Document"
|
10
|
-
|
11
|
-
expect(Document).to receive(:to_api_hash).with(document).and_return(document: "hash")
|
12
|
-
|
13
|
-
expect(Document.serialize(document)).to eq JSON.pretty_generate(document: "hash")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe ".to_api_hash" do
|
5
|
+
module ApiMappers
|
6
|
+
RSpec.describe DocumentMapper do
|
7
|
+
describe ".to_api" do
|
18
8
|
it "creates a hash that matches the api's expected format" do
|
19
9
|
form_field = double "FormField"
|
20
10
|
|
@@ -26,12 +16,12 @@ module Egree
|
|
26
16
|
form_fields: [form_field]
|
27
17
|
})
|
28
18
|
|
29
|
-
expect(Egree::
|
19
|
+
expect(Egree::ApiMappers::FormFieldMapper).to receive(:to_api).with(form_field).and_return({
|
30
20
|
name: "FieldKey",
|
31
21
|
value: "FieldValue"
|
32
22
|
})
|
33
23
|
|
34
|
-
expect(
|
24
|
+
expect(DocumentMapper.to_api(document)).to eq({
|
35
25
|
"Filename" => "agreement.pdf",
|
36
26
|
"Data" => "encoded-data",
|
37
27
|
"ContentType" => "application/pdf",
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "egree/api_mappers/form_field_mapper"
|
4
|
+
require "egree/form_field"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module ApiMappers
|
8
|
+
RSpec.describe FormFieldMapper do
|
9
|
+
specify ".to_api" do
|
10
|
+
form_field = Egree::FormField.new "The name", "The Value"
|
11
|
+
|
12
|
+
expect(FormFieldMapper.to_api(form_field)).to eq({
|
13
|
+
"Name" => "The name",
|
14
|
+
"Value" => "The Value"
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "egree/api_mappers/party_mapper"
|
3
|
+
|
4
|
+
module Egree
|
5
|
+
module ApiMappers
|
6
|
+
RSpec.describe PartyMapper do
|
7
|
+
describe ".to_api" do
|
8
|
+
it "creates a hash that matches the api's expected format" do
|
9
|
+
party = double("Party", {
|
10
|
+
name: "First Last",
|
11
|
+
email: "first-last@example.com",
|
12
|
+
social_security_number: "1234567890"
|
13
|
+
})
|
14
|
+
|
15
|
+
expect(PartyMapper.to_api(party)).to eq({
|
16
|
+
"Name" => "First Last",
|
17
|
+
"EmailAddress" => "first-last@example.com",
|
18
|
+
"SocialSecurityNumber" => "1234567890"
|
19
|
+
})
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "egree/api_mappers/reference_id_mapper"
|
4
|
+
require "egree/reference_id"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module ApiMappers
|
8
|
+
RSpec.describe ReferenceIdMapper do
|
9
|
+
specify "#to_api" do
|
10
|
+
reference_id = Egree::ReferenceId.new 123
|
11
|
+
|
12
|
+
expect(ReferenceIdMapper.to_api(reference_id)).to eq({
|
13
|
+
"CaseReferenceId" => "123"
|
14
|
+
})
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/egree/case_spec.rb
CHANGED
@@ -16,7 +16,9 @@ module Egree
|
|
16
16
|
it "sends the create case comamnd with a json representation of the case" do
|
17
17
|
allow(client).to receive :post
|
18
18
|
|
19
|
-
signature_case = double "Case"
|
19
|
+
signature_case = double "Case"
|
20
|
+
|
21
|
+
expect(Egree::Serializers::CaseSerializer).to receive(:serialize).with(signature_case).and_return "case-json"
|
20
22
|
|
21
23
|
client.create_case signature_case
|
22
24
|
|
@@ -13,14 +13,33 @@ module Egree
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#get_case_url" do
|
16
|
-
|
17
|
-
|
16
|
+
describe "with a reference_id as argument" do
|
17
|
+
it "sends the getviewcaseurl query with the case reference id json" do
|
18
|
+
allow(client).to receive :post
|
18
19
|
|
19
|
-
|
20
|
+
reference_id = Egree::Case.generate_reference_id
|
20
21
|
|
21
|
-
|
22
|
+
expect(Egree::Serializers::ReferenceIdSerializer).to receive(:serialize).with(reference_id.to_s).and_return "reference-id-json"
|
22
23
|
|
23
|
-
|
24
|
+
client.get_case_url reference_id
|
25
|
+
|
26
|
+
expect(client).to have_received(:post).with "/apiv1/getviewcaseurlquery", "reference-id-json"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "with a case as argument" do
|
31
|
+
it "sends the getviewcaseurl query with the case reference id json" do
|
32
|
+
allow(client).to receive :post
|
33
|
+
|
34
|
+
reference_id = double "Egree::ReferenceId"
|
35
|
+
signature_case = double "Egree::Case", reference_id: reference_id
|
36
|
+
|
37
|
+
expect(Egree::Serializers::ReferenceIdSerializer).to receive(:serialize).with(reference_id).and_return "reference-id-json"
|
38
|
+
|
39
|
+
client.get_case_url signature_case
|
40
|
+
|
41
|
+
expect(client).to have_received(:post).with "/apiv1/getviewcaseurlquery", "reference-id-json"
|
42
|
+
end
|
24
43
|
end
|
25
44
|
|
26
45
|
describe "when the case exists", vcr: { cassette_name: "Egree_Client/_get_case_url/case_exists" } do
|
@@ -19,22 +19,6 @@ module Egree
|
|
19
19
|
expect(ReferenceId.new(123).to_s).to eq "123"
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
describe "#to_json" do
|
24
|
-
it "uses Serializers::ReferenceId" do
|
25
|
-
reference_id = ReferenceId.new 123
|
26
|
-
|
27
|
-
expect(reference_id.to_json).to eq Serializers::ReferenceId.serialize(reference_id)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#to_api_hash" do
|
32
|
-
it "delegates to Serializers::ReferenceId" do
|
33
|
-
reference_id = ReferenceId.new 123
|
34
|
-
|
35
|
-
expect(reference_id.to_api_hash).to eq Serializers::ReferenceId.to_api_hash(reference_id)
|
36
|
-
end
|
37
|
-
end
|
38
22
|
end
|
39
23
|
end
|
40
24
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "egree/case"
|
4
|
+
require "egree/serializers/case_serializer"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module Serializers
|
8
|
+
RSpec.describe CaseSerializer do
|
9
|
+
describe ".serialize" do
|
10
|
+
it "maps the case to it's api representation and return it as json" do
|
11
|
+
signature_case = double "Egree::Case"
|
12
|
+
api_hash = { "The" => "Case" }
|
13
|
+
|
14
|
+
expect(Egree::ApiMappers::CaseMapper).to receive(:to_api).with(signature_case).and_return api_hash
|
15
|
+
|
16
|
+
expect(CaseSerializer.serialize(signature_case)).to eq JSON.pretty_generate(api_hash)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "egree/serializers/reference_id_serializer"
|
4
|
+
require "egree/reference_id"
|
5
|
+
|
6
|
+
module Egree
|
7
|
+
module Serializers
|
8
|
+
RSpec.describe ReferenceIdSerializer do
|
9
|
+
describe ".serialize" do
|
10
|
+
it "returns a json string of the api hash" do
|
11
|
+
reference_id = double "ReferenceId"
|
12
|
+
|
13
|
+
expect(Egree::ApiMappers::ReferenceIdMapper).to receive(:to_api).with(reference_id).and_return(reference_id: "value")
|
14
|
+
|
15
|
+
expect(ReferenceIdSerializer.serialize(reference_id)).to eq JSON.pretty_generate(reference_id: "value")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
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.2
|
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-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -138,18 +138,25 @@ files:
|
|
138
138
|
- Rakefile
|
139
139
|
- egree.gemspec
|
140
140
|
- lib/egree.rb
|
141
|
+
- lib/egree/api_mappers/case_mapper.rb
|
142
|
+
- lib/egree/api_mappers/document_mapper.rb
|
143
|
+
- lib/egree/api_mappers/form_field_mapper.rb
|
144
|
+
- lib/egree/api_mappers/party_mapper.rb
|
145
|
+
- lib/egree/api_mappers/reference_id_mapper.rb
|
141
146
|
- lib/egree/case.rb
|
142
147
|
- lib/egree/client.rb
|
143
148
|
- lib/egree/document.rb
|
144
149
|
- lib/egree/form_field.rb
|
145
150
|
- lib/egree/party.rb
|
146
151
|
- lib/egree/reference_id.rb
|
147
|
-
- lib/egree/serializers/
|
148
|
-
- lib/egree/serializers/
|
149
|
-
- lib/egree/serializers/form_field.rb
|
150
|
-
- lib/egree/serializers/party.rb
|
151
|
-
- lib/egree/serializers/reference_id.rb
|
152
|
+
- lib/egree/serializers/case_serializer.rb
|
153
|
+
- lib/egree/serializers/reference_id_serializer.rb
|
152
154
|
- lib/egree/version.rb
|
155
|
+
- spec/egree/api_mappers/case_mapper_spec.rb
|
156
|
+
- spec/egree/api_mappers/document_mapper_spec.rb
|
157
|
+
- spec/egree/api_mappers/form_field_mapper_spec.rb
|
158
|
+
- spec/egree/api_mappers/party_mapper_spec.rb
|
159
|
+
- spec/egree/api_mappers/reference_id_mapper_spec.rb
|
153
160
|
- spec/egree/case_spec.rb
|
154
161
|
- spec/egree/client/create_case_spec.rb
|
155
162
|
- spec/egree/client/get_case_url_spec.rb
|
@@ -158,11 +165,8 @@ files:
|
|
158
165
|
- spec/egree/form_field_spec.rb
|
159
166
|
- spec/egree/party_spec.rb
|
160
167
|
- spec/egree/reference_id_spec.rb
|
161
|
-
- spec/egree/serializers/
|
162
|
-
- spec/egree/serializers/
|
163
|
-
- spec/egree/serializers/form_field_spec.rb
|
164
|
-
- spec/egree/serializers/party_spec.rb
|
165
|
-
- spec/egree/serializers/reference_id_spec.rb
|
168
|
+
- spec/egree/serializers/case_serializer_spec.rb
|
169
|
+
- spec/egree/serializers/reference_id_serializer_spec.rb
|
166
170
|
- spec/egree_spec.rb
|
167
171
|
- spec/fixtures/agreement.pdf
|
168
172
|
- spec/fixtures/cassettes/Egree_Client/_create_case/invalid_case.yml
|
@@ -196,6 +200,11 @@ signing_key:
|
|
196
200
|
specification_version: 4
|
197
201
|
summary: Client for the Egree API
|
198
202
|
test_files:
|
203
|
+
- spec/egree/api_mappers/case_mapper_spec.rb
|
204
|
+
- spec/egree/api_mappers/document_mapper_spec.rb
|
205
|
+
- spec/egree/api_mappers/form_field_mapper_spec.rb
|
206
|
+
- spec/egree/api_mappers/party_mapper_spec.rb
|
207
|
+
- spec/egree/api_mappers/reference_id_mapper_spec.rb
|
199
208
|
- spec/egree/case_spec.rb
|
200
209
|
- spec/egree/client/create_case_spec.rb
|
201
210
|
- spec/egree/client/get_case_url_spec.rb
|
@@ -204,11 +213,8 @@ test_files:
|
|
204
213
|
- spec/egree/form_field_spec.rb
|
205
214
|
- spec/egree/party_spec.rb
|
206
215
|
- spec/egree/reference_id_spec.rb
|
207
|
-
- spec/egree/serializers/
|
208
|
-
- spec/egree/serializers/
|
209
|
-
- spec/egree/serializers/form_field_spec.rb
|
210
|
-
- spec/egree/serializers/party_spec.rb
|
211
|
-
- spec/egree/serializers/reference_id_spec.rb
|
216
|
+
- spec/egree/serializers/case_serializer_spec.rb
|
217
|
+
- spec/egree/serializers/reference_id_serializer_spec.rb
|
212
218
|
- spec/egree_spec.rb
|
213
219
|
- spec/fixtures/agreement.pdf
|
214
220
|
- spec/fixtures/cassettes/Egree_Client/_create_case/invalid_case.yml
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
require "egree/serializers/party"
|
3
|
-
require "egree/serializers/document"
|
4
|
-
|
5
|
-
module Egree
|
6
|
-
module Serializers
|
7
|
-
module Case
|
8
|
-
def self.serialize signature_case
|
9
|
-
JSON.pretty_generate to_api_hash(signature_case)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.to_api_hash signature_case
|
13
|
-
{
|
14
|
-
"Name" => signature_case.name,
|
15
|
-
"Documents" => signature_case.documents.map { |document| Document.to_api_hash(document) },
|
16
|
-
"Parties" => signature_case.parties.map { |party| Party.to_api_hash(party) },
|
17
|
-
"AllowedSignatureTypes" => signature_case.signature_types
|
18
|
-
}.merge(signature_case.reference_id.to_api_hash)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Egree
|
2
|
-
module Serializers
|
3
|
-
module FormField
|
4
|
-
def self.serialize form_field
|
5
|
-
JSON.pretty_generate to_api_hash(form_field)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.to_api_hash form_field
|
9
|
-
{
|
10
|
-
"Name" => form_field.name,
|
11
|
-
"Value" => form_field.value
|
12
|
-
}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
module Egree
|
4
|
-
module Serializers
|
5
|
-
module ReferenceId
|
6
|
-
def self.serialize reference_id
|
7
|
-
JSON.pretty_generate to_api_hash(reference_id)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.to_api_hash reference_id
|
11
|
-
{
|
12
|
-
"CaseReferenceId" => reference_id.to_s
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
require "egree/case"
|
4
|
-
require "egree/serializers/case"
|
5
|
-
|
6
|
-
module Egree
|
7
|
-
module Serializers
|
8
|
-
RSpec.describe Case do
|
9
|
-
it "serializes the case into the expected format" do
|
10
|
-
party = double "Party"
|
11
|
-
document = double "Document"
|
12
|
-
|
13
|
-
signature_case = Egree::Case.new "Agreement", ["electronicId"]
|
14
|
-
signature_case.add_party party
|
15
|
-
signature_case.add_document document
|
16
|
-
|
17
|
-
expect(Egree::Serializers::Party).to receive(:to_api_hash).with(party).and_return(party: "on")
|
18
|
-
expect(Egree::Serializers::Document).to receive(:to_api_hash).with(document).and_return(document: "on")
|
19
|
-
|
20
|
-
expect(Case.serialize(signature_case)).to eq JSON.pretty_generate({
|
21
|
-
"Name" => "Agreement",
|
22
|
-
"Documents" => [{ document: "on" }],
|
23
|
-
"Parties" => [{ party: "on" }],
|
24
|
-
"AllowedSignatureTypes" => ["electronicId"],
|
25
|
-
"CaseReferenceId" => signature_case.reference_id.to_s
|
26
|
-
})
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
require "egree/serializers/form_field"
|
4
|
-
require "egree/form_field"
|
5
|
-
|
6
|
-
module Egree
|
7
|
-
module Serializers
|
8
|
-
RSpec.describe FormField do
|
9
|
-
describe ".serialize" do
|
10
|
-
it "returns a json string of the api hash" do
|
11
|
-
form_field = double "FormField"
|
12
|
-
|
13
|
-
expect(FormField).to receive(:to_api_hash).with(form_field).and_return(form_field: "hash")
|
14
|
-
|
15
|
-
expect(FormField.serialize(form_field)).to eq JSON.pretty_generate(form_field: "hash")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
specify ".to_api_hash" do
|
20
|
-
form_field = Egree::FormField.new "The name", "The Value"
|
21
|
-
|
22
|
-
expect(FormField.to_api_hash(form_field)).to eq({
|
23
|
-
"Name" => "The name",
|
24
|
-
"Value" => "The Value"
|
25
|
-
})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "egree/serializers/party"
|
3
|
-
|
4
|
-
module Egree
|
5
|
-
module Serializers
|
6
|
-
RSpec.describe Party do
|
7
|
-
describe ".serialize" do
|
8
|
-
it "returns a json string of the api hash" do
|
9
|
-
party = double "Party"
|
10
|
-
|
11
|
-
expect(Party).to receive(:to_api_hash).with(party).and_return(party: "hash")
|
12
|
-
|
13
|
-
expect(Party.serialize(party)).to eq JSON.pretty_generate(party: "hash")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe ".to_api_hash" do
|
18
|
-
it "creates a hash that matches the api's expected format" do
|
19
|
-
party = double("Party", {
|
20
|
-
name: "First Last",
|
21
|
-
email: "first-last@example.com",
|
22
|
-
social_security_number: "1234567890"
|
23
|
-
})
|
24
|
-
|
25
|
-
expect(Party.to_api_hash(party)).to eq({
|
26
|
-
"Name" => "First Last",
|
27
|
-
"EmailAddress" => "first-last@example.com",
|
28
|
-
"SocialSecurityNumber" => "1234567890"
|
29
|
-
})
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
require "egree/serializers/reference_id"
|
4
|
-
require "egree/reference_id"
|
5
|
-
|
6
|
-
module Egree
|
7
|
-
module Serializers
|
8
|
-
RSpec.describe ReferenceId do
|
9
|
-
describe ".serialize" do
|
10
|
-
it "returns a json string of the api hash" do
|
11
|
-
reference_id = double "ReferenceId"
|
12
|
-
|
13
|
-
expect(ReferenceId).to receive(:to_api_hash).with(reference_id).and_return(reference_id: "value")
|
14
|
-
|
15
|
-
expect(ReferenceId.serialize(reference_id)).to eq JSON.pretty_generate(reference_id: "value")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
specify ".to_api_hash" do
|
20
|
-
reference_id = Egree::ReferenceId.new 123
|
21
|
-
|
22
|
-
expect(ReferenceId.to_api_hash(reference_id)).to eq({
|
23
|
-
"CaseReferenceId" => "123"
|
24
|
-
})
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|