<commit_before><?php
namespace Vigattin\Member;

use Vigattin\Connect\Connect;

class Member {
    
    public $connect;
    
    public function __construct() {
        $this->connect = new Connect();
    }
    
    /**
     * Read vigattin.com members database table
     * 
     * @param int $startId id + 1 where the start of reading will begin ex. if $start_id = 10 the reading will start from 11, 12, 13 and soon
     * @param int $limit tha max output number of row 
     * @return array result of the request
     */
    
    public function dbReadAllMembers($startId = 0, $limit = 30) {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_READ_ALL_MEMBERS,
            'start_id' => $startId,
            'limit' => $limit
        );
        $resultData = $this->connect->apiCall($request);
        return json_decode($resultData, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => Array
                    (
                        [0] => Array
                            (
                                [id] => 0000000011
                                [email] => <EMAIL>
                                [password] => <PASSWORD>
                                [first_name] => Ellaine
                                [last_name] => Gomez
                                [birthday] => 315532800
                                [gender] => 0
                                [country] => Anonymous
                                [verified] => 1
                                [type] => 1
                                [fbid] => 100001774838846
                                [name] => <NAME>
                                [time] => 1368753612
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                        [1] => Array
                            (
                                [id] => 0000000012
                                [email] => <EMAIL>
                                [password] => <PASSWORD>
                                [first_name] => Lovette
                                [last_name] => Jam
                                [birthday] => 478310400
                                [gender] => 0
                                [country] => Anonymous
                                [verified] => 1
                                [type] => 0
                                [fbid] => 1132617639
                                [name] => <NAME>
                                [time] => 0
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                        [2] => Array
                            (
                                [id] => 0000000013
                                [email] => <EMAIL>
                                [password] => <PASSWORD>
                                [first_name] => Ian
                                [last_name] => Freelancemasseur
                                [birthday] => 315532800
                                [gender] => 1
                                [country] => Anonymous
                                [verified] => 0
                                [type] => 0
                                [fbid] => 100003515029676
                                [name] => <NAME>
                                [time] => 0
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                    )

                [request] => Array
                    (
                        [mode] => 5
                        [start_id] => 10
                        [limit] => 3
                        [vapi_request_expire] => 1379407068
                    )
        */
    }
    
    /**
     * Update vigattin.com members database table
     * 
     * @param string $id_or_email the id or email of member from vigattin members table
     * @param array $field_array array of key value pair to be updated ex. update member first_name and last_name: $field_array = array('first_name' => 'vigattin', 'last_name' => 'inc.');
     * @return array result of the request
     */
    
    public function dbUpdateMember($id_or_email, $field_array = array()) {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_UPDATE_MEMBERS,
            'id_or_email' => $id_or_email,
            'field_array' => $field_array
        );
        $result_data = $this->connect->apiCall($request);
        return json_decode($result_data, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => update success
                [request] => Array
                    (
                        [mode] => 7
                        [id_or_email] => <EMAIL>
                        [field_array] => Array
                            (
                                [first_name] => Test
                                [last_name] => User
                            )

                        [vapi_request_expire] => 1379406901
                    )

            )
        */
    }
    
    /**
     * Create new vigattin.com member
     * 
     * @param string $email member email (must be a valid email)
     * @param string $password <PASSWORD>
     * @param string $first_name member first name
     * @param string $last_name member last name
     * @param string $gender member gender, posible value are male or female
     * @param ing $birthday member birthday in epoch time (optional)
     * @param int $verified Force the email to set as verified
     * @param int $version Add version to the inserted account for use in deleting or updating if problem occurs when inserting multiple account
     * @return array result of the request
     */
    
    public function dbCreateMember($email, $password, $first_name, $last_name, $gender, $birthday = '', $verified = 0, $version = 0) {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_CREATE_MEMBERS,
            'email' => $email,
            'password' => $password,
            'first_name' => $first_name,
            'last_name' => $last_name,
            'gender' => $gender,
            'birthday' => $birthday,
            'verified' => $verified,
            'version' => $version,
            'username' => ''
        );
        $result_data = $this->connect->apiCall($request);
        return json_decode($result_data, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => Array
                    (
                        [id] => 7843
                        [error] => 
                    )

                [request] => Array
                    (
                        [mode] => 6
                        [email] => <EMAIL>
                        [password] => <PASSWORD>
                        [first_name] => resty
                        [last_name] => rizal<commit_msg>update Member class<commit_after><?php
namespace Vigattin\Member;

use Vigattin\Connect\Connect;

class Member {
    
    public $connect;
    
    public function __construct() {
        $this->connect = new Connect();
    }
    
    /**
     * Read vigattin.com members database table
     * 
     * @param int $startId id + 1 where the start of reading will begin ex. if $start_id = 10 the reading will start from 11, 12, 13 and soon
     * @param int $limit tha max output number of row 
     * @return array result of the request
     */
    
    public function dbReadAllMembers($startId = 0, $limit = 30) {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_READ_ALL_MEMBERS,
            'start_id' => $startId,
            'limit' => $limit
        );
        $resultData = $this->connect->apiCall($request);
        return json_decode($resultData, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => Array
                    (
                        [0] => Array
                            (
                                [id] => 0000000011
                                [email] => <EMAIL>
                                [password] => <PASSWORD>
                                [first_name] => Ellaine
                                [last_name] => Gomez
                                [birthday] => 315532800
                                [gender] => 0
                                [country] => Anonymous
                                [verified] => 1
                                [type] => 1
                                [fbid] => 100001774838846
                                [name] => <NAME>
                                [time] => 1368753612
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                        [1] => Array
                            (
                                [id] => 0000000012
                                [email] => <EMAIL>
                                [password] => <PASSWORD>
                                [first_name] => Lovette
                                [last_name] => Jam
                                [birthday] => 478310400
                                [gender] => 0
                                [country] => Anonymous
                                [verified] => 1
                                [type] => 0
                                [fbid] => 1132617639
                                [name] => <NAME>
                                [time] => 0
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                        [2] => Array
                            (
                                [id] => 0000000013
                                [email] => <EMAIL>
                                [password] => <PASSWORD>974bec6ae589bf36734b11994707acda927
                                [first_name] => Ian
                                [last_name] => Freelancemasseur
                                [birthday] => 315532800
                                [gender] => 1
                                [country] => Anonymous
                                [verified] => 0
                                [type] => 0
                                [fbid] => 100003515029676
                                [name] => <NAME>
                                [time] => 0
                                [profile_photo] => 
                                [cover_photo] => 
                                [offset_y] => 0
                                [is_local] => 0
                                [new_user] => 1
                                [version] => 0
                            )

                    )

                [request] => Array
                    (
                        [mode] => 5
                        [start_id] => 10
                        [limit] => 3
                        [vapi_request_expire] => 1379407068
                    )
        */
    }
    
    /**
     * Update vigattin.com members database table
     * 
     * @param string $id_or_email the id or email of member from vigattin members table
     * @param array $field_array array of key value pair to be updated ex. update member first_name and last_name: $field_array = array('first_name' => 'vigattin', 'last_name' => 'inc.');
     * @return array result of the request
     */
    
    public function dbUpdateMember($id_or_email, $field_array = array()) {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_UPDATE_MEMBERS,
            'id_or_email' => $id_or_email,
            'field_array' => $field_array
        );
        $result_data = $this->connect->apiCall($request);
        return json_decode($result_data, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => update success
                [request] => Array
                    (
                        [mode] => 7
                        [id_or_email] => <EMAIL>.com
                        [field_array] => Array
                            (
                                [first_name] => Test
                                [last_name] => User
                            )

                        [vapi_request_expire] => 1379406901
                    )

            )
        */
    }
    
    /**
     * Create new vigattin.com member
     * 
     * @param string $email member email (must be a valid email)
     * @param string $password member password
     * @param string $first_name member first name
     * @param string $last_name member last name
     * @param string $gender member gender, posible value are male or female
     * @param ing $birthday member birthday in epoch time (optional)
     * @param int $verified Force the email to set as verified
     * @param int $version Add version to the inserted account for use in deleting or updating if problem occurs when inserting multiple account
     * @return array result of the request
     */
    
    public function dbCreateMember($email, $password, $first_name, $last_name, $gender, $birthday = '', $verified = 0, $version = 0, $username = '') {
        $request = array(
            'mode' => Connect::REQUEST_MODE_DB_CREATE_MEMBERS,
            'email' => $email,
            'password' => <PASSWORD>,
            'first_name' => $first_name,
            'last_name' => $last_name,
            'gender' => $gender,
            'birthday' => $birthday,
            'verified' => $verified,
            'version' => $version,
            'username' => $username
        );
        $result_data = $this->connect->apiCall($request);
        return json_decode($result_data, true);
        
        /*
        Sample Return:
            Array
            (
                [status] => ok
                [result] => Array
                    (
                        [id] => 7843
                        [error] => 
                    )

                [request] => Array
                    (
                        [mode] => 6
                        [email] => <EMAIL>
                        [password] => <PASSWORD>
                        [first_name] => resty
                        [last_name] => rizal
{'fraction_non_alphanumeric': 0.09342206296391092, 'fraction_numerical': 0.02412336831328385, 'mean_word_length': 0.8500236742424242, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 251, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2995703', 'n_tokens_mistral': 4125, 'n_tokens_neox': 3580, 'n_words': 894}