Update to accept new (post) parameters for new liege rn service.

This commit is contained in:
Christophe Boulanger 2019-07-01 12:23:17 +02:00
parent b4e801ef9c
commit 167c65e5b5
1 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,8 @@ from django.utils.translation import ugettext_lazy as _
from passerelle.base.models import BaseResource
from passerelle.utils.api import endpoint
import json
class ImioLiegeRn(BaseResource):
service_url = models.CharField(max_length=256, blank=False,
@ -37,14 +39,19 @@ class ImioLiegeRn(BaseResource):
def get_connector_slug(cls):
return 'imio-liege-rn'
@endpoint(perm='can_access', pattern='^(?P<nrn>\d+)/$',
@endpoint(perm='can_access', pattern='^(?P<nrn>\d+)/$', methods=['post', 'get'],
example_pattern='{nrn}/',
parameters={
'nrn': {'description': _('National Register Number'),
'example_value': '79061607381'}
})
def data(self, request, nrn):
response = self.requests.get(self.service_url + nrn,
str_data = ''
if request.body is not None and request.body != '':
json_acceptable_string = request.body.replace("'", "\"")
data = json.loads(json_acceptable_string)
str_data = ''.join([u'&{}={}'.format(k,v) for k,v in data.iteritems()])
response = self.requests.get(self.service_url + nrn + str_data,
verify=self.verify_cert,
timeout=5)
if response.status_code != 200: