<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/../../vendor/autoload.php';

use Automattic\WooCommerce\Client;

class WoocommercePricingTierApi
{
  public static function addUpdateRSP($productDetails)
  {
    var_dump('addUpdateRSP');
    $data = array(
      'rsp_data' => array($productDetails)
    );
    
    $woocommerce = new Client(
      Yii::app()->params['woocommerceAPIURL'], 
      'ck_d417ffed51c6f2e70dd3321938551376b025d659',//'ck_a032ba2d118a279f3763feda67aa2b18490b9c19', //'ck_c8d3611b9849c900900d590b0893bb6adb0159ff', 
      'cs_ce6e04370b7affbb95053fc22e5972a1c878bd11',//'cs_3f9ca435dc1f67f1691dfd8d7a13f0daf1e7ed04'//'cs_f8cbc6c51a18e0f8bd16cca4551d0bc7c5e4d2be',
      [
        'version' => 'wc/v3',
      ]
    );
    //Dev::pv($woocommerce);
    $res = $woocommerce->post('csp/rsp', $data);
    //Dev::pv($res);
    return $res;
  }

  public static function deleteRSP($productDetails)
  {
    var_dump('addUpdateRSP');
    $data = array(
      'rsp_data' => array($productDetails)
    );

    $woocommerce = new Client(
      Yii::app()->params['woocommerceAPIURL'], 
      'ck_d417ffed51c6f2e70dd3321938551376b025d659',//'ck_a032ba2d118a279f3763feda67aa2b18490b9c19',//'ck_c8d3611b9849c900900d590b0893bb6adb0159ff', 
      'cs_ce6e04370b7affbb95053fc22e5972a1c878bd11',//'cs_3f9ca435dc1f67f1691dfd8d7a13f0daf1e7ed04'//'cs_f8cbc6c51a18e0f8bd16cca4551d0bc7c5e4d2be',
      [
        'version' => 'wc/v3',
      ]
    );

    $res = $woocommerce->delete('csp/rsp', $data);

    return $res;
  }
}