Class: Websmsby::WebsmsbyApi
- Inherits:
-
Object
- Object
- Websmsby::WebsmsbyApi
- Defined in:
- lib/websmsby/websmsby_api.rb
Instance Method Summary collapse
Instance Method Details
#api(r, params = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/websmsby/websmsby_api.rb', line 28 def api(r, params = {}) post_params = form_post_params(params) uri = URI(config[:url]) response = Net::HTTP.post_form uri, post_params return JSON.parse response.body end |
#config ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/websmsby/websmsby_api.rb', line 9 def config { :url => "http://websms.by/", :user => Websmsby.user || "[email protected]", :apikey => Websmsby.apikey ||"qwerty123", :devkey => "I8uerYjw732jhhGJvhs" } end |
#form_post_params(params) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/websmsby/websmsby_api.rb', line 18 def form_post_params(params) post_params = {} params.each {|key, value| post_params[key] = value} post_params[:r] = r post_params[:user] = config[:user] post_params[:apikey] = config[:apikey] post_params[:devkey] = config[:devkey] post_params end |