pseng_ekg_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pseng_ekg_client/version.rb +1 -1
- data/lib/pseng_ekg_client.rb +23 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0527eac89cb61adcd6719c0c82d68162ea724a82
|
4
|
+
data.tar.gz: 1e399d6f98aaee47363b06790d13f71a5168c8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a45334104ab04d6d5cfabcfbc04df4881e982e9d6d64d91e12078bd0d9731bb49e88b9d067db25bd87b2a5d775373a55d791a1eed5a7e0996ee7902d9c4afce
|
7
|
+
data.tar.gz: 196bdb65307731024a9aef609e1dea56591f6c33abed1723b1b175286767d16ba05006907c7910a1e6a24132d7c16cd3740d787c9821442df4709c43baed8dbd
|
data/lib/pseng_ekg_client.rb
CHANGED
@@ -1,29 +1,31 @@
|
|
1
1
|
require "pseng_ekg_client/version"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module PsengEkgClient
|
4
|
+
class Api
|
5
|
+
include HTTParty
|
6
|
+
VALID_ACTIONS = %w(index show create update destroy)
|
7
|
+
VALID_RECORD_TYPES = %w(application task)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def initialize(base_uri)
|
10
|
+
self.base_uri base_uri
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def send_message(record_type, action, payload)
|
14
|
+
raise 'Invalid Action' unless VALID_ACTIONS.include?(action)
|
15
|
+
raise 'Invalid Record Type' unless VALID_RECORD_TYPES.include?(action)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
case action
|
18
|
+
when 'index'
|
19
|
+
self.class.get("/#{record_type}s.json", payload)
|
20
|
+
when 'show'
|
21
|
+
self.class.get("/#{record_type}s/#{payload.id}.json", payload)
|
22
|
+
when 'create'
|
23
|
+
self.class.post("/#{record_type}s.json", payload)
|
24
|
+
when 'update'
|
25
|
+
self.class.patch("/#{record_type}s/#{payload.id}.json", payload)
|
26
|
+
when 'destroy'
|
27
|
+
self.class.delete("/#{record_type}s/#{payload.id}.json", payload)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|