authentise 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +65 -25
- data/lib/authentise/api/print.rb +38 -0
- data/lib/authentise/api/users.rb +64 -0
- data/lib/authentise/api/warehouse.rb +258 -0
- data/lib/authentise/api.rb +23 -13
- data/lib/authentise/configuration.rb +10 -0
- data/lib/authentise/model.rb +88 -0
- data/lib/authentise/print.rb +37 -0
- data/lib/authentise/session.rb +25 -0
- data/lib/authentise/upload.rb +1 -0
- data/lib/authentise/user.rb +35 -0
- data/lib/authentise/version.rb +1 -1
- data/lib/authentise.rb +4 -0
- data/spec/api/print_spec.rb +53 -0
- data/spec/api/users_spec.rb +108 -0
- data/spec/api/warehouse_spec.rb +330 -0
- data/spec/api_spec.rb +10 -16
- data/spec/fixtures/example.stl +1 -0
- data/spec/model_spec.rb +135 -0
- data/spec/print_spec.rb +46 -0
- data/spec/session_spec.rb +30 -0
- data/spec/upload_spec.rb +26 -22
- data/spec/user_spec.rb +44 -0
- metadata +25 -2
data/spec/model_spec.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Authentise
|
4
|
+
describe Model do
|
5
|
+
let(:model) { Model.new(name: "Test") }
|
6
|
+
|
7
|
+
describe "#name" do
|
8
|
+
it { model.name.must_equal "Test" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#create" do
|
12
|
+
it "returns urls from the API" do
|
13
|
+
response = {
|
14
|
+
upload_url: "https://bah",
|
15
|
+
model_url: "https://beh",
|
16
|
+
}
|
17
|
+
API::Warehouse.stub :create_model, response do
|
18
|
+
result = model.create
|
19
|
+
result.must_equal true
|
20
|
+
|
21
|
+
model.upload_url.must_equal "https://bah"
|
22
|
+
model.url.must_equal "https://beh"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#send_file" do
|
28
|
+
it "returns true" do
|
29
|
+
API::Warehouse.stub :put_file, true do
|
30
|
+
model.send_file.must_equal true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#fetch" do
|
36
|
+
it "calls the API and sets what is returned" do
|
37
|
+
api_return = {
|
38
|
+
url: "http://self",
|
39
|
+
uuid: "4242",
|
40
|
+
name: "Test 2",
|
41
|
+
status: "error",
|
42
|
+
snapshot_url: "http://snapshot",
|
43
|
+
content_url: "http://content",
|
44
|
+
manifold: true,
|
45
|
+
created_at: Time.local(2015, 1, 1),
|
46
|
+
updated_at: Time.local(2015, 1, 2),
|
47
|
+
parents_urls: ["http://parent1", "http://parent2"],
|
48
|
+
children_urls: ["http://child1"],
|
49
|
+
}
|
50
|
+
API::Warehouse.stub :get_model, api_return do
|
51
|
+
result = model.fetch(session_token: "f56")
|
52
|
+
|
53
|
+
result.must_equal true
|
54
|
+
model.url.must_equal api_return[:url]
|
55
|
+
model.uuid.must_equal api_return[:uuid]
|
56
|
+
model.name.must_equal api_return[:name]
|
57
|
+
model.status.must_equal api_return[:status]
|
58
|
+
model.snapshot_url.must_equal api_return[:snapshot_url]
|
59
|
+
model.content_url.must_equal api_return[:content_url]
|
60
|
+
model.manifold.must_equal api_return[:manifold]
|
61
|
+
model.created_at.must_equal api_return[:created_at]
|
62
|
+
model.updated_at.must_equal api_return[:updated_at]
|
63
|
+
model.parents_urls.must_equal api_return[:parents_urls]
|
64
|
+
model.children_urls.must_equal api_return[:children_urls]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#find_by_url" do
|
70
|
+
it "finds a model" do
|
71
|
+
api_return = {
|
72
|
+
url: "http://model/4242",
|
73
|
+
uuid: "4242",
|
74
|
+
name: "Test 2",
|
75
|
+
status: "error",
|
76
|
+
snapshot_url: "http://snapshot",
|
77
|
+
content_url: "http://content",
|
78
|
+
manifold: true,
|
79
|
+
created_at: Time.local(2015, 1, 1),
|
80
|
+
updated_at: Time.local(2015, 1, 2),
|
81
|
+
parents_urls: ["http://parent1", "http://parent2"],
|
82
|
+
children_urls: ["http://child1"],
|
83
|
+
}
|
84
|
+
API::Warehouse.stub :get_model, api_return do
|
85
|
+
model = Model.find_by_url(url: "http://model/4242",
|
86
|
+
session_token: "f42")
|
87
|
+
model.url.must_equal api_return[:url]
|
88
|
+
model.uuid.must_equal api_return[:uuid]
|
89
|
+
model.name.must_equal api_return[:name]
|
90
|
+
model.status.must_equal api_return[:status]
|
91
|
+
model.snapshot_url.must_equal api_return[:snapshot_url]
|
92
|
+
model.content_url.must_equal api_return[:content_url]
|
93
|
+
model.manifold.must_equal api_return[:manifold]
|
94
|
+
model.created_at.must_equal api_return[:created_at]
|
95
|
+
model.updated_at.must_equal api_return[:updated_at]
|
96
|
+
model.parents_urls.must_equal api_return[:parents_urls]
|
97
|
+
model.children_urls.must_equal api_return[:children_urls]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#find_by_uuid" do
|
103
|
+
it "finds a model" do
|
104
|
+
api_return = {
|
105
|
+
url: "http://model/4242",
|
106
|
+
uuid: "4242",
|
107
|
+
name: "Test 2",
|
108
|
+
status: "error",
|
109
|
+
snapshot_url: "http://snapshot",
|
110
|
+
content_url: "http://content",
|
111
|
+
manifold: true,
|
112
|
+
created_at: Time.local(2015, 1, 1),
|
113
|
+
updated_at: Time.local(2015, 1, 2),
|
114
|
+
parents_urls: ["http://parent1", "http://parent2"],
|
115
|
+
children_urls: ["http://child1"],
|
116
|
+
}
|
117
|
+
API::Warehouse.stub :get_model, api_return do
|
118
|
+
model = Model.find_by_uuid(uuid: "4242",
|
119
|
+
session_token: "f42")
|
120
|
+
model.url.must_equal api_return[:url]
|
121
|
+
model.uuid.must_equal api_return[:uuid]
|
122
|
+
model.name.must_equal api_return[:name]
|
123
|
+
model.status.must_equal api_return[:status]
|
124
|
+
model.snapshot_url.must_equal api_return[:snapshot_url]
|
125
|
+
model.content_url.must_equal api_return[:content_url]
|
126
|
+
model.manifold.must_equal api_return[:manifold]
|
127
|
+
model.created_at.must_equal api_return[:created_at]
|
128
|
+
model.updated_at.must_equal api_return[:updated_at]
|
129
|
+
model.parents_urls.must_equal api_return[:parents_urls]
|
130
|
+
model.children_urls.must_equal api_return[:children_urls]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/spec/print_spec.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "authentise/print"
|
3
|
+
|
4
|
+
module Authentise
|
5
|
+
describe Print do
|
6
|
+
let(:print) do
|
7
|
+
Print.new(model_url: "https://example.com/model/1",
|
8
|
+
receiver_email: "example@example.com",
|
9
|
+
print_value: 42,
|
10
|
+
print_value_currency: "EUR",
|
11
|
+
partner_job_id: 43)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#url" do
|
15
|
+
it "returns a url from the API" do
|
16
|
+
response = {
|
17
|
+
url: "https://bah",
|
18
|
+
}
|
19
|
+
API::Print.stub :create_token, response do
|
20
|
+
print.url.must_equal "https://bah"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#model_url" do
|
26
|
+
it { print.model_url.must_equal "https://example.com/model/1" }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#receiver_email" do
|
30
|
+
it { print.receiver_email.must_equal "example@example.com" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#print_value" do
|
34
|
+
it { print.print_value.must_equal 42 }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#print_value_currency" do
|
38
|
+
it { print.print_value_currency.must_equal "EUR" }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#partner_job_id" do
|
42
|
+
it { print.partner_job_id.must_equal 43 }
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Authentise
|
4
|
+
describe Session do
|
5
|
+
let(:session) do
|
6
|
+
Session.new(username: "bob",
|
7
|
+
password: "builder")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#username" do
|
11
|
+
it { session.username.must_equal "bob" }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#password" do
|
15
|
+
it { session.password.must_equal "builder" }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#create" do
|
19
|
+
it "assigns a token from the API" do
|
20
|
+
response = { token: "zf300" }
|
21
|
+
API::Users.stub :create_session, response do
|
22
|
+
result = session.create
|
23
|
+
result.must_equal true
|
24
|
+
|
25
|
+
session.token.must_equal "zf300"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/upload_spec.rb
CHANGED
@@ -1,35 +1,39 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
let(:upload) {
|
5
|
-
Authentise::Upload.new(email: "example@example.com",
|
6
|
-
currency: "EUR",
|
7
|
-
cents: 1_00)
|
8
|
-
}
|
3
|
+
# DEPRECATED
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
module Authentise
|
6
|
+
describe Upload do
|
7
|
+
let(:upload) do
|
8
|
+
Upload.new(email: "example@example.com",
|
9
|
+
currency: "EUR",
|
10
|
+
cents: 1_00)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#token" do
|
14
|
+
it "returns a token from the API" do
|
15
|
+
API.stub :create_token, "meh" do
|
16
|
+
upload.token.must_equal "meh"
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
|
-
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
describe '#link_url' do
|
22
|
+
it "returns a token from the API" do
|
23
|
+
upload.stub :token, "meh" do
|
24
|
+
API.stub :upload_file, "https://bah" do
|
25
|
+
upload.link_url.must_equal "https://bah"
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
|
-
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
describe '#status' do
|
32
|
+
it "returns a status from the API" do
|
33
|
+
upload.stub :token, "meh" do
|
34
|
+
API.stub :upload_file, "stats…" do
|
35
|
+
upload.link_url.must_equal "stats…"
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
data/spec/user_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Authentise
|
4
|
+
describe User do
|
5
|
+
let(:user) do
|
6
|
+
User.new(email: "foo@foo.com",
|
7
|
+
name: "Bob",
|
8
|
+
username: "bob",
|
9
|
+
password: "builder")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#email" do
|
13
|
+
it { user.email.must_equal "foo@foo.com" }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#name" do
|
17
|
+
it { user.name.must_equal "Bob" }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#username" do
|
21
|
+
it { user.username.must_equal "bob" }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#password" do
|
25
|
+
it { user.password.must_equal "builder" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#create" do
|
29
|
+
it "assigns a token from the API" do
|
30
|
+
response = {
|
31
|
+
url: "http://exampkle.com/user/4242/",
|
32
|
+
uuid: "4242",
|
33
|
+
}
|
34
|
+
API::Users.stub :create_user, response do
|
35
|
+
result = user.create
|
36
|
+
result.must_equal true
|
37
|
+
|
38
|
+
user.url.must_equal "http://exampkle.com/user/4242/"
|
39
|
+
user.uuid.must_equal "4242"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -64,12 +64,27 @@ files:
|
|
64
64
|
- Rakefile
|
65
65
|
- lib/authentise.rb
|
66
66
|
- lib/authentise/api.rb
|
67
|
+
- lib/authentise/api/print.rb
|
68
|
+
- lib/authentise/api/users.rb
|
69
|
+
- lib/authentise/api/warehouse.rb
|
67
70
|
- lib/authentise/configuration.rb
|
71
|
+
- lib/authentise/model.rb
|
72
|
+
- lib/authentise/print.rb
|
73
|
+
- lib/authentise/session.rb
|
68
74
|
- lib/authentise/upload.rb
|
75
|
+
- lib/authentise/user.rb
|
69
76
|
- lib/authentise/version.rb
|
77
|
+
- spec/api/print_spec.rb
|
78
|
+
- spec/api/users_spec.rb
|
79
|
+
- spec/api/warehouse_spec.rb
|
70
80
|
- spec/api_spec.rb
|
81
|
+
- spec/fixtures/example.stl
|
82
|
+
- spec/model_spec.rb
|
83
|
+
- spec/print_spec.rb
|
84
|
+
- spec/session_spec.rb
|
71
85
|
- spec/spec_helper.rb
|
72
86
|
- spec/upload_spec.rb
|
87
|
+
- spec/user_spec.rb
|
73
88
|
homepage: http://github.com/sunny/authentise
|
74
89
|
licenses:
|
75
90
|
- MIT
|
@@ -95,6 +110,14 @@ signing_key:
|
|
95
110
|
specification_version: 4
|
96
111
|
summary: Access the Authentise v3 API
|
97
112
|
test_files:
|
113
|
+
- spec/api/print_spec.rb
|
114
|
+
- spec/api/users_spec.rb
|
115
|
+
- spec/api/warehouse_spec.rb
|
98
116
|
- spec/api_spec.rb
|
117
|
+
- spec/fixtures/example.stl
|
118
|
+
- spec/model_spec.rb
|
119
|
+
- spec/print_spec.rb
|
120
|
+
- spec/session_spec.rb
|
99
121
|
- spec/spec_helper.rb
|
100
122
|
- spec/upload_spec.rb
|
123
|
+
- spec/user_spec.rb
|