<commit_before><?php

namespace ChiarilloMassimo\Satispay\Handler;

use ChiarilloMassimo\Satispay\Model\ArrayCollection;
use ChiarilloMassimo\Satispay\Model\Refund;

/**
 * Class RefundHandler
 * @package ChiarilloMassimo\Satispay\Handler
 */
class RefundHandler extends AbstractHandler
{
    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#get-a-refund
     *
     * @param $id
     *
     * @return Charge
     */
    public function findOneById($id)
    {
        $response = $this->getClient()
            ->request(
                'GET',
                sprintf('/online/v1/refunds/%s', $id)
            );

        return Refund::makeFromObject($response->getData());
    }

    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#create-a-refund
     *
     * @param Refund $refund
     *
     * @return Refund
     */
    public function persist(Refund &$refund)
    {
        //var_dump(json_encode($refund->toArray()));die;
        $response = $this->getClient()
            ->request(
                'POST',
                '/online/v1/refunds',
                [
                    'json' => $refund->toArray()
                ]
            );

        $refund = Refund::makeFromObject($response->getData());

        return $refund;
    }

    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#update-a-refund
     *
     * @param Refund $refund
     *
     * @return Refund<commit_msg>Delete commets<commit_after><?php

namespace ChiarilloMassimo\Satispay\Handler;

use ChiarilloMassimo\Satispay\Model\ArrayCollection;
use ChiarilloMassimo\Satispay\Model\Refund;

/**
 * Class RefundHandler
 * @package ChiarilloMassimo\Satispay\Handler
 */
class RefundHandler extends AbstractHandler
{
    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#get-a-refund
     *
     * @param $id
     *
     * @return Charge
     */
    public function findOneById($id)
    {
        $response = $this->getClient()
            ->request(
                'GET',
                sprintf('/online/v1/refunds/%s', $id)
            );

        return Refund::makeFromObject($response->getData());
    }

    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#create-a-refund
     *
     * @param Refund $refund
     *
     * @return Refund
     */
    public function persist(Refund &$refund)
    {
        $response = $this->getClient()
            ->request(
                'POST',
                '/online/v1/refunds',
                [
                    'json' => $refund->toArray()
                ]
            );

        $refund = Refund::makeFromObject($response->getData());

        return $refund;
    }

    /**
     * @link https://s3-eu-west-1.amazonaws.com/docs.online.satispay.com/index.html#update-a-refund
     *
     * @param Refund $refund
     *
     * @return Refund
{'fraction_non_alphanumeric': 0.1461693548387097, 'fraction_numerical': 0.005376344086021506, 'mean_word_length': 1.8846899224806202, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7123985', 'n_tokens_mistral': 980, 'n_tokens_neox': 959, 'n_words': 123}