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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 173fc491f2988e7fd7a41435171cd60ec05e3116b838ab4c0257039788e0392a
4
- data.tar.gz: 1afb3fa818ae58646e293afa6f97891fbf32ead4e9cd8be68d5ca8ca38db6c44
3
+ metadata.gz: 70992b66145bf5215782eeb5513481e93bbb9c1ab2f220bbd99fc21af5f1b60f
4
+ data.tar.gz: 7c961f729fb0254ec016d0370cb25b4720a44d30fc8e88aea1b66fa64a5adf50
5
5
  SHA512:
6
- metadata.gz: a543fa05e7bcebac74107e6eaf2f655d4e5e37458e7a61e5d8a824760a009baf1b18eefd19c7c0559e3029c5b33a9f4464e11cbcfd92687a3ddb8242e17fbe42
7
- data.tar.gz: 571c2af3661344e704023c444a28f1578d896820f58424b8e9f50118517d51aae92341d21440a5391019461388cc6ae69cf618b5a7db5ab8846c02b99ea57389
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XRPC
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
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.0
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-02 00:00:00.000000000 Z
11
+ date: 2023-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json