RubyGlobe 1.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.rst +35 -0
  2. data/demo.rb +10 -0
  3. data/lib/rubyglobe.rb +48 -30
  4. metadata +4 -4
  5. data/README +0 -0
@@ -0,0 +1,35 @@
1
+ HOW TO INSTALL
2
+ --------------
3
+ To install run ``gem install RubyGlobe``
4
+
5
+
6
+ SENDING SMS
7
+ ------------
8
+ ::
9
+
10
+ require 'rubygems'
11
+ require 'rubyglobe'
12
+
13
+ begin
14
+ service = RubyGlobe.new '<globe API uname>','<globe API pin>','<11 digit mobile number>'
15
+ service.sendSMS 'Message through Globe Labs API'
16
+ rescue RubyGlobeInvalidServiceException, RubyGlobeInvalidURLException, RubyGlobeServerFaultException => e
17
+ puts "An error occurred: " << e
18
+ end
19
+
20
+ SENDING MMS
21
+ ------------
22
+ ::
23
+
24
+ require 'rubygems'
25
+ require 'rubyglobe'
26
+
27
+ #Valid SMIL (Synchronized Multimedia Integration Language)
28
+ smil = "<smil><head><layout><root-layout height='96' width='122' /><region height='67%' fit='meet' id='Image' width='100%' left='0%' top='0%' /><region height='33%' fit='scroll' id='Text' width='100%' left='0%' top='67%' /></layout></head><body><par dur='8000ms'><img src='https://www.globelabs.com.ph/Style%20Library/en-us/Core%20Styles/MasterPageStyles/images/globe_logo_NOtag_155x60px.png' region='Image' /><text src='http://ferdinandsilva.com/hello.txt' region='Text' /></par></body></smil>"
29
+
30
+ begin
31
+ service = RubyGlobe.new '<globe API uname>','<globe API pin>','<11 digit mobile number>'
32
+ service.sendMMS '<subject>', smil
33
+ rescue RubyGlobeInvalidServiceException, RubyGlobeInvalidURLException, RubyGlobeServerFaultException => e
34
+ puts "An error occurred: " << e
35
+ end
data/demo.rb CHANGED
@@ -0,0 +1,10 @@
1
+ require 'lib/rubyglobe'
2
+
3
+ smil = "<smil><head><layout><root-layout height='96' width='122' /><region height='67%' fit='meet' id='Image' width='100%' left='0%' top='0%' /><region height='33%' fit='scroll' id='Text' width='100%' left='0%' top='67%' /></layout></head><body><par dur='8000ms'><img src='https://www.globelabs.com.ph/Style%20Library/en-us/Core%20Styles/MasterPageStyles/images/globe_logo_NOtag_155x60px.png' region='Image' /><text src='http://ferdinandsilva.com/hello.txt' region='Text' /></par></body></smil>"
4
+
5
+ begin
6
+ service = RubyGlobe.new '<globe API uname>','<globe API pin>','<11 digit mobile number>'
7
+ service.sendMMS '<subject>', smil
8
+ rescue RubyGlobeInvalidServiceException, RubyGlobeInvalidURLException, RubyGlobeServerFaultException => e
9
+ puts "An error occurred: " << e
10
+ end
@@ -4,7 +4,6 @@
4
4
  * @email: ferdinandsilva@ferdinandsilva.com
5
5
  * @title: PyGlobe
6
6
  * @description: Ruby interface for Globe Labs API
7
- * @notes: sendMMS coming soon.. ;)
8
7
  ***********************************************
9
8
  =end
10
9
 
@@ -198,7 +197,7 @@ end
198
197
 
199
198
  class RubyGlobe
200
199
 
201
- @@__VERSION__ = "1.1"
200
+ @@__VERSION__ = "1.2"
202
201
  @@__AUTHOR__ = "Ferdinand E. Silva"
203
202
 
204
203
  def self.__VERSION__
@@ -231,40 +230,59 @@ class RubyGlobe
231
230
 
232
231
  end
233
232
 
234
- def sendSMS(message)
235
-
236
- begin
237
- ret = @service.sendSMS(:uName => @uname, :uPin => @pin, :MSISDN => @msisdn, :messageString => message, :Display => @display, :udh => @udh, :mwi => @mwi, :coding => @coding).return.to_s
238
-
239
- if ret == RubyGlobeReturnCode.SMS_ACCEPTED
240
- return true
241
- elsif ret == RubyGlobeReturnCode.NOT_ALLOWED
242
- raise RubyGlobeServerFaultException, "User is not allowed to access this service"
243
- elsif ret == RubyGlobeReturnCode.EXCEEDED_DAILY_CAP
244
- raise RubyGlobeServerFaultException, "User exceeded daily cap"
245
- elsif ret == RubyGlobeReturnCode.INVALID_MESSAGE_LENGTH
246
- raise RubyGlobeServerFaultException, "Invalid message length"
247
- elsif ret == RubyGlobeReturnCode.MAX_NUMBER_CONNECTION
248
- raise RubyGlobeServerFaultException, "Maximum Number of simultaneous connections reached"
249
- elsif ret == RubyGlobeReturnCode.INVALID_LOGIN_CREDENTIALS
250
- raise RubyGlobeServerFaultException, "Invalid login credentials"
251
- elsif ret == RubyGlobeReturnCode.SMS_SENDING_FAILED
252
- raise RubyGlobeServerFaultException, "SMS sending failed"
253
- elsif ret == RubyGlobeReturnCode.INVALID_TARGET
233
+ def translateMsg(ret)
234
+
235
+ if ret == RubyGlobeReturnCode.SMS_ACCEPTED || ret == RubyGlobeReturnCode.MMS_ACCEPTED
236
+ return true
237
+ elsif ret == RubyGlobeReturnCode.NOT_ALLOWED
238
+ raise RubyGlobeServerFaultException, "User is not allowed to access this service"
239
+ elsif ret == RubyGlobeReturnCode.EXCEEDED_DAILY_CAP
240
+ raise RubyGlobeServerFaultException, "User exceeded daily cap"
241
+ elsif ret == RubyGlobeReturnCode.INVALID_MESSAGE_LENGTH
242
+ raise RubyGlobeServerFaultException, "Invalid message length"
243
+ elsif ret == RubyGlobeReturnCode.MAX_NUMBER_CONNECTION
244
+ raise RubyGlobeServerFaultException, "Maximum Number of simultaneous connections reached"
245
+ elsif ret == RubyGlobeReturnCode.INVALID_LOGIN_CREDENTIALS
246
+ raise RubyGlobeServerFaultException, "Invalid login credentials"
247
+ elsif ret == RubyGlobeReturnCode.SMS_SENDING_FAILED
248
+ raise RubyGlobeServerFaultException, "SMS sending failed"
249
+ elsif ret == RubyGlobeReturnCode.INVALID_TARGET
254
250
  raise RubyGlobeServerFaultException, "Invalid target MSISDN"
255
- elsif ret == RubyGlobeReturnCode.INVALID_DISPLAY
251
+ elsif ret == RubyGlobeReturnCode.INVALID_DISPLAY
256
252
  raise RubyGlobeServerFaultException, "Invalid display type"
257
- elsif ret == RubyGlobeReturnCode.INVALID_MWI
253
+ elsif ret == RubyGlobeReturnCode.INVALID_MWI
258
254
  raise RubyGlobeServerFaultException, "Invalid MWI"
259
- elsif ret == RubyGlobeReturnCode.BAD_XML
255
+ elsif ret == RubyGlobeReturnCode.BAD_XML
260
256
  raise RubyGlobeServerFaultException, "Badly formed XML in SOAP request"
261
- elsif ret == RubyGlobeReturnCode.INVALID_CODING
257
+ elsif ret == RubyGlobeReturnCode.INVALID_CODING
262
258
  raise RubyGlobeServerFaultException, "Invalid Coding"
263
- elsif ret == RubyGlobeReturnCode.EMPTY_VALUE
259
+ elsif ret == RubyGlobeReturnCode.EMPTY_VALUE
264
260
  raise RubyGlobeServerFaultException, "Empty value given in required argument"
265
- elsif ret == RubyGlobeReturnCode.ARGUMENT_TOO_LARGE
266
- raise RubyGlobeServerFaultException, "Argument given too large"
267
- end
261
+ elsif ret == RubyGlobeReturnCode.ARGUMENT_TOO_LARGE
262
+ raise RubyGlobeServerFaultException, "Argument given too large"
263
+ end
264
+
265
+ end
266
+
267
+ def sendSMS(message)
268
+
269
+ begin
270
+ ret = @service.sendSMS(:uName => @uname, :uPin => @pin, :MSISDN => @msisdn, :messageString => message, :Display => @display, :udh => @udh, :mwi => @mwi, :coding => @coding).return.to_s
271
+
272
+ return translateMsg ret
273
+
274
+ rescue SocketError
275
+ raise RubyGlobeInvalidServiceException, "Service Unknown"
276
+ end
277
+
278
+ end
279
+
280
+ def sendMMS(subject, smil)
281
+
282
+ begin
283
+ ret = @service.sendMMS(:uName => @uname, :uPin => @pin, :MSISDN => @msisdn, :subject => subject, :smil => smil).return.to_s
284
+
285
+ return translateMsg ret
268
286
 
269
287
  rescue SocketError
270
288
  raise RubyGlobeInvalidServiceException, "Service Unknown"
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubyGlobe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
9
- version: "1.1"
8
+ - 2
9
+ version: "1.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ferdinand E. Silva
@@ -26,7 +26,7 @@ extensions: []
26
26
  extra_rdoc_files: []
27
27
 
28
28
  files:
29
- - README
29
+ - README.rst
30
30
  - Changelog
31
31
  - LICENSE
32
32
  - demo.rb
data/README DELETED
File without changes