Class: OAuthTest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ks) ⇒ OAuthTest

Returns a new instance of OAuthTest.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/oa_test/oa_test.rb', line 8

def initialize(ks)
  @key    = ks[:key]
  @secret = ks[:secret]
  @return = ks[:return]
  @host   = ks[:host] ? ks[:host] : 'http://www.koprol.com'
  @api    = ks[:api]  ? ks[:api]  : '/api/v2'
  @typ    = {
    :json => {"Accept" => "application/json", "Content-Type" => "application/json"},
    :xml  => {"Accept" => "application/xml", "Content-Type" => "application/xml"},
  }
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



6
7
8
# File 'lib/oa_test/oa_test.rb', line 6

def api
  @api
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/oa_test/oa_test.rb', line 6

def host
  @host
end

Instance Method Details

#delete(path) ⇒ Object



36
37
38
# File 'lib/oa_test/oa_test.rb', line 36

def delete(path)
  rtn @access_token.delete(@host+@api+path,typ(path))
end

#get(path) ⇒ Object



24
25
26
# File 'lib/oa_test/oa_test.rb', line 24

def get(path)
  rtn @access_token.get(@host+@api+path,typ(path))
end

#post(path, params) ⇒ Object



28
29
30
# File 'lib/oa_test/oa_test.rb', line 28

def post(path,params)
  rtn @access_token.post(@host+@api+path,params.to_json,typ(path))
end

#put(path, params) ⇒ Object



32
33
34
# File 'lib/oa_test/oa_test.rb', line 32

def put(path,params)
  rtn @access_token.put(@host+@api+path,params.to_json,typ(path))
end

#yauth(lp) ⇒ Object



20
21
22
# File 'lib/oa_test/oa_test.rb', line 20

def yauth(lp)
  get_part(lp).get_token()
end