vodem_sms 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 186f9e9a6a0075c58c7573ba2813627eee2183e9
4
- data.tar.gz: 7c006276d787e3052406ef8f1a2bbcb335119349
3
+ metadata.gz: 2b663b3e0bc7fe1dcfe944f66f3e2e699af7d751
4
+ data.tar.gz: b03aaffb816a849e545226dcf3f9f26991f04a78
5
5
  SHA512:
6
- metadata.gz: aa80618fa6ca63ee6e90e07d80a2a1c4d5b98c4f75bf75cd55673b70d324a4734597364480946245f1d2718803292f420f60bb589b7efd28ec6ced8ff70c6cd2
7
- data.tar.gz: f486b2694bf97f61d3c9aa350452be0c838be2b6ee320dd8d628e3bb2569b25f942f6ce6c0e14fa5f96939a4e6f29c0f8c62e930faa36c63db480ec8312cb5c1
6
+ metadata.gz: b3a49f4eb8e8c4badc9120694f85d79faaa60b8f880c2b4c8c0fc2f1b0726fa0daa4d7deee5755c82a8ca0413c5471d5989400d116f66e1e9bf2103a3304f543
7
+ data.tar.gz: ef456f9d5d0f55de1dfce9c4154aa6c9259f6361bb2b071eee928c037881c75ef1e5876bd874034aa874a0faa159d6aeb2b372e5fa803edd779aa88356c58644
data/README.md CHANGED
@@ -35,6 +35,17 @@ There are just a couple of commands at the moment, connect!, disconnect!. Also
35
35
  vodem.connect! #connect to the 3G network
36
36
  vodem.disconnect! #disconnect from the 3G network
37
37
 
38
+ # messages
39
+
40
+ latest_message = vodem.latest_message
41
+
42
+ message.from # mobile number it was sent from
43
+ message.id # id of the mobile
44
+ message.sent_at # DateTime timestamp of when it was sent
45
+ message.content # the actual text of the message.
46
+
47
+ message.delete! # delete the message off the modem
48
+
38
49
  ```
39
50
 
40
51
  ## Contributing
data/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.5 [April 2015]
2
+ * Add the ability to delete a message
3
+
1
4
  ## 0.0.3 [April 2015]
2
5
 
3
6
  * Add the ability to Read the latest SMS off the vodem
@@ -1,20 +1,10 @@
1
1
  module VodemSms
2
2
  class Commands
3
- WEBSERVER_SET_STATUS_URL = "http://192.168.9.1/goform/goform_set_cmd_process"
4
- WEBSERVER_HOST_HEADER = "192.168.9.1"
5
- AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
6
- LANGUAGE_HEADER= "en-US,en;q=0.5"
7
- ENCODING_HEADER = 'gzip, deflate'
8
- CACHE_CONTROL_HEADER = 'no-cache'
9
- CONNECTION_HEADER = 'keep-alive'
10
- CONTENT_TYPE_HEADER = 'application/x-www-form-urlencoded; charset=UTF-8'
11
- PRAGMA_HEADER = 'no-cache'
12
- X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
13
- REFERRER_HEADER = 'http://192.168.9.1/home.htm'
3
+ include VodemSms::Headers
14
4
 
15
5
  def connect!
16
6
  Typhoeus.post(
17
- WEBSERVER_SET_STATUS_URL,
7
+ WEBSERVER_SET_CMD_URL,
18
8
  headers: {
19
9
  Host: WEBSERVER_HOST_HEADER,
20
10
  "User-Agent" => AGENT_HEADER,
@@ -31,9 +21,31 @@ module VodemSms
31
21
  sleep 10
32
22
  end
33
23
 
24
+ def delete_message(id)
25
+ Typhoeus.post(
26
+ WEBSERVER_SET_CMD_URL,
27
+ headers: {
28
+ Host: WEBSERVER_HOST_HEADER,
29
+ "User-Agent" => AGENT_HEADER,
30
+ "Accept-Language" => LANGUAGE_HEADER,
31
+ "Accept-Encoding" => ENCODING_HEADER,
32
+ "Cache-Control" => CACHE_CONTROL_HEADER,
33
+ "Content-Type" => CONTENT_TYPE_HEADER,
34
+ "Pragma" => PRAGMA_HEADER,
35
+ "x-requested-with" => X_REQUESTED_WITH_HEADER,
36
+ "Referer" => REFERRER_HEADER,
37
+ Accept: "application/json"
38
+ },
39
+ body: {
40
+ goformId: "DELETE_SMS",
41
+ msg_id: id
42
+ }
43
+ )
44
+ end
45
+
34
46
  def disconnect!
35
47
  Typhoeus.post(
36
- WEBSERVER_SET_STATUS_URL,
48
+ WEBSERVER_SET_CMD_URL,
37
49
  headers: {
38
50
  Host: WEBSERVER_HOST_HEADER,
39
51
  "User-Agent" => AGENT_HEADER,
@@ -0,0 +1,17 @@
1
+ module VodemSms
2
+ module Headers
3
+ WEBSERVER_SET_CMD_URL = "http://192.168.9.1/goform/goform_set_cmd_process"
4
+ WEBSERVER_GET_CMD_URL = "http://192.168.9.1/goform/goform_get_cmd_process"
5
+
6
+ AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
7
+ CONTENT_TYPE_HEADER = 'application/x-www-form-urlencoded; charset=UTF-8'
8
+ CACHE_CONTROL_HEADER = 'no-cache'
9
+ CONNECTION_HEADER = 'keep-alive'
10
+ ENCODING_HEADER = 'gzip, deflate'
11
+ LANGUAGE_HEADER= "en-US,en;q=0.5"
12
+ PRAGMA_HEADER = 'no-cache'
13
+ REFERRER_HEADER = 'http://192.168.9.1/home.htm'
14
+ WEBSERVER_HOST_HEADER = "192.168.9.1"
15
+ X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
16
+ end
17
+ end
@@ -12,6 +12,9 @@ module VodemSms
12
12
  set_content(message["content"])
13
13
  end
14
14
 
15
+ def delete!
16
+ VodemSms::Commands.new.delete_message(id)
17
+ end
15
18
 
16
19
  private
17
20
 
@@ -2,21 +2,11 @@ require "vodem_sms/message"
2
2
 
3
3
  module VodemSms
4
4
  class Messages
5
- WEBSERVER_GET_MESSAGE_URL = "http://192.168.9.1/goform/goform_get_cmd_process"
6
- WEBSERVER_HOST_HEADER = "192.168.9.1"
7
- AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
8
- LANGUAGE_HEADER= "en-US,en;q=0.5"
9
- ENCODING_HEADER = 'gzip, deflate'
10
- CACHE_CONTROL_HEADER = 'no-cache'
11
- CONNECTION_HEADER = 'keep-alive'
12
- CONTENT_TYPE_HEADER = 'application/x-www-form-urlencoded; charset=UTF-8'
13
- PRAGMA_HEADER = 'no-cache'
14
- X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
15
- REFERRER_HEADER = 'http://192.168.9.1/home.htm'
5
+ include VodemSms::Headers
16
6
 
17
7
  def get_message
18
8
  response = Typhoeus.get(
19
- WEBSERVER_GET_MESSAGE_URL,
9
+ WEBSERVER_GET_CMD_URL,
20
10
  headers: {
21
11
  Host: WEBSERVER_HOST_HEADER,
22
12
  "User-Agent" => AGENT_HEADER,
@@ -1,12 +1,7 @@
1
1
  module VodemSms
2
2
  class StatusChecker
3
- WEBSERVER_STATUS_URL = "http://192.168.9.1/goform/goform_get_cmd_process"
4
- WEBSERVER_HOST_HEADER = "192.168.9.1"
5
- AGENT_HEADER = "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'"
6
- LANGUAGE_HEADER= "en-US,en;q=0.5"
7
- ENCODING_HEADER = 'gzip, deflate'
8
- X_REQUESTED_WITH_HEADER = 'XMLHttpRequest'
9
- REFERRER_HEADER = 'http://192.168.9.1/home.htm'
3
+ include VodemSms::Headers
4
+
10
5
  STATUS_FIELD = 'ppp_status'
11
6
 
12
7
  class Status
@@ -38,7 +33,7 @@ module VodemSms
38
33
 
39
34
  def get_status
40
35
  response = Typhoeus.get(
41
- WEBSERVER_STATUS_URL,
36
+ WEBSERVER_GET_CMD_URL,
42
37
  headers: {
43
38
  Host: WEBSERVER_HOST_HEADER,
44
39
  "User-Agent" => AGENT_HEADER,
@@ -1,3 +1,3 @@
1
1
  module VodemSms
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/vodem_sms.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "vodem_sms/version"
2
+ require "vodem_sms/headers"
2
3
  require "vodem_sms/status_checker"
3
4
  require "vodem_sms/commands"
4
5
  require "vodem_sms/messages"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vodem_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Davey
@@ -157,6 +157,7 @@ files:
157
157
  - lib/vodem_sms.rb
158
158
  - lib/vodem_sms/commands.rb
159
159
  - lib/vodem_sms/errors.rb
160
+ - lib/vodem_sms/headers.rb
160
161
  - lib/vodem_sms/message.rb
161
162
  - lib/vodem_sms/messages.rb
162
163
  - lib/vodem_sms/status_checker.rb