Module: Accredible
- Includes:
- RestClient
- Defined in:
- lib/accredible-ruby.rb,
lib/accredible-ruby/util.rb,
lib/accredible-ruby/version.rb,
lib/accredible-ruby/evidence.rb,
lib/accredible-ruby/template.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, Evidence, Reference, Template, Util
Constant Summary
collapse
- API_KEY_NOT_SET =
"No API Key"
- VERSION =
"0.1.8"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.api_base ⇒ Object
Returns the value of attribute api_base.
21
22
23
|
# File 'lib/accredible-ruby.rb', line 21
def api_base
@api_base
end
|
.api_key ⇒ Object
Returns the value of attribute api_key.
21
22
23
|
# File 'lib/accredible-ruby.rb', line 21
def api_key
@api_key
end
|
Class Method Details
.api_url(url = '', api_base_url = nil) ⇒ Object
24
25
26
|
# File 'lib/accredible-ruby.rb', line 24
def self.api_url(url='', api_base_url=nil)
(api_base_url || @api_base) + "/#{@api_version}/"+ url
end
|
.check_api_key ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/accredible-ruby.rb', line 49
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/accredible-ruby.rb', line 28
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
|
44
45
46
47
|
# File 'lib/accredible-ruby.rb', line 44
def self.
{:content_type => "application/json",
:authorization => "Token token=#{api_key}"}
end
|