xto10x

 avatar
unknown
python
3 years ago
19 kB
3
Indexable


import requests
import json

block_array = [
    {
        "id": "e31f99d6-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Career Development",
        "description": "This block represents how employees feel about their roles & opportunities to grow."
    },
    {
        "id": "e31f9a2f-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Performance & Rewards",
        "description": "This block represents how satisfied employees are with the performance management process, their compensation & benefits."
    },
    {
        "id": "e31f9973-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Hiring & Assimilation",
        "description": "This block represents the engine that hires & onboards at scale without lowering the talent bar in the organization."
    },
    {
        "id": "e31f9886-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Policies",
        "description": "This block represents how satisfied employees are with the employee policies & work environment."
    },
    {
        "id": "e31f9225-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Org Principles",
        "description": "This block represents the level of pride employees have towards the organization."
    },
    {
        "id": "e31f9b7e-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Decision Making",
        "description": "This block represents the effectiveness of the decision-making process and the level of autonomy with employees."
    },
    {
        "id": "e31f9ad5-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Communication",
        "description": "This block represents how effectively information flows across the organization."
    },
    {
        "id": "e31f9bdc-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Impact",
        "description": "This block represents impact orientation and bias for action in work."
    },
    {
        "id": "e31f9c31-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Innovation",
        "description": "This block represents how employees are empowered to think big, take risks, and innovate within the organization."
    },
    {
        "id": "e31f9b28-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Alignment",
        "description": "This block represents how clear employees are about the company objectives & how they align with their individual goals."
    },
    {
        "id": "e31f9767-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Managers",
        "description": "This block represents the effectiveness of managers in the organization."
    },
    {
        "id": "e31f97d1-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Teams",
        "description": "This block represents working relationships & collaboration within teams."
    },
    {
        "id": "e31f9831-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Leaders",
        "description": "This block represents how employees feel about the leadership team in the organization."
    },
    {
        "id": "e31f9a82-8b0a-11ea-af88-0215b6e3dd02",
        "name": "Collaboration",
        "description": "This block represents collaboration within a team and between teams."
    }
]
# block_array = [
#     {
#         "id": "e31f99d6-8b0a-11ea-af88-0215b6e3dd02",
#         "name": "Career Development",
#         "description": "This block represents how employees feel about their roles & opportunities to grow."
#     }
# ]
excel_response_team = {}
excel_response_main = []
excel_response_all = []
user_id_ma = '9a29ad4e-06cd-40d0-b646-82e92099b2ee'
user_id_kn = '9978a61b-2759-4b29-aaae-4db3e8cd2123'
user_id_rn = 'ba594bb5-2a55-4f35-a032-4d596798ac04'
# auth_key = 'eyJraWQiOiJ2NkNJYlwvZ21OQkpsU2pkUk9maUlOaU1LaHB0cWRiSDRTeWc2WW1aaXJGbz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI3YjU2ZmIxMy1mNjlhLTQ5MTctODJlNi05YTZjZmJlZmM4MDYiLCJjdXN0b206c2lnbl91cF9zb3VyY2UiOiJnb29nbGUiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmFwLXNvdXRoLTEuYW1hem9uYXdzLmNvbVwvYXAtc291dGgtMV9IQWE0NDMwdmkiLCJjb2duaXRvOnVzZXJuYW1lIjoiN2I1NmZiMTMtZjY5YS00OTE3LTgyZTYtOWE2Y2ZiZWZjODA2IiwiY3VzdG9tOnVzZXJfcmVmZXJlbmNlX2lkIjoiN2E0NjVlOGEtN2I2Ny00N2VlLTllYjctMDFlYWNhM2I3YjE0IiwiYXVkIjoicTBocWxzZ2U5bzRxMm5vcGdvM3FuN2ZwIiwiZXZlbnRfaWQiOiJkNDU4NDk5YS00MzUxLTRjOGQtYWFiOC1hZTJiMWRlOTc5YjQiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI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MzUxLTRjOGQtYWFiOC1hZTJiMWRlOTc5YjQiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY2NzYzNDkyMSwibmFtZSI6IkJoYXJhdCBCaGFydGlhIiwiZXhwIjoxNjY3ODIwNjAxLCJpYXQiOjE2Njc4MTcwMDEsImVtYWlsIjoiYmhhcmF0LmJoYXJ0aWFAd29ya2luZGlhLmluIn0.upt0nZKTphhVlh5XTv-PKVcsrJFQ5iOQQZCK_09iJU3reZEIdSziGvoQLszEnf1HDRtokXMTkceoKdnWXs4xB80FWO94PotISgvqtghKYvfTC5wBIUbglc8-c9iaf0e0SdwFlTJZwpv-FFbu7xOCtAdMEB_1-VVZWCS5Q9ZgUn-C7EvR2F6u8oveV48RC5aHtduvH-wwfBjfSIsEY3oajdttUev2baSYODZGELEpgW8S3U3Hl9RqO1PlNorDkmwF260c2aWzNfjLGBt0yt0hMBJfvoiI0St4g1XJyPyg9zmj371f0XbS1g_c9EpE-Im4SbS_TCN0m3qA9N8Vdsf3ng'
user_id = user_id_rn
for block in block_array:
    block_id = block['id']
    block_name = block['name']
    block_description = block['description']

    url = f"https://peoples-api.xto10x.com/v1/people/reports/survey-group/e09ddd0c-8f40-4936-aac7-7588aac2005d/block-report/{block_id}?user_id={user_id}"

    payload = {}
    headers = {
        'authority': 'peoples-api.xto10x.com',
        'accept': 'application/json, text/plain, */*',
        'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
        'authorization': auth_key,
        'org_id': '1e37327c-f1b9-42a7-9728-df862daae2b0',
        'origin': 'https://cues.xto10x.com',
        'product_id': 'PEOPLE',
        'requester_user_id': '7a465e8a-7b67-47ee-9eb7-01eaca3b7b14',
        'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"macOS"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-site',
        'source_type': 'cognito',
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
    }

    response = requests.request("GET", url, headers=headers, data=payload)

    block_details = json.loads(response.text)
    block_score = block_details['score']
    block_previous_score = block_details['previous_score']

    block_participants_response = block_details['block_participants_response']

    for block_participants in block_participants_response:
        type = block_participants['type']
        name = block_participants['name']
        questions_array = block_participants['questions']
        if type == 'TEAM':
            for questions in questions_array:
                question_id = questions['question_id']
                short_text = questions['short_text']
                long_text = questions['long_text']
                score = questions['score']

                import requests

                url = f"https://peoples-api.xto10x.com/v1/people/reports/blocks/{block_id}/questions/{question_id}/insights?survey_group_id=e09ddd0c-8f40-4936-aac7-7588aac2005d&user_id={user_id}"

                payload = {}
                headers = {
                    'authority': 'peoples-api.xto10x.com',
                    'accept': 'application/json, text/plain, */*',
                    'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
                    'authorization': auth_key,
                    'isretried': 'true',
                    'org_id': '1e37327c-f1b9-42a7-9728-df862daae2b0',
                    'origin': 'https://cues.xto10x.com',
                    'product_id': 'PEOPLE',
                    'requester_user_id': '7a465e8a-7b67-47ee-9eb7-01eaca3b7b14',
                    'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
                    'sec-ch-ua-mobile': '?0',
                    'sec-ch-ua-platform': '"macOS"',
                    'sec-fetch-dest': 'empty',
                    'sec-fetch-mode': 'cors',
                    'sec-fetch-site': 'same-site',
                    'source_type': 'cognito',
                    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
                }

                response1 = requests.request("GET", url, headers=headers, data=payload)

                question_response = json.loads(response1.text)

                question_txt = question_response['question_txt']
                question_insights = question_response['question_insights']
                for question_insight in question_insights:
                    _type = question_insight['type']

                    if _type == 'TEAM':
                        total_responses = question_insight['total_responses']
                        option_details = question_insight['option_details']

                        strongly_agree = 0
                        agree = 0
                        disagree = 0
                        strongly_disagree = 0

                        for option in option_details:
                            option_text = option['text']
                            if option_text == 'Strongly Agree':
                                strongly_agree = option['response_count']
                            if option_text == 'Agree':
                                agree = option['response_count']
                            if option_text == 'Disagree':
                                disagree = option['response_count']
                            if option_text == 'Strongly Disagree':
                                strongly_disagree = option['response_count']

                        sample_response_ma = {
                            'block_name': block_name,
                            'block_description': block_description,
                            'short_text': short_text,
                            'long_text': long_text,
                            'score': score,
                            'question_txt': question_txt,
                            'total_responses': total_responses,
                            'strongly_agree': strongly_agree,
                            'agree': agree,
                            'disagree': disagree,
                            'strongly_disagree': strongly_disagree
                        }
                        excel_response_main.append(sample_response_ma)
        elif type == 'USER':
            user_name = block_participants['name']
            for questions in questions_array:
                question_id = questions['question_id']
                short_text = questions['short_text']
                long_text = questions['long_text']
                score = questions['score']

                import requests

                url = f"https://peoples-api.xto10x.com/v1/people/reports/blocks/{block_id}/questions/{question_id}/insights?survey_group_id=e09ddd0c-8f40-4936-aac7-7588aac2005d&user_id={user_id}"

                payload = {}
                headers = {
                    'authority': 'peoples-api.xto10x.com',
                    'accept': 'application/json, text/plain, */*',
                    'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
                    'authorization': auth_key,
                    'isretried': 'true',
                    'org_id': '1e37327c-f1b9-42a7-9728-df862daae2b0',
                    'origin': 'https://cues.xto10x.com',
                    'product_id': 'PEOPLE',
                    'requester_user_id': '7a465e8a-7b67-47ee-9eb7-01eaca3b7b14',
                    'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
                    'sec-ch-ua-mobile': '?0',
                    'sec-ch-ua-platform': '"macOS"',
                    'sec-fetch-dest': 'empty',
                    'sec-fetch-mode': 'cors',
                    'sec-fetch-site': 'same-site',
                    'source_type': 'cognito',
                    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
                }

                response1 = requests.request("GET", url, headers=headers, data=payload)

                question_response = json.loads(response1.text)

                question_txt = question_response['question_txt']
                question_insights = question_response['question_insights']
                for question_insight in question_insights:
                    _type = question_insight['type']
                    user_name_question = question_insight.get('name')
                    if _type == 'USER' and user_name_question and user_name_question == user_name:
                        total_responses = question_insight['total_responses']
                        option_details = question_insight['option_details']

                        strongly_agree = 0
                        agree = 0
                        disagree = 0
                        strongly_disagree = 0

                        for option in option_details:
                            option_text = option['text']
                            if option_text == 'Strongly Agree':
                                strongly_agree = option['response_count']
                            if option_text == 'Agree':
                                agree = option['response_count']
                            if option_text == 'Disagree':
                                disagree = option['response_count']
                            if option_text == 'Strongly Disagree':
                                strongly_disagree = option['response_count']

                        sample_response_jk = {
                            'block_name': block_name,
                            'block_description': block_description,
                            'short_text': short_text,
                            'long_text': long_text,
                            'score': score,
                            'question_txt': question_txt,
                            'total_responses': total_responses,
                            'strongly_agree': strongly_agree,
                            'agree': agree,
                            'disagree': disagree,
                            'strongly_disagree': strongly_disagree
                        }
                        if user_name not in excel_response_team:
                            excel_response_team[user_name] = []
                        excel_response_team[user_name].append(sample_response_jk)
        elif type == 'ALL':
            for questions in questions_array:
                question_id = questions['question_id']
                short_text = questions['short_text']
                long_text = questions['long_text']
                score = questions['score']

                import requests

                url = f"https://peoples-api.xto10x.com/v1/people/reports/blocks/{block_id}/questions/{question_id}/insights?survey_group_id=e09ddd0c-8f40-4936-aac7-7588aac2005d&user_id={user_id}"

                payload = {}
                headers = {
                    'authority': 'peoples-api.xto10x.com',
                    'accept': 'application/json, text/plain, */*',
                    'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
                    'authorization': auth_key,
                    'isretried': 'true',
                    'org_id': '1e37327c-f1b9-42a7-9728-df862daae2b0',
                    'origin': 'https://cues.xto10x.com',
                    'product_id': 'PEOPLE',
                    'requester_user_id': '7a465e8a-7b67-47ee-9eb7-01eaca3b7b14',
                    'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
                    'sec-ch-ua-mobile': '?0',
                    'sec-ch-ua-platform': '"macOS"',
                    'sec-fetch-dest': 'empty',
                    'sec-fetch-mode': 'cors',
                    'sec-fetch-site': 'same-site',
                    'source_type': 'cognito',
                    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36'
                }

                response1 = requests.request("GET", url, headers=headers, data=payload)

                question_response = json.loads(response1.text)

                question_txt = question_response['question_txt']
                question_insights = question_response['question_insights']
                for question_insight in question_insights:
                    _type = question_insight['type']

                    if _type == 'ALL':
                        total_responses = question_insight['total_responses']
                        option_details = question_insight['option_details']

                        strongly_agree = 0
                        agree = 0
                        disagree = 0
                        strongly_disagree = 0

                        for option in option_details:
                            option_text = option['text']
                            if option_text == 'Strongly Agree':
                                strongly_agree = option['response_count']
                            if option_text == 'Agree':
                                agree = option['response_count']
                            if option_text == 'Disagree':
                                disagree = option['response_count']
                            if option_text == 'Strongly Disagree':
                                strongly_disagree = option['response_count']

                        sample_response_ma = {
                            'block_name': block_name,
                            'block_description': block_description,
                            'short_text': short_text,
                            'long_text': long_text,
                            'score': score,
                            'question_txt': question_txt,
                            'total_responses': total_responses,
                            'strongly_agree': strongly_agree,
                            'agree': agree,
                            'disagree': disagree,
                            'strongly_disagree': strongly_disagree
                        }
                        excel_response_all.append(sample_response_ma)


print(excel_response_main)
print(excel_response_all)
print(excel_response_team)
Editor is loading...