@@ -59,7 +59,7 @@ def run(self, endpoint_name, method='GET', data=None):
5959 def _find_endpoint (self , endpoint_name ):
6060 endpoints = self .get_endpoints ()
6161 for endpoint in endpoints :
62- if endpoint_name == endpoint .name :
62+ if '{}/{}' . format ( self . name , endpoint_name ) == endpoint .name :
6363 return endpoint
6464 raise SyncanoValueError ('Endpoint {} not found.' .format (endpoint_name ))
6565
@@ -127,14 +127,15 @@ class Meta:
127127
128128 def run (self , method = 'GET' , data = None ):
129129 endpoint_path = self .links .self
130+ _ , endpoint_name = self .name .split ('/' , 1 )
130131 connection = self ._get_connection ()
131132 if not self ._validate_method (method ):
132133 raise SyncanoValueError ('Method: {} not specified in calls for this custom socket.' .format (method ))
133134 method = method .lower ()
134135 if method in ['get' , 'delete' ]:
135- response = connection .request (method , endpoint_path )
136+ response = connection .request (method , "{}/{}" . format ( endpoint_path , endpoint_name ) )
136137 elif method in ['post' , 'put' , 'patch' ]:
137- response = connection .request (method , endpoint_path , data = data or {})
138+ response = connection .request (method , "{}/{}" . format ( endpoint_path , endpoint_name ) , data = data or {})
138139 else :
139140 raise SyncanoValueError ('Method: {} not supported.' .format (method ))
140141 return response
@@ -150,10 +151,6 @@ def get_all_endpoints(cls, instance_name=None):
150151 return [cls (** endpoint ) for endpoint in response ['objects' ]]
151152
152153 def _validate_method (self , method ):
153-
154- methods = []
155- for call in self .calls :
156- methods .extend (call ['methods' ])
157- if '*' in methods or method in methods :
154+ if '*' in self .allowed_methods or method in self .allowed_methods :
158155 return True
159156 return False
0 commit comments