Module: Accredible
- Includes:
- RestClient
- Defined in:
- lib/accredible-ruby.rb,
lib/accredible-ruby/util.rb,
lib/accredible-ruby/group.rb,
lib/accredible-ruby/design.rb,
lib/accredible-ruby/version.rb,
lib/accredible-ruby/evidence.rb,
lib/accredible-ruby/reference.rb,
lib/accredible-ruby/credential.rb,
lib/accredible-ruby/errors/accredible_error.rb,
lib/accredible-ruby/errors/authentication_error.rb
Defined Under Namespace
Classes: AccredibleError, AuthenticationError, Credential, Design, Evidence, Group, Reference, Util
Constant Summary
collapse
- API_KEY_NOT_SET =
"No API Key"
- VERSION =
"0.1.10"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.api_base ⇒ Object
Returns the value of attribute api_base.
22
23
24
|
# File 'lib/accredible-ruby.rb', line 22
def api_base
@api_base
end
|
.api_key ⇒ Object
Returns the value of attribute api_key.
22
23
24
|
# File 'lib/accredible-ruby.rb', line 22
def api_key
@api_key
end
|
Class Method Details
.api_url(url = '', api_base_url = nil) ⇒ Object
25
26
27
28
|
# File 'lib/accredible-ruby.rb', line 25
def self.api_url(url='', api_base_url=nil)
Accredible.check_api_key
(api_base_url || @api_base) + "/#{@api_version}/"+ url
end
|
.check_api_key ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/accredible-ruby.rb', line 51
def self.check_api_key
if api_key == API_KEY_NOT_SET || api_key.nil?
raise AuthenticationError.new("No API key provided. " \
"Set your API key using \"Accredible.api_key = <API-KEY>\". " \
"If you need an api key please visit https://accredible.com for " \
"details, or email [email protected] ")
end
end
|
.request(end_point_url, method = :get, values = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/accredible-ruby.rb', line 30
def self.request(end_point_url, method = :get, values = {})
Accredible.check_api_key
= Accredible.
if method == :get
RestClient.get(end_point_url, )
elsif method == :put
RestClient.put(end_point_url, values, )
elsif method == :delete
RestClient.delete(end_point_url)
else
RestClient.post(end_point_url, values, )
end
end
|
46
47
48
49
|
# File 'lib/accredible-ruby.rb', line 46
def self.
{:content_type => "application/json",
:authorization => "Token token=#{api_key}"}
end
|