Class: Vkontakte::API
- Inherits:
-
Object
- Object
- Vkontakte::API
- Defined in:
- lib/vkontakte/api.rb,
lib/vkontakte/api_error.rb
Overview
Make Vkontakte API requests
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(access_token = nil, proxy: nil, api_version: Vkontakte::API_VERSION, lang: 'ru', timeout: 60) ⇒ API
constructor
A new instance of API.
- #method_missing(method, *params) ⇒ Object
Constructor Details
#initialize(access_token = nil, proxy: nil, api_version: Vkontakte::API_VERSION, lang: 'ru', timeout: 60) ⇒ API
Returns a new instance of API.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vkontakte/api.rb', line 12 def initialize( access_token = nil, proxy: nil, api_version: Vkontakte::API_VERSION, lang: 'ru', timeout: 60 ) @access_token = access_token @proxy = proxy @api_version = api_version @lang = lang @timeout = timeout end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *params) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vkontakte/api.rb', line 26 def method_missing(method, *params) method_name = method.to_s.split('_').join('.') response = execute(method_name, *params) if response['error'] error_code = response['error']['error_code'] error_msg = response['error']['error_msg'] raise Vkontakte::API::Error.new(method_name, error_code, error_msg, params) end response['response'] end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/vkontakte/api.rb', line 9 def access_token @access_token end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
9 10 11 |
# File 'lib/vkontakte/api.rb', line 9 def api_version @api_version end |
#lang ⇒ Object
Returns the value of attribute lang.
10 11 12 |
# File 'lib/vkontakte/api.rb', line 10 def lang @lang end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
9 10 11 |
# File 'lib/vkontakte/api.rb', line 9 def proxy @proxy end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
9 10 11 |
# File 'lib/vkontakte/api.rb', line 9 def timeout @timeout end |