Class: Smartcall::Soap::SmsWSClient

Inherits:
Object
  • Object
show all
Defined in:
lib/smartcall/soap/sms_ws_client.rb

Constant Summary collapse

RESPONSE_HANDLER =
{ 'Success' => true , 'InvalidSourceAddress' => Proc.new { SmsWSClient.invalid_source_address_error } ,
'InvalidToken' => Proc.new { SmsWSClient.invalid_token_error } , 'Failed' => false ,
'InvalidNumber' => Proc.new { SmsWSClient.invalid_number_error }  }
DEFAULT_ENDPOINT =
"http://www.smartcalltech.co.za/SmsWS/Service.asmx"
@@debug_mode =
false

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, campaign_id, reference) ⇒ SmsWSClient

Returns a new instance of SmsWSClient.



39
40
41
42
43
44
# File 'lib/smartcall/soap/sms_ws_client.rb', line 39

def initialize(username, password, campaign_id, reference)
  @retry = true
  @username, @password, @campaign_id, @reference = username, password, campaign_id, reference
  @obj = SmsWSSoap.new(DEFAULT_ENDPOINT)
  @obj.wiredump_dev = STDERR if @@debug_mode
end

Class Method Details

.debug_mode=(value) ⇒ Object



26
27
28
# File 'lib/smartcall/soap/sms_ws_client.rb', line 26

def debug_mode=(value)
  @@debug_mode = value
end

.invalid_number_errorObject

Raises:



18
19
20
# File 'lib/smartcall/soap/sms_ws_client.rb', line 18

def invalid_number_error
  raise SmartcallError.new("SmsWSErrors: InvalidNumber")
end

.invalid_source_address_errorObject

Raises:



14
15
16
# File 'lib/smartcall/soap/sms_ws_client.rb', line 14

def invalid_source_address_error
  raise SmartcallError.new("SmsWSErrors: Invalid Source Address")
end

.invalid_token_errorObject

Raises:



10
11
12
# File 'lib/smartcall/soap/sms_ws_client.rb', line 10

def invalid_token_error
  raise SmartcallError.new("SmsWSErrors: Invalid Token")
end

.no_authorisation_errorObject

Raises:



6
7
8
# File 'lib/smartcall/soap/sms_ws_client.rb', line 6

def no_authorisation_error  
  raise SmartcallError.new("SmsWSErrors: Unable to Login")
end

.not_implemented_errorObject

Raises:



22
23
24
# File 'lib/smartcall/soap/sms_ws_client.rb', line 22

def not_implemented_error
  raise SmartcallError.new("SmsWSErrors: Not Implemented")
end

Instance Method Details

#send_binary_sms(cell, header, part) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/smartcall/soap/sms_ws_client.rb', line 59

def send_binary_sms(cell, header, part)
  @cell = cell
  @token ||= self.
  if @token
    s = SendBinaryString.new(@token, cell, header + part, @reference, @campaign_id)
    response = @obj.sendBinaryString(s)
    result = process_response(RESPONSE_HANDLER[response.sendBinaryStringResult])
    return result
  else
    update_token
  end
end

#send_sms(cell, msg) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/smartcall/soap/sms_ws_client.rb', line 46

def send_sms(cell , msg)
  @cell = cell
  @msg = msg
  @token ||= self.
  if @token
    s = SendSMS.new(@token , cell , msg , @reference , @campaign_id)
    response = @obj.sendSMS(s)
    return process_response(RESPONSE_HANDLER[response.sendSMSResult])  
  else
    update_token
  end
end


72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/smartcall/soap/sms_ws_client.rb', line 72

def send_wap_link(cell, href, msg)
  @cell = cell
  @msg = msg
  @token ||= self.
  if @token
    s = SendWAPLink.new(@token , cell , href, msg , @reference , @campaign_id)
    response = @obj.sendWAPLink(s)
    return process_response(RESPONSE_HANDLER[response.sendWAPLinkResult])  
  else
    update_token
  end
end