src/dirbs/api/v2/resources/msisdn.py
def msisdn_api(msisdn: str) -> Union[abort, jsonify]:
    """
    MSISDN API (version 2) GET endpoint.

    Arguments:
        msisdn: 15 digits MSISDN value
    """
    if len(msisdn) > 15:
        abort(400, 'Bad MSISDN format (too long)')

    try:
        int(msisdn)
    except ValueError:
        abort(400, 'Bad MSISDN format (can only contain digit characters)')

    with get_db_connection() as db_conn, db_conn.cursor() as cursor:
        cursor.execute("""SELECT mntc.imei_norm, mntc.imsi, reg.imei_norm AS reg_imei, reg.make, reg.model,
                                 reg.brand_name, gsma.tac, gsma.manufacturer,
                                 gsma.model_name, gsma.optional_fields, mntc.last_seen
                            FROM gsma_data AS gsma
                      RIGHT JOIN monthly_network_triplets_country_no_null_imeis AS mntc
                                            ON SUBSTRING(imei_norm, 1, 8) = tac
                       LEFT JOIN registration_list AS reg
                                            ON reg.imei_norm = mntc.imei_norm
                           WHERE msisdn = %s """, [msisdn])
        recs = cursor.fetchall()
        data = [MSISDN().dump(dict(imei_norm=rec[0], imsi=rec[1], last_seen=rec[10],
                                   gsma=rec._asdict() if rec[6] else None,
                                   registration=rec if rec[2] else None)).data for rec in recs]

    return jsonify({'results': data})

    MSISDN API (version 2) GET endpoint.

    Arguments:
        msisdn: 15 digits MSISDN value
    
MSISDN API (version 2) GET endpoint.
MSISDN API ( version 2 ) GET endpoint .
def msisdn_api(msisdn: str) -> Union[abort, jsonify]:
    if len(msisdn) > 15:
        abort(400, 'Bad MSISDN format (too long)')
    try:
        int(msisdn)
    except ValueError:
        abort(400, 'Bad MSISDN format (can only contain digit characters)')
    with get_db_connection() as db_conn, db_conn.cursor() as cursor:
        cursor.execute("""SELECT mntc.imei_norm, mntc.imsi, reg.imei_norm AS reg_imei, reg.make, reg.model,
                                 reg.brand_name, gsma.tac, gsma.manufacturer,
                                 gsma.model_name, gsma.optional_fields, mntc.last_seen
                            FROM gsma_data AS gsma
                      RIGHT JOIN monthly_network_triplets_country_no_null_imeis AS mntc
                                            ON SUBSTRING(imei_norm, 1, 8) = tac
                       LEFT JOIN registration_list AS reg
                                            ON reg.imei_norm = mntc.imei_norm
                           WHERE msisdn = %s """, [msisdn])
        recs = cursor.fetchall()
        data = [MSISDN().dump(dict(imei_norm=rec[0], imsi=rec[1], last_seen=rec[10],
                                   gsma=rec._asdict() if rec[6] else None,
                                   registration=rec if rec[2] else None)).data for rec in recs]
    return jsonify({'results': data})
def msisdn_api ( msisdn : str ) -> Union [ abort , jsonify ] : if len ( msisdn ) > 15 : abort ( 400 , 'Bad MSISDN format (too long)' ) try : int ( msisdn ) except ValueError : abort ( 400 , 'Bad MSISDN format (can only contain digit characters)' ) with get_db_connection ( ) as db_conn , db_conn . cursor ( ) as cursor : cursor . execute ( """SELECT mntc.imei_norm, mntc.imsi, reg.imei_norm AS reg_imei, reg.make, reg.model,
                                 reg.brand_name, gsma.tac, gsma.manufacturer,
                                 gsma.model_name, gsma.optional_fields, mntc.last_seen
                            FROM gsma_data AS gsma
                      RIGHT JOIN monthly_network_triplets_country_no_null_imeis AS mntc
                                            ON SUBSTRING(imei_norm, 1, 8) = tac
                       LEFT JOIN registration_list AS reg
                                            ON reg.imei_norm = mntc.imei_norm
                           WHERE msisdn = %s """ , [ msisdn ] ) recs = cursor . fetchall ( ) data = [ MSISDN ( ) . dump ( dict ( imei_norm = rec [ 0 ] , imsi = rec [ 1 ] , last_seen = rec [ 10 ] , gsma = rec . _asdict ( ) if rec [ 6 ] else None , registration = rec if rec [ 2 ] else None ) ) . data for rec in recs ] return jsonify ( { 'results' : data } )
MSISDN API (version 2) GET endpoint.
MSISDN API ( version 2 ) GET endpoint .
"""
    MSISDN API (version 2) GET endpoint.

    Arguments:
        msisdn: 15 digits MSISDN value
    """
msisdn
str
15 digits MSISDN value
15 digits MSISDN value