Code Duplication    Length = 13-13 lines in 7 locations

src/Api/Account.php 1 location

@@ 68-80 (lines=13) @@
65
    /**
66
     * @throws Exception
67
     */
68
    public function update(string $id, array $params)
69
    {
70
        $processor = new Processor();
71
        $processor->processConfiguration(new Configuration\AccountUpdate(), [$params]);
72
73
        $response = $this->httpPostRaw("/v1/accounts/$id", http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
74
75
        if (200 !== $response->getStatusCode()) {
76
            $this->handleErrors($response);
77
        }
78
79
        return $this->hydrator->hydrate($response, AccountModel::class);
80
    }
81
}
82

src/Api/Charge.php 1 location

@@ 54-66 (lines=13) @@
51
    /**
52
     * @throws Exception
53
     */
54
    public function update(string $id, array $params)
55
    {
56
        $processor = new Processor();
57
        $processor->processConfiguration(new Configuration\ChargeUpdate(), [$params]);
58
59
        $response = $this->httpPostRaw("/v1/charges/$id", http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
60
61
        if (200 !== $response->getStatusCode()) {
62
            $this->handleErrors($response);
63
        }
64
65
        return $this->hydrator->hydrate($response, ChargeModel::class);
66
    }
67
68
    /**
69
     * @throws Exception

src/Api/Coupon.php 1 location

@@ 51-63 (lines=13) @@
48
    /**
49
     * @throws Exception
50
     */
51
    public function create(array $params)
52
    {
53
        $processor = new Processor();
54
        $params = $processor->processConfiguration(new Configuration\CouponCreate(), [$params]);
55
56
        $response = $this->httpPostRaw('/v1/coupons', http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
57
58
        if (200 !== $response->getStatusCode()) {
59
            $this->handleErrors($response);
60
        }
61
62
        return $this->hydrator->hydrate($response, CouponModel::class);
63
    }
64
}
65

src/Api/Customer.php 1 location

@@ 56-68 (lines=13) @@
53
    /**
54
     * @throws Exception
55
     */
56
    public function create(array $params)
57
    {
58
        $processor = new Processor();
59
        $params = $processor->processConfiguration(new Configuration\CustomerCreate(), [$params]);
60
61
        $response = $this->httpPostRaw('/v1/customers', http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
62
63
        if (200 !== $response->getStatusCode()) {
64
            $this->handleErrors($response);
65
        }
66
67
        return $this->hydrator->hydrate($response, CustomerModel::class);
68
    }
69
}
70

src/Api/Product.php 1 location

@@ 54-66 (lines=13) @@
51
    /**
52
     * @throws Exception
53
     */
54
    public function update(string $id, array $params)
55
    {
56
        $processor = new Processor();
57
        $processor->processConfiguration(new Configuration\ProductUpdate(), [$params]);
58
59
        $response = $this->httpPostRaw("/v1/products/$id", http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
60
61
        if (200 !== $response->getStatusCode()) {
62
            $this->handleErrors($response);
63
        }
64
65
        return $this->hydrator->hydrate($response, ProductModel::class);
66
    }
67
68
    /**
69
     * @throws Exception

src/Api/Subscription.php 2 locations

@@ 52-64 (lines=13) @@
49
    /**
50
     * @throws Exception
51
     */
52
    public function create(array $params)
53
    {
54
        $processor = new Processor();
55
        $params = $processor->processConfiguration(new Configuration\SubscriptionCreate(), [$params]);
56
57
        $response = $this->httpPostRaw('/v1/subscriptions', http_build_query($params), ['Content-Type' => 'application/x-www-form-urlencoded']);
58
59
        if (200 !== $response->getStatusCode()) {
60
            $this->handleErrors($response);
61
        }
62
63
        return $this->hydrator->hydrate($response, SubscriptionModel::class);
64
    }
65
66
    /**
67
     * @throws Exception
@@ 69-81 (lines=13) @@
66
    /**
67
     * @throws Exception
68
     */
69
    public function cancel(string $id, array $params = [])
70
    {
71
        $processor = new Processor();
72
        $params = $processor->processConfiguration(new Configuration\SubscriptionCancel(), [$params]);
73
74
        $response = $this->httpDelete("/v1/subscriptions/$id?".http_build_query($params));
75
76
        if (200 !== $response->getStatusCode()) {
77
            $this->handleErrors($response);
78
        }
79
80
        return $this->hydrator->hydrate($response, SubscriptionModel::class);
81
    }
82
83
    /**
84
     * @throws Exception