def remove_service_inbound_api(service_id, inbound_api_id): inbound_api = get_service_inbound_api(inbound_api_id, service_id) if not inbound_api: error = "Service inbound API not found" raise InvalidRequest(error, status_code=404) delete_service_inbound_api(inbound_api) return "", 204
def update_service_inbound_api(service_id, inbound_api_id): data = request.get_json() validate(data, update_service_callback_api_schema) to_update = get_service_inbound_api(inbound_api_id, service_id) reset_service_inbound_api(service_inbound_api=to_update, updated_by_id=data["updated_by_id"], url=data.get("url", None), bearer_token=data.get("bearer_token", None)) return jsonify(data=to_update.serialize()), 200
def test_get_service_inbound_api(sample_service): service_inbound_api = ServiceInboundApi( service_id=sample_service.id, url="https://some_service/inbound_messages", bearer_token="some_unique_string", updated_by_id=sample_service.users[0].id ) save_service_inbound_api(service_inbound_api) inbound_api = get_service_inbound_api(service_inbound_api.id, sample_service.id) assert inbound_api.id is not None assert inbound_api.service_id == sample_service.id assert inbound_api.updated_by_id == sample_service.users[0].id assert inbound_api.url == "https://some_service/inbound_messages" assert inbound_api.bearer_token == "some_unique_string" assert inbound_api._bearer_token != "some_unique_string" assert inbound_api.updated_at is None
def fetch_service_inbound_api(service_id, inbound_api_id): inbound_api = get_service_inbound_api(inbound_api_id, service_id) return jsonify(data=inbound_api.serialize()), 200