xrpc 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7bca4020ba6ae0ace083ebbd62860273590ff6d135d712fd4c221233554913f
4
- data.tar.gz: 60ed91a5872c8008a2bb6bd64ea1543e1fdf670c822752eb0b9efe99126e7f96
3
+ metadata.gz: 5b9d6909205b1b8f08022bafa695a19308f96799b10fb6a3768e4508218ccaac
4
+ data.tar.gz: 7b338646cc76c4ae6cd4f5ff83a98e2533a0097fab5a6de3dc7408d059f6465d
5
5
  SHA512:
6
- metadata.gz: db08c3afd3532daf9aebc12c2bd32db20512654707a31d32068470f780eba97602e20b6b6bf052eb194bdf08f0d4f469175fe89d824d330ffcf52813c294dd17
7
- data.tar.gz: c00e3688d413fceec7ea3638f78d8d6bebc234934861fd2afda79b550551b913206124e4c5dc15eeebe8aeff43a047ac3071713b6293d0113b5f198fe71bc26c
6
+ metadata.gz: 178aa19c7dd2dddd725b0263d5eedb45607da2234afcc54ff4cec89804726d755803c5df65471113069e9c8f5e0e204e0e96f8a0fd3afb3ebbfff3d5eccab78e
7
+ data.tar.gz: e9f35c11f56f91b0ffdaf33d9b4d3632d6adf7c95beba8c48b91c7cb66696884e7f41ee042bd5e1ba96187e45145ae7e9d21c10303c587fee27978f8d20eebf3
data/lib/xrpc/client.rb CHANGED
@@ -12,8 +12,7 @@ module XRPC
12
12
  attr_reader :get, :post
13
13
 
14
14
  def initialize(base_url, token = nil)
15
- @headers = { :"Content-Type" => "application/json" }
16
- @headers = @headers.merge { :Authorization => "Bearer #{token}" } unless token.nil?
15
+ @headers = { :"Content-Type" => "application/json", :Authorization => "Bearer #{token}" }
17
16
  @base_url = base_url
18
17
  @get = GetRequest.new(base_url, @headers)
19
18
  @post = PostRequest.new(base_url, @headers)
@@ -28,7 +27,8 @@ module XRPC
28
27
  end
29
28
 
30
29
  def method_missing(method_name, **params)
31
- JSON.parse self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).body
30
+ response = self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).body
31
+ response.empty? ? nil : JSON.parse(response)
32
32
  end
33
33
  end
34
34
 
@@ -41,7 +41,8 @@ module XRPC
41
41
  end
42
42
 
43
43
  def method_missing(method_name, **params)
44
- JSON.parse self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params.to_json, headers: @headers).body
44
+ response = self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params.to_json, headers: @headers).body
45
+ response.empty? ? nil : JSON.parse(response)
45
46
  end
46
47
  end
47
48
  end
data/lib/xrpc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XRPC
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
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.1
4
+ version: 0.1.3
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-04 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json