accredible-ruby 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +1 -0
- data/Rakefile +8 -0
- data/accredible-ruby.gemspec +28 -0
- data/lib/accredible-ruby.rb +57 -0
- data/lib/accredible-ruby/credential.rb +39 -0
- data/lib/accredible-ruby/errors/accredible_error.rb +18 -0
- data/lib/accredible-ruby/errors/authentication_error.rb +4 -0
- data/lib/accredible-ruby/evidence.rb +31 -0
- data/lib/accredible-ruby/reference.rb +30 -0
- data/lib/accredible-ruby/template.rb +33 -0
- data/lib/accredible-ruby/util.rb +14 -0
- data/lib/accredible-ruby/version.rb +3 -0
- data/spec/accredible/base_spec.rb +18 -0
- data/spec/accredible/credential_spec.rb +50 -0
- data/spec/accredible/evidence_spec.rb +35 -0
- data/spec/accredible/reference_spec.rb +35 -0
- data/spec/accredible/template_spec.rb +30 -0
- data/spec/accredible/util_spec.rb +20 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/credential_helper.rb +29 -0
- data/spec/support/evidence_helper.rb +7 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3215fa05571869674a932321e67bb279dd3b7e02
|
4
|
+
data.tar.gz: 439468a8668ca4fd6796ec1eb633c2ccdbd387e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba3d26d15bd7b28887090aa9e34655c2d0f7ec2b041fea2cc9b03793940f271640133b92f3e6237e1e21ee48f6d61f464cd453d0b4cf7467e9d6f6366a012713
|
7
|
+
data.tar.gz: 8808ee31e391eb9ffcce06ff829d950fcc7b1cbda05e1c0ba3e80812a41a51d463f75529c7582823be49bab1ee88b825b86e8a289633a8d14fadf5ecd0e2a43f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jared Smith
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# accredible
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
require 'accredible-ruby/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'accredible-ruby'
|
6
|
+
s.version = Accredible::VERSION
|
7
|
+
s.required_ruby_version = '>= 2.0.0'
|
8
|
+
s.date = '2016-03-11'
|
9
|
+
s.summary = "Accredible API gem"
|
10
|
+
s.description = "A simple gem for interacting with the accredible certificate API"
|
11
|
+
s.authors = ["Jared Smith"]
|
12
|
+
s.email = 'jared.smith88@me.com'
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
s.homepage = 'https://github.com/sublimecoder/accredible'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
|
19
|
+
s.add_dependency("rest-client", "~> 1.8")
|
20
|
+
|
21
|
+
s.add_development_dependency("byebug", "~> 8.2")
|
22
|
+
s.add_development_dependency("pry", "~> 0.10")
|
23
|
+
s.add_development_dependency("pry-byebug", "~> 3.3")
|
24
|
+
s.add_development_dependency("rake", "~> 10.5")
|
25
|
+
s.add_development_dependency("rspec", "~> 3.4")
|
26
|
+
s.add_development_dependency("webmock", "~> 1.16.1")
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "accredible-ruby/version"
|
2
|
+
require "accredible-ruby/credential"
|
3
|
+
require "accredible-ruby/template"
|
4
|
+
require "accredible-ruby/evidence"
|
5
|
+
require "accredible-ruby/reference"
|
6
|
+
require "accredible-ruby/errors/accredible_error"
|
7
|
+
require "accredible-ruby/errors/authentication_error"
|
8
|
+
require "accredible-ruby/util"
|
9
|
+
require "json"
|
10
|
+
require "rest-client"
|
11
|
+
|
12
|
+
module Accredible
|
13
|
+
include RestClient
|
14
|
+
API_KEY_NOT_SET = "No API Key"
|
15
|
+
|
16
|
+
@api_base = "https://api.accredible.com"
|
17
|
+
@api_version = "v1"
|
18
|
+
@api_key = API_KEY_NOT_SET
|
19
|
+
|
20
|
+
class << self
|
21
|
+
attr_accessor :api_key, :api_base
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.api_url(url='', api_base_url=nil)
|
25
|
+
(api_base_url || @api_base) + "/#{@api_version}/"+ url
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.request(end_point_url, method = :get, values = {})
|
29
|
+
Accredible.check_api_key
|
30
|
+
|
31
|
+
request_headers = Accredible.request_headers
|
32
|
+
|
33
|
+
if method == :get
|
34
|
+
RestClient.get(end_point_url, request_headers)
|
35
|
+
elsif method == :put
|
36
|
+
RestClient.put(end_point_url, values, request_headers)
|
37
|
+
elsif method == :delete
|
38
|
+
RestClient.delete(end_point_url)
|
39
|
+
else
|
40
|
+
RestClient.post(end_point_url, values, request_headers)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.request_headers
|
45
|
+
{:content_type => "application/json",
|
46
|
+
:authorization => "Token token=#{api_key}"}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.check_api_key
|
50
|
+
if api_key == API_KEY_NOT_SET || api_key.nil?
|
51
|
+
raise AuthenticationError.new("No API key provided. " \
|
52
|
+
"Set your API key using \"Accredible.api_key = <API-KEY>\". " \
|
53
|
+
"If you need an api key please visit https://accredible.com for " \
|
54
|
+
"details, or email support@accredible.com ")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Accredible
|
2
|
+
class Credential
|
3
|
+
|
4
|
+
def self.view(id = nil)
|
5
|
+
uri = Credential.api_end_point(id)
|
6
|
+
Accredible.request(uri)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create(recipient:, credential:, evidence: {}, references: {})
|
10
|
+
params = Util.build_create_credential_params(recipient, credential, evidence, references)
|
11
|
+
uri = Credential.api_end_point
|
12
|
+
Accredible.request(uri, :post, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(achievement_id:, credential: {})
|
16
|
+
uri = Credential.api_end_point(achievement_id)
|
17
|
+
params = {credential: credential}.to_json
|
18
|
+
Accredible.request(uri, :put, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.delete(achievement_id)
|
22
|
+
uri = Credential.api_end_point(achievement_id)
|
23
|
+
Accredible.request(uri, :delete)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.view_all(achievement_id, email)
|
27
|
+
uri = Credential.view_all_end_point(achievement_id, email)
|
28
|
+
Accredible.request(uri)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.api_end_point(id = nil)
|
32
|
+
Accredible.api_url("credentials/#{id}")
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.view_all_end_point(achievement_id, email)
|
36
|
+
Accredible.api_url("credentials?achievement_id=#{achievement_id}&email=#{email}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Accredible
|
2
|
+
class AccredibleError < StandardError
|
3
|
+
attr_reader :message
|
4
|
+
attr_reader :status
|
5
|
+
attr_reader :body
|
6
|
+
|
7
|
+
def initialize(message=nil, status=nil, body=nil)
|
8
|
+
@message = message
|
9
|
+
@status = status
|
10
|
+
@body = body
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
status = "(Status #{@status}) " if @status.nil?
|
15
|
+
"#{status}#{@message}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Accredible
|
2
|
+
class Evidence
|
3
|
+
|
4
|
+
def self.view(credential_id: ,evidence_id:)
|
5
|
+
uri = Evidence.api_end_point(credential_id, evidence_id)
|
6
|
+
Accredible.request(uri)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create(credential_id:, evidence: {})
|
10
|
+
params = {evidence_item: evidence }.to_json
|
11
|
+
uri = Evidence.api_end_point(credential_id)
|
12
|
+
Accredible.request(uri, :post, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(credential_id:, evidence_id:, evidence: {})
|
16
|
+
uri = Evidence.api_end_point(credential_id, evidence_id)
|
17
|
+
params = {evidence_item: evidence}.to_json
|
18
|
+
Accredible.request(uri, :put, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.delete(credential_id:, evidence_id:)
|
22
|
+
uri = Evidence.api_end_point(credential_id, evidence_id)
|
23
|
+
Accredible.request(uri, :delete)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.api_end_point(credential_id, evidence_id = nil)
|
27
|
+
@url = Accredible.api_url("credentials/#{credential_id}/evidence_items/#{evidence_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Accredible
|
2
|
+
class Reference
|
3
|
+
|
4
|
+
def self.view(credential_id:, reference_id:)
|
5
|
+
uri = Reference.api_end_point(credential_id, reference_id)
|
6
|
+
Accredible.request(uri)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create(credential_id:, reference: {})
|
10
|
+
params = {reference: reference}.to_json
|
11
|
+
uri = Reference.api_end_point(credential_id)
|
12
|
+
Accredible.request(uri, :post, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(credential_id:, reference_id:, reference: {})
|
16
|
+
uri = Reference.api_end_point(credential_id, reference_id)
|
17
|
+
params = {reference: reference}.to_json
|
18
|
+
Accredible.request(uri, :put, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.delete(credential_id:, reference_id:)
|
22
|
+
uri = Reference.api_end_point(credential_id, reference_id)
|
23
|
+
Accredible.request(uri, :delete)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.api_end_point(credential_id, reference_id = nil)
|
27
|
+
@url = Accredible.api_url("credentials/#{credential_id}/references/#{reference_id}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Accredible
|
2
|
+
class Template
|
3
|
+
|
4
|
+
def self.copy(source_id:, new_template_name:)
|
5
|
+
uri = Template.copy_end_point
|
6
|
+
params = {source_id: source_id,
|
7
|
+
new_template_name: new_template_name}.to_json
|
8
|
+
Accredible.request(uri, :post, params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.delete(template_id)
|
12
|
+
uri = Template.api_end_point(template_id)
|
13
|
+
Accredible.request(uri, :delete)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.view_all
|
17
|
+
uri = Template.view_all_end_point
|
18
|
+
Accredible.request(uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.api_end_point(id = nil)
|
22
|
+
Accredible.api_url("templates/#{id}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.copy_end_point
|
26
|
+
Accredible.api_url("templates/copy")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.view_all_end_point
|
30
|
+
Accredible.api_url("templates")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Accredible
|
2
|
+
class Util
|
3
|
+
def self.build_create_credential_params(recipient={}, credential={}, evidence = {}, references = {})
|
4
|
+
credential[:recipient] = recipient
|
5
|
+
credential[:evidence_items] = evidence unless evidence.empty?
|
6
|
+
credential[:references] = references unless references.empty?
|
7
|
+
{ credential: credential }.to_json
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.build_update_credential_params(credential)
|
11
|
+
{ credential: credential }.to_json
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe Accredible do
|
2
|
+
it "should accept and API key" do
|
3
|
+
Accredible.api_key = "some_key"
|
4
|
+
|
5
|
+
expect(Accredible.api_key).to eq("some_key")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return the api url" do
|
9
|
+
Accredible.api_key = "some_key"
|
10
|
+
|
11
|
+
expect(Accredible.api_url("credential")).to include("credential")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return an error if no api key is set" do
|
15
|
+
Accredible.api_key = nil
|
16
|
+
expect {Accredible::Credential.view_all("123", "example@example.com")}.to raise_error(Accredible::AuthenticationError)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
describe Accredible::Credential do
|
2
|
+
let(:credential) { Accredible::Credential }
|
3
|
+
|
4
|
+
it "should return a list of credentials when view_all is called" do
|
5
|
+
credentials = credential.view_all("1234", "example@example.com")
|
6
|
+
|
7
|
+
expect(credentials).to eq("Stubbed Request")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create a credential when create is called" do
|
11
|
+
cred = credential.create(
|
12
|
+
recipient: recipient_details,
|
13
|
+
credential: credential_details)
|
14
|
+
|
15
|
+
expect(cred).to eq("Stubbed Request")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return a credential when view is called" do
|
19
|
+
cred = credential.view("1234")
|
20
|
+
|
21
|
+
expect(cred).to eq("Stubbed Request")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return a credential when view is called" do
|
25
|
+
cred = credential.update(achievement_id:"1234", credential: {name: "new credential name"})
|
26
|
+
|
27
|
+
expect(cred).to eq("Stubbed Request")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should delete a credential" do
|
31
|
+
cred = credential.delete("1234")
|
32
|
+
|
33
|
+
expect(cred).to eq("Stubbed Request")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "#api_end_point should return the default end point" do
|
37
|
+
end_point = credential.api_end_point
|
38
|
+
|
39
|
+
expect(end_point).to include("accredible")
|
40
|
+
expect(end_point).to include("credentials")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "#view_all_end_point should return the view all end point" do
|
44
|
+
end_point = credential.view_all_end_point("123", "example@example.com")
|
45
|
+
|
46
|
+
expect(end_point).to include("accredible")
|
47
|
+
expect(end_point).to include("credentials?achievement_id=123&email=example@example.com")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe Accredible::Evidence do
|
2
|
+
let(:evidence) { Accredible::Evidence }
|
3
|
+
|
4
|
+
it "should return evidence when view is called" do
|
5
|
+
evidences = evidence.view(credential_id: "123", evidence_id: "456")
|
6
|
+
|
7
|
+
expect(evidences).to eq("Stubbed Request")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return evidence when view is called" do
|
11
|
+
evidences = evidence.create(credential_id: "123", evidence: evidence_details)
|
12
|
+
|
13
|
+
expect(evidences).to eq("Stubbed Request")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should update an evidence when update is called" do
|
17
|
+
response = evidence.update(credential_id: "123", evidence_id: "456")
|
18
|
+
|
19
|
+
expect(response).to eq("Stubbed Request")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should delete an evidence" do
|
23
|
+
response = evidence.delete(credential_id:"1234", evidence_id: "567")
|
24
|
+
|
25
|
+
expect(response).to eq("Stubbed Request")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "#api_end_point should return the default end point" do
|
29
|
+
end_point = evidence.api_end_point("123", "456")
|
30
|
+
|
31
|
+
expect(end_point).to include("accredible")
|
32
|
+
expect(end_point).to include("evidence_items")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe Accredible::Reference do
|
2
|
+
let(:reference) { Accredible::Reference }
|
3
|
+
|
4
|
+
it "should return reference when view is called" do
|
5
|
+
references = reference.view(credential_id: "123", reference_id: "456")
|
6
|
+
|
7
|
+
expect(references).to eq("Stubbed Request")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return reference when view is called" do
|
11
|
+
references = reference.create(credential_id: "123", reference: reference_details)
|
12
|
+
|
13
|
+
expect(references).to eq("Stubbed Request")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should update an reference when update is called" do
|
17
|
+
response = reference.update(credential_id: "123", reference_id: "456")
|
18
|
+
|
19
|
+
expect(response).to eq("Stubbed Request")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should delete an reference" do
|
23
|
+
response = reference.delete(credential_id:"1234", reference_id: "567")
|
24
|
+
|
25
|
+
expect(response).to eq("Stubbed Request")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "#api_end_point should return the default end point" do
|
29
|
+
end_point = reference.api_end_point("123", "456")
|
30
|
+
|
31
|
+
expect(end_point).to include("accredible")
|
32
|
+
expect(end_point).to include("references")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe Accredible::Template do
|
2
|
+
let(:template) { Accredible::Template }
|
3
|
+
|
4
|
+
it "should return a list of templates when view_all is called" do
|
5
|
+
templates = template.view_all
|
6
|
+
|
7
|
+
expect(templates).to eq("Stubbed Request")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should delete a template" do
|
11
|
+
temp = template.delete("1234")
|
12
|
+
|
13
|
+
expect(temp).to eq("Stubbed Request")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "#api_end_point should return the default end point" do
|
17
|
+
end_point = template.api_end_point
|
18
|
+
|
19
|
+
expect(end_point).to include("accredible")
|
20
|
+
expect(end_point).to include("templates")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#view_all_end_point should return the view all end point" do
|
24
|
+
end_point = template.view_all_end_point
|
25
|
+
|
26
|
+
expect(end_point).to include("accredible")
|
27
|
+
expect(end_point).to include("templates")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe Accredible::Util do
|
2
|
+
let(:util) { Accredible::Util }
|
3
|
+
|
4
|
+
it "#build_create_credential_params should take request params and build json" do
|
5
|
+
recipient = recipient_details
|
6
|
+
credential = credential_details
|
7
|
+
evidence = evidence_list
|
8
|
+
references = reference_details
|
9
|
+
request_json = util.build_create_credential_params(recipeient: recipient, credential: credential, evidence: evidence, references: references)
|
10
|
+
|
11
|
+
expect {JSON.parse(request_json)}.to_not raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it "#build_update_credential_params should take request params and build json" do
|
15
|
+
request_json = util.build_update_credential_params(name: "Changed Credential Name", completed: true)
|
16
|
+
|
17
|
+
expect {JSON.parse(request_json)}.to_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
if ENV['CODECLIMATE_REPO_TOKEN']
|
2
|
+
require 'codeclimate-test-reporter'
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'accredible-ruby'
|
7
|
+
require 'pry'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
|
10
|
+
WebMock.disable_net_connect!(allow_localhost: true, allow: "codeclimate.com")
|
11
|
+
|
12
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.expect_with :rspec do |expectations|
|
16
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
17
|
+
config.include CredentialHelper
|
18
|
+
config.include EvidenceHelper
|
19
|
+
end
|
20
|
+
|
21
|
+
config.mock_with :rspec do |mocks|
|
22
|
+
mocks.verify_partial_doubles = true
|
23
|
+
end
|
24
|
+
|
25
|
+
config.before(:each) do
|
26
|
+
Accredible.api_key = "default_api_key"
|
27
|
+
end
|
28
|
+
|
29
|
+
config.before(:each) do
|
30
|
+
stub_request(:any, /api.accredible.com/).
|
31
|
+
with(:headers => {'Content-Type'=>'application/json'}).
|
32
|
+
to_return(:status => 200, :body => "Stubbed Request", :headers => {})
|
33
|
+
|
34
|
+
stub_request(:delete, /api.accredible.com/).
|
35
|
+
to_return(:status => 200, :body => "Stubbed Request", :headers => {})
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module CredentialHelper
|
2
|
+
def recipient_details
|
3
|
+
{name: "John Doe",
|
4
|
+
email: "example@example.com"}
|
5
|
+
end
|
6
|
+
|
7
|
+
def credential_details
|
8
|
+
{name: "My Credential",
|
9
|
+
cohort_name: "cohort_123",
|
10
|
+
description: "description of credential"}
|
11
|
+
end
|
12
|
+
|
13
|
+
def evidence_list
|
14
|
+
[{description: "Evidence of completion",
|
15
|
+
url: "http://example.com/evidence",
|
16
|
+
category: "url"},
|
17
|
+
{description: "Evidence of completion 2",
|
18
|
+
file: "https://s3.amazonaws.com/accredible_api_evidence_items/files/12/original/open-uri20140316-15266-1m3by6h.jpeg",
|
19
|
+
category: "file"}]
|
20
|
+
end
|
21
|
+
|
22
|
+
def reference_details
|
23
|
+
{description: "John worked hard",
|
24
|
+
relationshi: "managed",
|
25
|
+
referee: {name: "Jane Doe",
|
26
|
+
email: "jane@example.com",
|
27
|
+
avatar: "https://placehold.it/100x100"}}
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: accredible-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '8.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '8.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.16.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.16.1
|
111
|
+
description: A simple gem for interacting with the accredible certificate API
|
112
|
+
email: jared.smith88@me.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- ".gitignore"
|
118
|
+
- ".rspec"
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- accredible-ruby.gemspec
|
125
|
+
- lib/accredible-ruby.rb
|
126
|
+
- lib/accredible-ruby/credential.rb
|
127
|
+
- lib/accredible-ruby/errors/accredible_error.rb
|
128
|
+
- lib/accredible-ruby/errors/authentication_error.rb
|
129
|
+
- lib/accredible-ruby/evidence.rb
|
130
|
+
- lib/accredible-ruby/reference.rb
|
131
|
+
- lib/accredible-ruby/template.rb
|
132
|
+
- lib/accredible-ruby/util.rb
|
133
|
+
- lib/accredible-ruby/version.rb
|
134
|
+
- spec/accredible/base_spec.rb
|
135
|
+
- spec/accredible/credential_spec.rb
|
136
|
+
- spec/accredible/evidence_spec.rb
|
137
|
+
- spec/accredible/reference_spec.rb
|
138
|
+
- spec/accredible/template_spec.rb
|
139
|
+
- spec/accredible/util_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/support/credential_helper.rb
|
142
|
+
- spec/support/evidence_helper.rb
|
143
|
+
homepage: https://github.com/sublimecoder/accredible
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 2.0.0
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.6.1
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Accredible API gem
|
167
|
+
test_files: []
|