11from urllib .parse import urljoin
2-
2+ import json
33import requests
44
5+ with open ('config.json' , 'r' ) as f :
6+ config = json .load (f )
7+
58
69class Subscrypt :
710 def __init__ (
811 self ,
9- base_url : str = 'http://206.189.154.160:3000/'
12+ base_url : str = config [ 'nodeAddress' ]
1013 ):
1114 self .base_url = base_url
1215
@@ -23,100 +26,88 @@ def check_subscription(self, user_address: str, provider_address: str, plan_inde
2326 providerAddress = provider_address ,
2427 planIndex = plan_index ,
2528 )
26-
29+
2730 def check_subscription_with_username (self , username : str , provider_address : str , plan_index : int ):
2831 return self ._get (
2932 f'/subsCrypt/checkSubscription/{ username } /' ,
3033 providerAddress = provider_address ,
3134 planIndex = plan_index ,
3235 )
33-
36+
3437 def get_username (self , sender : str ):
3538 return self ._get (
3639 f'/subsCrypt/getUsername/{ sender } /' ,
3740 )
38-
41+
3942 def retrieve_whole_data_with_username (self , username : str , password : str ):
4043 return self ._get (
4144 '/subsCrypt/retrieveDataWithUsername/' ,
4245 username = username ,
4346 phrase = password ,
4447 )
45-
48+
4649 def retrieve_data_with_username (self , user_address : str , provider_address : str , password : str ):
4750 return self ._get (
4851 f'/subsCrypt/retrieveDataWithUsername/{ provider_address } /' ,
4952 username = user_address ,
5053 phrase = password ,
5154 )
52-
53- def retrieve_data_with_wallet (self , sender : str , provider_address : str ):
54- # TODO (there is no api doc in swagger)
55- raise NotImplemented
56-
57- def retrieve_whole_data_with_wallet (self , sender : str ):
58- # TODO (there is no api doc in swagger)
59- raise NotImplemented
6055
6156 def is_username_available (self , username : str ):
6257 return self ._get (
6358 f'/subsCrypt/isUsernameAvailable/{ username } ' ,
6459 )
65-
60+
6661 def check_auth (self , user_address : str , provider_address : str , password : str ):
6762 return self ._get (
6863 '/subsCrypt/checkAuth/' ,
6964 userAddress = user_address ,
7065 providerAddress = provider_address ,
7166 phrase = password ,
7267 )
73-
68+
7469 def check_auth_with_username (self , username : str , provider_address : str , password : str ):
7570 return self ._get (
7671 f'/subsCrypt/checkAuth/{ username } /' ,
7772 providerAddress = provider_address ,
7873 phrase = password ,
7974 )
80-
75+
8176 def user_check_auth (self , user_address : str , password : str ):
8277 return self ._get (
8378 '/subsCrypt/userCheckAuth/' ,
8479 userAddress = user_address ,
8580 phrase = password ,
8681 )
87-
82+
8883 def user_check_auth_with_username (self , username : str , password : str ):
8984 return self ._get (
9085 f'/subsCrypt/userCheckAuth/{ username } /' ,
9186 phrase = password ,
9287 )
93-
88+
9489 def get_plan_data (self , provider_address : str , plan_index : int ):
9590 return self ._get (
9691 f'/subsCrypt/getPlanData/{ provider_address } /{ plan_index } /' ,
9792 )
98-
93+
9994 def provider_check_auth (self , provider_address : str , password : str ):
10095 return self ._get (
10196 '/subsCrypt/providerCheckAuth/' ,
10297 providerAddress = provider_address ,
10398 phrase = password ,
10499 )
105-
100+
106101 def provider_check_auth_with_username (self , provider_username : str , password : str ):
107102 return self ._get (
108103 f'/subsCrypt/providerCheckAuth/{ provider_username } /' ,
109104 phrase = password ,
110105 )
111-
106+
112107 def get_plan_characteristics (self , provider_address : str , plan_index : int ):
113108 return self ._get (
114109 f'/subsCrypt/getPlanCharacteristics/{ provider_address } /{ plan_index } /' ,
115110 )
116-
117- def get_sha2 (self , string : str ):
118- # TODO (there is no api doc in swagger)
119- raise NotImplemented
120111
121112 def is_connected (self ):
122113 return self ._get (
0 commit comments