This commit is contained in:
Kenneth Kehl
2023-08-29 14:54:30 -07:00
parent 19dcd7a48b
commit 1ecb747c6d
588 changed files with 34100 additions and 23589 deletions

View File

@@ -2,6 +2,8 @@ from flask import Blueprint
from app.v2.errors import register_errors
v2_inbound_sms_blueprint = Blueprint("v2_inbound_sms", __name__, url_prefix='/v2/received-text-messages')
v2_inbound_sms_blueprint = Blueprint(
"v2_inbound_sms", __name__, url_prefix="/v2/received-text-messages"
)
register_errors(v2_inbound_sms_blueprint)

View File

@@ -7,32 +7,37 @@ from app.v2.inbound_sms import v2_inbound_sms_blueprint
from app.v2.inbound_sms.inbound_sms_schemas import get_inbound_sms_request
@v2_inbound_sms_blueprint.route("", methods=['GET'])
@v2_inbound_sms_blueprint.route("", methods=["GET"])
def get_inbound_sms():
data = validate(request.args.to_dict(), get_inbound_sms_request)
paginated_inbound_sms = inbound_sms_dao.dao_get_paginated_inbound_sms_for_service_for_public_api(
authenticated_service.id,
older_than=data.get('older_than', None),
page_size=current_app.config.get('API_PAGE_SIZE')
paginated_inbound_sms = (
inbound_sms_dao.dao_get_paginated_inbound_sms_for_service_for_public_api(
authenticated_service.id,
older_than=data.get("older_than", None),
page_size=current_app.config.get("API_PAGE_SIZE"),
)
)
return jsonify(
received_text_messages=[i.serialize() for i in paginated_inbound_sms],
links=_build_links(paginated_inbound_sms)
), 200
return (
jsonify(
received_text_messages=[i.serialize() for i in paginated_inbound_sms],
links=_build_links(paginated_inbound_sms),
),
200,
)
def _build_links(inbound_sms_list):
_links = {
'current': url_for(
"current": url_for(
"v2_inbound_sms.get_inbound_sms",
_external=True,
),
}
if inbound_sms_list:
_links['next'] = url_for(
_links["next"] = url_for(
"v2_inbound_sms.get_inbound_sms",
older_than=inbound_sms_list[-1].id,
_external=True,

View File

@@ -21,7 +21,7 @@ get_inbound_sms_single_response = {
"created_at": {
"format": "date-time",
"type": "string",
"description": "Date+time created at"
"description": "Date+time created at",
},
"service_id": uuid,
"id": uuid,
@@ -29,8 +29,12 @@ get_inbound_sms_single_response = {
"content": {"type": "string"},
},
"required": [
"id", "user_number", "created_at", "service_id",
"notify_number", "content"
"id",
"user_number",
"created_at",
"service_id",
"notify_number",
"content",
],
"additionalProperties": False,
}
@@ -42,28 +46,16 @@ get_inbound_sms_response = {
"properties": {
"received_text_messages": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/inbound_sms"
}
"items": {"type": "object", "$ref": "#/definitions/inbound_sms"},
},
"links": {
"type": "object",
"properties": {
"current": {
"type": "string"
},
"next": {
"type": "string"
}
},
"properties": {"current": {"type": "string"}, "next": {"type": "string"}},
"additionalProperties": False,
"required": ["current"]
}
"required": ["current"],
},
},
"required": ["received_text_messages", "links"],
"definitions": {
"inbound_sms": get_inbound_sms_single_response
},
"definitions": {"inbound_sms": get_inbound_sms_single_response},
"additionalProperties": False,
}