openmarket 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 313f1285d8dfc0d1a615e4d0e34b8d833df72e35
4
- data.tar.gz: 54bf9d7d27719f8883faf50abc03ccba6619e6a5
3
+ metadata.gz: e03574cf4234c4383d169c8a973df45152a4bf18
4
+ data.tar.gz: c6424fc60e44331e67a68a27bca98c25139c7c8b
5
5
  SHA512:
6
- metadata.gz: 4b97d23e3d060dae73ae4489b75e2291ff8b8f491ab05be1d5dd76e6512a9584fc5234580e353b9a8848ea7fc1f262dc7215cbea5ad3757675def646e8662ede
7
- data.tar.gz: f9e13cf97a53740a26f755e7d201cf92048c521cc78ccbaac75452462de1bb023e74e884d9787092ce42b4b875d66d0c3a8b2f9e2d6ece78c1947ef1a647484e
6
+ metadata.gz: ce88d406969b83cae11ffdd9e6b9ac1bc6d5e19161136b65319b5a9a3c46d0a88be7f491de6473ba4a9adb9eeecdcbba997941b870658df91002204cf60b788d
7
+ data.tar.gz: a108bc03bcc8970f01158d16d9996e3881743f4dd37bfa21af344f1f77e12a7642cd2c54421772c68b7447af968b4561f800eac8b8da6128110edbd1391970bc
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ### Configuratiion
23
+ ### Configuration
24
24
 
25
25
  The openmarket gem requires you to provide an id, password, program_id and short_code. Configure them before attempting any API calls.
26
26
 
@@ -102,7 +102,6 @@ result = OpenMarket::API.send_sms(
102
102
 
103
103
  ticket_id_for_retry: ticket_id # If this is a re-try of a failed ticket.
104
104
  )
105
-
106
105
  ```
107
106
  #### status
108
107
 
@@ -117,7 +116,34 @@ puts result.description # should be 'No Error'
117
116
  # Check the result of the SMS message
118
117
  puts result.status_code
119
118
  puts result.status_description
119
+ ```
120
+
121
+ ### Processing MO's
122
+
123
+ ```ruby
124
+ require 'openmarket/mo'
125
+ # In a Rails controller or Sinatra app environment, params will be defined
126
+ mo = OpenMarket::MO.new(params['xml'])
127
+ puts mo.inspect
128
+ # Do something with the MO...
129
+
130
+ # Just send a HTTP 200
131
+ render nothing: true # Rails
132
+ return [200] # Sinatra
133
+ ```
120
134
 
135
+ ### Processing DR's
136
+
137
+ ```ruby
138
+ require 'openmarket/dr'
139
+ # In a Rails controller or Sinatra app environment, params will be defined
140
+ dr = OpenMarket::DR.new(params['xml'])
141
+ puts dr.inspect
142
+ # Do something with the DR...
143
+
144
+ # Just send a HTTP 200
145
+ render nothing: true # Rails
146
+ return [200] # Sinatra
121
147
  ```
122
148
 
123
149
  ## Contributing
@@ -2,7 +2,8 @@ require "rexml/document"
2
2
 
3
3
  module OpenMarket
4
4
  class MO
5
- attr_reader :account_id, :carrier_id, :data, :data_coding, :destination_address, :destination_ton, :source_address, :source_ton, :ticket_id, :udhi
5
+ ATTRIBUTES = [:account_id, :carrier_id, :data, :data_coding, :destination_address, :destination_ton, :source_address, :source_ton, :ticket_id, :udhi]
6
+ attr_reader *ATTRIBUTES
6
7
  def initialize(data)
7
8
  (class << self; self; end).class_eval do
8
9
  # Defining a member variable for xml would pollute #inspect
@@ -17,13 +18,13 @@ module OpenMarket
17
18
  @account_id = account.attributes["id"]
18
19
  end
19
20
  if source = xml.elements["source"]
20
- @carrier_id = source.elements["carrier"]
21
- @source_ton = source.elements["ton"]
22
- @source_address = source.elements["address"]
21
+ @source_address = source.attributes["address"]
22
+ @carrier_id = source.attributes["carrier"]
23
+ @source_ton = source.attributes["ton"]
23
24
  end
24
25
  if destination = xml.elements["destination"]
25
- @destination_ton = destination.elements["ton"]
26
- @destination_address = destination.elements["address"]
26
+ @destination_address = destination.attributes["address"]
27
+ @destination_ton = destination.attributes["ton"]
27
28
  end
28
29
  if option = xml.elements["option"]
29
30
  @data_coding = option.attributes["datacoding"]
@@ -33,5 +34,9 @@ module OpenMarket
33
34
  @data = message.attributes["data"]
34
35
  end
35
36
  end
37
+
38
+ def ==(rhs)
39
+ rhs.is_a?(self.class) && ATTRIBUTES.all? { |a| send(a) == rhs.send(a) }
40
+ end
36
41
  end
37
42
  end
@@ -1,3 +1,3 @@
1
1
  module OpenMarket
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openmarket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Betesh
@@ -117,7 +117,7 @@ description: |
117
117
 
118
118
  ## Usage
119
119
 
120
- ### Configuratiion
120
+ ### Configuration
121
121
 
122
122
  The openmarket gem requires you to provide an id, password, program_id and short_code. Configure them before attempting any API calls.
123
123
 
@@ -199,7 +199,6 @@ description: |
199
199
 
200
200
  ticket_id_for_retry: ticket_id # If this is a re-try of a failed ticket.
201
201
  )
202
-
203
202
  ```
204
203
  #### status
205
204
 
@@ -214,7 +213,34 @@ description: |
214
213
  # Check the result of the SMS message
215
214
  puts result.status_code
216
215
  puts result.status_description
216
+ ```
217
+
218
+ ### Processing MO's
219
+
220
+ ```ruby
221
+ require 'openmarket/mo'
222
+ # In a Rails controller or Sinatra app environment, params will be defined
223
+ mo = OpenMarket::MO.new(params['xml'])
224
+ puts mo.inspect
225
+ # Do something with the MO...
226
+
227
+ # Just send a HTTP 200
228
+ render nothing: true # Rails
229
+ return [200] # Sinatra
230
+ ```
217
231
 
232
+ ### Processing DR's
233
+
234
+ ```ruby
235
+ require 'openmarket/dr'
236
+ # In a Rails controller or Sinatra app environment, params will be defined
237
+ dr = OpenMarket::DR.new(params['xml'])
238
+ puts dr.inspect
239
+ # Do something with the DR...
240
+
241
+ # Just send a HTTP 200
242
+ render nothing: true # Rails
243
+ return [200] # Sinatra
218
244
  ```
219
245
 
220
246
  ## Contributing