Class: Cellular::Backends::Sendega

Inherits:
Object
  • Object
show all
Defined in:
lib/cellular/backends/sendega.rb

Constant Summary collapse

GATEWAY_URL =
'https://smsc.sendega.com/Content.asmx?WSDL'

Class Method Summary collapse

Class Method Details

.deliver(options = {}, savon_options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cellular/backends/sendega.rb', line 9

def self.deliver(options = {}, savon_options = {})
  # Send an SMS and return its initial delivery status code.
  #
  # Delivery status codes:
  #    0 -- Message is received and is being processed.
  # 1001 -- Not validated
  # 1003 -- Wrong format: pid/dcs
  # 1004 -- Erroneous typeid
  # 1020 -- Fromalpha too long
  # 1021 -- Fromnumber too long
  # 1022 -- Erroneous recipient, integer overflow
  # 1023 -- No message content submitted
  # 1024 -- Premium sms must have abbreviated number as sender
  # 1025 -- The message sender is not allowed
  # 1026 -- Balance to low
  # 1027 -- Message too long
  # 1028 -- Alphanumeric sender is not valid
  # 1099 -- Internal error
  # 9001 -- Username and password does not match
  # 9002 -- Account is closed
  # 9004 -- Http not enabled
  # 9005 -- Smpp not enabled
  # 9006 -- Ip not allowed
  # 9007 -- Demo account empty
  #
  # See Gate API Documentation:
  # http://www.sendega.no/downloads/Sendega%20API%20documentation%20v2.0.pdf

  savon_options[:wsdl] = GATEWAY_URL

  client = Savon.client savon_options

  result = client.call(:send, message: {
      username: Cellular.config.username,
      password: Cellular.config.password,
      sender: options[:sender],
      destination: options[:recipient],
      pricegroup: options[:price] || 0, # default price to 0
      contentTypeID: 1,
      contentHeader: '',
      content: options[:message],
      dlrUrl: Cellular.config.delivery_url,
      ageLimit: 0,
      extID: '',
      sendDate: '',
      refID: '',
      priority: 0,
      gwID: 0,
      pid: 0,
      dcs: 0
    }
  )

  body = result.body[:send_response][:send_result]

  if body[:success]
    [
      body[:error_number].to_i,
      'Message is received and is being processed.'
    ]
  else
    [
      body[:error_number].to_i,
      body[:error_message]
    ]
  end
end

.receive(data) ⇒ Object

Raises:

  • (NotImplementedError)


77
78
79
# File 'lib/cellular/backends/sendega.rb', line 77

def self.receive(data)
  raise NotImplementedError
end