xrpc 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f3d51cb6ae781b3eb9c5d63e2169cb50190953addaa2c893818b6e3da7e6e4b
4
- data.tar.gz: dd43f705448252a67bca0b722dc7feb8042722d76d55d8b9e79d21994a15affb
3
+ metadata.gz: 89265cba7bc367d5a468be6b3ea0c0deb34fff4f2427f6b313ad6ea61da73848
4
+ data.tar.gz: 1c3c6b6971e69e3cb5d5baf27edc66663267a09dee219f730c94386720bc4c5a
5
5
  SHA512:
6
- metadata.gz: e1622cf6190d363d507d1db065d00e8db8acbb744ed049c85de0fc71b206d3ae693ea79dd9a66d3f9be14f488821fedc1b70a6d6c6c8adbdda7bfaef9cf7c3f4
7
- data.tar.gz: eb7834ed2d23dbb57ca42686603ba8cdae429a7070923f44d0db5efb3e5fce8d08f2cee1c5f6f843d468c719315e23d3fcec69e6d362fae91ceaa7e92efa70f0
6
+ metadata.gz: 2580f8cb019432556ca537833620af3bbb3b44011ceaa07a34fc8d4672a3e8a00289e2eb35e0443f7c27fae7b162b25f36f1f7215a216fc31689c58a2bbb551c
7
+ data.tar.gz: 60e7829c7f44abb67e3064cb17bbc6efebf5fa196666fbae10ec7c19a14832749baa25168badd88c077a7cf2ee6a5bbe126066a33cf2baf50a09cbbbb001c104
data/lib/xrpc/client.rb CHANGED
@@ -9,13 +9,28 @@ module XRPC
9
9
  end
10
10
 
11
11
  class Client
12
- attr_reader :get, :post
12
+ attr_accessor :headers, :token
13
13
 
14
14
  def initialize(base_url, token = nil)
15
- @headers = { :"Content-Type" => "application/json", :Authorization => "Bearer #{token}" }
15
+ @token = token
16
+ @headers = { :"Content-Type" => "application/json", :Authorization => "Bearer #{@token}" }
16
17
  @base_url = base_url
17
- @get = GetRequest.new(base_url, @headers)
18
- @post = PostRequest.new(base_url, @headers)
18
+ end
19
+
20
+ def headers!
21
+ @headers = { :"Content-Type" => "application/json", :Authorization => "Bearer #{@token}" }
22
+ end
23
+
24
+ def get
25
+ GetRequest.new(base_url, @headers)
26
+ end
27
+
28
+ def post
29
+ PostRequest.new(base_url, @headers)
30
+ end
31
+
32
+ def inspect
33
+ "XRPC::Client(\"#{@base_url}\")"
19
34
  end
20
35
 
21
36
  class GetRequest
@@ -27,8 +42,9 @@ module XRPC
27
42
  end
28
43
 
29
44
  def method_missing(method_name, **params)
30
- response = self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers)
31
- response.body.empty? ? response.code : JSON.parse(response.body)
45
+ self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).then do |response|
46
+ response.body.empty? ? response.code : JSON.parse(response.body)
47
+ end
32
48
  end
33
49
  end
34
50
 
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.6"
4
+ VERSION = "0.1.7"
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.6
4
+ version: 0.1.7
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-24 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json