import { Injectable } from '@angular/core';
import {SessionDataProviderService} from "./session-data-provider.service";
import {WrenchService} from "../services/wrench.service";

@Injectable({
  providedIn: 'root'
})
export class RecipientsService {

  constructor(
      public sessionDataProviderService: SessionDataProviderService,
      private wrenchService: WrenchService) {
      this.getMyRecipientsData();
  }

  usrData: {
    action:number, member_id: number,
    uid: string,
    sessionid: string,
    limit:20, page:1,
    offset: 0,
    amount: number
  };

  myRecipientsTotalData:any;
  myRecipientsData:any;
  async getMyRecipientsData(){
    this.usrData = {action:11175,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session ,
      limit:20, page:1,
      offset: 0, amount: 0}

    this.wrenchService.recipientAccount(this.usrData).subscribe(
        myRecipientsTotalData => {
          this.myRecipientsTotalData = myRecipientsTotalData;
          console.log("myRecipientsTotalData  RETURN->", this.myRecipientsTotalData);
          this.myRecipientsData = this.myRecipientsTotalData.result_list;
          console.log("myRecipientsData RETURN DATA->", this.myRecipientsData);
          return this.myRecipientsData;
        }
    );
  }

}
