<?php

namespace App\Jobs;

use App\Models_v2\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use RapidWeb\GoogleOAuth2Handler\GoogleOAuth2Handler;
use RapidWeb\GooglePeopleAPI\Contact;
use RapidWeb\GooglePeopleAPI\GooglePeople;

class AfterRegisterOwner implements ShouldQueue {
	use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

	/**
	 * Create a new job instance.
	 *
	 * @return void
	 */
	protected $user;

	public function onConnection( $connection ) {
		$this->connection = 'redis';

		return $this;
	}

	public function __construct( $user ) {
		/*
		 * $clientId     = '58403423691-9pke8pk4o8rhbla5o4m1q8kjlhtod40m.apps.googleusercontent.com';
		 * $clientSecret = 'h1zXskh1Atxi_Z-juJhYDbDM';
		 * $refreshToken = '1/EaCapuKy90SKUNCsRdpY5a6ovOKs_rcN_J55emjKnPoXEDn8UnqoHcl8VnIp0U3Z';
		 * $scopes       = ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/contacts', 'https://www.googleapis.com/auth/contacts.readonly'];
		 */
		$this->user = $user;
	}

	/**
	 * Execute the job.
	 *
	 * @return void
	 */
	public function handle() {
		//
		$amount = option( 'charge_owner', 200000 );
		//$this->user->increment( 'balance', $amount );
		$this->user->number_interacts = 100; // số lần tương tác
		$this->user->save();
//		Transaction::create( [
//			'user_id' => $this->user->id,
//			'amount'  => $amount,
//			'type' => Transaction::VOUCHER
//		] );

	}
}
