Class: Net::Wassr
- Inherits:
-
Object
- Object
- Net::Wassr
- Defined in:
- lib/net/wassr.rb
Instance Method Summary collapse
-
#initialize(user, pass) ⇒ Wassr
constructor
A new instance of Wassr.
- #post(end_point, params) ⇒ Object
- #post_channel(channel, status) ⇒ Object
- #post_status(status) ⇒ Object
Constructor Details
#initialize(user, pass) ⇒ Wassr
Returns a new instance of Wassr.
15 16 17 |
# File 'lib/net/wassr.rb', line 15 def initialize( user, pass ) @login = { user: user, pass: pass } end |
Instance Method Details
#post(end_point, params) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/net/wassr.rb', line 30 def post( end_point, params ) px_host, px_port = (ENV['http_proxy']||'').scan( %r|^(?:.*?)://(.*?):(\d+)?| ).flatten timeout( 10 ) do Net::HTTP.version_1_2 req = Net::HTTP::Post.new( end_point ) req.basic_auth( @login[:user], @login[:pass] ) req.body = params Net::HTTP::Proxy( px_host, px_port ).start( 'api.wassr.jp', 80 ) do |http| res = http.request( req ) end end end |
#post_channel(channel, status) ⇒ Object
24 25 26 27 |
# File 'lib/net/wassr.rb', line 24 def post_channel( channel, status ) params = "body=#{CGI::escape status}" post( "/channel_message/update.json?name_en=#{channel}", params ) end |
#post_status(status) ⇒ Object
19 20 21 22 |
# File 'lib/net/wassr.rb', line 19 def post_status( status ) params = "source=wassrfeed&status=#{CGI::escape status}" post( '/statuses/update.json', params ) end |