echochamber 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +79 -0
  6. data/LICENSE +21 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +87 -0
  9. data/Rakefile +12 -0
  10. data/doc/Echochamber.html +131 -0
  11. data/doc/Echochamber/Agreement.html +529 -0
  12. data/doc/Echochamber/Agreement/UrlFileInfo.html +263 -0
  13. data/doc/Echochamber/Client.html +4161 -0
  14. data/doc/Echochamber/CounterSignerInfo.html +265 -0
  15. data/doc/Echochamber/Credentials.html +330 -0
  16. data/doc/Echochamber/Credentials/CredentialsError.html +123 -0
  17. data/doc/Echochamber/Fileinfo.html +303 -0
  18. data/doc/Echochamber/InvalidParameterError.html +123 -0
  19. data/doc/Echochamber/ParameterError.html +123 -0
  20. data/doc/Echochamber/PhoneInfo.html +279 -0
  21. data/doc/Echochamber/Recipient.html +309 -0
  22. data/doc/Echochamber/RecipientSecurityOption.html +294 -0
  23. data/doc/Echochamber/Reminder.html +277 -0
  24. data/doc/Echochamber/Request.html +4167 -0
  25. data/doc/Echochamber/Request/Failure.html +123 -0
  26. data/doc/Echochamber/RequiredParameterError.html +123 -0
  27. data/doc/Echochamber/UrlFileInfo.html +295 -0
  28. data/doc/Echochamber/User.html +420 -0
  29. data/doc/Echochamber/Validatable.html +355 -0
  30. data/doc/Echochamber/Validator.html +180 -0
  31. data/doc/Echochamber/Widget.html +654 -0
  32. data/doc/Echochamber/WidgetCompletionInfo.html +309 -0
  33. data/doc/Echochamber/WidgetPersonalization.html +326 -0
  34. data/doc/Echochamber/WidgetSecurityOption.html +359 -0
  35. data/doc/Echochamber/WidgetSignerSecurityOption.html +296 -0
  36. data/doc/Echochamber/WidgetStatus.html +314 -0
  37. data/doc/Echochamber/WidgetVaultingInfo.html +265 -0
  38. data/doc/_index.html +338 -0
  39. data/doc/class_list.html +54 -0
  40. data/doc/css/common.css +1 -0
  41. data/doc/css/full_list.css +57 -0
  42. data/doc/css/style.css +339 -0
  43. data/doc/file.README.html +157 -0
  44. data/doc/file_list.html +56 -0
  45. data/doc/frames.html +26 -0
  46. data/doc/index.html +157 -0
  47. data/doc/js/app.js +219 -0
  48. data/doc/js/full_list.js +178 -0
  49. data/doc/js/jquery.js +4 -0
  50. data/doc/method_list.html +581 -0
  51. data/doc/top-level-namespace.html +112 -0
  52. data/echochamber.gemspec +35 -0
  53. data/features/support/env.rb +8 -0
  54. data/fixtures/agreement.pdf +0 -0
  55. data/fixtures/vcr_cassettes/agreement_combined_pdf.yml +1465 -0
  56. data/fixtures/vcr_cassettes/agreement_document_file.yml +1465 -0
  57. data/fixtures/vcr_cassettes/agreement_documents.yml +42 -0
  58. data/fixtures/vcr_cassettes/agreement_form_data.yml +44 -0
  59. data/fixtures/vcr_cassettes/agreement_info.yml +50 -0
  60. data/fixtures/vcr_cassettes/agreement_signing_urls.yml +42 -0
  61. data/fixtures/vcr_cassettes/audit_trail_pdf.yml +1643 -0
  62. data/fixtures/vcr_cassettes/cancel_agreement.yml +46 -0
  63. data/fixtures/vcr_cassettes/create_agreement.yml +50 -0
  64. data/fixtures/vcr_cassettes/create_reminder.yml +47 -0
  65. data/fixtures/vcr_cassettes/create_transient_document.yml +716 -0
  66. data/fixtures/vcr_cassettes/create_user.yml +50 -0
  67. data/fixtures/vcr_cassettes/create_widget.yml +48 -0
  68. data/fixtures/vcr_cassettes/get_agreements.yml +46 -0
  69. data/fixtures/vcr_cassettes/get_library_document.yml +45 -0
  70. data/fixtures/vcr_cassettes/get_library_document_data.yml +1191 -0
  71. data/fixtures/vcr_cassettes/get_library_document_file.yml +42 -0
  72. data/fixtures/vcr_cassettes/get_library_documents.yml +47 -0
  73. data/fixtures/vcr_cassettes/get_token.yml +44 -0
  74. data/fixtures/vcr_cassettes/get_user.yml +46 -0
  75. data/fixtures/vcr_cassettes/get_users.yml +43 -0
  76. data/fixtures/vcr_cassettes/get_widget.yml +49 -0
  77. data/fixtures/vcr_cassettes/get_widget_document_file.yml +2682 -0
  78. data/fixtures/vcr_cassettes/get_widget_documents.yml +44 -0
  79. data/fixtures/vcr_cassettes/get_widgets.yml +50 -0
  80. data/fixtures/vcr_cassettes/library_combined_document.yml +2197 -0
  81. data/fixtures/vcr_cassettes/library_document_audit_trail.yml +1570 -0
  82. data/fixtures/vcr_cassettes/personalize_widget.yml +47 -0
  83. data/fixtures/vcr_cassettes/update_widget_status.yml +46 -0
  84. data/lib/echochamber.rb +10 -0
  85. data/lib/echochamber/agreement.rb +32 -0
  86. data/lib/echochamber/agreement/client.rb +118 -0
  87. data/lib/echochamber/agreement/fileinfo.rb +20 -0
  88. data/lib/echochamber/agreement/phone_info.rb +19 -0
  89. data/lib/echochamber/agreement/recipient.rb +23 -0
  90. data/lib/echochamber/agreement/recipient_security_option.rb +20 -0
  91. data/lib/echochamber/agreement/request.rb +142 -0
  92. data/lib/echochamber/agreement/url_file_info.rb +18 -0
  93. data/lib/echochamber/client.rb +82 -0
  94. data/lib/echochamber/credentials.rb +33 -0
  95. data/lib/echochamber/library_documents/client.rb +83 -0
  96. data/lib/echochamber/library_documents/request.rb +78 -0
  97. data/lib/echochamber/reminder.rb +17 -0
  98. data/lib/echochamber/request.rb +141 -0
  99. data/lib/echochamber/user.rb +29 -0
  100. data/lib/echochamber/validatable.rb +54 -0
  101. data/lib/echochamber/version.rb +3 -0
  102. data/lib/echochamber/widget.rb +42 -0
  103. data/lib/echochamber/widget/client.rb +127 -0
  104. data/lib/echochamber/widget/counter_signer_info.rb +19 -0
  105. data/lib/echochamber/widget/request.rb +135 -0
  106. data/lib/echochamber/widget/widget_completion_info.rb +19 -0
  107. data/lib/echochamber/widget/widget_personalization.rb +21 -0
  108. data/lib/echochamber/widget/widget_security_option.rb +22 -0
  109. data/lib/echochamber/widget/widget_signer_security_option.rb +18 -0
  110. data/lib/echochamber/widget/widget_status.rb +20 -0
  111. data/lib/echochamber/widget/widget_vaulting_info.rb +16 -0
  112. data/spec/lib/agreement/client_spec.rb +157 -0
  113. data/spec/lib/client_spec.rb +78 -0
  114. data/spec/lib/library_documents/client_spec.rb +71 -0
  115. data/spec/lib/request_spec.rb +18 -0
  116. data/spec/lib/shared_client.rb +22 -0
  117. data/spec/lib/user_spec.rb +6 -0
  118. data/spec/lib/validatable_spec.rb +110 -0
  119. data/spec/lib/version_spec.rb +7 -0
  120. data/spec/lib/widget/client_spec.rb +154 -0
  121. data/spec/spec_helper.rb +21 -0
  122. metadata +344 -0
@@ -0,0 +1,22 @@
1
+ module Echochamber
2
+ class WidgetSecurityOption < Hash
3
+
4
+ include Validatable
5
+
6
+ # Widget initialization object
7
+ #
8
+ # @param [Hash] params SYMBOL-referenced Hash containing:
9
+ # @option params [String] :passwordProtection Specifies if signers are required to enter a password to have access to sign the widget. The possible values are NONE, EXTERNAL_USERS, INTERNAL_USERS, or ALL_USERS
10
+ # @option params [String] :kbaProtection Signers need to pass Knowledge Based Authentication before they gain access to view and sign the widget. The possible values are NONE, EXTERNAL_USERS, INTERNAL_USERS, or ALL_USERS
11
+ # @option params [String] :webIdentityProtection Specifies if signers are required to provide their web identity, before they gain access to view and sign the widget. The possible values are NONE, EXTERNAL_USERS, INTERNAL_USERS, or ALL_USERS
12
+ # @option params [Boolean] :protectOpen If set to true, the document is always be encrypted with this password every time it is sent by email. Recipients need to provide the password to be able to view the PDF files
13
+ # @option params [String] :internalPassword The secondary password that will be used to protect signing the widget for internal signers. Note that EchoSign will never show this password to anyone, so you will need to separately communicate it to any relevant parties. This password is applied only if password protection is specified for internal signers or all signers
14
+ # @option params [String] :externalPassword The secondary password that will be used to protect signing the widget for external signers. Note that EchoSign will never show this password to anyone, so you will need to separately communicate it to any relevant parties. This password is applied only if password protection is specified for external signers or all signers
15
+ # @option params [String] :openPassword The secondary password that will be used to secure the PDF document. Note that EchoSign will never show this password to anyone, so you will need to separately communicate it to any relevant parties. This password is used only if protectOpen field is set to true
16
+ def initialize(params)
17
+ merge!(params)
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -0,0 +1,18 @@
1
+ module Echochamber
2
+ class WidgetSignerSecurityOption < Hash
3
+
4
+ include Validatable
5
+
6
+ # Initialization object
7
+ #
8
+ # @param [Hash] params SYMBOL-referenced Hash containing:
9
+ # @option params [String] :authenticationMethod ['INHERITED_FROM_DOCUMENT' or 'KBA' or 'PASSWORD' or 'WEB_IDENTITY' or 'PHONE' or 'NONE']: The authentication method for the recipients to have access to view and sign the widget. PHONE authentication is only applicable to counter signers but not to widget signer
10
+ # @option params [String] :password The password required for the recipient to view and sign the widget
11
+ # @option params [Array] :phoneInfos Populated with instances of [Echochamber::PhoneInfo] The phoneInfo required for the counter signer to view and sign the widget if authentication method is PHONE. Not applicable to widget signer
12
+ def initialize(params)
13
+ require_keys([:authenticationMethod], params)
14
+ merge!(params)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module Echochamber
2
+ class WidgetStatus< Hash
3
+
4
+ include Validatable
5
+
6
+ # Status object
7
+ #
8
+ # @option [Hash] params
9
+ # @option params [String] :value The status to which the widget is to be updated. The possible values for this variable are ENABLE and DISABLE (REQUIRED)
10
+ # @option params [String] :message Display this custom message to the user when the widget is accessed. Note that this can contain wiki markup to include clickable links in the message. This is required if redirectUrl is not provided. Both message and redirectUrl can not be specified
11
+ # @option params [String] :redirectUrl Redirect the user to this URL when the widget is accessed. This is required if message is not provided. Both message and redirectUrl can not be specified
12
+ # @return [Echochamber::WidgetStatus]
13
+ def initialize(params)
14
+ require_keys([:value], params)
15
+ require_exactly_one([:message, :redirectUrl], params)
16
+ merge!(params)
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ module Echochamber
2
+ class WidgetVaultingInfo < Hash
3
+
4
+ include Validatable
5
+
6
+ # Initialization object
7
+ #
8
+ # @param [Hash] params SYMBOL-referenced Hash containing:
9
+ # @option params [Boolean] :enabled For accounts set up for document vaulting and the option to enable per agreement, this determines whether the document is to be vaulted
10
+ def initialize(params)
11
+ require_keys([:enabled], params)
12
+ merge!(params)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ require 'lib/shared_client.rb'
4
+
5
+ describe Echochamber::Client do
6
+ include_context "shared client"
7
+
8
+ describe '.create_agreement' do
9
+
10
+ let(:url_file_info) do
11
+ {
12
+ url: 'http://findgoplayers.com/resume.pdf',
13
+ mimeType: 'application/pdf',
14
+ name: 'resume.pdf'
15
+ }
16
+ end
17
+
18
+ let(:file_info) do
19
+ {
20
+ documentURL: Echochamber::UrlFileInfo.new(url_file_info)
21
+ }
22
+ end
23
+
24
+ let(:file_infos) do
25
+ [ Echochamber::Fileinfo.new(file_info) ]
26
+ end
27
+
28
+ let(:agreement_user_id) { nil }
29
+ let(:agreement_user_email) { nil }
30
+
31
+ let(:agreement_info) do
32
+ {
33
+ fileInfos: [ file_infos ],
34
+ recipients: [ Echochamber::Recipient.new({ role: 'SIGNER', email: 'goishi.san@gmail.com'})],
35
+ signatureFlow: "SENDER_SIGNS_LAST",
36
+ signatureType: "ESIGN",
37
+ name: "Rumplestiltskin Contract"
38
+ }
39
+ end
40
+
41
+ let(:agreement) { Echochamber::Agreement.new(agreement_user_id, agreement_user_email, agreement_info) }
42
+
43
+ it 'returns the agreement_id' do
44
+ VCR.use_cassette('create_agreement', :record => :once) do
45
+ agreement_id = client.create_agreement(agreement)
46
+ expect(agreement_id).to_not be_nil
47
+ end
48
+ end
49
+ end
50
+
51
+ describe '.get_agreements' do
52
+ it 'returns all agreements' do
53
+ VCR.use_cassette('get_agreements', :record => :once) do
54
+ response = client.get_agreements
55
+ expect(response).to_not be_nil
56
+ end
57
+ end
58
+ end
59
+
60
+ describe '.agreement_info' do
61
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
62
+ it 'returns detailed agreement info' do
63
+ VCR.use_cassette('agreement_info', :record => :once) do
64
+ response = client.agreement_info(agreement_id)
65
+ expect(response).to_not be_nil
66
+ end
67
+ end
68
+ end
69
+
70
+ describe '.agreement_form_data' do
71
+ let(:agreement_id) { "2AAABLblqZhDvfdYluvps8mSzQXnXr074OVtMYTwTVtljZYFJNi43iuzYeBaPUUOMTSlGXrt04Sw*" }
72
+ it 'returns CSV data' do
73
+ VCR.use_cassette('agreement_form_data', :record => :once) do
74
+ response = client.agreement_form_data(agreement_id)
75
+ expect(response).to_not be_nil
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '.cancel_agreement' do
81
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
82
+
83
+ it 'returns the result of the operation' do
84
+ VCR.use_cassette('cancel_agreement', :record => :once) do
85
+ result = client.cancel_agreement(agreement_id, true, 'Just because')
86
+ expect(result).to_not be_nil
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '.agreement_documents' do
92
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
93
+ let(:recipient_email) { 'goishi.san@gmail.com' }
94
+ let(:format) { 'CONVERTED_PDF' }
95
+ let(:version_id) { nil }
96
+
97
+ it 'returns information about documents for this agreement' do
98
+ VCR.use_cassette('agreement_documents', :record => :once) do
99
+ result = client.agreement_documents(agreement_id, recipient_email, format, version_id)
100
+ expect(result).to_not be_nil
101
+ end
102
+ end
103
+ end
104
+
105
+ describe '.agreement_document_file' do
106
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
107
+ let(:document_id) { "2AAABLblqZhDcteEO9jy6gSat9d_3XgpPVpxhetoDCpU4L9PoolGv_3mqgKL1DhIGTXTHhqAHlHk*" }
108
+
109
+ it 'returns a document file from the selected agreement' do
110
+ VCR.use_cassette('agreement_document_file', :record => :once) do
111
+ result = client.agreement_document_file(agreement_id, document_id)
112
+ expect(result).to be_a String
113
+ expect(result).to_not be_nil
114
+ end
115
+ end
116
+ end
117
+
118
+ describe '.audit_trail_pdf' do
119
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
120
+
121
+ it 'returns a pdf file for an audit trail on the agreement' do
122
+ VCR.use_cassette('audit_trail_pdf', :record => :once) do
123
+ result = client.audit_trail_pdf(agreement_id)
124
+ expect(result).to be_a String
125
+ expect(result).to_not be_nil
126
+ end
127
+ end
128
+ end
129
+
130
+ describe '.agreement_combined_pdf' do
131
+ let(:agreement_id) { "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*" }
132
+
133
+ it 'returns a combined pdf file ' do
134
+ VCR.use_cassette('agreement_combined_pdf', :record => :once) do
135
+ result = client.agreement_combined_pdf(agreement_id)
136
+ expect(result).to be_a String
137
+ expect(result).to_not be_nil
138
+ end
139
+ end
140
+ end
141
+
142
+ describe '.agreement_signing_urls' do
143
+ let(:agreement_id) { "2AAABLblqZhDdfTP0uM4EIz2UE2Mq27D7PXGl7Uk3e5nO4RtzlkN8GMANmeVwUVRWGGuUGCQoRQc*" }
144
+
145
+ it 'returns URL information for the agreement' do
146
+ VCR.use_cassette('agreement_signing_urls', :record => :once) do
147
+ result = client.agreement_signing_urls(agreement_id)
148
+ expect(result).to be_a Hash
149
+ end
150
+ end
151
+ end
152
+
153
+
154
+
155
+ end
156
+
157
+
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'lib/shared_client.rb'
3
+
4
+ describe Echochamber::Client do
5
+ include_context "shared client"
6
+
7
+ describe '.create_user' do
8
+ let (:user_params) do
9
+ {
10
+ firstName: 'JohnQ',
11
+ lastName: 'Public',
12
+ email: 'publius@comcast.net',
13
+ password: 'kN12oK9p!3',
14
+ title: 'Hedge Wizard'
15
+ }
16
+ end
17
+ let (:user) { Echochamber::User.new(user_params) }
18
+
19
+ it 'returns the User ID' do
20
+ VCR.use_cassette('create_user', :record => :once) do
21
+ user_id = client.create_user(user)
22
+ expect(user_id).to_not be_nil
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.get_users' do
28
+ let(:email) { "cthomas@railjumper.com" }
29
+ it 'returns user data' do
30
+ VCR.use_cassette('get_users', :record => :once) do
31
+ response = client.get_users(email)
32
+ expect(response).to be_a Hash
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '.get_user' do
38
+ let(:id) { "2AAABLblqZhBp6sZ412RCo4_5P1OCDATcuKQf3gzb7M-kea77rqC7h6kzMKSpofswP8rY9Cwv9Vw*" }
39
+ it 'returns user data' do
40
+ VCR.use_cassette('get_user', :record => :once) do
41
+ response = client.get_user(id)
42
+ expect(response).to be_a Hash
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '.create_reminder' do
48
+ let(:reminderInfo) { {
49
+ agreementId: "2AAABLblqZhA79nM-6ALjW2nXMKKb_ECz-Nr2yr_WrJ-3-Vz7d5D5_Dn9B6K-25C_EDktQqawW7M*",
50
+ comment: "Hey don't forget..."
51
+ } }
52
+ let(:reminder) { Echochamber::Reminder.new(reminderInfo) }
53
+
54
+ it 'returns result' do
55
+ VCR.use_cassette('create_reminder', :record => :once) do
56
+ response = client.create_reminder(reminder)
57
+ expect(response).to be_a Hash
58
+ end
59
+ end
60
+ end
61
+
62
+ describe '.create_transient_document' do
63
+ let(:file_name) { 'agreement.pdf' }
64
+ let(:mime_type) { 'application/pdf' }
65
+ let(:file) { File.new("fixtures/agreement.pdf", 'rb') }
66
+
67
+ it 'returns the transient document ID' do
68
+ VCR.use_cassette('create_transient_document', :record => :once) do
69
+ tran_doc_id = client.create_transient_document(file_name, mime_type, file)
70
+ expect(tran_doc_id).to_not be_nil
71
+ end
72
+ end
73
+ end
74
+
75
+
76
+ end # describe Echochamber::Client
77
+
78
+
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe Echochamber::Client do
4
+ include_context "shared client"
5
+
6
+ describe '.get_library_documents' do
7
+ let(:user_id) { nil }
8
+ let(:user_email) { 'cthomas@railjumper.com' }
9
+ it 'returns info about library documents' do
10
+ VCR.use_cassette('get_library_documents', :record => :once) do
11
+ response = client.get_library_documents(user_id, user_email)
12
+ expect(response).to be_a Hash
13
+ end
14
+ end
15
+ end
16
+
17
+ describe '.get_library_document' do
18
+ let(:library_document_id) {"2AAABLblqZhCri9FNiCHjwsixnFegzTxO6cP52B-FIhfOXZjjDHggZoYPQB5r0YS66QZg4DLQV-g*"}
19
+ it 'returns info about library document' do
20
+ VCR.use_cassette('get_library_document', :record => :once) do
21
+ response = client.get_library_document(library_document_id)
22
+ expect(response).to be_a Hash
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.get_library_document_files' do
28
+ let(:library_document_id) {"2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*"}
29
+ it 'returns info about library document files' do
30
+ VCR.use_cassette('get_library_document_file', :record => :once) do
31
+ response = client.get_library_document_files(library_document_id)
32
+ expect(response).to be_a Hash
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '.get_library_document_file' do
38
+ let(:library_document_id) { "2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*" }
39
+ let(:file_id) { "2AAABLblqZhD0YJu7EaQ3t2aKYe74spEGcgIXHeloWBdhkceuEbfqs9cw0pdkFB6z3RR4N8OWkZg*" }
40
+ it 'returns library document file data' do
41
+ VCR.use_cassette('get_library_document_data', :record => :once) do
42
+ response = client.get_library_document_file(library_document_id, file_id)
43
+ expect(response).to_not be_nil
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '.library_document_audit_trail' do
49
+ let(:library_document_id) { "2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*" }
50
+ it 'returns library document file data' do
51
+ VCR.use_cassette('library_document_audit_trail', :record => :once) do
52
+ response = client.library_document_audit_trail(library_document_id)
53
+ expect(response).to_not be_nil
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '.library_combined_document' do
59
+ let(:library_document_id) { "2AAABLblqZhAlC4t0c3xAJ92RFv44xFGZhbCuHpalUdpcHW9k72imMEG-W1SYCmUoia1ZNgQZ-FE*" }
60
+ it 'returns library combined document file data' do
61
+ VCR.use_cassette('library_combined_document', :record => :once) do
62
+ response = client.library_combined_document(library_document_id, nil, true)
63
+ expect(response).to_not be_nil
64
+ end
65
+ end
66
+ end
67
+
68
+
69
+
70
+ end
71
+
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'lib/shared_client.rb'
3
+
4
+ describe Echochamber::Request do
5
+ include_context "shared client"
6
+
7
+ describe '#get_token' do
8
+
9
+ it 'returns the accessToken' do
10
+ VCR.use_cassette('get_token', :record => :once) do
11
+ token = Echochamber::Request.get_token(credentials)
12
+ expect(token).to_not be_nil
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,22 @@
1
+ RSpec.shared_context "shared client" do
2
+
3
+ let(:app_id) { "9Q444442AX82M" }
4
+ let(:app_secret) { "390db09fc6672388b9457593a7" }
5
+ let(:api_key) { "XCFDJKSFLNL5Y" }
6
+ let(:email) { "nobody@nobody.com" }
7
+ let(:password) { "password" }
8
+
9
+ #let(:email) { "cthomas@railjumper.com" }
10
+ #let(:password) { "badpassword" }
11
+
12
+
13
+ let(:credentials) do
14
+ Echochamber::Credentials.new(app_id, app_secret, api_key, email, password)
15
+ end
16
+
17
+ let(:client) do
18
+ VCR.use_cassette('get_token', :record => :once) do
19
+ Echochamber::Client.new(credentials)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe Echochamber::User do
4
+
5
+ end
6
+
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+
3
+ require 'echochamber/validatable'
4
+
5
+ describe Echochamber::Validatable do
6
+
7
+ let(:first_name) { "John" }
8
+ let(:last_name) { "Public" }
9
+
10
+ let(:params) do
11
+ {
12
+ firstName: first_name,
13
+ lastName: last_name,
14
+ phone: "885551234"
15
+ }
16
+ end
17
+
18
+ let(:validatable_object) do
19
+ class Foo
20
+ include Echochamber::Validatable
21
+ end
22
+ Foo.new
23
+ end
24
+
25
+ describe ".validate_field" do
26
+
27
+ context "when field is nil" do
28
+ let(:first_name) { nil }
29
+
30
+ it "raises an invalid parameter error" do
31
+ expect do
32
+ validatable_object.validate_field(first_name, params)
33
+ end.to raise_error(Echochamber::RequiredParameterError)
34
+ end
35
+ end
36
+
37
+ context "when field is empty" do
38
+ let(:first_name) { '' }
39
+
40
+ it "raises an invalid parameter error" do
41
+ expect do
42
+ validatable_object.validate_field(first_name, params)
43
+ end.to raise_error(Echochamber::RequiredParameterError)
44
+ end
45
+
46
+ end
47
+
48
+ context "when key is not present" do
49
+ it "raises an invalid parameter error" do
50
+ expect do
51
+ validatable_object.validate_field([:unknown_field], params)
52
+ end.to raise_error(Echochamber::RequiredParameterError)
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ describe '.require_keys' do
59
+ let(:required_fields) do
60
+ [
61
+ :firstName,
62
+ :lastName
63
+ ]
64
+ end
65
+
66
+ context 'when all required fields are present' do
67
+ it 'it does not raise an error' do
68
+ expect do
69
+ validatable_object.require_keys(required_fields, params)
70
+ end.to_not raise_error
71
+ end
72
+ end
73
+
74
+ context 'when a required field is not present' do
75
+ it 'it raises an error' do
76
+ expect do
77
+ validatable_object.require_keys(required_fields.push(:unknown_field), params)
78
+ end.to raise_error(Echochamber::RequiredParameterError)
79
+ end
80
+ end
81
+ end
82
+
83
+ describe '.require_exactly_one' do
84
+ context 'when more than one key value is present' do
85
+ it 'it raises an error' do
86
+ expect do
87
+ validatable_object.require_exactly_one([:firstName, :lastName], params)
88
+ end.to raise_error(Echochamber::ParameterError)
89
+ end
90
+ end
91
+
92
+ context 'when none of the key values are present' do
93
+ it 'it raises an error' do
94
+ expect do
95
+ validatable_object.require_exactly_one([:unknown_field], params)
96
+ end.to raise_error(Echochamber::ParameterError)
97
+ end
98
+ end
99
+
100
+ context 'when exactly one of the key values is present' do
101
+ it 'it does not raise an error' do
102
+ expect do
103
+ validatable_object.require_exactly_one([:firstName], params)
104
+ end.to_not raise_error
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ end