xrpc 0.1.0 → 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/xrpc/client.rb +10 -7
- data/lib/xrpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70992b66145bf5215782eeb5513481e93bbb9c1ab2f220bbd99fc21af5f1b60f
|
4
|
+
data.tar.gz: 7c961f729fb0254ec016d0370cb25b4720a44d30fc8e88aea1b66fa64a5adf50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf7ac4f5e26ffca6f9b9e54d61dd075f0428de51e8f37a3c4dfac297b329e2bdd6a34005415179332b97162c542845e337daa02f8b379fdba9d235e6a50b714
|
7
|
+
data.tar.gz: 624bde9278e9c98f3533aea575badfd3636609812d0e493d3c6db0ee3a32f9c58e311fdfd5a15e629385931b766bcd8a2b23ef1700bc0d2f74b96e8827b5764d
|
data/lib/xrpc/client.rb
CHANGED
@@ -11,33 +11,36 @@ module XRPC
|
|
11
11
|
class Client
|
12
12
|
attr_reader :get, :post
|
13
13
|
|
14
|
-
def initialize(base_url)
|
14
|
+
def initialize(base_url, token = nil)
|
15
|
+
@headers = { :"Content-Type" => "application/json", :Authorization => "Bearer #{token}" }
|
15
16
|
@base_url = base_url
|
16
|
-
@get = GetRequest.new(base_url)
|
17
|
-
@post = PostRequest.new(base_url)
|
17
|
+
@get = GetRequest.new(base_url, @headers)
|
18
|
+
@post = PostRequest.new(base_url, @headers)
|
18
19
|
end
|
19
20
|
|
20
21
|
class GetRequest
|
21
22
|
include HTTParty
|
22
23
|
|
23
|
-
def initialize(base_url)
|
24
|
+
def initialize(base_url, headers)
|
24
25
|
self.class.base_uri base_url
|
26
|
+
@headers = headers
|
25
27
|
end
|
26
28
|
|
27
29
|
def method_missing(method_name, **params)
|
28
|
-
JSON.parse self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params).body
|
30
|
+
JSON.parse self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).body
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
class PostRequest
|
33
35
|
include HTTParty
|
34
36
|
|
35
|
-
def initialize(base_url)
|
37
|
+
def initialize(base_url, headers)
|
36
38
|
self.class.base_uri base_url
|
39
|
+
@headers = headers
|
37
40
|
end
|
38
41
|
|
39
42
|
def method_missing(method_name, **params)
|
40
|
-
JSON.parse self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params).body
|
43
|
+
JSON.parse self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params.to_json, headers: @headers).body
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
data/lib/xrpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shreyan Jain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|