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