vault-invoice-builder-client 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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +5 -2
- data/Gemfile.lock +66 -34
- data/Rakefile +1 -1
- data/lib/vault-invoice-builder-client/client.rb +18 -0
- data/lib/vault-invoice-builder-client/version.rb +1 -1
- data/test/client_test.rb +26 -8
- data/vault-invoice-builder-client.gemspec +1 -0
- metadata +26 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ad40783466009e0b45d9265d6932b1806a0377a
|
4
|
+
data.tar.gz: 9b1dc214c173b93414663554d60d77d9074f9663
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 381e2dcff4194d9f1958700e030efa7d90c83883e828454a013b84cde8b5beed3355ce45f40b13b31077d3a23bf72a65a511bc880ff6c5d491011dbb241c21e1
|
7
|
+
data.tar.gz: f74a038b8f5548521db7511bc0e880dc46cf1234fd34aa9e78536f3acc0d4fa52decb734d111e105423559f847c899134f5a5d12e5279eee1c70e4e41ef83c38
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'rake'
|
7
|
+
gem 'yard'
|
8
|
+
gem 'debugger'
|
9
|
+
gem 'multi_json'
|
7
10
|
end
|
8
11
|
|
9
12
|
group :test do
|
10
13
|
gem 'rr'
|
11
|
-
gem 'vault-test-tools'
|
14
|
+
gem 'vault-test-tools'
|
12
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,88 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/heroku/vault-test-tools.git
|
3
|
-
revision: 5eabd67610f279b81cadb803cee8ef704093a05d
|
4
|
-
specs:
|
5
|
-
vault-test-tools (0.2.2)
|
6
|
-
minitest
|
7
|
-
nokogiri
|
8
|
-
rack-perftools_profiler
|
9
|
-
rack-test
|
10
|
-
rdoc
|
11
|
-
redcarpet
|
12
|
-
turn
|
13
|
-
yard
|
14
|
-
|
15
1
|
PATH
|
16
2
|
remote: .
|
17
3
|
specs:
|
18
|
-
vault-invoice-builder-client (0.0.
|
4
|
+
vault-invoice-builder-client (0.0.3)
|
19
5
|
excon
|
6
|
+
multi_json
|
20
7
|
yajl-ruby
|
21
8
|
|
22
9
|
GEM
|
23
|
-
remote:
|
10
|
+
remote: https://rubygems.org/
|
24
11
|
specs:
|
25
12
|
ansi (1.4.3)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
celluloid (0.15.2)
|
14
|
+
timers (~> 1.1.0)
|
15
|
+
coderay (1.1.0)
|
16
|
+
columnize (0.8.9)
|
17
|
+
debugger (1.6.6)
|
18
|
+
columnize (>= 0.3.1)
|
19
|
+
debugger-linecache (~> 1.2.0)
|
20
|
+
debugger-ruby_core_source (~> 1.3.2)
|
21
|
+
debugger-linecache (1.2.0)
|
22
|
+
debugger-ruby_core_source (1.3.2)
|
23
|
+
excon (0.38.0)
|
24
|
+
ffi (1.9.3)
|
25
|
+
formatador (0.2.5)
|
26
|
+
guard (2.6.1)
|
27
|
+
formatador (>= 0.2.4)
|
28
|
+
listen (~> 2.7)
|
29
|
+
lumberjack (~> 1.0)
|
30
|
+
pry (>= 0.9.12)
|
31
|
+
thor (>= 0.18.1)
|
32
|
+
guard-minitest (2.3.2)
|
33
|
+
guard (~> 2.0)
|
34
|
+
minitest (>= 3.0)
|
35
|
+
listen (2.7.9)
|
36
|
+
celluloid (>= 0.15.2)
|
37
|
+
rb-fsevent (>= 0.9.3)
|
38
|
+
rb-inotify (>= 0.9)
|
39
|
+
logfmt (0.0.6)
|
40
|
+
lumberjack (1.0.9)
|
41
|
+
method_source (0.8.2)
|
42
|
+
mini_portile (0.6.0)
|
43
|
+
minitest (4.7.5)
|
44
|
+
multi_json (1.10.0)
|
45
|
+
nokogiri (1.6.3.1)
|
46
|
+
mini_portile (= 0.6.0)
|
47
|
+
pry (0.10.1)
|
48
|
+
coderay (~> 1.1.0)
|
49
|
+
method_source (~> 0.8.1)
|
50
|
+
slop (~> 3.4)
|
32
51
|
rack (1.5.2)
|
33
|
-
rack-perftools_profiler (0.6.0)
|
34
|
-
open4 (~> 1.0)
|
35
|
-
perftools.rb (~> 2.0.0)
|
36
|
-
rack (~> 1.0)
|
37
52
|
rack-test (0.6.2)
|
38
53
|
rack (>= 1.0)
|
39
54
|
rake (10.0.3)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
rr (1.
|
44
|
-
|
55
|
+
rb-fsevent (0.9.4)
|
56
|
+
rb-inotify (0.9.5)
|
57
|
+
ffi (>= 0.5.0)
|
58
|
+
rr (1.1.2)
|
59
|
+
scrolls (0.3.8)
|
60
|
+
slop (3.6.0)
|
61
|
+
thor (0.19.1)
|
62
|
+
timers (1.1.0)
|
63
|
+
turn (0.9.7)
|
45
64
|
ansi
|
46
|
-
|
47
|
-
|
65
|
+
minitest (~> 4)
|
66
|
+
vault-test-tools (0.3.8)
|
67
|
+
guard-minitest
|
68
|
+
logfmt
|
69
|
+
minitest (~> 4.7.4)
|
70
|
+
nokogiri
|
71
|
+
rack-test
|
72
|
+
rr
|
73
|
+
scrolls
|
74
|
+
turn
|
75
|
+
yajl-ruby (1.2.0)
|
76
|
+
yard (0.8.7.4)
|
48
77
|
|
49
78
|
PLATFORMS
|
50
79
|
ruby
|
51
80
|
|
52
81
|
DEPENDENCIES
|
82
|
+
debugger
|
83
|
+
multi_json
|
53
84
|
rake
|
54
85
|
rr
|
55
86
|
vault-invoice-builder-client!
|
56
|
-
vault-test-tools
|
87
|
+
vault-test-tools
|
88
|
+
yard
|
data/Rakefile
CHANGED
@@ -31,6 +31,24 @@ module Vault::InvoiceBuilder
|
|
31
31
|
response.body
|
32
32
|
end
|
33
33
|
|
34
|
+
# POST an encrypted statement URL to to the proxy-able /statement/:id
|
35
|
+
# endpoint
|
36
|
+
#
|
37
|
+
# @param statement_url [String] An encrypted URL to an object matching the
|
38
|
+
# statement format described in the `Vault::InvoiceBuilder` README.
|
39
|
+
# @raise [Excon::Errors::HTTPStatusError] Raised if the server returns an
|
40
|
+
# unsuccessful HTTP status code.
|
41
|
+
# @return [Excon::Response] The response object.
|
42
|
+
def post_url(statement_url)
|
43
|
+
connection = Excon.new(@url)
|
44
|
+
response = connection.post(
|
45
|
+
path: "/statements",
|
46
|
+
headers: {'Content-Type' => 'application/json'},
|
47
|
+
body: JSON.generate(url: statement_url),
|
48
|
+
expects: [202])
|
49
|
+
end
|
50
|
+
|
51
|
+
# @deprecated Please use {#post_url} instead
|
34
52
|
# POST a statement to to the proxy-able /statement/:id endpoint
|
35
53
|
#
|
36
54
|
# @param statement [Hash] An object matching the statement format described in
|
data/test/client_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'multi_json'
|
2
3
|
|
3
4
|
class ClientTest < Vault::TestCase
|
4
5
|
include Vault::Test::EnvironmentHelpers
|
@@ -39,8 +40,8 @@ class ClientTest < Vault::TestCase
|
|
39
40
|
def test_render_html
|
40
41
|
content = '<html><body><p>Hello, world!</p></body></html>'
|
41
42
|
Excon.stub(method: :post) do |request|
|
42
|
-
assert_equal('vault-invoice-builder.herokuapp.com
|
43
|
-
|
43
|
+
assert_equal('vault-invoice-builder.herokuapp.com', request[:host])
|
44
|
+
assert_equal(443, request[:port])
|
44
45
|
assert_equal("/invoice.html", request[:path])
|
45
46
|
Excon.stubs.pop
|
46
47
|
{status: 200, body: content}
|
@@ -65,8 +66,8 @@ class ClientTest < Vault::TestCase
|
|
65
66
|
# Vault::InvoiceBuilder to generate the invoice and store it to S3.
|
66
67
|
def test_store
|
67
68
|
Excon.stub(method: :post) do |request|
|
68
|
-
assert_equal('vault-invoice-builder.herokuapp.com
|
69
|
-
|
69
|
+
assert_equal('vault-invoice-builder.herokuapp.com', request[:host])
|
70
|
+
assert_equal(443, request[:port])
|
70
71
|
assert_equal('/store', request[:path])
|
71
72
|
assert_equal('application/json', request[:headers]['Content-Type'])
|
72
73
|
Excon.stubs.pop
|
@@ -92,8 +93,8 @@ class ClientTest < Vault::TestCase
|
|
92
93
|
def test_post_with_symbol_id_key
|
93
94
|
@statement[:id] = 1
|
94
95
|
Excon.stub(method: :post) do |request|
|
95
|
-
assert_equal('vault-invoice-builder.herokuapp.com
|
96
|
-
|
96
|
+
assert_equal('vault-invoice-builder.herokuapp.com', request[:host])
|
97
|
+
assert_equal(443, request[:port])
|
97
98
|
assert_equal('/statement/1', request[:path])
|
98
99
|
assert_equal('application/json', request[:headers]['Content-Type'])
|
99
100
|
Excon.stubs.pop
|
@@ -107,8 +108,8 @@ class ClientTest < Vault::TestCase
|
|
107
108
|
def test_post_with_string_id_key
|
108
109
|
@statement['id'] = 1
|
109
110
|
Excon.stub(method: :post) do |request|
|
110
|
-
assert_equal('vault-invoice-builder.herokuapp.com
|
111
|
-
|
111
|
+
assert_equal('vault-invoice-builder.herokuapp.com', request[:host])
|
112
|
+
assert_equal(443, request[:port])
|
112
113
|
assert_equal('/statement/1', request[:path])
|
113
114
|
assert_equal('application/json', request[:headers]['Content-Type'])
|
114
115
|
Excon.stubs.pop
|
@@ -129,4 +130,21 @@ class ClientTest < Vault::TestCase
|
|
129
130
|
@client.post(@statement)
|
130
131
|
end
|
131
132
|
end
|
133
|
+
|
134
|
+
# Client.post_url makes a POST request to the canonical statement drain API
|
135
|
+
def test_post_url_with_url
|
136
|
+
json = { url: 'http://encrypted.url.example' }
|
137
|
+
Excon.stub(method: :post) do |request|
|
138
|
+
assert_equal('vault-invoice-builder.herokuapp.com', request[:host])
|
139
|
+
assert_equal(443, request[:port])
|
140
|
+
assert_equal('/statements', request[:path])
|
141
|
+
assert_equal('application/json', request[:headers]['Content-Type'])
|
142
|
+
assert_equal(json, MultiJson.load(request[:body], {symbolize_keys: true}))
|
143
|
+
Excon.stubs.pop
|
144
|
+
{status: 202}
|
145
|
+
end
|
146
|
+
response = @client.post_url('http://encrypted.url.example')
|
147
|
+
assert_equal(202, response.status)
|
148
|
+
end
|
149
|
+
|
132
150
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-invoice-builder-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Continanza
|
@@ -11,38 +10,48 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: excon
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - '>='
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: '0'
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
|
-
- -
|
26
|
+
- - '>='
|
30
27
|
- !ruby/object:Gem::Version
|
31
28
|
version: '0'
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: yajl-ruby
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
|
-
- -
|
33
|
+
- - '>='
|
38
34
|
- !ruby/object:Gem::Version
|
39
35
|
version: '0'
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
|
-
- -
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: multi_json
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
46
55
|
- !ruby/object:Gem::Version
|
47
56
|
version: '0'
|
48
57
|
description: Client for Vault::InvoiceBuilder
|
@@ -55,6 +64,7 @@ extensions: []
|
|
55
64
|
extra_rdoc_files: []
|
56
65
|
files:
|
57
66
|
- .gitignore
|
67
|
+
- .travis.yml
|
58
68
|
- .yardopts
|
59
69
|
- Gemfile
|
60
70
|
- Gemfile.lock
|
@@ -69,33 +79,26 @@ files:
|
|
69
79
|
- vault-invoice-builder-client.gemspec
|
70
80
|
homepage: https://github.com/heroku/vault-invoice-builder-client
|
71
81
|
licenses: []
|
82
|
+
metadata: {}
|
72
83
|
post_install_message:
|
73
84
|
rdoc_options: []
|
74
85
|
require_paths:
|
75
86
|
- lib
|
76
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
88
|
requirements:
|
79
|
-
- -
|
89
|
+
- - '>='
|
80
90
|
- !ruby/object:Gem::Version
|
81
91
|
version: '0'
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
hash: -3070326704752709441
|
85
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
93
|
requirements:
|
88
|
-
- -
|
94
|
+
- - '>='
|
89
95
|
- !ruby/object:Gem::Version
|
90
96
|
version: '0'
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
hash: -3070326704752709441
|
94
97
|
requirements: []
|
95
98
|
rubyforge_project:
|
96
|
-
rubygems_version:
|
99
|
+
rubygems_version: 2.0.14
|
97
100
|
signing_key:
|
98
|
-
specification_version:
|
101
|
+
specification_version: 4
|
99
102
|
summary: A simple wrapper for the Vault::InvoiceBuilder HTTP API
|
100
103
|
test_files: []
|
101
104
|
has_rdoc:
|