Class: Odnoklassniki::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/odnoklassniki/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
# File 'lib/odnoklassniki/client.rb', line 6

def initialize(attrs= {})
  attrs = Odnoklassniki.options.merge(attrs)
  Config::VALID_OPTIONS_KEYS.each do |key|
    instance_variable_set("@#{key}".to_sym, attrs[key])
  end
  @refreshed = false
end

Instance Method Details

#get(method, params = {}, &block) ⇒ Object



14
15
16
# File 'lib/odnoklassniki/client.rb', line 14

def get(method, params={}, &block)
  request_method(:get, method, params, block)
end

#post(method, params = {}, &block) ⇒ Object



18
19
20
# File 'lib/odnoklassniki/client.rb', line 18

def post(method, params={}, &block)
  request_method(:post, method, params, block)
end

#refresh_token!Object



22
23
24
25
26
27
# File 'lib/odnoklassniki/client.rb', line 22

def refresh_token!
  @refreshed = true
  data = request.post('/oauth/token.do', refresh_credentials)
  @request = nil
  @access_token = data['access_token']
end