/**
  * Get a list of renewals
  *
  * ## Options
  *
  * [--<field>=<value>]
  * : Include additional query args in keys query.
  *
  * [--fields=<fields>]
  * : Return designated object fields.
  *
  * [--raw]
  * : Return raw values. IDs instead of human readable names.
  *
  * @param $args
  * @param $assoc_args
  *
  * @subcommand list
  */
 public function list_($args, $assoc_args)
 {
     $query_args = wp_parse_args($assoc_args, array('items_per_page' => 20, 'page' => 1));
     $query_args['order'] = array('id' => 'DESC');
     $results = itelic_get_renewals($query_args);
     $items = array();
     foreach ($results as $item) {
         $items[] = $this->get_fields_for_object($item, \WP_CLI\Utils\get_flag_value($assoc_args, 'raw', false));
     }
     if (empty($assoc_args['fields'])) {
         $assoc_args['fields'] = array('id', 'key', 'renewal_date', 'expired_date', 'transaction', 'revenue');
     }
     $formatter = $this->get_formatter($assoc_args);
     $formatter->display_items($items);
 }
Esempio n. 2
0
 /**
  * Delete the license key.
  */
 public function delete()
 {
     /**
      * Fires before a key is deleted.
      *
      * @since 1.0
      *
      * @param Activation $this
      */
     do_action('itelic_delete_key', $this);
     $activations = itelic_get_activations(array('key' => $this->get_key()));
     foreach ($activations as $activation) {
         $activation->delete();
     }
     $renewals = itelic_get_renewals(array('key' => $this->get_key()));
     foreach ($renewals as $renewal) {
         $renewal->delete();
     }
     parent::delete();
     /**
      * Fires after a key is deleted.
      *
      * @since 1.0
      *
      * @param Activation $this
      */
     do_action('itelic_deleted_key', $this);
 }