/**
 * EasyHTTP Library
 * Library for making HTTP requests
 *
 * @version 1.0.0
 * @author  Sameh Deyab
 * @license privet
 *
 **/

class ApiData {
    // Make an HTTP GET Request 
    async get(url) {
      const response = await fetch(url);
      const resData = await response.json();
      return resData;
    }
  
    // Make an HTTP POST Request
    async post(url, data) {
      const response = await fetch(url, {
        method: 'POST',
        headers: {
          'Content-type': 'application/json'
        },
        body: JSON.stringify(data)
      });
  
      const resData = await response;
      return resData;
     
    }
  
     // Make an HTTP PUT Request
     async put(url, data) {
      const response = await fetch(url, {
        method: 'PUT',
        headers: {
          'Content-type': 'application/json'
        },
        body: JSON.stringify(data)
      });
      
      const resData = await response.json();
      return resData;
    }
  
    // Make an HTTP DELETE Request
    async delete(url) {
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          'Content-type': 'application/json'
        }
      });
  
      const resData = 'Resource Deleted...';
      return resData;
    }
  
   }

   class UI {
    constructor() {
      this.second_customer = document.getElementById('second_customer');
    }
  
    // Display profile in UI
    second_customer(data) {
      this.second_customer.innerHTML = `
      <div class="row">
        <output class="out_free w75 t_right t_h" type="text">${data.cust_name3}</output>
        <output class="out_free w2 hd t_center" type="text">مستاجر إضافي</output>
      </div>
      <div class="row">
        <output class="out_free w2 t_right " type="text">${data.license3}</output>
        <output class="out_free w2 t_right hd " type="text">نهاية الرخصة</output>
        <output class="out_free w2 t_right" type="text">${data.lic_expire3}</output>
        <output class="out_free w2 t_right hd" type="text">رقم الرخصة</output>
      </div>
      <div class="row">
        <output class="out_free w35 t_right " type="text">${data.address3}</output>
        <output class="out_free w1 hd t_right " type="text">:العنوان</output>
      </div>
      <br>
      <div class="row ts hd brr">
        <p class="t_right">بتوقيعي مستأجر إضافي أصبحت ملزم بشروط و أحكام هذا العقد في كلا الوجهين وأكون كفيلاّ في السداد</p>
        <p class="t_left"> By my signature I accept all terms and conditions on both sides of this rental agreement and sponser in payment</p>
      </div>
      <div class="row">
        <output class="out_free w4 t_center " type="text"></output>
        <output class="out_free w4 t_right " type="text">المستاجر الإضافي</output>
      </div>
      `;
    }}