Exemple #1
0
def update_configuration(config, key):
    try:
        blipSession = BlipSession(key)
        res = blipSession.process_command(set_working_configuration(config))
        print(f'updated configuration with status: {res["status"]}')
        return res
    except Exception as ex:
        print(f'failed to update configuration - Exception: {ex}')
Exemple #2
0
def update_flow(flow, key):
    try:
        blipSession = BlipSession(key)
        res = blipSession.process_command(set_working_flow(flow))
        print(f'updated flow with status: {res["status"]}')
        return res
    except Exception as ex:
        print(f'failed to update flow - Exception: {ex}')
Exemple #3
0
def request_configuration(key):
    try:
        blipSession = BlipSession(key)
        res_config = blipSession.process_command(get_working_configuration())
        config = res_config['resource']
        print(f'requested configuration with status: {res_config["status"]}')
        return config
    except Exception as ex:
        print(f'failed to request configuration - Exception: {ex}')
Exemple #4
0
def request_flow(key):
    try:
        blipSession = BlipSession(key)
        res_flow = blipSession.process_command(get_working_flow())
        flow = res_flow['resource']
        print(f'requested flow with status: {res_flow["status"]}')
        return flow
    except Exception as ex:
        print(f'failed to request flow - Exception: {ex}')
Exemple #5
0
        'to': '*****@*****.**',
        'uri': f'/contexts/{USER_IDENTITY}'
    }


def get_specific_data_context_request(context_var):
    return {
        'method': GET_METHOD,
        'to': '*****@*****.**',
        'uri': f'/contexts/{USER_IDENTITY}/{context_var}'
    }


if __name__ == "__main__":
    blipSession = BlipSession(BOT_AUTHORIZATION)
    res_context = blipSession.process_command(get_all_context_request())
    jsonResponse = {}

    if (res_context.get('status') == 'success'):
        for context_var in res_context['resource']['items']:
            res__get_data_context = blipSession.process_command(
                get_specific_data_context_request(context_var))
            if res__get_data_context['status'] == 'success':
                data_var = res__get_data_context['resource'].encode(
                    'utf-8').decode('utf-8')
                jsonResponse[context_var] = data_var

        print(json.dumps(jsonResponse, ensure_ascii=False))
        print('Finished')
        exit(-1)
    if (res_context.get('status') == 'failure'):
from blip_session import BlipSession

my_auth_key = '{{bot_auth_key}}'
bs = BlipSession(my_auth_key)
user_id = '{{phone_number}}@wa.gw.msging.net'
ccrb = {'method': 'get', 'uri': f'/contexts/{user_id}'}

response = bs.force_command(ccrb)
print(response)
context_variables = response['resource']['items']

for context in context_variables:

    bs.process_command({
        'method': 'delete',
        'uri': f'/contexts/{user_id}/{context}'
    })
Exemple #7
0
        'to': '*****@*****.**',
        'uri': f'/contexts/{USER_IDENTITY}'
    }


def delete_specific_context_variable(context_var):
    return {
        'method': DELETE_METHOD,
        'to': '*****@*****.**',
        'uri': f'/contexts/{USER_IDENTITY}/{context_var}'
    }


if __name__ == "__main__":
    blipSession = BlipSession(BOT_AUTHORIZATION)
    res_context = blipSession.process_command(create_all_context_request())

    if (res_context.get('status') == 'success'):

        for context_var in res_context['resource']['items']:
            res__delete_context = blipSession.process_command(
                delete_specific_context_variable(context_var))
            if res__delete_context['status'] == 'success':
                print(f'Deleted context var :{context_var}')
            else:
                print(
                    f'[ERROR] Reason: {res__delete_context["reason"]["description"]}'
                )

        print('Finished')
        exit(-1)
Exemple #8
0
    })
    return command


def set_context_value(identity, name, value, mime_type, client):
    identity = identity.replace('prd', '')
    client.force_command({
        'method': 'set',
        'uri': f'/contexts/{identity}/{name}',
        'type': mime_type,
        'resource': value
    })


contacts = bot_client.process_command({
    'method': 'get',
    'uri': '/contacts?$take=9999'
})['resource']['items']
print(f'found {len(contacts)} contacts')

for contact in contacts:
    print(f'Merging with router contact {contact["identity"]}')
    merge_contact(contact, router_client)

contexts = bot_client.process_command({
    'method': 'get',
    'uri': '/contexts?$take=9999'
})['resource']['items']
print(f'fount {len(contexts)} contexts')

for user_context in contexts:
    print(f'Merging with router context {user_context}')