Module: CompanionApi
- Defined in:
- lib/companion_api.rb,
lib/companion_api/base.rb,
lib/companion_api/error.rb,
lib/companion_api/profile.rb,
lib/companion_api/request.rb,
lib/companion_api/version.rb,
lib/companion_api/configuration.rb,
lib/companion_api/resources/login.rb,
lib/companion_api/resources/market.rb,
lib/companion_api/resources/account.rb
Defined Under Namespace
Modules: Resources
Classes: ApiError, Base, Configuration, Error, LoginError, Profile, Request, TokenExpiredError
Constant Summary
collapse
- VERSION =
'0.1.5'.freeze
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
24
25
26
|
# File 'lib/companion_api/configuration.rb', line 24
def config
@config ||= Configuration.new
end
|
19
20
21
22
|
# File 'lib/companion_api/configuration.rb', line 19
def configure
@config ||= Configuration.new
yield @config
end
|
.debug(message, args = {}) ⇒ Object
49
50
51
52
53
|
# File 'lib/companion_api.rb', line 49
def debug(message, args = {})
return if config.debug == false || config.logger.nil?
config.logger.debug(format(message, args))
end
|
.generate_uuid ⇒ Object
36
37
38
|
# File 'lib/companion_api.rb', line 36
def generate_uuid
SecureRandom.uuid.upcase
end
|
.pbkdf2(value, salt) ⇒ Object
40
41
42
|
# File 'lib/companion_api.rb', line 40
def pbkdf2(value, salt)
PBKDF2.new(password: value, salt: salt, iterations: 1000, hash_function: OpenSSL::Digest::SHA1, key_length: 128).hex_string
end
|
.refresh_uuid ⇒ Object
32
33
34
|
# File 'lib/companion_api.rb', line 32
def refresh_uuid
@uuid = generate_uuid
end
|
.rsa ⇒ Object
44
45
46
47
|
# File 'lib/companion_api.rb', line 44
def rsa
pem = File.read(File.join(CompanionApi.config.directory, 'public-key.pem')).strip
OpenSSL::PKey::RSA.new(Base64.decode64(pem))
end
|
.uuid ⇒ Object
28
29
30
|
# File 'lib/companion_api.rb', line 28
def uuid
@uuid ||= generate_uuid
end
|