29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/sms_ru.rb', line 29
def self.method_missing(m, options = {})
if @@stack_method
query_options = methods.configuration.to_h[@@stack_method].to_h[m].to_h
query_options.deep_merge!(api_id: api_id)
query_options.deep_merge! options
uri = URI.parse("http://sms.ru/#{@@stack_method.to_s}/#{m.to_s}")
@@stack_method = nil
response = Net::HTTP.post_form(uri, query_options)
raise 'you have troubles with internet connection or API query is missing' unless response. == '200'
raise "something going wrong: #{query_options}, #{response.body}" unless response.body.match(/^100/)
response.body
else
@@stack_method = m
return self
end
end
|