pseng_ekg_client 0.1.5 → 0.1.6
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.rb +13 -8
- data/lib/pseng_ekg_client/version.rb +1 -1
- 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: d9ae09a3e58a486de47ee190cd73b23a589537f4
|
4
|
+
data.tar.gz: a1417ecb611a7ee8093ac99656b9b721e2134080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57a39e750f5be447169956b56da141a87d7859ac42f85ae1345770fc6b391bd92123b9bc6b9d4576a1344b8c3c7e400227ccaa9c44bd69ee1b9af2a89d7dfe37
|
7
|
+
data.tar.gz: 28c1d1c68b031e7bf669976852da00ceeae6d8a3338b0f2b8ed6f1588313a1884830dd1a9f6b8a57fa93489c0b94220dd3d550a0273e5b9e30b9bfb8777d7ce4
|
data/lib/pseng_ekg_client.rb
CHANGED
@@ -3,29 +3,34 @@ require 'httparty'
|
|
3
3
|
|
4
4
|
module PsengEkgClient
|
5
5
|
class Api
|
6
|
-
include
|
6
|
+
include HTTParty
|
7
7
|
VALID_ACTIONS = %w(index show create update destroy)
|
8
8
|
VALID_RECORD_TYPES = %w(application task)
|
9
9
|
|
10
10
|
def initialize(base_uri)
|
11
|
-
self.class.
|
11
|
+
self.class.base_uri base_uri
|
12
12
|
end
|
13
13
|
|
14
14
|
def send_message(record_type, action, payload)
|
15
15
|
raise 'Invalid Action' unless VALID_ACTIONS.include?(action)
|
16
|
-
raise 'Invalid Record Type' unless VALID_RECORD_TYPES.include?(
|
16
|
+
raise 'Invalid Record Type' unless VALID_RECORD_TYPES.include?(record_type)
|
17
|
+
|
18
|
+
options = {
|
19
|
+
body: payload.to_json,
|
20
|
+
headers: { 'Content-Type' => 'application/json' }
|
21
|
+
}
|
17
22
|
|
18
23
|
case action
|
19
24
|
when 'index'
|
20
|
-
self.class.get("/#{record_type}s.json",
|
25
|
+
self.class.get("/#{record_type}s.json", options)
|
21
26
|
when 'show'
|
22
|
-
self.class.get("/#{record_type}s/#{payload.id}.json",
|
27
|
+
self.class.get("/#{record_type}s/#{payload.id}.json", options)
|
23
28
|
when 'create'
|
24
|
-
self.class.post("/#{record_type}s.json",
|
29
|
+
self.class.post("/#{record_type}s.json", options)
|
25
30
|
when 'update'
|
26
|
-
self.class.patch("/#{record_type}s/#{payload.id}.json",
|
31
|
+
self.class.patch("/#{record_type}s/#{payload.id}.json", options)
|
27
32
|
when 'destroy'
|
28
|
-
self.class.delete("/#{record_type}s/#{payload.id}.json",
|
33
|
+
self.class.delete("/#{record_type}s/#{payload.id}.json", options)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|