Module: Cafe24Sms::SendSms

Included in:
Cafe24Sms
Defined in:
lib/cafe24_sms/send_sms.rb

Instance Method Summary collapse

Instance Method Details

#_form_data(options) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/cafe24_sms/send_sms.rb', line 16

def _form_data(options)
  { :sms_url => Configuration::SMS_URL,
    :user_id => self.user_id,
    :secure => self.secure,
    :sphone1 => self.sphone1,
    :sphone2 => self.sphone2,
    :sphone3 => self.sphone3
  }.merge(options)
end

#remaining_smsObject



26
27
28
29
# File 'lib/cafe24_sms/send_sms.rb', line 26

def remaining_sms
  auth_data = {:user_id => self.user_id, :secure => self.secure}
  Net::HTTP.post_form(URI.parse(Configuration::SMS_REMAIN_URL), auth_data)
end

#send_sms(options) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/cafe24_sms/send_sms.rb', line 6

def send_sms(options)
  url = URI.parse(Configuration::SMS_URL)
  req = Net::HTTP::Post.new(url.path)
  req.set_form_data(_form_data(options), '&')

  http_session = Net::HTTP.new(url.host, url.port)
  http_session.use_ssl = true
  http_session.start {|http| http.request(req)}
end