xrpc 0.1.0 → 0.1.1
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 +11 -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: d7bca4020ba6ae0ace083ebbd62860273590ff6d135d712fd4c221233554913f
|
4
|
+
data.tar.gz: 60ed91a5872c8008a2bb6bd64ea1543e1fdf670c822752eb0b9efe99126e7f96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db08c3afd3532daf9aebc12c2bd32db20512654707a31d32068470f780eba97602e20b6b6bf052eb194bdf08f0d4f469175fe89d824d330ffcf52813c294dd17
|
7
|
+
data.tar.gz: c00e3688d413fceec7ea3638f78d8d6bebc234934861fd2afda79b550551b913206124e4c5dc15eeebe8aeff43a047ac3071713b6293d0113b5f198fe71bc26c
|
data/lib/xrpc/client.rb
CHANGED
@@ -11,33 +11,37 @@ 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" }
|
16
|
+
@headers = @headers.merge { :Authorization => "Bearer #{token}" } unless token.nil?
|
15
17
|
@base_url = base_url
|
16
|
-
@get = GetRequest.new(base_url)
|
17
|
-
@post = PostRequest.new(base_url)
|
18
|
+
@get = GetRequest.new(base_url, @headers)
|
19
|
+
@post = PostRequest.new(base_url, @headers)
|
18
20
|
end
|
19
21
|
|
20
22
|
class GetRequest
|
21
23
|
include HTTParty
|
22
24
|
|
23
|
-
def initialize(base_url)
|
25
|
+
def initialize(base_url, headers)
|
24
26
|
self.class.base_uri base_url
|
27
|
+
@headers = headers
|
25
28
|
end
|
26
29
|
|
27
30
|
def method_missing(method_name, **params)
|
28
|
-
JSON.parse self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params).body
|
31
|
+
JSON.parse self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).body
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
32
35
|
class PostRequest
|
33
36
|
include HTTParty
|
34
37
|
|
35
|
-
def initialize(base_url)
|
38
|
+
def initialize(base_url, headers)
|
36
39
|
self.class.base_uri base_url
|
40
|
+
@headers = headers
|
37
41
|
end
|
38
42
|
|
39
43
|
def method_missing(method_name, **params)
|
40
|
-
JSON.parse self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params).body
|
44
|
+
JSON.parse self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params.to_json, headers: @headers).body
|
41
45
|
end
|
42
46
|
end
|
43
47
|
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.1
|
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
|