mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-27 17:39:51 -04:00
Add create_service_inbound_api
This commit is contained in:
@@ -449,13 +449,21 @@ def service_set_inbound_api(service_id):
|
||||
form = ServiceInboundApiForm(url=inbound_api.get('url') if inbound_api else '')
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service_inbound_api(
|
||||
service_id,
|
||||
url=form.url.data,
|
||||
bearer_token=form.bearer_token.data,
|
||||
user_id=current_user.id,
|
||||
inbound_api_id=inbound_api.get('id') if inbound_api else ''
|
||||
)
|
||||
if inbound_api:
|
||||
service_api_client.update_service_inbound_api(
|
||||
service_id,
|
||||
url=form.url.data,
|
||||
bearer_token=form.bearer_token.data,
|
||||
user_id=current_user.id,
|
||||
inbound_api_id=inbound_api.get('id') if inbound_api else ''
|
||||
)
|
||||
else:
|
||||
service_api_client.create_service_inbound_api(
|
||||
service_id,
|
||||
url=form.url.data,
|
||||
bearer_token=form.bearer_token.data,
|
||||
user_id=current_user.id
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
|
||||
@@ -266,14 +266,21 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
'/service/{}/inbound-sms/summary'.format(service_id)
|
||||
)
|
||||
|
||||
def create_service_inbound_api(self, service_id, url, bearer_token, user_id):
|
||||
data = {
|
||||
"url": url,
|
||||
"bearer_token": bearer_token,
|
||||
"updated_by_id": user_id
|
||||
}
|
||||
return self.post("/service/{}/inbound-api".format(service_id), data)
|
||||
|
||||
def update_service_inbound_api(self, service_id, url, bearer_token, user_id, inbound_api_id):
|
||||
data = {
|
||||
"url": url,
|
||||
"bearer_token": bearer_token,
|
||||
"updated_by_id": user_id
|
||||
}
|
||||
update_inbound_api_path = '/{}'.format(inbound_api_id) if inbound_api_id else ''
|
||||
return self.post("/service/{}/inbound-api{}".format(service_id, update_inbound_api_path), data)
|
||||
return self.post("/service/{}/inbound-api/{}".format(service_id, inbound_api_id), data)
|
||||
|
||||
def get_service_inbound_api(self, service_id, inbound_sms_api_id):
|
||||
return self.get(
|
||||
|
||||
Reference in New Issue
Block a user