Module: Semse

Defined in:
lib/semse.rb,
lib/semse/version.rb

Constant Summary collapse

API_ADDR =
'https://api.semse.pl'
STATUSES =
{
  '1'   => "Niepoporawna apiKey lub apiSecret",
  '2'   => "Niepoprawny numer telefonu w parametrze msgTo",
  '3'   => "Pusta wiadomość w parametrze msgBody",
  '4'   => "nieważny abonament",
  '5'   => "przekroczono limit wiadomości na kluczu przekazanym w parametrze apiKey",
  '6'   => "za długa wiadomość w parametrze msgBody - maksymalnie 640 znaków",
  '500' => "Błąd serwera SMS",
  '101' => "Wiadomość została wysłana"
}
VERSION =
"0.0.3"
@@api_key =
''
@@api_secret =
''

Class Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Semse)

    the object that the method was called on



26
27
28
# File 'lib/semse.rb', line 26

def self.configure
  yield self
end

.send(recipient, message, polish_chars = 0) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/semse.rb', line 30

def self.send(recipient, message, polish_chars=0)
  args = {
    'apiKey' => api_key,
    'apiSecret' => api_secret,
    'queryType' => 1,
    'msgTo' => recipient,
    'msgBody' => message,
    'polishChars' => polish_chars
  }
  resp = Net::HTTP.post_form(URI(API_ADDR), args)
  
  if resp.code == "200"
    JSON.parse(resp.body)
  else
    nil    
  end
end