1
1
defmodule Atex.XRPC do
2
- alias Atex.XRPC
3
-
4
- defp adapter do
5
- Application . get_env ( :atex , :adapter , XRPC.Adapter.Req )
6
- end
2
+ alias Atex . { HTTP , XRPC }
7
3
8
4
# TODO: automatic user-agent, and env for changing it
9
5
@@ -16,38 +12,38 @@ defmodule Atex.XRPC do
16
12
@ doc """
17
13
Perform a HTTP GET on a XRPC resource. Called a "query" in lexicons.
18
14
"""
19
- @ spec get ( XRPC.Client . t ( ) , String . t ( ) , keyword ( ) ) :: XRPC .Adapter. result ( )
15
+ @ spec get ( XRPC.Client . t ( ) , String . t ( ) , keyword ( ) ) :: HTTP .Adapter. result ( )
20
16
def get ( % XRPC.Client { } = client , name , opts \\ [ ] ) do
21
17
opts = put_auth ( opts , client . access_token )
22
- adapter ( ) . get ( url ( client , name ) , opts )
18
+ HTTP . get ( url ( client , name ) , opts )
23
19
end
24
20
25
21
@ doc """
26
22
Perform a HTTP POST on a XRPC resource. Called a "prodecure" in lexicons.
27
23
"""
28
- @ spec post ( XRPC.Client . t ( ) , String . t ( ) , keyword ( ) ) :: XRPC .Adapter. result ( )
24
+ @ spec post ( XRPC.Client . t ( ) , String . t ( ) , keyword ( ) ) :: HTTP .Adapter. result ( )
29
25
def post ( % XRPC.Client { } = client , name , opts \\ [ ] ) do
30
26
# TODO: look through available HTTP clients and see if they have a
31
27
# consistent way of providing JSON bodies with auto content-type. If not,
32
28
# create one for adapters.
33
29
opts = put_auth ( opts , client . access_token )
34
- adapter ( ) . post ( url ( client , name ) , opts )
30
+ HTTP . post ( url ( client , name ) , opts )
35
31
end
36
32
37
33
@ doc """
38
34
Like `get/3` but is unauthenticated by default.
39
35
"""
40
- @ spec unauthed_get ( String . t ( ) , String . t ( ) , keyword ( ) ) :: XRPC .Adapter. result ( )
36
+ @ spec unauthed_get ( String . t ( ) , String . t ( ) , keyword ( ) ) :: HTTP .Adapter. result ( )
41
37
def unauthed_get ( endpoint , name , opts \\ [ ] ) do
42
- adapter ( ) . get ( url ( endpoint , name ) , opts )
38
+ HTTP . get ( url ( endpoint , name ) , opts )
43
39
end
44
40
45
41
@ doc """
46
42
Like `post/3` but is unauthenticated by default.
47
43
"""
48
- @ spec unauthed_post ( String . t ( ) , String . t ( ) , keyword ( ) ) :: XRPC .Adapter. result ( )
44
+ @ spec unauthed_post ( String . t ( ) , String . t ( ) , keyword ( ) ) :: HTTP .Adapter. result ( )
49
45
def unauthed_post ( endpoint , name , opts \\ [ ] ) do
50
- adapter ( ) . post ( url ( endpoint , name ) , opts )
46
+ HTTP . post ( url ( endpoint , name ) , opts )
51
47
end
52
48
53
49
# TODO: use URI module for joining instead?
0 commit comments