Class: OAuthTest
- Inherits:
-
Object
- Object
- OAuthTest
- Defined in:
- lib/oa_test/oa_test.rb,
lib/oa_test/oa_config.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#host ⇒ Object
Returns the value of attribute host.
-
#resp ⇒ Object
readonly
Returns the value of attribute resp.
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(ks) ⇒ OAuthTest
constructor
A new instance of OAuthTest.
- #post(path, params) ⇒ Object
- #put(path, params) ⇒ Object
- #yauth(lp) ⇒ Object
Constructor Details
#initialize(ks) ⇒ OAuthTest
Returns a new instance of OAuthTest.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/oa_test/oa_test.rb', line 9 def initialize(ks) config_load(ks) @key = config.key @secret = config.secret @return = config.return @host = config.host @api = config.api @irb = (config.file ? config.file=~/bin\/oa_test$/ : false) @typ = { :json => {"Accept" => "application/json", "Content-Type" => "application/json"}, :xml => {"Accept" => "application/xml", "Content-Type" => "application/xml"}, } end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
6 7 8 |
# File 'lib/oa_test/oa_test.rb', line 6 def api @api end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/oa_test/oa_config.rb', line 18 def config @config end |
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/oa_test/oa_test.rb', line 6 def host @host end |
#resp ⇒ Object (readonly)
Returns the value of attribute resp.
7 8 9 |
# File 'lib/oa_test/oa_test.rb', line 7 def resp @resp end |
Instance Method Details
#delete(path) ⇒ Object
42 43 44 45 |
# File 'lib/oa_test/oa_test.rb', line 42 def delete(path) puts "DELETE #{@host+@api+path}" if @irb rtn @access_token.delete(@host+@api+path,typ(path)) end |
#get(path) ⇒ Object
27 28 29 30 |
# File 'lib/oa_test/oa_test.rb', line 27 def get(path) puts "GET #{@host+@api+path}" if @irb rtn @access_token.get(@host+@api+path,typ(path)) end |
#post(path, params) ⇒ Object
32 33 34 35 |
# File 'lib/oa_test/oa_test.rb', line 32 def post(path,params) puts "POST #{@host+@api+path}, body:#{params.inspect}" if @irb rtn @access_token.post(@host+@api+path,params.to_json,typ(path)) end |
#put(path, params) ⇒ Object
37 38 39 40 |
# File 'lib/oa_test/oa_test.rb', line 37 def put(path,params) puts "PUT #{@host+@api+path}, body:#{params.inspect}" if @irb rtn @access_token.put(@host+@api+path,params.to_json,typ(path)) end |
#yauth(lp) ⇒ Object
23 24 25 |
# File 'lib/oa_test/oa_test.rb', line 23 def yauth(lp) get_part(lp).get_token() end |