Class: VkMusicLoader::Authorizer
- Inherits:
-
Object
- Object
- VkMusicLoader::Authorizer
- Defined in:
- lib/vk_music_loader/authorizer.rb
Constant Summary collapse
- AUTH_FILE_PATH =
File.('~') + '/.vk_music_loader/auth_data'
- API_CHECK_AUDIO_METHOD_PATH =
'http://api.xn--41a.ws/api.php'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(auth_key = nil) ⇒ Authorizer
constructor
A new instance of Authorizer.
- #perform ⇒ Object
Constructor Details
#initialize(auth_key = nil) ⇒ Authorizer
Returns a new instance of Authorizer.
7 8 9 |
# File 'lib/vk_music_loader/authorizer.rb', line 7 def initialize(auth_key = nil) @auth_key = auth_key end |
Class Method Details
.auth_key_valid?(auth_key) ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'lib/vk_music_loader/authorizer.rb', line 11 def self.auth_key_valid?(auth_key) uri = URI(API_CHECK_AUDIO_METHOD_PATH) uri.query = URI.encode_www_form(key: auth_key, method: :by_owner, owner_id: :dummy) req = Net::HTTP::Get.new(uri) res = Net::HTTP.new(uri.host, uri.port).request(req) res.body != 'wrong key' && res.body != 'key wrong format' end |
Instance Method Details
#perform ⇒ Object
21 22 23 |
# File 'lib/vk_music_loader/authorizer.rb', line 21 def perform get_auth_token end |