accredible-api-ruby 0.1.10

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6602b8712b5921aea9dc781ffa7f43f463825b4
4
+ data.tar.gz: eb7836e18bc27097d900441891c6762a38f40955
5
+ SHA512:
6
+ metadata.gz: 04bbd5388287a377f428a193d44e0d86f02bad489ada0fbd21ee7c8fb0aeab5793fd849fe6b3c44f488016b7e25fb536b1032b81f6dc4dd8c8c700d0fbb7c44d
7
+ data.tar.gz: 7b360bed0eea30797728aeea5dd0835599acd7924e947e42ddc2cab859288072bcae41da1834800b02abc5810d91b8a8e3ed34a247e75804f1ecbd41422df127
@@ -0,0 +1,7 @@
1
+ /accredible-ruby-*.gem
2
+ /Gemfile.lock
3
+ .rvmrc
4
+ Gemfile.lock
5
+ tags
6
+ coverage/
7
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.8.7
5
+ - 2.0.0
6
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rake'
5
+ gem "codeclimate-test-reporter", require: nil
6
+ end
7
+
8
+ gemspec
9
+
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.
@@ -0,0 +1,122 @@
1
+ # accredible
2
+ Overview
3
+ --------
4
+ The Accredible platform enables organizations to create, manage and distribute digital credentials as digital certificates or open badges.
5
+
6
+ An example digital certificate and badge can be viewed here: https://www.credential.net/10000005
7
+
8
+ This gem wraps the Accredible API in Ruby for easy integration into projects. Full API documentation can be found here: http://docs.accrediblecredentialapi.apiary.io/
9
+
10
+ Install
11
+ --------
12
+ Add the following line to Gemfile:
13
+
14
+ ```ruby
15
+ gem 'accredible-ruby'
16
+ ```
17
+ and run `bundle install` from your shell.
18
+ Then add the following line to an initializer, or appropriate config file.
19
+
20
+ ```ruby
21
+ Accredible.api_key = ENV['ACCREDIBLE_API_KEY']
22
+ ```
23
+
24
+ Basic Usage
25
+ -----------
26
+ ```ruby
27
+ # creating a certificate
28
+ recipient = {name: "Jared Smith", email: "example@example.com"}
29
+ credential = {name: "#{course.title}",
30
+ group_name: "Example Group",
31
+ description: "A certificate of completion for a cool course"}
32
+
33
+ Accredible::Credential.create(
34
+ recipient: recipient,
35
+ credential: credential)
36
+ ```
37
+
38
+ Further Examples
39
+ -----------
40
+ ```ruby
41
+ # creating a credential
42
+ recipient = {name: "Jared Smith", email: "example@example.com"}
43
+ credential = {
44
+ group_name: "Example Group",
45
+ issued_on: "2016-03-15"}
46
+
47
+ # evidence and references are both optional but can be constructed like this
48
+ evidence =
49
+ [{description: "Evidence of completion",
50
+ url: "http://example.com/evidence",
51
+ category: "url"},
52
+ {description: "Evidence of completion 2",
53
+ file: "https://s3.amazonaws.com/accredible_api_evidence_items/files/12/original/open-uri20140316-15266-1m3by6h.jpeg",
54
+ category: "file"}]
55
+ references= [{description: "John worked hard",
56
+ relationship: "managed",
57
+ referee: {name: "Jane Doe",
58
+ email: "jane@example.com",
59
+ avatar: "https://placehold.it/100x100"}}
60
+ ]
61
+
62
+ Accredible::Credential.create(
63
+ recipient: recipient,
64
+ credential: credential,
65
+ evidence: evidence,
66
+ references: references)
67
+
68
+ #updating a credential
69
+ credential = {reciopient: {name: "Updated Name"}}
70
+ Accredible::Credential.update(id:"1234", credential: {name: "new credential name"})
71
+
72
+ #deleting a credential
73
+ cred = Accredible::Credential.delete("1234")
74
+
75
+ #for viewing all credentials
76
+ groups = Accredible::Credential.view_all(group_id: "1234", email: "student@example.com")
77
+
78
+ # creating a group
79
+ group =
80
+ {
81
+ "name": "new group",
82
+ "course_name": "Intro to Prgramming",
83
+ "course_description": "Description of course",
84
+ "course_link": "http://www.example.com",
85
+ "language": "en",
86
+ "attach_pdf": false
87
+ }
88
+
89
+
90
+ Accredible::Group.create(
91
+ group: group,
92
+ design_id: 12)
93
+
94
+ #updating a group
95
+ Accredible::Group.update(group_id:"1234", group: {name: "new group name"})
96
+
97
+ #deleting a group
98
+ Accredible::Group.delete(group_id:"1234")
99
+
100
+ #for viewing a group
101
+ Accredible::Group.view("1234")
102
+
103
+ #for viewing all groups
104
+ groups = Accredible::Group.view_all
105
+
106
+ #for viewing all designs
107
+ designs = Accredible::Design.view_all
108
+
109
+ ```
110
+ Supported Ruby versions
111
+ -----------------------
112
+ Currently only Ruby 2.0+ is supported. Contributions are welcome if you need to
113
+ support a different version.
114
+
115
+ License
116
+ -------
117
+ Accredible-Ruby is is free software, and may be redistributed under the
118
+ terms specified in the [LICENSE](/LICENSE) file.
119
+
120
+ Thanks to
121
+ ---------
122
+ [One Month](http://onemonth.com) - For allowing this gem to be extracted and open sourced.
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
6
+ rescue LoadError
7
+ # no rspec available
8
+ end
@@ -0,0 +1,59 @@
1
+ require "accredible-ruby/version"
2
+ require "accredible-ruby/credential"
3
+ require "accredible-ruby/group"
4
+ require "accredible-ruby/evidence"
5
+ require "accredible-ruby/reference"
6
+ require "accredible-ruby/design"
7
+ require "accredible-ruby/errors/accredible_error"
8
+ require "accredible-ruby/errors/authentication_error"
9
+ require "accredible-ruby/util"
10
+ require "json"
11
+ require "rest-client"
12
+
13
+ module Accredible
14
+ include RestClient
15
+ API_KEY_NOT_SET = "No API Key"
16
+
17
+ @api_base = "https://api.accredible.com"
18
+ @api_version = "v1"
19
+ @api_key = API_KEY_NOT_SET
20
+
21
+ class << self
22
+ attr_accessor :api_key, :api_base
23
+ end
24
+
25
+ def self.api_url(url='', api_base_url=nil)
26
+ Accredible.check_api_key
27
+ (api_base_url || @api_base) + "/#{@api_version}/"+ url
28
+ end
29
+
30
+ def self.request(end_point_url, method = :get, values = {})
31
+ Accredible.check_api_key
32
+
33
+ request_headers = Accredible.request_headers
34
+
35
+ if method == :get
36
+ RestClient.get(end_point_url, request_headers)
37
+ elsif method == :put
38
+ RestClient.put(end_point_url, values, request_headers)
39
+ elsif method == :delete
40
+ RestClient.delete(end_point_url)
41
+ else
42
+ RestClient.post(end_point_url, values, request_headers)
43
+ end
44
+ end
45
+
46
+ def self.request_headers
47
+ {:content_type => "application/json",
48
+ :authorization => "Token token=#{api_key}"}
49
+ end
50
+
51
+ def self.check_api_key
52
+ if api_key == API_KEY_NOT_SET || api_key.nil?
53
+ raise AuthenticationError.new("No API key provided. " \
54
+ "Set your API key using \"Accredible.api_key = <API-KEY>\". " \
55
+ "If you need an api key please visit https://accredible.com for " \
56
+ "details, or email support@accredible.com ")
57
+ end
58
+ end
59
+ 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(id:, credential: {})
16
+ uri = Credential.api_end_point(id)
17
+ params = {credential: credential}.to_json
18
+ Accredible.request(uri, :put, params)
19
+ end
20
+
21
+ def self.delete(id)
22
+ uri = Credential.api_end_point(id)
23
+ Accredible.request(uri, :delete)
24
+ end
25
+
26
+ def self.view_all(group_id, email, page=1,page_size=20)
27
+ uri = Credential.view_all_end_point(group_id, email, page, page_size)
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(group_id, email,page=1,page_size=20)
36
+ Accredible.api_url("all_credentials?group_id=#{group_id}&email=#{email}&page=#{page}&page_size={page_size}")
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ module Accredible
2
+ class Design
3
+
4
+ def self.view_all
5
+ uri = Design.view_all_end_point
6
+ Accredible.request(uri)
7
+ end
8
+
9
+ def self.view_all_end_point
10
+ Accredible.api_url("issuer/all_designs")
11
+ end
12
+ end
13
+ 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,4 @@
1
+ module Accredible
2
+ class AuthenticationError < AccredibleError
3
+ end
4
+ 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,41 @@
1
+ module Accredible
2
+ class Group
3
+
4
+ def self.delete(group_id)
5
+ uri = Group.api_end_point(group_id)
6
+ Accredible.request(uri, :delete)
7
+ end
8
+
9
+ def self.view_all
10
+ uri = Group.view_all_end_point
11
+ Accredible.request(uri)
12
+ end
13
+
14
+ def self.create(group:, design_id: nil)
15
+ params = Util.build_create_group_params(group, design_id)
16
+ uri = Group.api_end_point
17
+ Accredible.request(uri, :post, params)
18
+ end
19
+
20
+ def self.update(group_id:, group: {})
21
+ uri = Group.api_end_point(group_id)
22
+ params = {group: group}.to_json
23
+ Accredible.request(uri, :put, params)
24
+ end
25
+
26
+ def self.view(group_id = nil)
27
+ uri = Group.api_end_point(group_id)
28
+ Accredible.request(uri)
29
+ end
30
+
31
+ def self.api_end_point(id = nil)
32
+ Accredible.api_url("/issuer/group/#{id}")
33
+ end
34
+
35
+
36
+ def self.view_all_end_point
37
+ Accredible.api_url("/issuer/group")
38
+ end
39
+ end
40
+ end
41
+
@@ -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,20 @@
1
+ module Accredible
2
+ class Util
3
+ def self.build_create_credential_params(recipient={}, credential={}, evidence = {}, references = {}, group)
4
+ credential[:recipient] = recipient
5
+ credential[:evidence_items] = evidence unless evidence.empty?
6
+ credential[:references] = references unless references.empty?
7
+ credential[:group] = group
8
+ { credential: credential }.to_json
9
+ end
10
+
11
+ def self.build_update_credential_params(credential)
12
+ { credential: credential }.to_json
13
+ end
14
+
15
+ def self.build_create_group_params(group,design_id)
16
+ group[:design_id] = design_id
17
+ {group: group}.to_json
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Accredible
2
+ VERSION = "0.1.10"
3
+ 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 update a credential when update is called" do
25
+ cred = credential.update(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?group_id=123&email=example@example.com")
48
+ end
49
+
50
+ end
@@ -0,0 +1,18 @@
1
+ describe Accredible::Design do
2
+ let(:design) { Accredible::Design }
3
+
4
+ it "should return a list of groups when view_all is called" do
5
+ designs = design.view_all
6
+
7
+ expect(designs).to eq("Stubbed Request")
8
+ end
9
+
10
+ it "#api_end_point should return the default end point" do
11
+ end_point = design.view_all_end_point
12
+
13
+ expect(end_point).to include("accredible")
14
+ expect(end_point).to include("issuer")
15
+ expect(end_point).to include("designs")
16
+ end
17
+
18
+ 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,50 @@
1
+ describe Accredible::Group do
2
+ let(:group) { Accredible::Group }
3
+
4
+ it "should return a list of groups when view_all is called" do
5
+ groups = group.view_all
6
+
7
+ expect(groups).to eq("Stubbed Request")
8
+ end
9
+
10
+ it "should create a group when create is called" do
11
+ gro = group.create(group: group_details)
12
+
13
+ expect(gro).to eq("Stubbed Request")
14
+ end
15
+
16
+ it "should update a group when update is called" do
17
+ cred = group.update(group_id:"1234", group: {name: "new group name"})
18
+
19
+ expect(cred).to eq("Stubbed Request")
20
+ end
21
+
22
+ it "should return a group when view is called" do
23
+ cred = group.view("1234")
24
+
25
+ expect(cred).to eq("Stubbed Request")
26
+ end
27
+
28
+ it "should delete a group" do
29
+ temp = group.delete("1234")
30
+
31
+ expect(temp).to eq("Stubbed Request")
32
+ end
33
+
34
+ it "#api_end_point should return the default end point" do
35
+ end_point = group.api_end_point
36
+
37
+ expect(end_point).to include("accredible")
38
+ expect(end_point).to include("issuer")
39
+ expect(end_point).to include("group")
40
+ end
41
+
42
+ it "#view_all_end_point should return the view all end point" do
43
+ end_point = group.view_all_end_point
44
+
45
+ expect(end_point).to include("accredible")
46
+ expect(end_point).to include("group")
47
+ expect(end_point).to include("issuer")
48
+ end
49
+
50
+ 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,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
@@ -0,0 +1,38 @@
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
+ config.include GroupHelper
20
+ end
21
+
22
+ config.mock_with :rspec do |mocks|
23
+ mocks.verify_partial_doubles = true
24
+ end
25
+
26
+ config.before(:each) do
27
+ Accredible.api_key = "default_api_key"
28
+ end
29
+
30
+ config.before(:each) do
31
+ stub_request(:any, /api.accredible.com/).
32
+ with(:headers => {'Content-Type'=>'application/json'}).
33
+ to_return(:status => 200, :body => "Stubbed Request", :headers => {})
34
+
35
+ stub_request(:delete, /api.accredible.com/).
36
+ to_return(:status => 200, :body => "Stubbed Request", :headers => {})
37
+ end
38
+ 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
+ description: "description of credential",
10
+ group_name: "testing group"}
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
+ relationship: "managed",
25
+ referee: {name: "Jane Doe",
26
+ email: "jane@example.com",
27
+ avatar: "https://placehold.it/100x100"}}
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ module EvidenceHelper
2
+ def evidence_details
3
+ { description: "Example file",
4
+ file: "http://www.antennahouse.com/XSLsample/pdf/sample-link_1.pdf",
5
+ category: "file"}
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module GroupHelper
2
+ def group_details
3
+ {
4
+ "name": "new group",
5
+ "course_name": "Intro to Prgramming",
6
+ "course_description": "Description of course",
7
+ "course_link": "http://www.example.com",
8
+ "language": "en",
9
+ "attach_pdf": true
10
+ }
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: accredible-api-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.10
5
+ platform: ruby
6
+ authors:
7
+ - Jared Smith
8
+ - Deepender Singla
9
+ - Alan Heppenstall
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-03-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rest-client
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.8'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.8'
29
+ - !ruby/object:Gem::Dependency
30
+ name: byebug
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '8.2'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '8.2'
43
+ - !ruby/object:Gem::Dependency
44
+ name: pry
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.10'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.10'
57
+ - !ruby/object:Gem::Dependency
58
+ name: pry-byebug
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.3'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.3'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '10.5'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '10.5'
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3.4'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '3.4'
99
+ - !ruby/object:Gem::Dependency
100
+ name: webmock
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: 1.16.1
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: 1.16.1
113
+ description: A simple gem for interacting with the accredible certificate & badge
114
+ API
115
+ email: deepender@accredible.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE
126
+ - README.md
127
+ - Rakefile
128
+ - lib/accredible-ruby.rb
129
+ - lib/accredible-ruby/credential.rb
130
+ - lib/accredible-ruby/design.rb
131
+ - lib/accredible-ruby/errors/accredible_error.rb
132
+ - lib/accredible-ruby/errors/authentication_error.rb
133
+ - lib/accredible-ruby/evidence.rb
134
+ - lib/accredible-ruby/group.rb
135
+ - lib/accredible-ruby/reference.rb
136
+ - lib/accredible-ruby/util.rb
137
+ - lib/accredible-ruby/version.rb
138
+ - spec/accredible/base_spec.rb
139
+ - spec/accredible/credential_spec.rb
140
+ - spec/accredible/design_spec.rb
141
+ - spec/accredible/evidence_spec.rb
142
+ - spec/accredible/group_spec.rb
143
+ - spec/accredible/reference_spec.rb
144
+ - spec/accredible/util_spec.rb
145
+ - spec/spec_helper.rb
146
+ - spec/support/credential_helper.rb
147
+ - spec/support/evidence_helper.rb
148
+ - spec/support/group_helper.rb
149
+ homepage: https://github.com/accredible/accredible-api-ruby
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: 2.0.0
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.5.1
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Accredible API gem
173
+ test_files: []