Metadata-Version: 2.1
Name: profile-local
Version: 0.0.39
Summary: This is a package for sharing common crud operation to profile schema in the db
Home-page: https://github.com/circles-zone/profile-local-python-package
Author: Circles
Author-email: info@circles.life
Classifier: Programming Language :: Python :: 3
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: pytest>=7.4.0
Requires-Dist: database-mysql-local>=0.0.113
Requires-Dist: logger-local>=0.0.67
Requires-Dist: location-profile-local>=0.0.49
Requires-Dist: operational-hours-local>=0.0.19
Requires-Dist: database-infrastructure-local>=0.0.17
Requires-Dist: person-local>=0.0.20
Requires-Dist: gender-local>=0.0.6
Requires-Dist: location-local>=0.0.54
Requires-Dist: reaction-local>=0.0.8
Requires-Dist: profile-reaction-local>=0.0.14
Requires-Dist: language-local>=0.0.6
Requires-Dist: user-context-remote>=0.0.33
Requires-Dist: storage-local>=0.1.27

# Installation and upgrade
To install this package run "pip install profile-local".
To upgrade this package run "pip install --upgrade profile-local".

# Import 
from profile_local.generic_profile_insert import generic_profile_insert

# Use example
data =  {
            'location': LOCATION_DATA,
            'profile': PROFILE_DATA,
            'storage': STORAGE_DATA,
            'reaction': REACTION_JSON,
            'operational_hours': OPERATIONAL_HOURS
}

Where LOCATION_DATA, PROFILE_DATA, STORAGE_DATA, REACTION_JSON, OPERATIONAL_HOURS are dictionaries with the relevant data for the table
i.e. for profile_table:
PROFILE_DATA = {
    'profile_name': NAME,
    'name_approved': NAME_APPROVED,
    'lang_code': LANG_CODE,
    'user_id': USER_ID,     # Optional
    'is_main': IS_MAIN,     # Optional
    'visibility_id': VISIBILITY_ID,
    'is_approved': IS_APPROVED,
    'profile_type_id': PROFILE_TYPE_ID,     # Optional
    'preferred_lang_code': PREFERRED_LANG_CODE,     # Optional
    'experience_years_min': EXPERIENCE_YEARS_MIN,       # Optional
    'main_phone_id': MAIN_PHONE_ID,     # Optional
    'rip': RIP,     # Optional
    'gender_id': GENDER_ID,     # Optional
    'stars': STARS,
    'last_dialog_workflow_state_id': LAST_DIALOG_WORKFLOW_STATE_ID
}

Then call json.dumps:
data_json=json.dumps(data)

Now we can call the generic_profile_insert function:
profile_id = generic_profile_insert(data_json)

If the function inserted a profile successfully it returns the profile_id of the inserted profile.
The function doesn't have to always insert a profile, for example you can use it to insert only a location with
data =  {
            'location': LOCATION_DATA,
}

and then the returned profile_id will be 'None'.
