Module: Chuanglan

Defined in:
lib/chuanglan.rb,
lib/chuanglan/request.rb,
lib/chuanglan/version.rb,
lib/chuanglan/international.rb,
lib/chuanglan/request_exception.rb

Defined Under Namespace

Classes: International, Request, RequestException

Constant Summary collapse

GATEWAY =
'https://sms.253.com'
VERSION =
"1.1.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.passwordObject

Returns the value of attribute password.



11
12
13
# File 'lib/chuanglan.rb', line 11

def password
  @password
end

.signatureObject

Returns the value of attribute signature.



11
12
13
# File 'lib/chuanglan.rb', line 11

def signature
  @signature
end

.timeoutObject

Returns the value of attribute timeout.



11
12
13
# File 'lib/chuanglan.rb', line 11

def timeout
  @timeout
end

.usernameObject

Returns the value of attribute username.



11
12
13
# File 'lib/chuanglan.rb', line 11

def username
  @username
end

Class Method Details

.balanceObject



21
22
23
24
# File 'lib/chuanglan.rb', line 21

def balance
  rsp = Request.new("#{GATEWAY}/msg/balance", un: username, pw: password).perform
  success_or_raise_exception(rsp).to_i
end

.send_to!(recipients, message, params = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/chuanglan.rb', line 13

def send_to!(recipients, message, params = {})
  params = base_params.merge(params)
  params[:phone] = Array(recipients).join(',')
  params[:msg] = "#{params.delete(:signature) || signature}#{message}"
  rsp = Request.new("#{GATEWAY}/msg/send", params).perform
  success_or_raise_exception(rsp)
end