diff --git a/README.md b/README.md index dd60ebc..05c4dbc 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ In order to setup authentication and initialization of the API client, you need | Parameter | Description | |-----------|-------------| +| serviceRefererName | TODO: add a description | | basicAuthUserName | The username to use with basic authentication | | basicAuthPassword | The password to use with basic authentication | @@ -121,10 +122,11 @@ In order to setup authentication and initialization of the API client, you need API client can be initialized as following. ```php +$serviceRefererName = 'serviceRefererName'; $basicAuthUserName = 'basicAuthUserName'; // The username to use with basic authentication $basicAuthPassword = 'basicAuthPassword'; // The password to use with basic authentication -$client = new PagarmeCoreApiLib\PagarmeCoreApiClient($basicAuthUserName, $basicAuthPassword); +$client = new PagarmeCoreApiLib\PagarmeCoreApiClient($serviceRefererName, $basicAuthUserName, $basicAuthPassword); ``` @@ -140,8 +142,8 @@ $client = new PagarmeCoreApiLib\PagarmeCoreApiClient($basicAuthUserName, $basicA * [ChargesController](#charges_controller) * [RecipientsController](#recipients_controller) * [TokensController](#tokens_controller) -* [TransactionsController](#transactions_controller) * [TransfersController](#transfers_controller) +* [TransactionsController](#transactions_controller) ## ![Class: ](https://apidocs.io/img/class.png ".SubscriptionsController") SubscriptionsController @@ -199,16 +201,15 @@ $result = $subscriptions->updateSubscriptionCard($subscriptionId, $body, $idempo -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteUsage") deleteUsage +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createAnUsage") createAnUsage -> Deletes a usage +> Create Usage ```php -function deleteUsage( +function createAnUsage( $subscriptionId, $itemId, - $usageId, $idempotencyKey = null) ``` @@ -216,9 +217,8 @@ function deleteUsage( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| itemId | ``` Required ``` | The subscription item id | -| usageId | ``` Required ``` | The usage id | +| subscriptionId | ``` Required ``` | Subscription id | +| itemId | ``` Required ``` | Item id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -228,10 +228,9 @@ function deleteUsage( ```php $subscriptionId = 'subscription_id'; $itemId = 'item_id'; -$usageId = 'usage_id'; $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->deleteUsage($subscriptionId, $itemId, $usageId, $idempotencyKey); +$result = $subscriptions->createAnUsage($subscriptionId, $itemId, $idempotencyKey); ``` @@ -248,13 +247,13 @@ $result = $subscriptions->deleteUsage($subscriptionId, $itemId, $usageId, $idemp -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createDiscount") createDiscount +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionPaymentMethod") updateSubscriptionPaymentMethod -> Creates a discount +> Updates the payment method from a subscription ```php -function createDiscount( +function updateSubscriptionPaymentMethod( $subscriptionId, $body, $idempotencyKey = null) @@ -265,7 +264,7 @@ function createDiscount( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | Subscription id | -| body | ``` Required ``` | Request for creating a discount | +| body | ``` Required ``` | Request for updating the paymentmethod from a subscription | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -274,10 +273,10 @@ function createDiscount( ```php $subscriptionId = 'subscription_id'; -$body = new CreateDiscountRequest(); +$body = new UpdateSubscriptionPaymentMethodRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->createDiscount($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->updateSubscriptionPaymentMethod($subscriptionId, $body, $idempotencyKey); ``` @@ -294,15 +293,15 @@ $result = $subscriptions->createDiscount($subscriptionId, $body, $idempotencyKey -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createAnUsage") createAnUsage +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createSubscriptionItem") createSubscriptionItem -> Create Usage +> Creates a new Subscription item ```php -function createAnUsage( +function createSubscriptionItem( $subscriptionId, - $itemId, + $body, $idempotencyKey = null) ``` @@ -311,7 +310,7 @@ function createAnUsage( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | Subscription id | -| itemId | ``` Required ``` | Item id | +| body | ``` Required ``` | Request for creating a subscription item | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -320,10 +319,10 @@ function createAnUsage( ```php $subscriptionId = 'subscription_id'; -$itemId = 'item_id'; +$body = new CreateSubscriptionItemRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->createAnUsage($subscriptionId, $itemId, $idempotencyKey); +$result = $subscriptions->createSubscriptionItem($subscriptionId, $body, $idempotencyKey); ``` @@ -340,35 +339,23 @@ $result = $subscriptions->createAnUsage($subscriptionId, $itemId, $idempotencyKe -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getUsages") getUsages +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionItem") getSubscriptionItem -> Lists all usages from a subscription item +> Get Subscription Item ```php -function getUsages( +function getSubscriptionItem( $subscriptionId, - $itemId, - $page = null, - $size = null, - $code = null, - $group = null, - $usedSince = null, - $usedUntil = null) + $itemId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| itemId | ``` Required ``` | The subscription item id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| code | ``` Optional ``` | Identification code in the client system | -| group | ``` Optional ``` | Identification group in the client system | -| usedSince | ``` Optional ``` | TODO: Add a parameter description | -| usedUntil | ``` Optional ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | Subscription Id | +| itemId | ``` Required ``` | Item id | @@ -377,14 +364,8 @@ function getUsages( ```php $subscriptionId = 'subscription_id'; $itemId = 'item_id'; -$page = 150; -$size = 150; -$code = 'code'; -$group = 'group'; -$usedSince = date("D M d, Y G:i"); -$usedUntil = date("D M d, Y G:i"); -$result = $subscriptions->getUsages($subscriptionId, $itemId, $page, $size, $code, $group, $usedSince, $usedUntil); +$result = $subscriptions->getSubscriptionItem($subscriptionId, $itemId); ``` @@ -401,13 +382,13 @@ $result = $subscriptions->getUsages($subscriptionId, $itemId, $page, $size, $cod -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateCurrentCycleStatus") updateCurrentCycleStatus +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionAffiliationId") updateSubscriptionAffiliationId -> UpdateCurrentCycleStatus +> UpdateSubscriptionAffiliationId ```php -function updateCurrentCycleStatus( +function updateSubscriptionAffiliationId( $subscriptionId, $body, $idempotencyKey = null) @@ -417,8 +398,8 @@ function updateCurrentCycleStatus( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription Id | -| body | ``` Required ``` | Request for updating the end date of the subscription current status | +| subscriptionId | ``` Required ``` | TODO: Add a parameter description | +| body | ``` Required ``` | Request for updating a subscription affiliation id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -427,10 +408,10 @@ function updateCurrentCycleStatus( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateCurrentCycleStatusRequest(); +$body = new UpdateSubscriptionAffiliationIdRequest(); $idempotencyKey = 'idempotency-key'; -$subscriptions->updateCurrentCycleStatus($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->updateSubscriptionAffiliationId($subscriptionId, $body, $idempotencyKey); ``` @@ -447,13 +428,59 @@ $subscriptions->updateCurrentCycleStatus($subscriptionId, $body, $idempotencyKey -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionPaymentMethod") updateSubscriptionPaymentMethod +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getIncrements") getIncrements -> Updates the payment method from a subscription +> GetIncrements ```php -function updateSubscriptionPaymentMethod( +function getIncrements( + $subscriptionId, + $page = null, + $size = null) +``` + +#### Parameters + +| Parameter | Tags | Description | +|-----------|------|-------------| +| subscriptionId | ``` Required ``` | The subscription id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | + + + +#### Example Usage + +```php +$subscriptionId = 'subscription_id'; +$page = 188; +$size = 188; + +$result = $subscriptions->getIncrements($subscriptionId, $page, $size); + +``` + +#### Errors + +| Error Code | Error Description | +|------------|-------------------| +| 400 | Invalid request | +| 401 | Invalid API key | +| 404 | An informed resource was not found | +| 412 | Business validation error | +| 422 | Contract validation error | +| 500 | Internal server error | + + + +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionDueDays") updateSubscriptionDueDays + +> Updates the boleto due days from a subscription + + +```php +function updateSubscriptionDueDays( $subscriptionId, $body, $idempotencyKey = null) @@ -463,8 +490,8 @@ function updateSubscriptionPaymentMethod( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| body | ``` Required ``` | Request for updating the paymentmethod from a subscription | +| subscriptionId | ``` Required ``` | Subscription Id | +| body | ``` Required ``` | TODO: Add a parameter description | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -473,10 +500,10 @@ function updateSubscriptionPaymentMethod( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionPaymentMethodRequest(); +$body = new UpdateSubscriptionDueDaysRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->updateSubscriptionPaymentMethod($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->updateSubscriptionDueDays($subscriptionId, $body, $idempotencyKey); ``` @@ -493,15 +520,15 @@ $result = $subscriptions->updateSubscriptionPaymentMethod($subscriptionId, $body -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteDiscount") deleteDiscount +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionStartAt") updateSubscriptionStartAt -> Deletes a discount +> Updates the start at date from a subscription ```php -function deleteDiscount( +function updateSubscriptionStartAt( $subscriptionId, - $discountId, + $body, $idempotencyKey = null) ``` @@ -509,8 +536,8 @@ function deleteDiscount( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| discountId | ``` Required ``` | Discount Id | +| subscriptionId | ``` Required ``` | The subscription id | +| body | ``` Required ``` | Request for updating the subscription start date | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -519,10 +546,10 @@ function deleteDiscount( ```php $subscriptionId = 'subscription_id'; -$discountId = 'discount_id'; +$body = new UpdateSubscriptionStartAtRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->deleteDiscount($subscriptionId, $discountId, $idempotencyKey); +$result = $subscriptions->updateSubscriptionStartAt($subscriptionId, $body, $idempotencyKey); ``` @@ -539,22 +566,15 @@ $result = $subscriptions->deleteDiscount($subscriptionId, $discountId, $idempote -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionItems") getSubscriptionItems +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionCycleById") getSubscriptionCycleById -> Get Subscription Items +> GetSubscriptionCycleById ```php -function getSubscriptionItems( +function getSubscriptionCycleById( $subscriptionId, - $page = null, - $size = null, - $name = null, - $code = null, - $status = null, - $description = null, - $createdSince = null, - $createdUntil = null) + $cycleId) ``` #### Parameters @@ -562,14 +582,7 @@ function getSubscriptionItems( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | The subscription id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| name | ``` Optional ``` | The item name | -| code | ``` Optional ``` | Identification code in the client system | -| status | ``` Optional ``` | The item statis | -| description | ``` Optional ``` | The item description | -| createdSince | ``` Optional ``` | Filter for item's creation date start range | -| createdUntil | ``` Optional ``` | Filter for item's creation date end range | +| cycleId | ``` Required ``` | TODO: Add a parameter description | @@ -577,16 +590,9 @@ function getSubscriptionItems( ```php $subscriptionId = 'subscription_id'; -$page = 150; -$size = 150; -$name = 'name'; -$code = 'code'; -$status = 'status'; -$description = 'description'; -$createdSince = 'created_since'; -$createdUntil = 'created_until'; +$cycleId = 'cycleId'; -$result = $subscriptions->getSubscriptionItems($subscriptionId, $page, $size, $name, $code, $status, $description, $createdSince, $createdUntil); +$result = $subscriptions->getSubscriptionCycleById($subscriptionId, $cycleId); ``` @@ -603,15 +609,15 @@ $result = $subscriptions->getSubscriptionItems($subscriptionId, $page, $size, $n -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createSubscriptionItem") createSubscriptionItem +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteDiscount") deleteDiscount -> Creates a new Subscription item +> Deletes a discount ```php -function createSubscriptionItem( +function deleteDiscount( $subscriptionId, - $body, + $discountId, $idempotencyKey = null) ``` @@ -620,7 +626,7 @@ function createSubscriptionItem( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | Subscription id | -| body | ``` Required ``` | Request for creating a subscription item | +| discountId | ``` Required ``` | Discount Id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -629,10 +635,10 @@ function createSubscriptionItem( ```php $subscriptionId = 'subscription_id'; -$body = new CreateSubscriptionItemRequest(); +$discountId = 'discount_id'; $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->createSubscriptionItem($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->deleteDiscount($subscriptionId, $discountId, $idempotencyKey); ``` @@ -649,23 +655,37 @@ $result = $subscriptions->createSubscriptionItem($subscriptionId, $body, $idempo -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionItem") getSubscriptionItem +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionItems") getSubscriptionItems -> Get Subscription Item +> Get Subscription Items ```php -function getSubscriptionItem( +function getSubscriptionItems( $subscriptionId, - $itemId) + $page = null, + $size = null, + $name = null, + $code = null, + $status = null, + $description = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription Id | -| itemId | ``` Required ``` | Item id | +| subscriptionId | ``` Required ``` | The subscription id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | +| name | ``` Optional ``` | The item name | +| code | ``` Optional ``` | Identification code in the client system | +| status | ``` Optional ``` | The item statis | +| description | ``` Optional ``` | The item description | +| createdSince | ``` Optional ``` | Filter for item's creation date start range | +| createdUntil | ``` Optional ``` | Filter for item's creation date end range | @@ -673,9 +693,16 @@ function getSubscriptionItem( ```php $subscriptionId = 'subscription_id'; -$itemId = 'item_id'; +$page = 188; +$size = 188; +$name = 'name'; +$code = 'code'; +$status = 'status'; +$description = 'description'; +$createdSince = 'created_since'; +$createdUntil = 'created_until'; -$result = $subscriptions->getSubscriptionItem($subscriptionId, $itemId); +$result = $subscriptions->getSubscriptionItems($subscriptionId, $page, $size, $name, $code, $status, $description, $createdSince, $createdUntil); ``` @@ -741,82 +768,9 @@ $result = $subscriptions->updateSubscriptionItem($subscriptionId, $itemId, $body -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptions") getSubscriptions +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createSubscription") createSubscription -> Gets all subscriptions - - -```php -function getSubscriptions( - $page = null, - $size = null, - $code = null, - $billingType = null, - $customerId = null, - $planId = null, - $cardId = null, - $status = null, - $nextBillingSince = null, - $nextBillingUntil = null, - $createdSince = null, - $createdUntil = null) -``` - -#### Parameters - -| Parameter | Tags | Description | -|-----------|------|-------------| -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| code | ``` Optional ``` | Filter for subscription's code | -| billingType | ``` Optional ``` | Filter for subscription's billing type | -| customerId | ``` Optional ``` | Filter for subscription's customer id | -| planId | ``` Optional ``` | Filter for subscription's plan id | -| cardId | ``` Optional ``` | Filter for subscription's card id | -| status | ``` Optional ``` | Filter for subscription's status | -| nextBillingSince | ``` Optional ``` | Filter for subscription's next billing date start range | -| nextBillingUntil | ``` Optional ``` | Filter for subscription's next billing date end range | -| createdSince | ``` Optional ``` | Filter for subscription's creation date start range | -| createdUntil | ``` Optional ``` | Filter for subscriptions creation date end range | - - - -#### Example Usage - -```php -$page = 150; -$size = 150; -$code = 'code'; -$billingType = 'billing_type'; -$customerId = 'customer_id'; -$planId = 'plan_id'; -$cardId = 'card_id'; -$status = 'status'; -$nextBillingSince = date("D M d, Y G:i"); -$nextBillingUntil = date("D M d, Y G:i"); -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); - -$result = $subscriptions->getSubscriptions($page, $size, $code, $billingType, $customerId, $planId, $cardId, $status, $nextBillingSince, $nextBillingUntil, $createdSince, $createdUntil); - -``` - -#### Errors - -| Error Code | Error Description | -|------------|-------------------| -| 400 | Invalid request | -| 401 | Invalid API key | -| 404 | An informed resource was not found | -| 412 | Business validation error | -| 422 | Contract validation error | -| 500 | Internal server error | - - - -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createSubscription") createSubscription - -> Creates a new subscription +> Creates a new subscription ```php @@ -857,25 +811,23 @@ $result = $subscriptions->createSubscription($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.cancelSubscription") cancelSubscription +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getDiscountById") getDiscountById -> Cancels a subscription +> GetDiscountById ```php -function cancelSubscription( +function getDiscountById( $subscriptionId, - $idempotencyKey = null, - $body = null) + $discountId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | -| body | ``` Optional ``` | Request for cancelling a subscription | +| subscriptionId | ``` Required ``` | The subscription id | +| discountId | ``` Required ``` | TODO: Add a parameter description | @@ -883,10 +835,9 @@ function cancelSubscription( ```php $subscriptionId = 'subscription_id'; -$idempotencyKey = 'idempotency-key'; -$body = new CreateCancelSubscriptionRequest(); +$discountId = 'discountId'; -$result = $subscriptions->cancelSubscription($subscriptionId, $idempotencyKey, $body); +$result = $subscriptions->getDiscountById($subscriptionId, $discountId); ``` @@ -903,20 +854,25 @@ $result = $subscriptions->cancelSubscription($subscriptionId, $idempotencyKey, $ -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscription") getSubscription +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionBillingDate") updateSubscriptionBillingDate -> Gets a subscription +> Updates the billing date from a subscription ```php -function getSubscription($subscriptionId) +function updateSubscriptionBillingDate( + $subscriptionId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | +| subscriptionId | ``` Required ``` | The subscription id | +| body | ``` Required ``` | Request for updating the subscription billing date | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -924,8 +880,10 @@ function getSubscription($subscriptionId) ```php $subscriptionId = 'subscription_id'; +$body = new UpdateSubscriptionBillingDateRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->getSubscription($subscriptionId); +$result = $subscriptions->updateSubscriptionBillingDate($subscriptionId, $body, $idempotencyKey); ``` @@ -942,13 +900,13 @@ $result = $subscriptions->getSubscription($subscriptionId); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createIncrement") createIncrement +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateLatestPeriodEndAt") updateLatestPeriodEndAt -> Creates a increment +> UpdateLatestPeriodEndAt ```php -function createIncrement( +function updateLatestPeriodEndAt( $subscriptionId, $body, $idempotencyKey = null) @@ -958,8 +916,8 @@ function createIncrement( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| body | ``` Required ``` | Request for creating a increment | +| subscriptionId | ``` Required ``` | TODO: Add a parameter description | +| body | ``` Required ``` | Request for updating the end date of the current signature cycle | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -968,10 +926,10 @@ function createIncrement( ```php $subscriptionId = 'subscription_id'; -$body = new CreateIncrementRequest(); +$body = new UpdateCurrentCycleEndDateRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->createIncrement($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->updateLatestPeriodEndAt($subscriptionId, $body, $idempotencyKey); ``` @@ -988,23 +946,25 @@ $result = $subscriptions->createIncrement($subscriptionId, $body, $idempotencyKe -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getDiscountById") getDiscountById +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createDiscount") createDiscount -> GetDiscountById +> Creates a discount ```php -function getDiscountById( +function createDiscount( $subscriptionId, - $discountId) + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| discountId | ``` Required ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | Subscription id | +| body | ``` Required ``` | Request for creating a discount | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1012,9 +972,10 @@ function getDiscountById( ```php $subscriptionId = 'subscription_id'; -$discountId = 'discountId'; +$body = new CreateDiscountRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->getDiscountById($subscriptionId, $discountId); +$result = $subscriptions->createDiscount($subscriptionId, $body, $idempotencyKey); ``` @@ -1031,15 +992,16 @@ $result = $subscriptions->getDiscountById($subscriptionId, $discountId); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionAffiliationId") updateSubscriptionAffiliationId +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteUsage") deleteUsage -> UpdateSubscriptionAffiliationId +> Deletes a usage ```php -function updateSubscriptionAffiliationId( +function deleteUsage( $subscriptionId, - $body, + $itemId, + $usageId, $idempotencyKey = null) ``` @@ -1047,8 +1009,9 @@ function updateSubscriptionAffiliationId( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | TODO: Add a parameter description | -| body | ``` Required ``` | Request for updating a subscription affiliation id | +| subscriptionId | ``` Required ``` | The subscription id | +| itemId | ``` Required ``` | The subscription item id | +| usageId | ``` Required ``` | The usage id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1057,10 +1020,11 @@ function updateSubscriptionAffiliationId( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionAffiliationIdRequest(); +$itemId = 'item_id'; +$usageId = 'usage_id'; $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->updateSubscriptionAffiliationId($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->deleteUsage($subscriptionId, $itemId, $usageId, $idempotencyKey); ``` @@ -1077,16 +1041,21 @@ $result = $subscriptions->updateSubscriptionAffiliationId($subscriptionId, $body -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionMetadata") updateSubscriptionMetadata +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getUsages") getUsages -> Updates the metadata from a subscription +> Lists all usages from a subscription item ```php -function updateSubscriptionMetadata( +function getUsages( $subscriptionId, - $body, - $idempotencyKey = null) + $itemId, + $page = null, + $size = null, + $code = null, + $group = null, + $usedSince = null, + $usedUntil = null) ``` #### Parameters @@ -1094,8 +1063,13 @@ function updateSubscriptionMetadata( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | The subscription id | -| body | ``` Required ``` | Request for updating the subscrption metadata | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| itemId | ``` Required ``` | The subscription item id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | +| code | ``` Optional ``` | Identification code in the client system | +| group | ``` Optional ``` | Identification group in the client system | +| usedSince | ``` Optional ``` | TODO: Add a parameter description | +| usedUntil | ``` Optional ``` | TODO: Add a parameter description | @@ -1103,10 +1077,15 @@ function updateSubscriptionMetadata( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateMetadataRequest(); -$idempotencyKey = 'idempotency-key'; +$itemId = 'item_id'; +$page = 229; +$size = 229; +$code = 'code'; +$group = 'group'; +$usedSince = date("D M d, Y G:i"); +$usedUntil = date("D M d, Y G:i"); -$result = $subscriptions->updateSubscriptionMetadata($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->getUsages($subscriptionId, $itemId, $page, $size, $code, $group, $usedSince, $usedUntil); ``` @@ -1123,15 +1102,15 @@ $result = $subscriptions->updateSubscriptionMetadata($subscriptionId, $body, $id -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteIncrement") deleteIncrement +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateCurrentCycleStatus") updateCurrentCycleStatus -> Deletes a increment +> UpdateCurrentCycleStatus ```php -function deleteIncrement( +function updateCurrentCycleStatus( $subscriptionId, - $incrementId, + $body, $idempotencyKey = null) ``` @@ -1139,8 +1118,8 @@ function deleteIncrement( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| incrementId | ``` Required ``` | Increment id | +| subscriptionId | ``` Required ``` | Subscription Id | +| body | ``` Required ``` | Request for updating the end date of the subscription current status | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1149,10 +1128,10 @@ function deleteIncrement( ```php $subscriptionId = 'subscription_id'; -$incrementId = 'increment_id'; +$body = new UpdateCurrentCycleStatusRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->deleteIncrement($subscriptionId, $incrementId, $idempotencyKey); +$subscriptions->updateCurrentCycleStatus($subscriptionId, $body, $idempotencyKey); ``` @@ -1169,23 +1148,25 @@ $result = $subscriptions->deleteIncrement($subscriptionId, $incrementId, $idempo -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getIncrementById") getIncrementById +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.cancelSubscription") cancelSubscription -> GetIncrementById +> Cancels a subscription ```php -function getIncrementById( +function cancelSubscription( $subscriptionId, - $incrementId) + $idempotencyKey = null, + $body = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription Id | -| incrementId | ``` Required ``` | The increment Id | +| subscriptionId | ``` Required ``` | Subscription id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| body | ``` Optional ``` | Request for cancelling a subscription | @@ -1193,9 +1174,10 @@ function getIncrementById( ```php $subscriptionId = 'subscription_id'; -$incrementId = 'increment_id'; +$idempotencyKey = 'idempotency-key'; +$body = new CreateCancelSubscriptionRequest(); -$result = $subscriptions->getIncrementById($subscriptionId, $incrementId); +$result = $subscriptions->cancelSubscription($subscriptionId, $idempotencyKey, $body); ``` @@ -1212,25 +1194,25 @@ $result = $subscriptions->getIncrementById($subscriptionId, $incrementId); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionCycles") getSubscriptionCycles +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.createIncrement") createIncrement -> GetSubscriptionCycles +> Creates a increment ```php -function getSubscriptionCycles( +function createIncrement( $subscriptionId, - $page, - $size) + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription Id | -| page | ``` Required ``` | Page number | -| size | ``` Required ``` | Page size | +| subscriptionId | ``` Required ``` | Subscription id | +| body | ``` Required ``` | Request for creating a increment | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1238,10 +1220,10 @@ function getSubscriptionCycles( ```php $subscriptionId = 'subscription_id'; -$page = 'page'; -$size = 'size'; +$body = new CreateIncrementRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->getSubscriptionCycles($subscriptionId, $page, $size); +$result = $subscriptions->createIncrement($subscriptionId, $body, $idempotencyKey); ``` @@ -1258,14 +1240,15 @@ $result = $subscriptions->getSubscriptionCycles($subscriptionId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.renewSubscription") renewSubscription +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionMetadata") updateSubscriptionMetadata -> RenewSubscription +> Updates the metadata from a subscription ```php -function renewSubscription( +function updateSubscriptionMetadata( $subscriptionId, + $body, $idempotencyKey = null) ``` @@ -1273,7 +1256,8 @@ function renewSubscription( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | The subscription id | +| body | ``` Required ``` | Request for updating the subscrption metadata | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1282,9 +1266,10 @@ function renewSubscription( ```php $subscriptionId = 'subscription_id'; +$body = new UpdateMetadataRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->renewSubscription($subscriptionId, $idempotencyKey); +$result = $subscriptions->updateSubscriptionMetadata($subscriptionId, $body, $idempotencyKey); ``` @@ -1327,8 +1312,8 @@ function getDiscounts( ```php $subscriptionId = 'subscription_id'; -$page = 241; -$size = 241; +$page = 229; +$size = 229; $result = $subscriptions->getDiscounts($subscriptionId, $page, $size); @@ -1347,13 +1332,13 @@ $result = $subscriptions->getDiscounts($subscriptionId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionBillingDate") updateSubscriptionBillingDate +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionMiniumPrice") updateSubscriptionMiniumPrice -> Updates the billing date from a subscription +> Atualização do valor mínimo da assinatura ```php -function updateSubscriptionBillingDate( +function updateSubscriptionMiniumPrice( $subscriptionId, $body, $idempotencyKey = null) @@ -1363,8 +1348,8 @@ function updateSubscriptionBillingDate( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| body | ``` Required ``` | Request for updating the subscription billing date | +| subscriptionId | ``` Required ``` | Subscription Id | +| body | ``` Required ``` | Request da requisição com o valor mínimo que será configurado | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1373,10 +1358,10 @@ function updateSubscriptionBillingDate( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionBillingDateRequest(); +$body = new UpdateSubscriptionMinimumPriceRequest(); $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->updateSubscriptionBillingDate($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->updateSubscriptionMiniumPrice($subscriptionId, $body, $idempotencyKey); ``` @@ -1393,36 +1378,33 @@ $result = $subscriptions->updateSubscriptionBillingDate($subscriptionId, $body, -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteSubscriptionItem") deleteSubscriptionItem +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSplitSubscription") updateSplitSubscription -> Deletes a subscription item +> UpdateSplitSubscription ```php -function deleteSubscriptionItem( - $subscriptionId, - $subscriptionItemId, - $idempotencyKey = null) +function updateSplitSubscription( + $id, + $body) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription id | -| subscriptionItemId | ``` Required ``` | Subscription item id | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| id | ``` Required ``` | Subscription's id | +| body | ``` Required ``` | TODO: Add a parameter description | #### Example Usage ```php -$subscriptionId = 'subscription_id'; -$subscriptionItemId = 'subscription_item_id'; -$idempotencyKey = 'idempotency-key'; +$id = 'id'; +$body = new UpdateSubscriptionSplitRequest(); -$result = $subscriptions->deleteSubscriptionItem($subscriptionId, $subscriptionItemId, $idempotencyKey); +$result = $subscriptions->updateSplitSubscription($id, $body); ``` @@ -1439,36 +1421,63 @@ $result = $subscriptions->deleteSubscriptionItem($subscriptionId, $subscriptionI -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getIncrements") getIncrements +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptions") getSubscriptions -> GetIncrements +> Gets all subscriptions ```php -function getIncrements( - $subscriptionId, +function getSubscriptions( $page = null, - $size = null) + $size = null, + $code = null, + $billingType = null, + $customerId = null, + $planId = null, + $cardId = null, + $status = null, + $nextBillingSince = null, + $nextBillingUntil = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | | page | ``` Optional ``` | Page number | | size | ``` Optional ``` | Page size | +| code | ``` Optional ``` | Filter for subscription's code | +| billingType | ``` Optional ``` | Filter for subscription's billing type | +| customerId | ``` Optional ``` | Filter for subscription's customer id | +| planId | ``` Optional ``` | Filter for subscription's plan id | +| cardId | ``` Optional ``` | Filter for subscription's card id | +| status | ``` Optional ``` | Filter for subscription's status | +| nextBillingSince | ``` Optional ``` | Filter for subscription's next billing date start range | +| nextBillingUntil | ``` Optional ``` | Filter for subscription's next billing date end range | +| createdSince | ``` Optional ``` | Filter for subscription's creation date start range | +| createdUntil | ``` Optional ``` | Filter for subscriptions creation date end range | #### Example Usage ```php -$subscriptionId = 'subscription_id'; -$page = 241; -$size = 241; +$page = 229; +$size = 229; +$code = 'code'; +$billingType = 'billing_type'; +$customerId = 'customer_id'; +$planId = 'plan_id'; +$cardId = 'card_id'; +$status = 'status'; +$nextBillingSince = date("D M d, Y G:i"); +$nextBillingUntil = date("D M d, Y G:i"); +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $subscriptions->getIncrements($subscriptionId, $page, $size); +$result = $subscriptions->getSubscriptions($page, $size, $code, $billingType, $customerId, $planId, $cardId, $status, $nextBillingSince, $nextBillingUntil, $createdSince, $createdUntil); ``` @@ -1485,25 +1494,20 @@ $result = $subscriptions->getIncrements($subscriptionId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionDueDays") updateSubscriptionDueDays +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscription") getSubscription -> Updates the boleto due days from a subscription +> Gets a subscription ```php -function updateSubscriptionDueDays( - $subscriptionId, - $body, - $idempotencyKey = null) +function getSubscription($subscriptionId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription Id | -| body | ``` Required ``` | TODO: Add a parameter description | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | Subscription id | @@ -1511,10 +1515,8 @@ function updateSubscriptionDueDays( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionDueDaysRequest(); -$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->updateSubscriptionDueDays($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->getSubscription($subscriptionId); ``` @@ -1531,15 +1533,15 @@ $result = $subscriptions->updateSubscriptionDueDays($subscriptionId, $body, $ide -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionStartAt") updateSubscriptionStartAt +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteIncrement") deleteIncrement -> Updates the start at date from a subscription +> Deletes a increment ```php -function updateSubscriptionStartAt( +function deleteIncrement( $subscriptionId, - $body, + $incrementId, $idempotencyKey = null) ``` @@ -1547,8 +1549,8 @@ function updateSubscriptionStartAt( | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| body | ``` Required ``` | Request for updating the subscription start date | +| subscriptionId | ``` Required ``` | Subscription id | +| incrementId | ``` Required ``` | Increment id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1557,10 +1559,10 @@ function updateSubscriptionStartAt( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionStartAtRequest(); +$incrementId = 'increment_id'; $idempotencyKey = 'idempotency-key'; -$result = $subscriptions->updateSubscriptionStartAt($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->deleteIncrement($subscriptionId, $incrementId, $idempotencyKey); ``` @@ -1577,25 +1579,23 @@ $result = $subscriptions->updateSubscriptionStartAt($subscriptionId, $body, $ide -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateLatestPeriodEndAt") updateLatestPeriodEndAt +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getIncrementById") getIncrementById -> UpdateLatestPeriodEndAt +> GetIncrementById ```php -function updateLatestPeriodEndAt( +function getIncrementById( $subscriptionId, - $body, - $idempotencyKey = null) + $incrementId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | TODO: Add a parameter description | -| body | ``` Required ``` | Request for updating the end date of the current signature cycle | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | The subscription Id | +| incrementId | ``` Required ``` | The increment Id | @@ -1603,10 +1603,9 @@ function updateLatestPeriodEndAt( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateCurrentCycleEndDateRequest(); -$idempotencyKey = 'idempotency-key'; +$incrementId = 'increment_id'; -$result = $subscriptions->updateLatestPeriodEndAt($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->getIncrementById($subscriptionId, $incrementId); ``` @@ -1623,16 +1622,16 @@ $result = $subscriptions->updateLatestPeriodEndAt($subscriptionId, $body, $idemp -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSubscriptionMiniumPrice") updateSubscriptionMiniumPrice +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionCycles") getSubscriptionCycles -> Atualização do valor mínimo da assinatura +> GetSubscriptionCycles ```php -function updateSubscriptionMiniumPrice( +function getSubscriptionCycles( $subscriptionId, - $body, - $idempotencyKey = null) + $page, + $size) ``` #### Parameters @@ -1640,8 +1639,8 @@ function updateSubscriptionMiniumPrice( | Parameter | Tags | Description | |-----------|------|-------------| | subscriptionId | ``` Required ``` | Subscription Id | -| body | ``` Required ``` | Request da requisição com o valor mínimo que será configurado | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| page | ``` Required ``` | Page number | +| size | ``` Required ``` | Page size | @@ -1649,10 +1648,10 @@ function updateSubscriptionMiniumPrice( ```php $subscriptionId = 'subscription_id'; -$body = new UpdateSubscriptionMinimumPriceRequest(); -$idempotencyKey = 'idempotency-key'; +$page = 'page'; +$size = 'size'; -$result = $subscriptions->updateSubscriptionMiniumPrice($subscriptionId, $body, $idempotencyKey); +$result = $subscriptions->getSubscriptionCycles($subscriptionId, $page, $size); ``` @@ -1669,23 +1668,23 @@ $result = $subscriptions->updateSubscriptionMiniumPrice($subscriptionId, $body, -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getSubscriptionCycleById") getSubscriptionCycleById +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.renewSubscription") renewSubscription -> GetSubscriptionCycleById +> RenewSubscription ```php -function getSubscriptionCycleById( +function renewSubscription( $subscriptionId, - $cycleId) + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | -|-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription id | -| cycleId | ``` Required ``` | TODO: Add a parameter description | +|-----------|------|-------------| +| subscriptionId | ``` Required ``` | TODO: Add a parameter description | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1693,9 +1692,9 @@ function getSubscriptionCycleById( ```php $subscriptionId = 'subscription_id'; -$cycleId = 'cycleId'; +$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->getSubscriptionCycleById($subscriptionId, $cycleId); +$result = $subscriptions->renewSubscription($subscriptionId, $idempotencyKey); ``` @@ -1712,23 +1711,25 @@ $result = $subscriptions->getSubscriptionCycleById($subscriptionId, $cycleId); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getUsageReport") getUsageReport +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.deleteSubscriptionItem") deleteSubscriptionItem -> GetUsageReport +> Deletes a subscription item ```php -function getUsageReport( +function deleteSubscriptionItem( $subscriptionId, - $periodId) + $subscriptionItemId, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | The subscription Id | -| periodId | ``` Required ``` | The period Id | +| subscriptionId | ``` Required ``` | Subscription id | +| subscriptionItemId | ``` Required ``` | Subscription item id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1736,9 +1737,10 @@ function getUsageReport( ```php $subscriptionId = 'subscription_id'; -$periodId = 'period_id'; +$subscriptionItemId = 'subscription_item_id'; +$idempotencyKey = 'idempotency-key'; -$result = $subscriptions->getUsageReport($subscriptionId, $periodId); +$result = $subscriptions->deleteSubscriptionItem($subscriptionId, $subscriptionItemId, $idempotencyKey); ``` @@ -1755,33 +1757,33 @@ $result = $subscriptions->getUsageReport($subscriptionId, $periodId); -### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.updateSplitSubscription") updateSplitSubscription +### ![Method: ](https://apidocs.io/img/method.png ".SubscriptionsController.getUsageReport") getUsageReport -> UpdateSplitSubscription +> GetUsageReport ```php -function updateSplitSubscription( - $id, - $body) +function getUsageReport( + $subscriptionId, + $periodId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| id | ``` Required ``` | Subscription's id | -| body | ``` Required ``` | TODO: Add a parameter description | +| subscriptionId | ``` Required ``` | The subscription Id | +| periodId | ``` Required ``` | The period Id | #### Example Usage ```php -$id = 'id'; -$body = new UpdateSubscriptionSplitRequest(); +$subscriptionId = 'subscription_id'; +$periodId = 'period_id'; -$result = $subscriptions->updateSplitSubscription($id, $body); +$result = $subscriptions->getUsageReport($subscriptionId, $periodId); ``` @@ -1843,8 +1845,8 @@ function getOrders( #### Example Usage ```php -$page = 241; -$size = 241; +$page = 229; +$size = 229; $code = 'code'; $status = 'status'; $createdSince = date("D M d, Y G:i"); @@ -1911,14 +1913,15 @@ $result = $orders->createOrder($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.deleteAllOrderItems") deleteAllOrderItems +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.createOrderItem") createOrderItem -> DeleteAllOrderItems +> CreateOrderItem ```php -function deleteAllOrderItems( +function createOrderItem( $orderId, + $body, $idempotencyKey = null) ``` @@ -1927,6 +1930,7 @@ function deleteAllOrderItems( | Parameter | Tags | Description | |-----------|------|-------------| | orderId | ``` Required ``` | Order Id | +| body | ``` Required ``` | Order Item Model | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -1935,9 +1939,10 @@ function deleteAllOrderItems( ```php $orderId = 'orderId'; +$body = new CreateOrderItemRequest(); $idempotencyKey = 'idempotency-key'; -$result = $orders->deleteAllOrderItems($orderId, $idempotencyKey); +$result = $orders->createOrderItem($orderId, $body, $idempotencyKey); ``` @@ -1954,16 +1959,15 @@ $result = $orders->deleteAllOrderItems($orderId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.createOrderItem") createOrderItem +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.getOrderItem") getOrderItem -> CreateOrderItem +> GetOrderItem ```php -function createOrderItem( +function getOrderItem( $orderId, - $body, - $idempotencyKey = null) + $itemId) ``` #### Parameters @@ -1971,8 +1975,7 @@ function createOrderItem( | Parameter | Tags | Description | |-----------|------|-------------| | orderId | ``` Required ``` | Order Id | -| body | ``` Required ``` | Order Item Model | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| itemId | ``` Required ``` | Item Id | @@ -1980,10 +1983,9 @@ function createOrderItem( ```php $orderId = 'orderId'; -$body = new CreateOrderItemRequest(); -$idempotencyKey = 'idempotency-key'; +$itemId = 'itemId'; -$result = $orders->createOrderItem($orderId, $body, $idempotencyKey); +$result = $orders->getOrderItem($orderId, $itemId); ``` @@ -2000,16 +2002,15 @@ $result = $orders->createOrderItem($orderId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.updateOrderItem") updateOrderItem +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.deleteOrderItem") deleteOrderItem -> UpdateOrderItem +> DeleteOrderItem ```php -function updateOrderItem( +function deleteOrderItem( $orderId, $itemId, - $body, $idempotencyKey = null) ``` @@ -2019,7 +2020,6 @@ function updateOrderItem( |-----------|------|-------------| | orderId | ``` Required ``` | Order Id | | itemId | ``` Required ``` | Item Id | -| body | ``` Required ``` | Item Model | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2029,10 +2029,9 @@ function updateOrderItem( ```php $orderId = 'orderId'; $itemId = 'itemId'; -$body = new UpdateOrderItemRequest(); $idempotencyKey = 'idempotency-key'; -$result = $orders->updateOrderItem($orderId, $itemId, $body, $idempotencyKey); +$result = $orders->deleteOrderItem($orderId, $itemId, $idempotencyKey); ``` @@ -2049,15 +2048,15 @@ $result = $orders->updateOrderItem($orderId, $itemId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.deleteOrderItem") deleteOrderItem +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.updateOrderMetadata") updateOrderMetadata -> DeleteOrderItem +> Updates the metadata from an order ```php -function deleteOrderItem( +function updateOrderMetadata( $orderId, - $itemId, + $body, $idempotencyKey = null) ``` @@ -2065,8 +2064,8 @@ function deleteOrderItem( | Parameter | Tags | Description | |-----------|------|-------------| -| orderId | ``` Required ``` | Order Id | -| itemId | ``` Required ``` | Item Id | +| orderId | ``` Required ``` | The order id | +| body | ``` Required ``` | Request for updating the order metadata | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2074,11 +2073,11 @@ function deleteOrderItem( #### Example Usage ```php -$orderId = 'orderId'; -$itemId = 'itemId'; +$orderId = 'order_id'; +$body = new UpdateMetadataRequest(); $idempotencyKey = 'idempotency-key'; -$result = $orders->deleteOrderItem($orderId, $itemId, $idempotencyKey); +$result = $orders->updateOrderMetadata($orderId, $body, $idempotencyKey); ``` @@ -2095,15 +2094,15 @@ $result = $orders->deleteOrderItem($orderId, $itemId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.getOrderItem") getOrderItem +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.deleteAllOrderItems") deleteAllOrderItems -> GetOrderItem +> DeleteAllOrderItems ```php -function getOrderItem( +function deleteAllOrderItems( $orderId, - $itemId) + $idempotencyKey = null) ``` #### Parameters @@ -2111,7 +2110,7 @@ function getOrderItem( | Parameter | Tags | Description | |-----------|------|-------------| | orderId | ``` Required ``` | Order Id | -| itemId | ``` Required ``` | Item Id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2119,9 +2118,9 @@ function getOrderItem( ```php $orderId = 'orderId'; -$itemId = 'itemId'; +$idempotencyKey = 'idempotency-key'; -$result = $orders->getOrderItem($orderId, $itemId); +$result = $orders->deleteAllOrderItems($orderId, $idempotencyKey); ``` @@ -2138,14 +2137,15 @@ $result = $orders->getOrderItem($orderId, $itemId); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.closeOrder") closeOrder +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.updateOrderItem") updateOrderItem -> CloseOrder +> UpdateOrderItem ```php -function closeOrder( - $id, +function updateOrderItem( + $orderId, + $itemId, $body, $idempotencyKey = null) ``` @@ -2154,8 +2154,9 @@ function closeOrder( | Parameter | Tags | Description | |-----------|------|-------------| -| id | ``` Required ``` | Order Id | -| body | ``` Required ``` | Update Order Model | +| orderId | ``` Required ``` | Order Id | +| itemId | ``` Required ``` | Item Id | +| body | ``` Required ``` | Item Model | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2163,11 +2164,12 @@ function closeOrder( #### Example Usage ```php -$id = 'id'; -$body = new UpdateOrderStatusRequest(); +$orderId = 'orderId'; +$itemId = 'itemId'; +$body = new UpdateOrderItemRequest(); $idempotencyKey = 'idempotency-key'; -$result = $orders->closeOrder($id, $body, $idempotencyKey); +$result = $orders->updateOrderItem($orderId, $itemId, $body, $idempotencyKey); ``` @@ -2184,14 +2186,14 @@ $result = $orders->closeOrder($id, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.updateOrderMetadata") updateOrderMetadata +### ![Method: ](https://apidocs.io/img/method.png ".OrdersController.closeOrder") closeOrder -> Updates the metadata from an order +> CloseOrder ```php -function updateOrderMetadata( - $orderId, +function closeOrder( + $id, $body, $idempotencyKey = null) ``` @@ -2200,8 +2202,8 @@ function updateOrderMetadata( | Parameter | Tags | Description | |-----------|------|-------------| -| orderId | ``` Required ``` | The order id | -| body | ``` Required ``` | Request for updating the order metadata | +| id | ``` Required ``` | Order Id | +| body | ``` Required ``` | Update Order Model | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2209,11 +2211,11 @@ function updateOrderMetadata( #### Example Usage ```php -$orderId = 'order_id'; -$body = new UpdateMetadataRequest(); +$id = 'id'; +$body = new UpdateOrderStatusRequest(); $idempotencyKey = 'idempotency-key'; -$result = $orders->updateOrderMetadata($orderId, $body, $idempotencyKey); +$result = $orders->closeOrder($id, $body, $idempotencyKey); ``` @@ -2320,14 +2322,13 @@ $result = $plans->getPlan($planId); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlan") updatePlan +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.createPlan") createPlan -> Updates a plan +> Creates a new plan ```php -function updatePlan( - $planId, +function createPlan( $body, $idempotencyKey = null) ``` @@ -2336,52 +2337,7 @@ function updatePlan( | Parameter | Tags | Description | |-----------|------|-------------| -| planId | ``` Required ``` | Plan id | -| body | ``` Required ``` | Request for updating a plan | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | - - - -#### Example Usage - -```php -$planId = 'plan_id'; -$body = new UpdatePlanRequest(); -$idempotencyKey = 'idempotency-key'; - -$result = $plans->updatePlan($planId, $body, $idempotencyKey); - -``` - -#### Errors - -| Error Code | Error Description | -|------------|-------------------| -| 400 | Invalid request | -| 401 | Invalid API key | -| 404 | An informed resource was not found | -| 412 | Business validation error | -| 422 | Contract validation error | -| 500 | Internal server error | - - - -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.deletePlan") deletePlan - -> Deletes a plan - - -```php -function deletePlan( - $planId, - $idempotencyKey = null) -``` - -#### Parameters - -| Parameter | Tags | Description | -|-----------|------|-------------| -| planId | ``` Required ``` | Plan id | +| body | ``` Required ``` | Request for creating a plan | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2389,10 +2345,10 @@ function deletePlan( #### Example Usage ```php -$planId = 'plan_id'; +$body = new CreatePlanRequest(); $idempotencyKey = 'idempotency-key'; -$result = $plans->deletePlan($planId, $idempotencyKey); +$result = $plans->createPlan($body, $idempotencyKey); ``` @@ -2409,13 +2365,13 @@ $result = $plans->deletePlan($planId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlanMetadata") updatePlanMetadata +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlan") updatePlan -> Updates the metadata from a plan +> Updates a plan ```php -function updatePlanMetadata( +function updatePlan( $planId, $body, $idempotencyKey = null) @@ -2425,8 +2381,8 @@ function updatePlanMetadata( | Parameter | Tags | Description | |-----------|------|-------------| -| planId | ``` Required ``` | The plan id | -| body | ``` Required ``` | Request for updating the plan metadata | +| planId | ``` Required ``` | Plan id | +| body | ``` Required ``` | Request for updating a plan | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2435,10 +2391,10 @@ function updatePlanMetadata( ```php $planId = 'plan_id'; -$body = new UpdateMetadataRequest(); +$body = new UpdatePlanRequest(); $idempotencyKey = 'idempotency-key'; -$result = $plans->updatePlanMetadata($planId, $body, $idempotencyKey); +$result = $plans->updatePlan($planId, $body, $idempotencyKey); ``` @@ -2455,17 +2411,15 @@ $result = $plans->updatePlanMetadata($planId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlanItem") updatePlanItem +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.getPlanItem") getPlanItem -> Updates a plan item +> Gets a plan item ```php -function updatePlanItem( +function getPlanItem( $planId, - $planItemId, - $body, - $idempotencyKey = null) + $planItemId) ``` #### Parameters @@ -2474,8 +2428,6 @@ function updatePlanItem( |-----------|------|-------------| | planId | ``` Required ``` | Plan id | | planItemId | ``` Required ``` | Plan item id | -| body | ``` Required ``` | Request for updating the plan item | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2484,10 +2436,8 @@ function updatePlanItem( ```php $planId = 'plan_id'; $planItemId = 'plan_item_id'; -$body = new UpdatePlanItemRequest(); -$idempotencyKey = 'idempotency-key'; -$result = $plans->updatePlanItem($planId, $planItemId, $body, $idempotencyKey); +$result = $plans->getPlanItem($planId, $planItemId); ``` @@ -2504,15 +2454,16 @@ $result = $plans->updatePlanItem($planId, $planItemId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.getPlanItem") getPlanItem +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.createPlanItem") createPlanItem -> Gets a plan item +> Adds a new item to a plan ```php -function getPlanItem( +function createPlanItem( $planId, - $planItemId) + $body, + $idempotencyKey = null) ``` #### Parameters @@ -2520,7 +2471,8 @@ function getPlanItem( | Parameter | Tags | Description | |-----------|------|-------------| | planId | ``` Required ``` | Plan id | -| planItemId | ``` Required ``` | Plan item id | +| body | ``` Required ``` | Request for creating a plan item | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2528,9 +2480,10 @@ function getPlanItem( ```php $planId = 'plan_id'; -$planItemId = 'plan_item_id'; +$body = new CreatePlanItemRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $plans->getPlanItem($planId, $planItemId); +$result = $plans->createPlanItem($planId, $body, $idempotencyKey); ``` @@ -2547,36 +2500,48 @@ $result = $plans->getPlanItem($planId, $planItemId); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.deletePlanItem") deletePlanItem +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.getPlans") getPlans -> Removes an item from a plan +> Gets all plans ```php -function deletePlanItem( - $planId, - $planItemId, - $idempotencyKey = null) +function getPlans( + $page = null, + $size = null, + $name = null, + $status = null, + $billingType = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| planId | ``` Required ``` | Plan id | -| planItemId | ``` Required ``` | Plan item id | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | +| name | ``` Optional ``` | Filter for Plan's name | +| status | ``` Optional ``` | Filter for Plan's status | +| billingType | ``` Optional ``` | Filter for plan's billing type | +| createdSince | ``` Optional ``` | Filter for plan's creation date start range | +| createdUntil | ``` Optional ``` | Filter for plan's creation date end range | #### Example Usage ```php -$planId = 'plan_id'; -$planItemId = 'plan_item_id'; -$idempotencyKey = 'idempotency-key'; +$page = 229; +$size = 229; +$name = 'name'; +$status = 'status'; +$billingType = 'billing_type'; +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $plans->deletePlanItem($planId, $planItemId, $idempotencyKey); +$result = $plans->getPlans($page, $size, $name, $status, $billingType, $createdSince, $createdUntil); ``` @@ -2593,15 +2558,14 @@ $result = $plans->deletePlanItem($planId, $planItemId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.createPlanItem") createPlanItem +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.deletePlan") deletePlan -> Adds a new item to a plan +> Deletes a plan ```php -function createPlanItem( +function deletePlan( $planId, - $body, $idempotencyKey = null) ``` @@ -2610,7 +2574,6 @@ function createPlanItem( | Parameter | Tags | Description | |-----------|------|-------------| | planId | ``` Required ``` | Plan id | -| body | ``` Required ``` | Request for creating a plan item | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2619,10 +2582,9 @@ function createPlanItem( ```php $planId = 'plan_id'; -$body = new CreatePlanItemRequest(); $idempotencyKey = 'idempotency-key'; -$result = $plans->createPlanItem($planId, $body, $idempotencyKey); +$result = $plans->deletePlan($planId, $idempotencyKey); ``` @@ -2639,13 +2601,14 @@ $result = $plans->createPlanItem($planId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.createPlan") createPlan +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlanMetadata") updatePlanMetadata -> Creates a new plan +> Updates the metadata from a plan ```php -function createPlan( +function updatePlanMetadata( + $planId, $body, $idempotencyKey = null) ``` @@ -2654,7 +2617,8 @@ function createPlan( | Parameter | Tags | Description | |-----------|------|-------------| -| body | ``` Required ``` | Request for creating a plan | +| planId | ``` Required ``` | The plan id | +| body | ``` Required ``` | Request for updating the plan metadata | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -2662,10 +2626,11 @@ function createPlan( #### Example Usage ```php -$body = new CreatePlanRequest(); +$planId = 'plan_id'; +$body = new UpdateMetadataRequest(); $idempotencyKey = 'idempotency-key'; -$result = $plans->createPlan($body, $idempotencyKey); +$result = $plans->updatePlanMetadata($planId, $body, $idempotencyKey); ``` @@ -2682,48 +2647,39 @@ $result = $plans->createPlan($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".PlansController.getPlans") getPlans +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.updatePlanItem") updatePlanItem -> Gets all plans +> Updates a plan item ```php -function getPlans( - $page = null, - $size = null, - $name = null, - $status = null, - $billingType = null, - $createdSince = null, - $createdUntil = null) +function updatePlanItem( + $planId, + $planItemId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| name | ``` Optional ``` | Filter for Plan's name | -| status | ``` Optional ``` | Filter for Plan's status | -| billingType | ``` Optional ``` | Filter for plan's billing type | -| createdSince | ``` Optional ``` | Filter for plan's creation date start range | -| createdUntil | ``` Optional ``` | Filter for plan's creation date end range | +| planId | ``` Required ``` | Plan id | +| planItemId | ``` Required ``` | Plan item id | +| body | ``` Required ``` | Request for updating the plan item | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | #### Example Usage ```php -$page = 241; -$size = 241; -$name = 'name'; -$status = 'status'; -$billingType = 'billing_type'; -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$planId = 'plan_id'; +$planItemId = 'plan_item_id'; +$body = new UpdatePlanItemRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $plans->getPlans($page, $size, $name, $status, $billingType, $createdSince, $createdUntil); +$result = $plans->updatePlanItem($planId, $planItemId, $body, $idempotencyKey); ``` @@ -2740,41 +2696,36 @@ $result = $plans->getPlans($page, $size, $name, $status, $billingType, $createdS -[Back to List of Controllers](#list_of_controllers) - -## ![Class: ](https://apidocs.io/img/class.png ".InvoicesController") InvoicesController - -### Get singleton instance - -The singleton instance of the ``` InvoicesController ``` class can be accessed from the API Client. - -```php -$invoices = $client->getInvoices(); -``` - -### ![Method: ](https://apidocs.io/img/method.png ".InvoicesController.getPartialInvoice") getPartialInvoice +### ![Method: ](https://apidocs.io/img/method.png ".PlansController.deletePlanItem") deletePlanItem -> GetPartialInvoice +> Removes an item from a plan ```php -function getPartialInvoice($subscriptionId) +function deletePlanItem( + $planId, + $planItemId, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| subscriptionId | ``` Required ``` | Subscription Id | +| planId | ``` Required ``` | Plan id | +| planItemId | ``` Required ``` | Plan item id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | #### Example Usage ```php -$subscriptionId = 'subscription_id'; +$planId = 'plan_id'; +$planItemId = 'plan_item_id'; +$idempotencyKey = 'idempotency-key'; -$result = $invoices->getPartialInvoice($subscriptionId); +$result = $plans->deletePlanItem($planId, $planItemId, $idempotencyKey); ``` @@ -2791,6 +2742,18 @@ $result = $invoices->getPartialInvoice($subscriptionId); +[Back to List of Controllers](#list_of_controllers) + +## ![Class: ](https://apidocs.io/img/class.png ".InvoicesController") InvoicesController + +### Get singleton instance + +The singleton instance of the ``` InvoicesController ``` class can be accessed from the API Client. + +```php +$invoices = $client->getInvoices(); +``` + ### ![Method: ](https://apidocs.io/img/method.png ".InvoicesController.cancelInvoice") cancelInvoice > Cancels an invoice @@ -3009,8 +2972,8 @@ function getInvoices( #### Example Usage ```php -$page = 241; -$size = 241; +$page = 229; +$size = 229; $code = 'code'; $customerId = 'customer_id'; $subscriptionId = 'subscription_id'; @@ -3038,6 +3001,45 @@ $result = $invoices->getInvoices($page, $size, $code, $customerId, $subscription +### ![Method: ](https://apidocs.io/img/method.png ".InvoicesController.getPartialInvoice") getPartialInvoice + +> GetPartialInvoice + + +```php +function getPartialInvoice($subscriptionId) +``` + +#### Parameters + +| Parameter | Tags | Description | +|-----------|------|-------------| +| subscriptionId | ``` Required ``` | Subscription Id | + + + +#### Example Usage + +```php +$subscriptionId = 'subscription_id'; + +$result = $invoices->getPartialInvoice($subscriptionId); + +``` + +#### Errors + +| Error Code | Error Description | +|------------|-------------------| +| 400 | Invalid request | +| 401 | Invalid API key | +| 404 | An informed resource was not found | +| 412 | Business validation error | +| 422 | Contract validation error | +| 500 | Internal server error | + + + ### ![Method: ](https://apidocs.io/img/method.png ".InvoicesController.updateInvoiceStatus") updateInvoiceStatus > Updates the status from an invoice @@ -3096,16 +3098,15 @@ The singleton instance of the ``` CustomersController ``` class can be accessed $customers = $client->getCustomers(); ``` -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCard") updateCard +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteCard") deleteCard -> Updates a card +> Delete a customer's card ```php -function updateCard( +function deleteCard( $customerId, $cardId, - $body, $idempotencyKey = null) ``` @@ -3114,8 +3115,7 @@ function updateCard( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| cardId | ``` Required ``` | Card id | -| body | ``` Required ``` | Request for updating a card | +| cardId | ``` Required ``` | Card Id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3125,10 +3125,9 @@ function updateCard( ```php $customerId = 'customer_id'; $cardId = 'card_id'; -$body = new UpdateCardRequest(); $idempotencyKey = 'idempotency-key'; -$result = $customers->updateCard($customerId, $cardId, $body, $idempotencyKey); +$result = $customers->deleteCard($customerId, $cardId, $idempotencyKey); ``` @@ -3145,15 +3144,16 @@ $result = $customers->updateCard($customerId, $cardId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteCard") deleteCard +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateAddress") updateAddress -> Delete a customer's card +> Updates an address ```php -function deleteCard( +function updateAddress( $customerId, - $cardId, + $addressId, + $body, $idempotencyKey = null) ``` @@ -3162,7 +3162,8 @@ function deleteCard( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| cardId | ``` Required ``` | Card Id | +| addressId | ``` Required ``` | Address Id | +| body | ``` Required ``` | Request for updating an address | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3171,10 +3172,11 @@ function deleteCard( ```php $customerId = 'customer_id'; -$cardId = 'card_id'; +$addressId = 'address_id'; +$body = new UpdateAddressRequest(); $idempotencyKey = 'idempotency-key'; -$result = $customers->deleteCard($customerId, $cardId, $idempotencyKey); +$result = $customers->updateAddress($customerId, $addressId, $body, $idempotencyKey); ``` @@ -3191,15 +3193,15 @@ $result = $customers->deleteCard($customerId, $cardId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCard") getCard +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAddress") getAddress -> Get a customer's card +> Get a customer's address ```php -function getCard( +function getAddress( $customerId, - $cardId) + $addressId) ``` #### Parameters @@ -3207,7 +3209,7 @@ function getCard( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer id | -| cardId | ``` Required ``` | Card id | +| addressId | ``` Required ``` | Address Id | @@ -3215,9 +3217,9 @@ function getCard( ```php $customerId = 'customer_id'; -$cardId = 'card_id'; +$addressId = 'address_id'; -$result = $customers->getCard($customerId, $cardId); +$result = $customers->getAddress($customerId, $addressId); ``` @@ -3234,17 +3236,16 @@ $result = $customers->getCard($customerId, $cardId); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateAddress") updateAddress +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAccessTokens") getAccessTokens -> Updates an address +> Get all access tokens from a customer ```php -function updateAddress( +function getAccessTokens( $customerId, - $addressId, - $body, - $idempotencyKey = null) + $page = null, + $size = null) ``` #### Parameters @@ -3252,9 +3253,8 @@ function updateAddress( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| addressId | ``` Required ``` | Address Id | -| body | ``` Required ``` | Request for updating an address | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | @@ -3262,11 +3262,10 @@ function updateAddress( ```php $customerId = 'customer_id'; -$addressId = 'address_id'; -$body = new UpdateAddressRequest(); -$idempotencyKey = 'idempotency-key'; +$page = 138; +$size = 138; -$result = $customers->updateAddress($customerId, $addressId, $body, $idempotencyKey); +$result = $customers->getAccessTokens($customerId, $page, $size); ``` @@ -3283,15 +3282,16 @@ $result = $customers->updateAddress($customerId, $addressId, $body, $idempotency -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAddress") getAddress +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCustomer") updateCustomer -> Get a customer's address +> Updates a customer ```php -function getAddress( +function updateCustomer( $customerId, - $addressId) + $body, + $idempotencyKey = null) ``` #### Parameters @@ -3299,7 +3299,8 @@ function getAddress( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer id | -| addressId | ``` Required ``` | Address Id | +| body | ``` Required ``` | Request for updating a customer | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3307,9 +3308,10 @@ function getAddress( ```php $customerId = 'customer_id'; -$addressId = 'address_id'; +$body = new UpdateCustomerRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $customers->getAddress($customerId, $addressId); +$result = $customers->updateCustomer($customerId, $body, $idempotencyKey); ``` @@ -3326,15 +3328,15 @@ $result = $customers->getAddress($customerId, $addressId); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAddress") deleteAddress +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.renewCard") renewCard -> Delete a Customer's address +> Renew a card ```php -function deleteAddress( +function renewCard( $customerId, - $addressId, + $cardId, $idempotencyKey = null) ``` @@ -3342,8 +3344,8 @@ function deleteAddress( | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer Id | -| addressId | ``` Required ``` | Address Id | +| customerId | ``` Required ``` | Customer id | +| cardId | ``` Required ``` | Card Id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3352,10 +3354,10 @@ function deleteAddress( ```php $customerId = 'customer_id'; -$addressId = 'address_id'; +$cardId = 'card_id'; $idempotencyKey = 'idempotency-key'; -$result = $customers->deleteAddress($customerId, $addressId, $idempotencyKey); +$result = $customers->renewCard($customerId, $cardId, $idempotencyKey); ``` @@ -3372,36 +3374,45 @@ $result = $customers->deleteAddress($customerId, $addressId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAccessToken") deleteAccessToken +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCustomers") getCustomers -> Delete a customer's access token +> Get all Customers ```php -function deleteAccessToken( - $customerId, - $tokenId, - $idempotencyKey = null) +function getCustomers( + $name = null, + $document = null, + $page = 1, + $size = 10, + $email = null, + $code = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer Id | -| tokenId | ``` Required ``` | Token Id | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| name | ``` Optional ``` | Name of the Customer | +| document | ``` Optional ``` | Document of the Customer | +| page | ``` Optional ``` ``` DefaultValue ``` | Current page the the search | +| size | ``` Optional ``` ``` DefaultValue ``` | Quantity pages of the search | +| email | ``` Optional ``` | Customer's email | +| code | ``` Optional ``` | Customer's code | #### Example Usage ```php -$customerId = 'customer_id'; -$tokenId = 'token_id'; -$idempotencyKey = 'idempotency-key'; +$name = 'name'; +$document = 'document'; +$page = 1; +$size = 10; +$email = 'email'; +$code = 'Code'; -$result = $customers->deleteAccessToken($customerId, $tokenId, $idempotencyKey); +$result = $customers->getCustomers($name, $document, $page, $size, $email, $code); ``` @@ -3418,15 +3429,13 @@ $result = $customers->deleteAccessToken($customerId, $tokenId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAccessToken") getAccessToken +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAccessTokens") deleteAccessTokens -> Get a Customer's access token +> Delete a Customer's access tokens ```php -function getAccessToken( - $customerId, - $tokenId) +function deleteAccessTokens($customerId) ``` #### Parameters @@ -3434,7 +3443,6 @@ function getAccessToken( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| tokenId | ``` Required ``` | Token Id | @@ -3442,9 +3450,8 @@ function getAccessToken( ```php $customerId = 'customer_id'; -$tokenId = 'token_id'; -$result = $customers->getAccessToken($customerId, $tokenId); +$result = $customers->deleteAccessTokens($customerId); ``` @@ -3461,16 +3468,13 @@ $result = $customers->getAccessToken($customerId, $tokenId); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createAccessToken") createAccessToken +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCustomer") getCustomer -> Creates a access token for a customer +> Get a customer ```php -function createAccessToken( - $customerId, - $body, - $idempotencyKey = null) +function getCustomer($customerId) ``` #### Parameters @@ -3478,8 +3482,6 @@ function createAccessToken( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| body | ``` Required ``` | Request for creating a access token | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3487,10 +3489,8 @@ function createAccessToken( ```php $customerId = 'customer_id'; -$body = new CreateAccessTokenRequest(); -$idempotencyKey = 'idempotency-key'; -$result = $customers->createAccessToken($customerId, $body, $idempotencyKey); +$result = $customers->getCustomer($customerId); ``` @@ -3507,16 +3507,17 @@ $result = $customers->createAccessToken($customerId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAccessTokens") getAccessTokens +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCard") updateCard -> Get all access tokens from a customer +> Updates a card ```php -function getAccessTokens( +function updateCard( $customerId, - $page = null, - $size = null) + $cardId, + $body, + $idempotencyKey = null) ``` #### Parameters @@ -3524,8 +3525,9 @@ function getAccessTokens( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | +| cardId | ``` Required ``` | Card id | +| body | ``` Required ``` | Request for updating a card | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3533,10 +3535,11 @@ function getAccessTokens( ```php $customerId = 'customer_id'; -$page = 200; -$size = 200; +$cardId = 'card_id'; +$body = new UpdateCardRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $customers->getAccessTokens($customerId, $page, $size); +$result = $customers->updateCard($customerId, $cardId, $body, $idempotencyKey); ``` @@ -3553,15 +3556,15 @@ $result = $customers->getAccessTokens($customerId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createAddress") createAddress +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAddress") deleteAddress -> Creates a new address for a customer +> Delete a Customer's address ```php -function createAddress( +function deleteAddress( $customerId, - $body, + $addressId, $idempotencyKey = null) ``` @@ -3570,7 +3573,7 @@ function createAddress( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| body | ``` Required ``` | Request for creating an address | +| addressId | ``` Required ``` | Address Id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3579,10 +3582,10 @@ function createAddress( ```php $customerId = 'customer_id'; -$body = new CreateAddressRequest(); +$addressId = 'address_id'; $idempotencyKey = 'idempotency-key'; -$result = $customers->createAddress($customerId, $body, $idempotencyKey); +$result = $customers->deleteAddress($customerId, $addressId, $idempotencyKey); ``` @@ -3599,25 +3602,25 @@ $result = $customers->createAddress($customerId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAddresses") getAddresses +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createAccessToken") createAccessToken -> Gets all adressess from a customer +> Creates a access token for a customer ```php -function getAddresses( +function createAccessToken( $customerId, - $page = null, - $size = null) + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | +| customerId | ``` Required ``` | Customer Id | +| body | ``` Required ``` | Request for creating a access token | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3625,10 +3628,10 @@ function getAddresses( ```php $customerId = 'customer_id'; -$page = 200; -$size = 200; +$body = new CreateAccessTokenRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $customers->getAddresses($customerId, $page, $size); +$result = $customers->createAccessToken($customerId, $body, $idempotencyKey); ``` @@ -3645,13 +3648,14 @@ $result = $customers->getAddresses($customerId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createCustomer") createCustomer +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createAddress") createAddress -> Creates a new customer +> Creates a new address for a customer ```php -function createCustomer( +function createAddress( + $customerId, $body, $idempotencyKey = null) ``` @@ -3660,7 +3664,8 @@ function createCustomer( | Parameter | Tags | Description | |-----------|------|-------------| -| body | ``` Required ``` | Request for creating a customer | +| customerId | ``` Required ``` | Customer Id | +| body | ``` Required ``` | Request for creating an address | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3668,10 +3673,11 @@ function createCustomer( #### Example Usage ```php -$body = new CreateCustomerRequest(); +$customerId = 'customer_id'; +$body = new CreateAddressRequest(); $idempotencyKey = 'idempotency-key'; -$result = $customers->createCustomer($body, $idempotencyKey); +$result = $customers->createAddress($customerId, $body, $idempotencyKey); ``` @@ -3688,45 +3694,36 @@ $result = $customers->createCustomer($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCustomers") getCustomers +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCards") getCards -> Get all Customers +> Get all cards from a customer ```php -function getCustomers( - $name = null, - $document = null, - $page = 1, - $size = 10, - $email = null, - $code = null) +function getCards( + $customerId, + $page = null, + $size = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| name | ``` Optional ``` | Name of the Customer | -| document | ``` Optional ``` | Document of the Customer | -| page | ``` Optional ``` ``` DefaultValue ``` | Current page the the search | -| size | ``` Optional ``` ``` DefaultValue ``` | Quantity pages of the search | -| email | ``` Optional ``` | Customer's email | -| code | ``` Optional ``` | Customer's code | +| customerId | ``` Required ``` | Customer Id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | #### Example Usage ```php -$name = 'name'; -$document = 'document'; -$page = 1; -$size = 10; -$email = 'email'; -$code = 'Code'; +$customerId = 'customer_id'; +$page = 138; +$size = 138; -$result = $customers->getCustomers($name, $document, $page, $size, $email, $code); +$result = $customers->getCards($customerId, $page, $size); ``` @@ -3743,20 +3740,25 @@ $result = $customers->getCustomers($name, $document, $page, $size, $email, $code -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAccessTokens") deleteAccessTokens +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCustomerMetadata") updateCustomerMetadata -> Delete a Customer's access tokens +> Updates the metadata a customer ```php -function deleteAccessTokens($customerId) +function updateCustomerMetadata( + $customerId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer Id | +| customerId | ``` Required ``` | The customer id | +| body | ``` Required ``` | Request for updating the customer metadata | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3764,8 +3766,10 @@ function deleteAccessTokens($customerId) ```php $customerId = 'customer_id'; +$body = new UpdateMetadataRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $customers->deleteAccessTokens($customerId); +$result = $customers->updateCustomerMetadata($customerId, $body, $idempotencyKey); ``` @@ -3782,16 +3786,15 @@ $result = $customers->deleteAccessTokens($customerId); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createCard") createCard +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCard") getCard -> Creates a new card for a customer +> Get a customer's card ```php -function createCard( +function getCard( $customerId, - $body, - $idempotencyKey = null) + $cardId) ``` #### Parameters @@ -3799,8 +3802,7 @@ function createCard( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer id | -| body | ``` Required ``` | Request for creating a card | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| cardId | ``` Required ``` | Card id | @@ -3808,10 +3810,9 @@ function createCard( ```php $customerId = 'customer_id'; -$body = new CreateCardRequest(); -$idempotencyKey = 'idempotency-key'; +$cardId = 'card_id'; -$result = $customers->createCard($customerId, $body, $idempotencyKey); +$result = $customers->getCard($customerId, $cardId); ``` @@ -3828,16 +3829,16 @@ $result = $customers->createCard($customerId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCards") getCards +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.deleteAccessToken") deleteAccessToken -> Get all cards from a customer +> Delete a customer's access token ```php -function getCards( +function deleteAccessToken( $customerId, - $page = null, - $size = null) + $tokenId, + $idempotencyKey = null) ``` #### Parameters @@ -3845,8 +3846,8 @@ function getCards( | Parameter | Tags | Description | |-----------|------|-------------| | customerId | ``` Required ``` | Customer Id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | +| tokenId | ``` Required ``` | Token Id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3854,10 +3855,10 @@ function getCards( ```php $customerId = 'customer_id'; -$page = 200; -$size = 200; +$tokenId = 'token_id'; +$idempotencyKey = 'idempotency-key'; -$result = $customers->getCards($customerId, $page, $size); +$result = $customers->deleteAccessToken($customerId, $tokenId, $idempotencyKey); ``` @@ -3874,25 +3875,23 @@ $result = $customers->getCards($customerId, $page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCustomer") updateCustomer +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAccessToken") getAccessToken -> Updates a customer +> Get a Customer's access token ```php -function updateCustomer( - $customerId, - $body, - $idempotencyKey = null) +function getAccessToken( + $customerId, + $tokenId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer id | -| body | ``` Required ``` | Request for updating a customer | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| customerId | ``` Required ``` | Customer Id | +| tokenId | ``` Required ``` | Token Id | @@ -3900,10 +3899,9 @@ function updateCustomer( ```php $customerId = 'customer_id'; -$body = new UpdateCustomerRequest(); -$idempotencyKey = 'idempotency-key'; +$tokenId = 'token_id'; -$result = $customers->updateCustomer($customerId, $body, $idempotencyKey); +$result = $customers->getAccessToken($customerId, $tokenId); ``` @@ -3920,20 +3918,25 @@ $result = $customers->updateCustomer($customerId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getCustomer") getCustomer +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.getAddresses") getAddresses -> Get a customer +> Gets all adressess from a customer ```php -function getCustomer($customerId) +function getAddresses( + $customerId, + $page = null, + $size = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer Id | +| customerId | ``` Required ``` | Customer id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | @@ -3941,8 +3944,10 @@ function getCustomer($customerId) ```php $customerId = 'customer_id'; +$page = 138; +$size = 138; -$result = $customers->getCustomer($customerId); +$result = $customers->getAddresses($customerId, $page, $size); ``` @@ -3959,15 +3964,14 @@ $result = $customers->getCustomer($customerId); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.renewCard") renewCard +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createCustomer") createCustomer -> Renew a card +> Creates a new customer ```php -function renewCard( - $customerId, - $cardId, +function createCustomer( + $body, $idempotencyKey = null) ``` @@ -3975,8 +3979,7 @@ function renewCard( | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | Customer id | -| cardId | ``` Required ``` | Card Id | +| body | ``` Required ``` | Request for creating a customer | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -3984,11 +3987,10 @@ function renewCard( #### Example Usage ```php -$customerId = 'customer_id'; -$cardId = 'card_id'; +$body = new CreateCustomerRequest(); $idempotencyKey = 'idempotency-key'; -$result = $customers->renewCard($customerId, $cardId, $idempotencyKey); +$result = $customers->createCustomer($body, $idempotencyKey); ``` @@ -4005,13 +4007,13 @@ $result = $customers->renewCard($customerId, $cardId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.updateCustomerMetadata") updateCustomerMetadata +### ![Method: ](https://apidocs.io/img/method.png ".CustomersController.createCard") createCard -> Updates the metadata a customer +> Creates a new card for a customer ```php -function updateCustomerMetadata( +function createCard( $customerId, $body, $idempotencyKey = null) @@ -4021,8 +4023,8 @@ function updateCustomerMetadata( | Parameter | Tags | Description | |-----------|------|-------------| -| customerId | ``` Required ``` | The customer id | -| body | ``` Required ``` | Request for updating the customer metadata | +| customerId | ``` Required ``` | Customer id | +| body | ``` Required ``` | Request for creating a card | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4031,10 +4033,10 @@ function updateCustomerMetadata( ```php $customerId = 'customer_id'; -$body = new UpdateMetadataRequest(); +$body = new CreateCardRequest(); $idempotencyKey = 'idempotency-key'; -$result = $customers->updateCustomerMetadata($customerId, $body, $idempotencyKey); +$result = $customers->createCard($customerId, $body, $idempotencyKey); ``` @@ -4063,25 +4065,25 @@ The singleton instance of the ``` ChargesController ``` class can be accessed fr $charges = $client->getCharges(); ``` -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargeMetadata") updateChargeMetadata +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.captureCharge") captureCharge -> Updates the metadata from a charge +> Captures a charge ```php -function updateChargeMetadata( +function captureCharge( $chargeId, - $body, - $idempotencyKey = null) + $idempotencyKey = null, + $body = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | The charge id | -| body | ``` Required ``` | Request for updating the charge metadata | +| chargeId | ``` Required ``` | Charge id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| body | ``` Optional ``` | Request for capturing a charge | @@ -4089,10 +4091,10 @@ function updateChargeMetadata( ```php $chargeId = 'charge_id'; -$body = new UpdateMetadataRequest(); $idempotencyKey = 'idempotency-key'; +$body = new CreateCaptureChargeRequest(); -$result = $charges->updateChargeMetadata($chargeId, $body, $idempotencyKey); +$result = $charges->captureCharge($chargeId, $idempotencyKey, $body); ``` @@ -4109,25 +4111,25 @@ $result = $charges->updateChargeMetadata($chargeId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.captureCharge") captureCharge +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getChargeTransactions") getChargeTransactions -> Captures a charge +> GetChargeTransactions ```php -function captureCharge( +function getChargeTransactions( $chargeId, - $idempotencyKey = null, - $body = null) + $page = null, + $size = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | Charge id | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | -| body | ``` Optional ``` | Request for capturing a charge | +| chargeId | ``` Required ``` | Charge Id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | @@ -4135,10 +4137,10 @@ function captureCharge( ```php $chargeId = 'charge_id'; -$idempotencyKey = 'idempotency-key'; -$body = new CreateCaptureChargeRequest(); +$page = 138; +$size = 138; -$result = $charges->captureCharge($chargeId, $idempotencyKey, $body); +$result = $charges->getChargeTransactions($chargeId, $page, $size); ``` @@ -4155,36 +4157,54 @@ $result = $charges->captureCharge($chargeId, $idempotencyKey, $body); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargePaymentMethod") updateChargePaymentMethod +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getCharges") getCharges -> Updates a charge's payment method +> Lists all charges ```php -function updateChargePaymentMethod( - $chargeId, - $body, - $idempotencyKey = null) +function getCharges( + $page = null, + $size = null, + $code = null, + $status = null, + $paymentMethod = null, + $customerId = null, + $orderId = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | Charge id | -| body | ``` Required ``` | Request for updating the payment method from a charge | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | +| code | ``` Optional ``` | Filter for charge's code | +| status | ``` Optional ``` | Filter for charge's status | +| paymentMethod | ``` Optional ``` | Filter for charge's payment method | +| customerId | ``` Optional ``` | Filter for charge's customer id | +| orderId | ``` Optional ``` | Filter for charge's order id | +| createdSince | ``` Optional ``` | Filter for the beginning of the range for charge's creation | +| createdUntil | ``` Optional ``` | Filter for the end of the range for charge's creation | #### Example Usage ```php -$chargeId = 'charge_id'; -$body = new UpdateChargePaymentMethodRequest(); -$idempotencyKey = 'idempotency-key'; +$page = 138; +$size = 138; +$code = 'code'; +$status = 'status'; +$paymentMethod = 'payment_method'; +$customerId = 'customer_id'; +$orderId = 'order_id'; +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $charges->updateChargePaymentMethod($chargeId, $body, $idempotencyKey); +$result = $charges->getCharges($page, $size, $code, $status, $paymentMethod, $customerId, $orderId, $createdSince, $createdUntil); ``` @@ -4201,25 +4221,25 @@ $result = $charges->updateChargePaymentMethod($chargeId, $body, $idempotencyKey) -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getChargeTransactions") getChargeTransactions +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargePaymentMethod") updateChargePaymentMethod -> GetChargeTransactions +> Updates a charge's payment method ```php -function getChargeTransactions( +function updateChargePaymentMethod( $chargeId, - $page = null, - $size = null) + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | Charge Id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | +| chargeId | ``` Required ``` | Charge id | +| body | ``` Required ``` | Request for updating the payment method from a charge | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4227,10 +4247,10 @@ function getChargeTransactions( ```php $chargeId = 'charge_id'; -$page = 200; -$size = 200; +$body = new UpdateChargePaymentMethodRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $charges->getChargeTransactions($chargeId, $page, $size); +$result = $charges->updateChargePaymentMethod($chargeId, $body, $idempotencyKey); ``` @@ -4293,54 +4313,36 @@ $result = $charges->updateChargeDueDate($chargeId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getCharges") getCharges +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.confirmPayment") confirmPayment -> Lists all charges +> ConfirmPayment ```php -function getCharges( - $page = null, - $size = null, - $code = null, - $status = null, - $paymentMethod = null, - $customerId = null, - $orderId = null, - $createdSince = null, - $createdUntil = null) +function confirmPayment( + $chargeId, + $idempotencyKey = null, + $body = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| code | ``` Optional ``` | Filter for charge's code | -| status | ``` Optional ``` | Filter for charge's status | -| paymentMethod | ``` Optional ``` | Filter for charge's payment method | -| customerId | ``` Optional ``` | Filter for charge's customer id | -| orderId | ``` Optional ``` | Filter for charge's order id | -| createdSince | ``` Optional ``` | Filter for the beginning of the range for charge's creation | -| createdUntil | ``` Optional ``` | Filter for the end of the range for charge's creation | +| chargeId | ``` Required ``` | TODO: Add a parameter description | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| body | ``` Optional ``` | Request for confirm payment | #### Example Usage ```php -$page = 200; -$size = 200; -$code = 'code'; -$status = 'status'; -$paymentMethod = 'payment_method'; -$customerId = 'customer_id'; -$orderId = 'order_id'; -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$chargeId = 'charge_id'; +$idempotencyKey = 'idempotency-key'; +$body = new CreateConfirmPaymentRequest(); -$result = $charges->getCharges($page, $size, $code, $status, $paymentMethod, $customerId, $orderId, $createdSince, $createdUntil); +$result = $charges->confirmPayment($chargeId, $idempotencyKey, $body); ``` @@ -4357,16 +4359,13 @@ $result = $charges->getCharges($page, $size, $code, $status, $paymentMethod, $cu -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargeCard") updateChargeCard +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getCharge") getCharge -> Updates the card from a charge +> Get a charge from its id ```php -function updateChargeCard( - $chargeId, - $body, - $idempotencyKey = null) +function getCharge($chargeId) ``` #### Parameters @@ -4374,8 +4373,6 @@ function updateChargeCard( | Parameter | Tags | Description | |-----------|------|-------------| | chargeId | ``` Required ``` | Charge id | -| body | ``` Required ``` | Request for updating a charge's card | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4383,10 +4380,8 @@ function updateChargeCard( ```php $chargeId = 'charge_id'; -$body = new UpdateChargeCardRequest(); -$idempotencyKey = 'idempotency-key'; -$result = $charges->updateChargeCard($chargeId, $body, $idempotencyKey); +$result = $charges->getCharge($chargeId); ``` @@ -4403,13 +4398,15 @@ $result = $charges->updateChargeCard($chargeId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getCharge") getCharge +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.retryCharge") retryCharge -> Get a charge from its id +> Retries a charge ```php -function getCharge($chargeId) +function retryCharge( + $chargeId, + $idempotencyKey = null) ``` #### Parameters @@ -4417,6 +4414,7 @@ function getCharge($chargeId) | Parameter | Tags | Description | |-----------|------|-------------| | chargeId | ``` Required ``` | Charge id | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4424,8 +4422,9 @@ function getCharge($chargeId) ```php $chargeId = 'charge_id'; +$idempotencyKey = 'idempotency-key'; -$result = $charges->getCharge($chargeId); +$result = $charges->retryCharge($chargeId, $idempotencyKey); ``` @@ -4442,25 +4441,25 @@ $result = $charges->getCharge($chargeId); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.cancelCharge") cancelCharge +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargeMetadata") updateChargeMetadata -> Cancel a charge +> Updates the metadata from a charge ```php -function cancelCharge( +function updateChargeMetadata( $chargeId, - $idempotencyKey = null, - $body = null) + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | Charge id | +| chargeId | ``` Required ``` | The charge id | +| body | ``` Required ``` | Request for updating the charge metadata | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | -| body | ``` Optional ``` | Request for cancelling a charge | @@ -4468,10 +4467,10 @@ function cancelCharge( ```php $chargeId = 'charge_id'; +$body = new UpdateMetadataRequest(); $idempotencyKey = 'idempotency-key'; -$body = new CreateCancelChargeRequest(); -$result = $charges->cancelCharge($chargeId, $idempotencyKey, $body); +$result = $charges->updateChargeMetadata($chargeId, $body, $idempotencyKey); ``` @@ -4488,36 +4487,36 @@ $result = $charges->cancelCharge($chargeId, $idempotencyKey, $body); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getChargesSummary") getChargesSummary +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.updateChargeCard") updateChargeCard -> GetChargesSummary +> Updates the card from a charge ```php -function getChargesSummary( - $status, - $createdSince = null, - $createdUntil = null) +function updateChargeCard( + $chargeId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| status | ``` Required ``` | TODO: Add a parameter description | -| createdSince | ``` Optional ``` | TODO: Add a parameter description | -| createdUntil | ``` Optional ``` | TODO: Add a parameter description | +| chargeId | ``` Required ``` | Charge id | +| body | ``` Required ``` | Request for updating a charge's card | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | #### Example Usage ```php -$status = 'status'; -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$chargeId = 'charge_id'; +$body = new UpdateChargeCardRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $charges->getChargesSummary($status, $createdSince, $createdUntil); +$result = $charges->updateChargeCard($chargeId, $body, $idempotencyKey); ``` @@ -4534,15 +4533,16 @@ $result = $charges->getChargesSummary($status, $createdSince, $createdUntil); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.retryCharge") retryCharge +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.cancelCharge") cancelCharge -> Retries a charge +> Cancel a charge ```php -function retryCharge( +function cancelCharge( $chargeId, - $idempotencyKey = null) + $idempotencyKey = null, + $body = null) ``` #### Parameters @@ -4551,6 +4551,7 @@ function retryCharge( |-----------|------|-------------| | chargeId | ``` Required ``` | Charge id | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| body | ``` Optional ``` | Request for cancelling a charge | @@ -4559,8 +4560,9 @@ function retryCharge( ```php $chargeId = 'charge_id'; $idempotencyKey = 'idempotency-key'; +$body = new CreateCancelChargeRequest(); -$result = $charges->retryCharge($chargeId, $idempotencyKey); +$result = $charges->cancelCharge($chargeId, $idempotencyKey, $body); ``` @@ -4577,33 +4579,36 @@ $result = $charges->retryCharge($chargeId, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.createCharge") createCharge +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.getChargesSummary") getChargesSummary -> Creates a new charge +> GetChargesSummary ```php -function createCharge( - $body, - $idempotencyKey = null) +function getChargesSummary( + $status, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| body | ``` Required ``` | Request for creating a charge | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| status | ``` Required ``` | TODO: Add a parameter description | +| createdSince | ``` Optional ``` | TODO: Add a parameter description | +| createdUntil | ``` Optional ``` | TODO: Add a parameter description | #### Example Usage ```php -$body = new CreateChargeRequest(); -$idempotencyKey = 'idempotency-key'; +$status = 'status'; +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $charges->createCharge($body, $idempotencyKey); +$result = $charges->getChargesSummary($status, $createdSince, $createdUntil); ``` @@ -4620,36 +4625,33 @@ $result = $charges->createCharge($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.confirmPayment") confirmPayment +### ![Method: ](https://apidocs.io/img/method.png ".ChargesController.createCharge") createCharge -> ConfirmPayment +> Creates a new charge ```php -function confirmPayment( - $chargeId, - $idempotencyKey = null, - $body = null) +function createCharge( + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| chargeId | ``` Required ``` | TODO: Add a parameter description | +| body | ``` Required ``` | Request for creating a charge | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | -| body | ``` Optional ``` | Request for confirm payment | #### Example Usage ```php -$chargeId = 'charge_id'; +$body = new CreateChargeRequest(); $idempotencyKey = 'idempotency-key'; -$body = new CreateConfirmPaymentRequest(); -$result = $charges->confirmPayment($chargeId, $idempotencyKey, $body); +$result = $charges->createCharge($body, $idempotencyKey); ``` @@ -4721,25 +4723,20 @@ $result = $recipients->getTransfer($recipientId, $transferId); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipient") updateRecipient +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipient") getRecipient -> Updates a recipient +> Retrieves recipient information ```php -function updateRecipient( - $recipientId, - $body, - $idempotencyKey = null) +function getRecipient($recipientId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipient id | -| body | ``` Required ``` | Recipient data | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| recipientId | ``` Required ``` | Recipiend id | @@ -4747,10 +4744,8 @@ function updateRecipient( ```php $recipientId = 'recipient_id'; -$body = new UpdateRecipientRequest(); -$idempotencyKey = 'idempotency-key'; -$result = $recipients->updateRecipient($recipientId, $body, $idempotencyKey); +$result = $recipients->getRecipient($recipientId); ``` @@ -4767,20 +4762,25 @@ $result = $recipients->updateRecipient($recipientId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipient") getRecipient +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientMetadata") updateRecipientMetadata -> Retrieves recipient information +> Updates recipient metadata ```php -function getRecipient($recipientId) +function updateRecipientMetadata( + $recipientId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipiend id | +| recipientId | ``` Required ``` | Recipient id | +| body | ``` Required ``` | Metadata | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4788,8 +4788,10 @@ function getRecipient($recipientId) ```php $recipientId = 'recipient_id'; +$body = new UpdateMetadataRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $recipients->getRecipient($recipientId); +$result = $recipients->updateRecipientMetadata($recipientId, $body, $idempotencyKey); ``` @@ -4806,13 +4808,13 @@ $result = $recipients->getRecipient($recipientId); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createAnticipation") createAnticipation +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createTransfer") createTransfer -> Creates an anticipation +> Creates a transfer for a recipient ```php -function createAnticipation( +function createTransfer( $recipientId, $body, $idempotencyKey = null) @@ -4822,8 +4824,8 @@ function createAnticipation( | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipient id | -| body | ``` Required ``` | Anticipation data | +| recipientId | ``` Required ``` | Recipient Id | +| body | ``` Required ``` | Transfer data | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4832,10 +4834,10 @@ function createAnticipation( ```php $recipientId = 'recipient_id'; -$body = new CreateAnticipationRequest(); +$body = new CreateTransferRequest(); $idempotencyKey = 'idempotency-key'; -$result = $recipients->createAnticipation($recipientId, $body, $idempotencyKey); +$result = $recipients->createTransfer($recipientId, $body, $idempotencyKey); ``` @@ -4852,22 +4854,16 @@ $result = $recipients->createAnticipation($recipientId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipations") getAnticipations +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateAutomaticAnticipationSettings") updateAutomaticAnticipationSettings -> Retrieves a paginated list of anticipations from a recipient +> Updates recipient metadata ```php -function getAnticipations( +function updateAutomaticAnticipationSettings( $recipientId, - $page = null, - $size = null, - $status = null, - $timeframe = null, - $paymentDateSince = null, - $paymentDateUntil = null, - $createdSince = null, - $createdUntil = null) + $body, + $idempotencyKey = null) ``` #### Parameters @@ -4875,14 +4871,8 @@ function getAnticipations( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| status | ``` Optional ``` | Filter for anticipation status | -| timeframe | ``` Optional ``` | Filter for anticipation timeframe | -| paymentDateSince | ``` Optional ``` | Filter for start range for anticipation payment date | -| paymentDateUntil | ``` Optional ``` | Filter for end range for anticipation payment date | -| createdSince | ``` Optional ``` | Filter for start range for anticipation creation date | -| createdUntil | ``` Optional ``` | Filter for end range for anticipation creation date | +| body | ``` Required ``` | Metadata | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -4890,16 +4880,10 @@ function getAnticipations( ```php $recipientId = 'recipient_id'; -$page = 200; -$size = 200; -$status = 'status'; -$timeframe = 'timeframe'; -$paymentDateSince = date("D M d, Y G:i"); -$paymentDateUntil = date("D M d, Y G:i"); -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$body = new UpdateAutomaticAnticipationSettingsRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $recipients->getAnticipations($recipientId, $page, $size, $status, $timeframe, $paymentDateSince, $paymentDateUntil, $createdSince, $createdUntil); +$result = $recipients->updateAutomaticAnticipationSettings($recipientId, $body, $idempotencyKey); ``` @@ -4916,16 +4900,13 @@ $result = $recipients->getAnticipations($recipientId, $page, $size, $status, $ti -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipationLimits") getAnticipationLimits +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getBalance") getBalance -> Gets the anticipation limits for a recipient +> Get balance information for a recipient ```php -function getAnticipationLimits( - $recipientId, - $timeframe, - $paymentDate) +function getBalance($recipientId) ``` #### Parameters @@ -4933,8 +4914,6 @@ function getAnticipationLimits( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| timeframe | ``` Required ``` | Timeframe | -| paymentDate | ``` Required ``` | Anticipation payment date | @@ -4942,10 +4921,8 @@ function getAnticipationLimits( ```php $recipientId = 'recipient_id'; -$timeframe = 'timeframe'; -$paymentDate = date("D M d, Y G:i"); -$result = $recipients->getAnticipationLimits($recipientId, $timeframe, $paymentDate); +$result = $recipients->getBalance($recipientId); ``` @@ -4962,33 +4939,54 @@ $result = $recipients->getAnticipationLimits($recipientId, $timeframe, $paymentD -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipients") getRecipients +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipations") getAnticipations -> Retrieves paginated recipients information +> Retrieves a paginated list of anticipations from a recipient ```php -function getRecipients( +function getAnticipations( + $recipientId, $page = null, - $size = null) + $size = null, + $status = null, + $timeframe = null, + $paymentDateSince = null, + $paymentDateUntil = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| +| recipientId | ``` Required ``` | Recipient id | | page | ``` Optional ``` | Page number | | size | ``` Optional ``` | Page size | +| status | ``` Optional ``` | Filter for anticipation status | +| timeframe | ``` Optional ``` | Filter for anticipation timeframe | +| paymentDateSince | ``` Optional ``` | Filter for start range for anticipation payment date | +| paymentDateUntil | ``` Optional ``` | Filter for end range for anticipation payment date | +| createdSince | ``` Optional ``` | Filter for start range for anticipation creation date | +| createdUntil | ``` Optional ``` | Filter for end range for anticipation creation date | #### Example Usage ```php -$page = 200; -$size = 200; +$recipientId = 'recipient_id'; +$page = 138; +$size = 138; +$status = 'status'; +$timeframe = 'timeframe'; +$paymentDateSince = date("D M d, Y G:i"); +$paymentDateUntil = date("D M d, Y G:i"); +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $recipients->getRecipients($page, $size); +$result = $recipients->getAnticipations($recipientId, $page, $size, $status, $timeframe, $paymentDateSince, $paymentDateUntil, $createdSince, $createdUntil); ``` @@ -5005,33 +5003,33 @@ $result = $recipients->getRecipients($page, $size); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createRecipient") createRecipient +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getWithdrawById") getWithdrawById -> Creates a new recipient +> GetWithdrawById ```php -function createRecipient( - $body, - $idempotencyKey = null) +function getWithdrawById( + $recipientId, + $withdrawalId) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| body | ``` Required ``` | Recipient data | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| recipientId | ``` Required ``` | TODO: Add a parameter description | +| withdrawalId | ``` Required ``` | TODO: Add a parameter description | #### Example Usage ```php -$body = new CreateRecipientRequest(); -$idempotencyKey = 'idempotency-key'; +$recipientId = 'recipient_id'; +$withdrawalId = 'withdrawal_id'; -$result = $recipients->createRecipient($body, $idempotencyKey); +$result = $recipients->getWithdrawById($recipientId, $withdrawalId); ``` @@ -5048,15 +5046,15 @@ $result = $recipients->createRecipient($body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getWithdrawById") getWithdrawById +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createWithdraw") createWithdraw -> GetWithdrawById +> CreateWithdraw ```php -function getWithdrawById( +function createWithdraw( $recipientId, - $withdrawalId) + $body) ``` #### Parameters @@ -5064,7 +5062,7 @@ function getWithdrawById( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | TODO: Add a parameter description | -| withdrawalId | ``` Required ``` | TODO: Add a parameter description | +| body | ``` Required ``` | TODO: Add a parameter description | @@ -5072,9 +5070,9 @@ function getWithdrawById( ```php $recipientId = 'recipient_id'; -$withdrawalId = 'withdrawal_id'; +$body = new CreateWithdrawRequest(); -$result = $recipients->getWithdrawById($recipientId, $withdrawalId); +$result = $recipients->createWithdraw($recipientId, $body); ``` @@ -5091,13 +5089,13 @@ $result = $recipients->getWithdrawById($recipientId, $withdrawalId); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientDefaultBankAccount") updateRecipientDefaultBankAccount +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipient") updateRecipient -> Updates the default bank account from a recipient +> Updates a recipient ```php -function updateRecipientDefaultBankAccount( +function updateRecipient( $recipientId, $body, $idempotencyKey = null) @@ -5108,7 +5106,7 @@ function updateRecipientDefaultBankAccount( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| body | ``` Required ``` | Bank account data | +| body | ``` Required ``` | Recipient data | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -5117,10 +5115,10 @@ function updateRecipientDefaultBankAccount( ```php $recipientId = 'recipient_id'; -$body = new UpdateRecipientBankAccountRequest(); +$body = new UpdateRecipientRequest(); $idempotencyKey = 'idempotency-key'; -$result = $recipients->updateRecipientDefaultBankAccount($recipientId, $body, $idempotencyKey); +$result = $recipients->updateRecipient($recipientId, $body, $idempotencyKey); ``` @@ -5137,13 +5135,13 @@ $result = $recipients->updateRecipientDefaultBankAccount($recipientId, $body, $i -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientMetadata") updateRecipientMetadata +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createAnticipation") createAnticipation -> Updates recipient metadata +> Creates an anticipation ```php -function updateRecipientMetadata( +function createAnticipation( $recipientId, $body, $idempotencyKey = null) @@ -5154,7 +5152,7 @@ function updateRecipientMetadata( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| body | ``` Required ``` | Metadata | +| body | ``` Required ``` | Anticipation data | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -5163,10 +5161,10 @@ function updateRecipientMetadata( ```php $recipientId = 'recipient_id'; -$body = new UpdateMetadataRequest(); +$body = new CreateAnticipationRequest(); $idempotencyKey = 'idempotency-key'; -$result = $recipients->updateRecipientMetadata($recipientId, $body, $idempotencyKey); +$result = $recipients->createAnticipation($recipientId, $body, $idempotencyKey); ``` @@ -5183,19 +5181,16 @@ $result = $recipients->updateRecipientMetadata($recipientId, $body, $idempotency -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getTransfers") getTransfers +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientDefaultBankAccount") updateRecipientDefaultBankAccount -> Gets a paginated list of transfers for the recipient +> Updates the default bank account from a recipient ```php -function getTransfers( +function updateRecipientDefaultBankAccount( $recipientId, - $page = null, - $size = null, - $status = null, - $createdSince = null, - $createdUntil = null) + $body, + $idempotencyKey = null) ``` #### Parameters @@ -5203,11 +5198,8 @@ function getTransfers( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| page | ``` Optional ``` | Page number | -| size | ``` Optional ``` | Page size | -| status | ``` Optional ``` | Filter for transfer status | -| createdSince | ``` Optional ``` | Filter for start range of transfer creation date | -| createdUntil | ``` Optional ``` | Filter for end range of transfer creation date | +| body | ``` Required ``` | Bank account data | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -5215,13 +5207,10 @@ function getTransfers( ```php $recipientId = 'recipient_id'; -$page = 36; -$size = 36; -$status = 'status'; -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$body = new UpdateRecipientBankAccountRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $recipients->getTransfers($recipientId, $page, $size, $status, $createdSince, $createdUntil); +$result = $recipients->updateRecipientDefaultBankAccount($recipientId, $body, $idempotencyKey); ``` @@ -5238,36 +5227,29 @@ $result = $recipients->getTransfers($recipientId, $page, $size, $status, $create -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createTransfer") createTransfer +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipientByCode") getRecipientByCode -> Creates a transfer for a recipient +> Retrieves recipient information ```php -function createTransfer( - $recipientId, - $body, - $idempotencyKey = null) +function getRecipientByCode($code) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipient Id | -| body | ``` Required ``` | Transfer data | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| code | ``` Required ``` | Recipient code | #### Example Usage ```php -$recipientId = 'recipient_id'; -$body = new CreateTransferRequest(); -$idempotencyKey = 'idempotency-key'; +$code = 'code'; -$result = $recipients->createTransfer($recipientId, $body, $idempotencyKey); +$result = $recipients->getRecipientByCode($code); ``` @@ -5284,23 +5266,25 @@ $result = $recipients->createTransfer($recipientId, $body, $idempotencyKey); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createWithdraw") createWithdraw +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipationLimits") getAnticipationLimits -> CreateWithdraw +> Gets the anticipation limits for a recipient ```php -function createWithdraw( +function getAnticipationLimits( $recipientId, - $body) + $timeframe, + $paymentDate) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | TODO: Add a parameter description | -| body | ``` Required ``` | TODO: Add a parameter description | +| recipientId | ``` Required ``` | Recipient id | +| timeframe | ``` Required ``` | Timeframe | +| paymentDate | ``` Required ``` | Anticipation payment date | @@ -5308,9 +5292,10 @@ function createWithdraw( ```php $recipientId = 'recipient_id'; -$body = new CreateWithdrawRequest(); +$timeframe = 'timeframe'; +$paymentDate = date("D M d, Y G:i"); -$result = $recipients->createWithdraw($recipientId, $body); +$result = $recipients->getAnticipationLimits($recipientId, $timeframe, $paymentDate); ``` @@ -5327,45 +5312,33 @@ $result = $recipients->createWithdraw($recipientId, $body); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getWithdrawals") getWithdrawals +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipients") getRecipients -> Gets a paginated list of transfers for the recipient +> Retrieves paginated recipients information ```php -function getWithdrawals( - $recipientId, +function getRecipients( $page = null, - $size = null, - $status = null, - $createdSince = null, - $createdUntil = null) + $size = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | TODO: Add a parameter description | -| page | ``` Optional ``` | TODO: Add a parameter description | -| size | ``` Optional ``` | TODO: Add a parameter description | -| status | ``` Optional ``` | TODO: Add a parameter description | -| createdSince | ``` Optional ``` | TODO: Add a parameter description | -| createdUntil | ``` Optional ``` | TODO: Add a parameter description | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | #### Example Usage ```php -$recipientId = 'recipient_id'; -$page = 36; -$size = 36; -$status = 'status'; -$createdSince = date("D M d, Y G:i"); -$createdUntil = date("D M d, Y G:i"); +$page = 180; +$size = 180; -$result = $recipients->getWithdrawals($recipientId, $page, $size, $status, $createdSince, $createdUntil); +$result = $recipients->getRecipients($page, $size); ``` @@ -5382,14 +5355,13 @@ $result = $recipients->getWithdrawals($recipientId, $page, $size, $status, $crea -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateAutomaticAnticipationSettings") updateAutomaticAnticipationSettings +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.createRecipient") createRecipient -> Updates recipient metadata +> Creates a new recipient ```php -function updateAutomaticAnticipationSettings( - $recipientId, +function createRecipient( $body, $idempotencyKey = null) ``` @@ -5398,8 +5370,7 @@ function updateAutomaticAnticipationSettings( | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipient id | -| body | ``` Required ``` | Metadata | +| body | ``` Required ``` | Recipient data | | idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | @@ -5407,11 +5378,10 @@ function updateAutomaticAnticipationSettings( #### Example Usage ```php -$recipientId = 'recipient_id'; -$body = new UpdateAutomaticAnticipationSettingsRequest(); +$body = new CreateRecipientRequest(); $idempotencyKey = 'idempotency-key'; -$result = $recipients->updateAutomaticAnticipationSettings($recipientId, $body, $idempotencyKey); +$result = $recipients->createRecipient($body, $idempotencyKey); ``` @@ -5428,15 +5398,19 @@ $result = $recipients->updateAutomaticAnticipationSettings($recipientId, $body, -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipation") getAnticipation +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getTransfers") getTransfers -> Gets an anticipation +> Gets a paginated list of transfers for the recipient ```php -function getAnticipation( +function getTransfers( $recipientId, - $anticipationId) + $page = null, + $size = null, + $status = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters @@ -5444,7 +5418,11 @@ function getAnticipation( | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | -| anticipationId | ``` Required ``` | Anticipation id | +| page | ``` Optional ``` | Page number | +| size | ``` Optional ``` | Page size | +| status | ``` Optional ``` | Filter for transfer status | +| createdSince | ``` Optional ``` | Filter for start range of transfer creation date | +| createdUntil | ``` Optional ``` | Filter for end range of transfer creation date | @@ -5452,9 +5430,13 @@ function getAnticipation( ```php $recipientId = 'recipient_id'; -$anticipationId = 'anticipation_id'; +$page = 180; +$size = 180; +$status = 'status'; +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $recipients->getAnticipation($recipientId, $anticipationId); +$result = $recipients->getTransfers($recipientId, $page, $size, $status, $createdSince, $createdUntil); ``` @@ -5471,25 +5453,31 @@ $result = $recipients->getAnticipation($recipientId, $anticipationId); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientTransferSettings") updateRecipientTransferSettings +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getWithdrawals") getWithdrawals -> UpdateRecipientTransferSettings +> Gets a paginated list of transfers for the recipient ```php -function updateRecipientTransferSettings( +function getWithdrawals( $recipientId, - $body, - $idempotencyKey = null) + $page = null, + $size = null, + $status = null, + $createdSince = null, + $createdUntil = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| recipientId | ``` Required ``` | Recipient Identificator | -| body | ``` Required ``` | TODO: Add a parameter description | -| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | +| recipientId | ``` Required ``` | TODO: Add a parameter description | +| page | ``` Optional ``` | TODO: Add a parameter description | +| size | ``` Optional ``` | TODO: Add a parameter description | +| status | ``` Optional ``` | TODO: Add a parameter description | +| createdSince | ``` Optional ``` | TODO: Add a parameter description | +| createdUntil | ``` Optional ``` | TODO: Add a parameter description | @@ -5497,10 +5485,13 @@ function updateRecipientTransferSettings( ```php $recipientId = 'recipient_id'; -$body = new UpdateTransferSettingsRequest(); -$idempotencyKey = 'idempotency-key'; +$page = 180; +$size = 180; +$status = 'status'; +$createdSince = date("D M d, Y G:i"); +$createdUntil = date("D M d, Y G:i"); -$result = $recipients->updateRecipientTransferSettings($recipientId, $body, $idempotencyKey); +$result = $recipients->getWithdrawals($recipientId, $page, $size, $status, $createdSince, $createdUntil); ``` @@ -5517,13 +5508,15 @@ $result = $recipients->updateRecipientTransferSettings($recipientId, $body, $ide -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getBalance") getBalance +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getAnticipation") getAnticipation -> Get balance information for a recipient +> Gets an anticipation ```php -function getBalance($recipientId) +function getAnticipation( + $recipientId, + $anticipationId) ``` #### Parameters @@ -5531,6 +5524,7 @@ function getBalance($recipientId) | Parameter | Tags | Description | |-----------|------|-------------| | recipientId | ``` Required ``` | Recipient id | +| anticipationId | ``` Required ``` | Anticipation id | @@ -5538,8 +5532,9 @@ function getBalance($recipientId) ```php $recipientId = 'recipient_id'; +$anticipationId = 'anticipation_id'; -$result = $recipients->getBalance($recipientId); +$result = $recipients->getAnticipation($recipientId, $anticipationId); ``` @@ -5556,29 +5551,36 @@ $result = $recipients->getBalance($recipientId); -### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.getRecipientByCode") getRecipientByCode +### ![Method: ](https://apidocs.io/img/method.png ".RecipientsController.updateRecipientTransferSettings") updateRecipientTransferSettings -> Retrieves recipient information +> UpdateRecipientTransferSettings ```php -function getRecipientByCode($code) +function updateRecipientTransferSettings( + $recipientId, + $body, + $idempotencyKey = null) ``` #### Parameters | Parameter | Tags | Description | |-----------|------|-------------| -| code | ``` Required ``` | Recipient code | +| recipientId | ``` Required ``` | Recipient Identificator | +| body | ``` Required ``` | TODO: Add a parameter description | +| idempotencyKey | ``` Optional ``` | TODO: Add a parameter description | #### Example Usage ```php -$code = 'code'; +$recipientId = 'recipient_id'; +$body = new UpdateTransferSettingsRequest(); +$idempotencyKey = 'idempotency-key'; -$result = $recipients->getRecipientByCode($code); +$result = $recipients->updateRecipientTransferSettings($recipientId, $body, $idempotencyKey); ``` @@ -5738,39 +5740,30 @@ $result = $tokens->getToken($id, $publicKey, $appId); [Back to List of Controllers](#list_of_controllers) -## ![Class: ](https://apidocs.io/img/class.png ".TransactionsController") TransactionsController +## ![Class: ](https://apidocs.io/img/class.png ".TransfersController") TransfersController ### Get singleton instance -The singleton instance of the ``` TransactionsController ``` class can be accessed from the API Client. +The singleton instance of the ``` TransfersController ``` class can be accessed from the API Client. ```php -$transactions = $client->getTransactions(); +$transfers = $client->getTransfers(); ``` -### ![Method: ](https://apidocs.io/img/method.png ".TransactionsController.getTransaction") getTransaction +### ![Method: ](https://apidocs.io/img/method.png ".TransfersController.getTransfers1") getTransfers1 -> GetTransaction +> Gets all transfers ```php -function getTransaction($transactionId) +function getTransfers1() ``` -#### Parameters - -| Parameter | Tags | Description | -|-----------|------|-------------| -| transactionId | ``` Required ``` | TODO: Add a parameter description | - - - #### Example Usage ```php -$transactionId = 'transaction_id'; -$result = $transactions->getTransaction($transactionId); +$result = $transfers->getTransfers1(); ``` @@ -5787,18 +5780,6 @@ $result = $transactions->getTransaction($transactionId); -[Back to List of Controllers](#list_of_controllers) - -## ![Class: ](https://apidocs.io/img/class.png ".TransfersController") TransfersController - -### Get singleton instance - -The singleton instance of the ``` TransfersController ``` class can be accessed from the API Client. - -```php -$transfers = $client->getTransfers(); -``` - ### ![Method: ](https://apidocs.io/img/method.png ".TransfersController.getTransferById") getTransferById > GetTransferById @@ -5877,20 +5858,41 @@ $result = $transfers->postCreateTransfer($body); -### ![Method: ](https://apidocs.io/img/method.png ".TransfersController.getTransfers1") getTransfers1 +[Back to List of Controllers](#list_of_controllers) -> Gets all transfers +## ![Class: ](https://apidocs.io/img/class.png ".TransactionsController") TransactionsController + +### Get singleton instance +The singleton instance of the ``` TransactionsController ``` class can be accessed from the API Client. ```php -function getTransfers1() +$transactions = $client->getTransactions(); +``` + +### ![Method: ](https://apidocs.io/img/method.png ".TransactionsController.getTransaction") getTransaction + +> GetTransaction + + +```php +function getTransaction($transactionId) ``` +#### Parameters + +| Parameter | Tags | Description | +|-----------|------|-------------| +| transactionId | ``` Required ``` | TODO: Add a parameter description | + + + #### Example Usage ```php +$transactionId = 'transaction_id'; -$result = $transfers->getTransfers1(); +$result = $transactions->getTransaction($transactionId); ``` diff --git a/src/Configuration.php b/src/Configuration.php index 62487c9..e978451 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -18,6 +18,10 @@ class Configuration * @var string */ public static $BASEURI = 'https://api.pagar.me/core/v5'; + /** + * @todo Replace the $serviceRefererName with an appropriate value + */ + public static $serviceRefererName = ''; /** * The username to use with basic authentication diff --git a/src/Controllers/BaseController.php b/src/Controllers/BaseController.php index 8c08ef7..52248ab 100644 --- a/src/Controllers/BaseController.php +++ b/src/Controllers/BaseController.php @@ -24,7 +24,7 @@ class BaseController * User-agent to be sent with API calls * @var string */ - const USER_AGENT = 'PagarmeCoreApi - PHP 5.7.4'; + const USER_AGENT = 'PagarmeCoreApi - PHP 5.7.5'; /** * HttpCallBack instance associated with this controller @@ -58,15 +58,15 @@ protected function getJsonMapper() { $mapper = new JsonMapper(); $mapper->arChildClasses['PagarmeCoreApiLib\\Models\\GetTransactionResponse'] = array( - 'PagarmeCoreApiLib\\Models\\GetBankTransferTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetSafetyPayTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetBankTransferTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetVoucherTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetBoletoTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetDebitCardTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetPrivateLabelTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetCashTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetCreditCardTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetPixTransactionResponse' + 'PagarmeCoreApiLib\\Models\\GetBoletoTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetPixTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetCreditCardTransactionResponse' ); return $mapper; } diff --git a/src/Controllers/ChargesController.php b/src/Controllers/ChargesController.php index cde6b3b..fd8fa52 100644 --- a/src/Controllers/ChargesController.php +++ b/src/Controllers/ChargesController.php @@ -43,22 +43,22 @@ public static function getInstance() } /** - * Updates the metadata from a charge + * Captures a charge * - * @param string $chargeId The charge id - * @param Models\UpdateMetadataRequest $body Request for updating the charge metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $chargeId Charge id + * @param string $idempotencyKey (optional) TODO: type description here + * @param Models\CreateCaptureChargeRequest $body (optional) Request for capturing a charge * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateChargeMetadata( + public function captureCharge( $chargeId, - $body, - $idempotencyKey = null + $idempotencyKey = null, + $body = null ) { //prepare query string for API call - $_queryBuilder = '/Charges/{charge_id}/metadata'; + $_queryBuilder = '/charges/{charge_id}/capture'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -72,6 +72,7 @@ public function updateChargeMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -83,13 +84,13 @@ public function updateChargeMetadata( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -133,28 +134,34 @@ public function updateChargeMetadata( } /** - * Captures a charge + * GetChargeTransactions * - * @param string $chargeId Charge id - * @param string $idempotencyKey (optional) TODO: type description here - * @param Models\CreateCaptureChargeRequest $body (optional) Request for capturing a charge + * @param string $chargeId Charge Id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function captureCharge( + public function getChargeTransactions( $chargeId, - $idempotencyKey = null, - $body = null + $page = null, + $size = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/capture'; + $_queryBuilder = '/charges/{charge_id}/transactions'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, + 'charge_id' => $chargeId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -162,24 +169,20 @@ public function captureCharge( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -219,32 +222,51 @@ public function captureCharge( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListChargeTransactionsResponse'); } /** - * Updates a charge's payment method + * Lists all charges * - * @param string $chargeId Charge id - * @param Models\UpdateChargePaymentMethodRequest $body Request for updating the payment method from a - * charge - * @param string $idempotencyKey (optional) TODO: type description here + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $code (optional) Filter for charge's code + * @param string $status (optional) Filter for charge's status + * @param string $paymentMethod (optional) Filter for charge's payment method + * @param string $customerId (optional) Filter for charge's customer id + * @param string $orderId (optional) Filter for charge's order id + * @param DateTime $createdSince (optional) Filter for the beginning of the range for charge's creation + * @param DateTime $createdUntil (optional) Filter for the end of the range for charge's creation * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateChargePaymentMethod( - $chargeId, - $body, - $idempotencyKey = null + public function getCharges( + $page = null, + $size = null, + $code = null, + $status = null, + $paymentMethod = null, + $customerId = null, + $orderId = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/payment-method'; + $_queryBuilder = '/charges'; //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, - )); + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'code' => $code, + 'status' => $status, + 'payment_method' => $paymentMethod, + 'customer_id' => $customerId, + 'order_id' => $orderId, + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -253,24 +275,20 @@ public function updateChargePaymentMethod( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -310,58 +328,59 @@ public function updateChargePaymentMethod( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListChargesResponse'); } /** - * GetChargeTransactions + * Updates a charge's payment method * - * @param string $chargeId Charge Id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param string $chargeId Charge id + * @param Models\UpdateChargePaymentMethodRequest $body Request for updating the payment method from a + * charge + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getChargeTransactions( + public function updateChargePaymentMethod( $chargeId, - $page = null, - $size = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/transactions'; + $_queryBuilder = '/charges/{charge_id}/payment-method'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, + 'charge_id' => $chargeId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -401,7 +420,7 @@ public function getChargeTransactions( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListChargeTransactionsResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); } /** @@ -434,6 +453,7 @@ public function updateChargeDueDate( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -495,47 +515,27 @@ public function updateChargeDueDate( } /** - * Lists all charges + * ConfirmPayment * - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $code (optional) Filter for charge's code - * @param string $status (optional) Filter for charge's status - * @param string $paymentMethod (optional) Filter for charge's payment method - * @param string $customerId (optional) Filter for charge's customer id - * @param string $orderId (optional) Filter for charge's order id - * @param DateTime $createdSince (optional) Filter for the beginning of the range for charge's creation - * @param DateTime $createdUntil (optional) Filter for the end of the range for charge's creation + * @param string $chargeId TODO: type description here + * @param string $idempotencyKey (optional) TODO: type description here + * @param Models\CreateConfirmPaymentRequest $body (optional) Request for confirm payment * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCharges( - $page = null, - $size = null, - $code = null, - $status = null, - $paymentMethod = null, - $customerId = null, - $orderId = null, - $createdSince = null, - $createdUntil = null + public function confirmPayment( + $chargeId, + $idempotencyKey = null, + $body = null ) { //prepare query string for API call - $_queryBuilder = '/charges'; + $_queryBuilder = '/charges/{charge_id}/confirm-payment'; //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'code' => $code, - 'status' => $status, - 'payment_method' => $paymentMethod, - 'customer_id' => $customerId, - 'order_id' => $orderId, - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'charge_id' => $chargeId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -543,20 +543,26 @@ public function getCharges( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -596,30 +602,26 @@ public function getCharges( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListChargesResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); } /** - * Updates the card from a charge + * Get a charge from its id * - * @param string $chargeId Charge id - * @param Models\UpdateChargeCardRequest $body Request for updating a charge's card - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $chargeId Charge id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateChargeCard( - $chargeId, - $body, - $idempotencyKey = null + public function getCharge( + $chargeId ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/card'; + $_queryBuilder = '/charges/{charge_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, + 'charge_id' => $chargeId, )); //validate and preprocess url @@ -629,24 +631,20 @@ public function updateChargeCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -690,22 +688,24 @@ public function updateChargeCard( } /** - * Get a charge from its id + * Retries a charge * - * @param string $chargeId Charge id + * @param string $chargeId Charge id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCharge( - $chargeId + public function retryCharge( + $chargeId, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}'; + $_queryBuilder = '/charges/{charge_id}/retry'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, + 'charge_id' => $chargeId, )); //validate and preprocess url @@ -714,20 +714,22 @@ public function getCharge( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -771,22 +773,22 @@ public function getCharge( } /** - * Cancel a charge + * Updates the metadata from a charge * - * @param string $chargeId Charge id - * @param string $idempotencyKey (optional) TODO: type description here - * @param Models\CreateCancelChargeRequest $body (optional) Request for cancelling a charge + * @param string $chargeId The charge id + * @param Models\UpdateMetadataRequest $body Request for updating the charge metadata + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function cancelCharge( + public function updateChargeMetadata( $chargeId, - $idempotencyKey = null, - $body = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}'; + $_queryBuilder = '/Charges/{charge_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -800,6 +802,7 @@ public function cancelCharge( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -811,13 +814,13 @@ public function cancelCharge( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers, $_bodyJson); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -861,29 +864,27 @@ public function cancelCharge( } /** - * GetChargesSummary + * Updates the card from a charge * - * @param string $status TODO: type description here - * @param DateTime $createdSince (optional) TODO: type description here - * @param DateTime $createdUntil (optional) TODO: type description here + * @param string $chargeId Charge id + * @param Models\UpdateChargeCardRequest $body Request for updating a charge's card + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getChargesSummary( - $status, - $createdSince = null, - $createdUntil = null + public function updateChargeCard( + $chargeId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/charges/summary'; + $_queryBuilder = '/charges/{charge_id}/card'; //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'status' => $status, - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'charge_id' => $chargeId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -891,20 +892,26 @@ public function getChargesSummary( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -944,24 +951,26 @@ public function getChargesSummary( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargesSummaryResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); } /** - * Retries a charge + * Cancel a charge * - * @param string $chargeId Charge id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $chargeId Charge id + * @param string $idempotencyKey (optional) TODO: type description here + * @param Models\CreateCancelChargeRequest $body (optional) Request for cancelling a charge * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function retryCharge( + public function cancelCharge( $chargeId, - $idempotencyKey = null + $idempotencyKey = null, + $body = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/retry'; + $_queryBuilder = '/charges/{charge_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -975,20 +984,25 @@ public function retryCharge( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1032,20 +1046,29 @@ public function retryCharge( } /** - * Creates a new charge + * GetChargesSummary * - * @param Models\CreateChargeRequest $body Request for creating a charge - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $status TODO: type description here + * @param DateTime $createdSince (optional) TODO: type description here + * @param DateTime $createdUntil (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createCharge( - $body, - $idempotencyKey = null + public function getChargesSummary( + $status, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/Charges'; + $_queryBuilder = '/charges/summary'; + + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'status' => $status, + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1054,24 +1077,20 @@ public function createCharge( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1111,31 +1130,24 @@ public function createCharge( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargeResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetChargesSummaryResponse'); } /** - * ConfirmPayment + * Creates a new charge * - * @param string $chargeId TODO: type description here - * @param string $idempotencyKey (optional) TODO: type description here - * @param Models\CreateConfirmPaymentRequest $body (optional) Request for confirm payment + * @param Models\CreateChargeRequest $body Request for creating a charge + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function confirmPayment( - $chargeId, - $idempotencyKey = null, - $body = null + public function createCharge( + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/charges/{charge_id}/confirm-payment'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'charge_id' => $chargeId, - )); + $_queryBuilder = '/Charges'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1144,6 +1156,7 @@ public function confirmPayment( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); diff --git a/src/Controllers/CustomersController.php b/src/Controllers/CustomersController.php index f1bb13f..167c3b5 100644 --- a/src/Controllers/CustomersController.php +++ b/src/Controllers/CustomersController.php @@ -42,19 +42,17 @@ public static function getInstance() } /** - * Updates a card + * Delete a customer's card * - * @param string $customerId Customer Id - * @param string $cardId Card id - * @param Models\UpdateCardRequest $body Request for updating a card - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param string $cardId Card Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateCard( + public function deleteCard( $customerId, $cardId, - $body, $idempotencyKey = null ) { @@ -74,24 +72,21 @@ public function updateCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -135,27 +130,29 @@ public function updateCard( } /** - * Delete a customer's card + * Updates an address * - * @param string $customerId Customer Id - * @param string $cardId Card Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param string $addressId Address Id + * @param Models\UpdateAddressRequest $body Request for updating an address + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteCard( + public function updateAddress( $customerId, - $cardId, + $addressId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/cards/{card_id}'; + $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, - 'card_id' => $cardId, + 'address_id' => $addressId, )); //validate and preprocess url @@ -165,20 +162,25 @@ public function deleteCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -218,29 +220,29 @@ public function deleteCard( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); } /** - * Get a customer's card + * Get a customer's address * * @param string $customerId Customer id - * @param string $cardId Card id + * @param string $addressId Address Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCard( + public function getAddress( $customerId, - $cardId + $addressId ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/cards/{card_id}'; + $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, - 'card_id' => $cardId, + 'address_id' => $addressId, )); //validate and preprocess url @@ -249,7 +251,8 @@ public function getCard( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -302,35 +305,38 @@ public function getCard( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); } /** - * Updates an address + * Get all access tokens from a customer * - * @param string $customerId Customer Id - * @param string $addressId Address Id - * @param Models\UpdateAddressRequest $body Request for updating an address - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateAddress( + public function getAccessTokens( $customerId, - $addressId, - $body, - $idempotencyKey = null + $page = null, + $size = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; + $_queryBuilder = '/customers/{customer_id}/access-tokens'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, - 'address_id' => $addressId, + 'customer_id' => $customerId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -338,24 +344,20 @@ public function updateAddress( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -395,29 +397,30 @@ public function updateAddress( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAccessTokensResponse'); } /** - * Get a customer's address + * Updates a customer * - * @param string $customerId Customer id - * @param string $addressId Address Id + * @param string $customerId Customer id + * @param Models\UpdateCustomerRequest $body Request for updating a customer + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAddress( + public function updateCustomer( $customerId, - $addressId + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; + $_queryBuilder = '/customers/{customer_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, - 'address_id' => $addressId, + 'customer_id' => $customerId, )); //validate and preprocess url @@ -426,20 +429,26 @@ public function getAddress( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -479,31 +488,31 @@ public function getAddress( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); } /** - * Delete a Customer's address + * Renew a card * - * @param string $customerId Customer Id - * @param string $addressId Address Id + * @param string $customerId Customer id + * @param string $cardId Card Id * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteAddress( + public function renewCard( $customerId, - $addressId, + $cardId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; + $_queryBuilder = '/customers/{customer_id}/cards/{card_id}/renew'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, - 'address_id' => $addressId, + 'card_id' => $cardId, )); //validate and preprocess url @@ -513,6 +522,7 @@ public function deleteAddress( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); @@ -520,13 +530,13 @@ public function deleteAddress( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -566,32 +576,42 @@ public function deleteAddress( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); } /** - * Delete a customer's access token + * Get all Customers * - * @param string $customerId Customer Id - * @param string $tokenId Token Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $name (optional) Name of the Customer + * @param string $document (optional) Document of the Customer + * @param integer $page (optional) Current page the the search + * @param integer $size (optional) Quantity pages of the search + * @param string $email (optional) Customer's email + * @param string $code (optional) Customer's code * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteAccessToken( - $customerId, - $tokenId, - $idempotencyKey = null + public function getCustomers( + $name = null, + $document = null, + $page = 1, + $size = 10, + $email = null, + $code = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/access-tokens/{token_id}'; + $_queryBuilder = '/customers'; //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, - 'token_id' => $tokenId, - )); + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'name' => $name, + 'document' => $document, + 'page' => (null != $page) ? $page : 1, + 'size' => (null != $size) ? $size : 10, + 'email' => $email, + 'Code' => $code, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -600,20 +620,20 @@ public function deleteAccessToken( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -653,29 +673,26 @@ public function deleteAccessToken( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCustomersResponse'); } /** - * Get a Customer's access token + * Delete a Customer's access tokens * * @param string $customerId Customer Id - * @param string $tokenId Token Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAccessToken( - $customerId, - $tokenId + public function deleteAccessTokens( + $customerId ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/access-tokens/{token_id}'; + $_queryBuilder = '/customers/{customer_id}/access-tokens/'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, - 'token_id' => $tokenId, )); //validate and preprocess url @@ -684,7 +701,8 @@ public function getAccessToken( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -737,30 +755,26 @@ public function getAccessToken( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAccessTokensResponse'); } /** - * Creates a access token for a customer + * Get a customer * - * @param string $customerId Customer Id - * @param Models\CreateAccessTokenRequest $body Request for creating a access token - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createAccessToken( - $customerId, - $body, - $idempotencyKey = null + public function getCustomer( + $customerId ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/access-tokens'; + $_queryBuilder = '/customers/{customer_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, )); //validate and preprocess url @@ -770,24 +784,20 @@ public function createAccessToken( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -827,58 +837,61 @@ public function createAccessToken( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); } /** - * Get all access tokens from a customer + * Updates a card * - * @param string $customerId Customer Id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param string $customerId Customer Id + * @param string $cardId Card id + * @param Models\UpdateCardRequest $body Request for updating a card + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAccessTokens( + public function updateCard( $customerId, - $page = null, - $size = null + $cardId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/access-tokens'; + $_queryBuilder = '/customers/{customer_id}/cards/{card_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, + 'card_id' => $cardId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -918,30 +931,31 @@ public function getAccessTokens( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAccessTokensResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); } /** - * Creates a new address for a customer + * Delete a Customer's address * - * @param string $customerId Customer Id - * @param Models\CreateAddressRequest $body Request for creating an address - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param string $addressId Address Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createAddress( + public function deleteAddress( $customerId, - $body, + $addressId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/addresses'; + $_queryBuilder = '/customers/{customer_id}/addresses/{address_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, + 'address_id' => $addressId, )); //validate and preprocess url @@ -951,24 +965,21 @@ public function createAddress( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1012,33 +1023,27 @@ public function createAddress( } /** - * Gets all adressess from a customer + * Creates a access token for a customer * - * @param string $customerId Customer id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param string $customerId Customer Id + * @param Models\CreateAccessTokenRequest $body Request for creating a access token + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAddresses( + public function createAccessToken( $customerId, - $page = null, - $size = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/addresses'; + $_queryBuilder = '/customers/{customer_id}/access-tokens'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, - )); - - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - )); + 'customer_id' => $customerId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1046,20 +1051,26 @@ public function getAddresses( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1099,24 +1110,31 @@ public function getAddresses( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAddressesResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); } /** - * Creates a new customer + * Creates a new address for a customer * - * @param Models\CreateCustomerRequest $body Request for creating a customer - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param Models\CreateAddressRequest $body Request for creating an address + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createCustomer( + public function createAddress( + $customerId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers'; + $_queryBuilder = '/customers/{customer_id}/addresses'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'customer_id' => $customerId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1125,6 +1143,7 @@ public function createCustomer( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -1182,41 +1201,36 @@ public function createCustomer( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAddressResponse'); } /** - * Get all Customers + * Get all cards from a customer * - * @param string $name (optional) Name of the Customer - * @param string $document (optional) Document of the Customer - * @param integer $page (optional) Current page the the search - * @param integer $size (optional) Quantity pages of the search - * @param string $email (optional) Customer's email - * @param string $code (optional) Customer's code + * @param string $customerId Customer Id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCustomers( - $name = null, - $document = null, - $page = 1, - $size = 10, - $email = null, - $code = null + public function getCards( + $customerId, + $page = null, + $size = null ) { //prepare query string for API call - $_queryBuilder = '/customers'; + $_queryBuilder = '/customers/{customer_id}/cards'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'customer_id' => $customerId, + )); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'name' => $name, - 'document' => $document, - 'page' => (null != $page) ? $page : 1, - 'size' => (null != $size) ? $size : 10, - 'email' => $email, - 'Code' => $code, + 'page' => $page, + 'size' => $size, )); //validate and preprocess url @@ -1225,7 +1239,8 @@ public function getCustomers( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -1278,26 +1293,30 @@ public function getCustomers( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCustomersResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCardsResponse'); } /** - * Delete a Customer's access tokens + * Updates the metadata a customer * - * @param string $customerId Customer Id + * @param string $customerId The customer id + * @param Models\UpdateMetadataRequest $body Request for updating the customer metadata + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteAccessTokens( - $customerId + public function updateCustomerMetadata( + $customerId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/access-tokens/'; + $_queryBuilder = '/Customers/{customer_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, )); //validate and preprocess url @@ -1306,20 +1325,26 @@ public function deleteAccessTokens( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1359,30 +1384,29 @@ public function deleteAccessTokens( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAccessTokensResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); } /** - * Creates a new card for a customer + * Get a customer's card * - * @param string $customerId Customer id - * @param Models\CreateCardRequest $body Request for creating a card - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer id + * @param string $cardId Card id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createCard( + public function getCard( $customerId, - $body, - $idempotencyKey = null + $cardId ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/cards'; + $_queryBuilder = '/customers/{customer_id}/cards/{card_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, + 'card_id' => $cardId, )); //validate and preprocess url @@ -1392,24 +1416,20 @@ public function createCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1453,54 +1473,51 @@ public function createCard( } /** - * Get all cards from a customer + * Delete a customer's access token * - * @param string $customerId Customer Id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param string $customerId Customer Id + * @param string $tokenId Token Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCards( + public function deleteAccessToken( $customerId, - $page = null, - $size = null + $tokenId, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/cards'; + $_queryBuilder = '/customers/{customer_id}/access-tokens/{token_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, + 'token_id' => $tokenId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1540,30 +1557,29 @@ public function getCards( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCardsResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); } /** - * Updates a customer + * Get a Customer's access token * - * @param string $customerId Customer id - * @param Models\UpdateCustomerRequest $body Request for updating a customer - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer Id + * @param string $tokenId Token Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateCustomer( + public function getAccessToken( $customerId, - $body, - $idempotencyKey = null + $tokenId ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}'; + $_queryBuilder = '/customers/{customer_id}/access-tokens/{token_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, + 'customer_id' => $customerId, + 'token_id' => $tokenId, )); //validate and preprocess url @@ -1573,24 +1589,20 @@ public function updateCustomer( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1630,35 +1642,46 @@ public function updateCustomer( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAccessTokenResponse'); } /** - * Get a customer + * Gets all adressess from a customer * - * @param string $customerId Customer Id + * @param string $customerId Customer id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getCustomer( - $customerId + public function getAddresses( + $customerId, + $page = null, + $size = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}'; + $_queryBuilder = '/customers/{customer_id}/addresses'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'customer_id' => $customerId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -1711,32 +1734,24 @@ public function getCustomer( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAddressesResponse'); } /** - * Renew a card + * Creates a new customer * - * @param string $customerId Customer id - * @param string $cardId Card Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param Models\CreateCustomerRequest $body Request for creating a customer + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function renewCard( - $customerId, - $cardId, + public function createCustomer( + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/customers/{customer_id}/cards/{card_id}/renew'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'customer_id' => $customerId, - 'card_id' => $cardId, - )); + $_queryBuilder = '/customers'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1745,9 +1760,14 @@ public function renewCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); @@ -1758,7 +1778,7 @@ public function renewCard( } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1798,26 +1818,26 @@ public function renewCard( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); } /** - * Updates the metadata a customer + * Creates a new card for a customer * - * @param string $customerId The customer id - * @param Models\UpdateMetadataRequest $body Request for updating the customer metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $customerId Customer id + * @param Models\CreateCardRequest $body Request for creating a card + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateCustomerMetadata( + public function createCard( $customerId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/Customers/{customer_id}/metadata'; + $_queryBuilder = '/customers/{customer_id}/cards'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -1831,6 +1851,7 @@ public function updateCustomerMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -1842,13 +1863,13 @@ public function updateCustomerMetadata( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1888,6 +1909,6 @@ public function updateCustomerMetadata( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCustomerResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetCardResponse'); } } diff --git a/src/Controllers/InvoicesController.php b/src/Controllers/InvoicesController.php index cfa6d2a..203337b 100644 --- a/src/Controllers/InvoicesController.php +++ b/src/Controllers/InvoicesController.php @@ -42,87 +42,6 @@ public static function getInstance() return static::$instance; } - /** - * GetPartialInvoice - * - * @param string $subscriptionId Subscription Id - * @return mixed response from the API call - * @throws APIException Thrown if API call fails - */ - public function getPartialInvoice( - $subscriptionId - ) { - - //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/partial-invoice'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'subscription_id' => $subscriptionId, - )); - - //validate and preprocess url - $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); - - //prepare headers - $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' - ); - - //set HTTP basic auth parameters - Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); - - //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); - if ($this->getHttpCallBack() != null) { - $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); - } - - //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); - - $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); - $_httpContext = new HttpContext($_httpRequest, $_httpResponse); - - //call on-after Http callback - if ($this->getHttpCallBack() != null) { - $this->getHttpCallBack()->callOnAfterRequest($_httpContext); - } - - //Error handling using HTTP status codes - if ($response->code == 400) { - throw new Exceptions\ErrorException('Invalid request', $_httpContext); - } - - if ($response->code == 401) { - throw new Exceptions\ErrorException('Invalid API key', $_httpContext); - } - - if ($response->code == 404) { - throw new Exceptions\ErrorException('An informed resource was not found', $_httpContext); - } - - if ($response->code == 412) { - throw new Exceptions\ErrorException('Business validation error', $_httpContext); - } - - if ($response->code == 422) { - throw new Exceptions\ErrorException('Contract validation error', $_httpContext); - } - - if ($response->code == 500) { - throw new Exceptions\ErrorException('Internal server error', $_httpContext); - } - - //handle errors defined at the API level - $this->validateResponse($_httpResponse, $_httpContext); - - $mapper = $this->getJsonMapper(); - - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetInvoiceResponse'); - } - /** * Cancels an invoice * @@ -151,6 +70,7 @@ public function cancelInvoice( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); @@ -232,7 +152,8 @@ public function getInvoice( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -321,6 +242,7 @@ public function createInvoice( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -411,6 +333,7 @@ public function updateInvoiceMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -526,7 +449,8 @@ public function getInvoices( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -582,6 +506,88 @@ public function getInvoices( return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListInvoicesResponse'); } + /** + * GetPartialInvoice + * + * @param string $subscriptionId Subscription Id + * @return mixed response from the API call + * @throws APIException Thrown if API call fails + */ + public function getPartialInvoice( + $subscriptionId + ) { + + //prepare query string for API call + $_queryBuilder = '/subscriptions/{subscription_id}/partial-invoice'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'subscription_id' => $subscriptionId, + )); + + //validate and preprocess url + $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); + + //prepare headers + $_headers = array ( + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName + ); + + //set HTTP basic auth parameters + Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); + + //call on-before Http callback + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + if ($this->getHttpCallBack() != null) { + $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); + } + + //and invoke the API call request to fetch the response + $response = Request::get($_queryUrl, $_headers); + + $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); + $_httpContext = new HttpContext($_httpRequest, $_httpResponse); + + //call on-after Http callback + if ($this->getHttpCallBack() != null) { + $this->getHttpCallBack()->callOnAfterRequest($_httpContext); + } + + //Error handling using HTTP status codes + if ($response->code == 400) { + throw new Exceptions\ErrorException('Invalid request', $_httpContext); + } + + if ($response->code == 401) { + throw new Exceptions\ErrorException('Invalid API key', $_httpContext); + } + + if ($response->code == 404) { + throw new Exceptions\ErrorException('An informed resource was not found', $_httpContext); + } + + if ($response->code == 412) { + throw new Exceptions\ErrorException('Business validation error', $_httpContext); + } + + if ($response->code == 422) { + throw new Exceptions\ErrorException('Contract validation error', $_httpContext); + } + + if ($response->code == 500) { + throw new Exceptions\ErrorException('Internal server error', $_httpContext); + } + + //handle errors defined at the API level + $this->validateResponse($_httpResponse, $_httpContext); + + $mapper = $this->getJsonMapper(); + + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetInvoiceResponse'); + } + /** * Updates the status from an invoice * @@ -612,6 +618,7 @@ public function updateInvoiceStatus( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); diff --git a/src/Controllers/OrdersController.php b/src/Controllers/OrdersController.php index 7a5b045..b0cc757 100644 --- a/src/Controllers/OrdersController.php +++ b/src/Controllers/OrdersController.php @@ -85,7 +85,8 @@ public function getOrders( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -164,6 +165,7 @@ public function createOrder( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -225,15 +227,17 @@ public function createOrder( } /** - * DeleteAllOrderItems + * CreateOrderItem * - * @param string $orderId Order Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $orderId Order Id + * @param Models\CreateOrderItemRequest $body Order Item Model + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteAllOrderItems( + public function createOrderItem( $orderId, + $body, $idempotencyKey = null ) { @@ -252,20 +256,25 @@ public function deleteAllOrderItems( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -305,30 +314,29 @@ public function deleteAllOrderItems( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderItemResponse'); } /** - * CreateOrderItem + * GetOrderItem * - * @param string $orderId Order Id - * @param Models\CreateOrderItemRequest $body Order Item Model - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $orderId Order Id + * @param string $itemId Item Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createOrderItem( + public function getOrderItem( $orderId, - $body, - $idempotencyKey = null + $itemId ) { //prepare query string for API call - $_queryBuilder = '/orders/{orderId}/items'; + $_queryBuilder = '/orders/{orderId}/items/{itemId}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'orderId' => $orderId, + 'orderId' => $orderId, + 'itemId' => $itemId, )); //validate and preprocess url @@ -338,24 +346,20 @@ public function createOrderItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -399,19 +403,17 @@ public function createOrderItem( } /** - * UpdateOrderItem + * DeleteOrderItem * - * @param string $orderId Order Id - * @param string $itemId Item Id - * @param Models\UpdateOrderItemRequest $body Item Model - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $orderId Order Id + * @param string $itemId Item Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateOrderItem( + public function deleteOrderItem( $orderId, $itemId, - $body, $idempotencyKey = null ) { @@ -431,24 +433,21 @@ public function updateOrderItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -492,27 +491,26 @@ public function updateOrderItem( } /** - * DeleteOrderItem + * Updates the metadata from an order * - * @param string $orderId Order Id - * @param string $itemId Item Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $orderId The order id + * @param Models\UpdateMetadataRequest $body Request for updating the order metadata + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteOrderItem( + public function updateOrderMetadata( $orderId, - $itemId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/orders/{orderId}/items/{itemId}'; + $_queryBuilder = '/Orders/{order_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'orderId' => $orderId, - 'itemId' => $itemId, + 'order_id' => $orderId, )); //validate and preprocess url @@ -522,20 +520,25 @@ public function deleteOrderItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -575,29 +578,28 @@ public function deleteOrderItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderResponse'); } /** - * GetOrderItem + * DeleteAllOrderItems * - * @param string $orderId Order Id - * @param string $itemId Item Id + * @param string $orderId Order Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getOrderItem( + public function deleteAllOrderItems( $orderId, - $itemId + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/orders/{orderId}/items/{itemId}'; + $_queryBuilder = '/orders/{orderId}/items'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'orderId' => $orderId, - 'itemId' => $itemId, + 'orderId' => $orderId, )); //validate and preprocess url @@ -606,20 +608,22 @@ public function getOrderItem( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -659,30 +663,33 @@ public function getOrderItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderResponse'); } /** - * CloseOrder + * UpdateOrderItem * - * @param string $id Order Id - * @param Models\UpdateOrderStatusRequest $body Update Order Model - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $orderId Order Id + * @param string $itemId Item Id + * @param Models\UpdateOrderItemRequest $body Item Model + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function closeOrder( - $id, + public function updateOrderItem( + $orderId, + $itemId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/orders/{id}/closed'; + $_queryBuilder = '/orders/{orderId}/items/{itemId}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'id' => $id, + 'orderId' => $orderId, + 'itemId' => $itemId, )); //validate and preprocess url @@ -692,6 +699,7 @@ public function closeOrder( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -703,13 +711,13 @@ public function closeOrder( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -749,30 +757,30 @@ public function closeOrder( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetOrderItemResponse'); } /** - * Updates the metadata from an order + * CloseOrder * - * @param string $orderId The order id - * @param Models\UpdateMetadataRequest $body Request for updating the order metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $id Order Id + * @param Models\UpdateOrderStatusRequest $body Update Order Model + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateOrderMetadata( - $orderId, + public function closeOrder( + $id, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/Orders/{order_id}/metadata'; + $_queryBuilder = '/orders/{id}/closed'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'order_id' => $orderId, + 'id' => $id, )); //validate and preprocess url @@ -782,6 +790,7 @@ public function updateOrderMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -867,7 +876,8 @@ public function getOrder( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters diff --git a/src/Controllers/PlansController.php b/src/Controllers/PlansController.php index a74813e..10bc070 100644 --- a/src/Controllers/PlansController.php +++ b/src/Controllers/PlansController.php @@ -67,7 +67,8 @@ public function getPlan( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -124,27 +125,20 @@ public function getPlan( } /** - * Updates a plan + * Creates a new plan * - * @param string $planId Plan id - * @param Models\UpdatePlanRequest $body Request for updating a plan + * @param Models\CreatePlanRequest $body Request for creating a plan * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updatePlan( - $planId, + public function createPlan( $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans/{plan_id}'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'plan_id' => $planId, - )); + $_queryBuilder = '/plans'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -153,6 +147,7 @@ public function updatePlan( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -164,13 +159,13 @@ public function updatePlan( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -214,15 +209,17 @@ public function updatePlan( } /** - * Deletes a plan + * Updates a plan * - * @param string $planId Plan id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $planId Plan id + * @param Models\UpdatePlanRequest $body Request for updating a plan + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deletePlan( + public function updatePlan( $planId, + $body, $idempotencyKey = null ) { @@ -241,20 +238,25 @@ public function deletePlan( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -298,26 +300,25 @@ public function deletePlan( } /** - * Updates the metadata from a plan + * Gets a plan item * - * @param string $planId The plan id - * @param Models\UpdateMetadataRequest $body Request for updating the plan metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $planId Plan id + * @param string $planItemId Plan item id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updatePlanMetadata( + public function getPlanItem( $planId, - $body, - $idempotencyKey = null + $planItemId ) { //prepare query string for API call - $_queryBuilder = '/Plans/{plan_id}/metadata'; + $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'plan_id' => $planId, + 'plan_id' => $planId, + 'plan_item_id' => $planItemId, )); //validate and preprocess url @@ -327,24 +328,20 @@ public function updatePlanMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -384,33 +381,30 @@ public function updatePlanMetadata( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); } /** - * Updates a plan item + * Adds a new item to a plan * * @param string $planId Plan id - * @param string $planItemId Plan item id - * @param Models\UpdatePlanItemRequest $body Request for updating the plan item + * @param Models\CreatePlanItemRequest $body Request for creating a plan item * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updatePlanItem( + public function createPlanItem( $planId, - $planItemId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; + $_queryBuilder = '/plans/{plan_id}/items'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'plan_id' => $planId, - 'plan_item_id' => $planItemId, )); //validate and preprocess url @@ -420,6 +414,7 @@ public function updatePlanItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -431,13 +426,13 @@ public function updatePlanItem( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -481,26 +476,41 @@ public function updatePlanItem( } /** - * Gets a plan item + * Gets all plans * - * @param string $planId Plan id - * @param string $planItemId Plan item id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $name (optional) Filter for Plan's name + * @param string $status (optional) Filter for Plan's status + * @param string $billingType (optional) Filter for plan's billing type + * @param DateTime $createdSince (optional) Filter for plan's creation date start range + * @param DateTime $createdUntil (optional) Filter for plan's creation date end range * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getPlanItem( - $planId, - $planItemId + public function getPlans( + $page = null, + $size = null, + $name = null, + $status = null, + $billingType = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; + $_queryBuilder = '/plans'; //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'plan_id' => $planId, - 'plan_item_id' => $planItemId, - )); + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'name' => $name, + 'status' => $status, + 'billing_type' => $billingType, + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -508,7 +518,8 @@ public function getPlanItem( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -561,31 +572,28 @@ public function getPlanItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListPlansResponse'); } /** - * Removes an item from a plan + * Deletes a plan * * @param string $planId Plan id - * @param string $planItemId Plan item id * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deletePlanItem( + public function deletePlan( $planId, - $planItemId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; + $_queryBuilder = '/plans/{plan_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'plan_id' => $planId, - 'plan_item_id' => $planItemId, )); //validate and preprocess url @@ -595,6 +603,7 @@ public function deletePlanItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); @@ -648,26 +657,26 @@ public function deletePlanItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanResponse'); } /** - * Adds a new item to a plan + * Updates the metadata from a plan * - * @param string $planId Plan id - * @param Models\CreatePlanItemRequest $body Request for creating a plan item + * @param string $planId The plan id + * @param Models\UpdateMetadataRequest $body Request for updating the plan metadata * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createPlanItem( + public function updatePlanMetadata( $planId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans/{plan_id}/items'; + $_queryBuilder = '/Plans/{plan_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -681,6 +690,7 @@ public function createPlanItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -692,13 +702,13 @@ public function createPlanItem( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -738,24 +748,34 @@ public function createPlanItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanResponse'); } /** - * Creates a new plan + * Updates a plan item * - * @param Models\CreatePlanRequest $body Request for creating a plan - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $planId Plan id + * @param string $planItemId Plan item id + * @param Models\UpdatePlanItemRequest $body Request for updating the plan item + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createPlan( + public function updatePlanItem( + $planId, + $planItemId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans'; + $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'plan_id' => $planId, + 'plan_item_id' => $planItemId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -764,6 +784,7 @@ public function createPlan( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -775,13 +796,13 @@ public function createPlan( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -821,45 +842,32 @@ public function createPlan( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); } /** - * Gets all plans + * Removes an item from a plan * - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $name (optional) Filter for Plan's name - * @param string $status (optional) Filter for Plan's status - * @param string $billingType (optional) Filter for plan's billing type - * @param DateTime $createdSince (optional) Filter for plan's creation date start range - * @param DateTime $createdUntil (optional) Filter for plan's creation date end range + * @param string $planId Plan id + * @param string $planItemId Plan item id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getPlans( - $page = null, - $size = null, - $name = null, - $status = null, - $billingType = null, - $createdSince = null, - $createdUntil = null + public function deletePlanItem( + $planId, + $planItemId, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/plans'; + $_queryBuilder = '/plans/{plan_id}/items/{plan_item_id}'; //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'name' => $name, - 'status' => $status, - 'billing_type' => $billingType, - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'plan_id' => $planId, + 'plan_item_id' => $planItemId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -867,20 +875,22 @@ public function getPlans( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -920,6 +930,6 @@ public function getPlans( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListPlansResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPlanItemResponse'); } } diff --git a/src/Controllers/RecipientsController.php b/src/Controllers/RecipientsController.php index 10c74d6..5d713e6 100644 --- a/src/Controllers/RecipientsController.php +++ b/src/Controllers/RecipientsController.php @@ -70,7 +70,8 @@ public function getTransfer( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -127,18 +128,14 @@ public function getTransfer( } /** - * Updates a recipient + * Retrieves recipient information * - * @param string $recipientId Recipient id - * @param Models\UpdateRecipientRequest $body Recipient data - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId Recipiend id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateRecipient( - $recipientId, - $body, - $idempotencyKey = null + public function getRecipient( + $recipientId ) { //prepare query string for API call @@ -146,7 +143,7 @@ public function updateRecipient( //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, )); //validate and preprocess url @@ -156,24 +153,20 @@ public function updateRecipient( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -217,22 +210,26 @@ public function updateRecipient( } /** - * Retrieves recipient information + * Updates recipient metadata * - * @param string $recipientId Recipiend id + * @param string $recipientId Recipient id + * @param Models\UpdateMetadataRequest $body Metadata + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getRecipient( - $recipientId + public function updateRecipientMetadata( + $recipientId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}'; + $_queryBuilder = '/recipients/{recipient_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, )); //validate and preprocess url @@ -241,20 +238,26 @@ public function getRecipient( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -298,22 +301,22 @@ public function getRecipient( } /** - * Creates an anticipation + * Creates a transfer for a recipient * - * @param string $recipientId Recipient id - * @param Models\CreateAnticipationRequest $body Anticipation data - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId Recipient Id + * @param Models\CreateTransferRequest $body Transfer data + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createAnticipation( + public function createTransfer( $recipientId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/anticipations'; + $_queryBuilder = '/recipients/{recipient_id}/transfers'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -327,6 +330,7 @@ public function createAnticipation( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -384,76 +388,59 @@ public function createAnticipation( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetTransferResponse'); } /** - * Retrieves a paginated list of anticipations from a recipient + * Updates recipient metadata * - * @param string $recipientId Recipient id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $status (optional) Filter for anticipation status - * @param string $timeframe (optional) Filter for anticipation timeframe - * @param DateTime $paymentDateSince (optional) Filter for start range for anticipation payment date - * @param DateTime $paymentDateUntil (optional) Filter for end range for anticipation payment date - * @param DateTime $createdSince (optional) Filter for start range for anticipation creation date - * @param DateTime $createdUntil (optional) Filter for end range for anticipation creation date + * @param string $recipientId Recipient id + * @param Models\UpdateAutomaticAnticipationSettingsRequest $body Metadata + * @param string $idempotencyKey (optional) TODO: type description + * here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAnticipations( + public function updateAutomaticAnticipationSettings( $recipientId, - $page = null, - $size = null, - $status = null, - $timeframe = null, - $paymentDateSince = null, - $paymentDateUntil = null, - $createdSince = null, - $createdUntil = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/anticipations'; + $_queryBuilder = '/recipients/{recipient_id}/automatic-anticipation-settings'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'status' => $status, - 'timeframe' => $timeframe, - 'payment_date_since' => DateTimeHelper::toRfc3339DateTime($paymentDateSince), - 'payment_date_until' => DateTimeHelper::toRfc3339DateTime($paymentDateUntil), - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -493,45 +480,36 @@ public function getAnticipations( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAnticipationResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); } /** - * Gets the anticipation limits for a recipient + * Get balance information for a recipient * - * @param string $recipientId Recipient id - * @param string $timeframe Timeframe - * @param DateTime $paymentDate Anticipation payment date + * @param string $recipientId Recipient id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAnticipationLimits( - $recipientId, - $timeframe, - $paymentDate + public function getBalance( + $recipientId ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/anticipation_limits'; + $_queryBuilder = '/recipients/{recipient_id}/balance'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'recipient_id' => $recipientId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'timeframe' => $timeframe, - 'payment_date' => DateTimeHelper::toRfc3339DateTime($paymentDate), - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -584,29 +562,54 @@ public function getAnticipationLimits( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationLimitResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetBalanceResponse'); } /** - * Retrieves paginated recipients information + * Retrieves a paginated list of anticipations from a recipient * - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param string $recipientId Recipient id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $status (optional) Filter for anticipation status + * @param string $timeframe (optional) Filter for anticipation timeframe + * @param DateTime $paymentDateSince (optional) Filter for start range for anticipation payment date + * @param DateTime $paymentDateUntil (optional) Filter for end range for anticipation payment date + * @param DateTime $createdSince (optional) Filter for start range for anticipation creation date + * @param DateTime $createdUntil (optional) Filter for end range for anticipation creation date * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getRecipients( + public function getAnticipations( + $recipientId, $page = null, - $size = null + $size = null, + $status = null, + $timeframe = null, + $paymentDateSince = null, + $paymentDateUntil = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/recipients'; + $_queryBuilder = '/recipients/{recipient_id}/anticipations'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'recipient_id' => $recipientId, + )); //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, + 'page' => $page, + 'size' => $size, + 'status' => $status, + 'timeframe' => $timeframe, + 'payment_date_since' => DateTimeHelper::toRfc3339DateTime($paymentDateSince), + 'payment_date_until' => DateTimeHelper::toRfc3339DateTime($paymentDateUntil), + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), )); //validate and preprocess url @@ -614,8 +617,9 @@ public function getRecipients( //prepare headers $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -668,24 +672,30 @@ public function getRecipients( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListRecipientResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListAnticipationResponse'); } /** - * Creates a new recipient + * GetWithdrawById * - * @param Models\CreateRecipientRequest $body Recipient data - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId TODO: type description here + * @param string $withdrawalId TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createRecipient( - $body, - $idempotencyKey = null + public function getWithdrawById( + $recipientId, + $withdrawalId ) { //prepare query string for API call - $_queryBuilder = '/recipients'; + $_queryBuilder = '/recipients/{recipient_id}/withdrawals/{withdrawal_id}'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'recipient_id' => $recipientId, + 'withdrawal_id' => $withdrawalId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -694,24 +704,20 @@ public function createRecipient( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -751,29 +757,28 @@ public function createRecipient( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetWithdrawResponse'); } /** - * GetWithdrawById + * CreateWithdraw * - * @param string $recipientId TODO: type description here - * @param string $withdrawalId TODO: type description here + * @param string $recipientId TODO: type description here + * @param Models\CreateWithdrawRequest $body TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getWithdrawById( + public function createWithdraw( $recipientId, - $withdrawalId + $body ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/withdrawals/{withdrawal_id}'; + $_queryBuilder = '/recipients/{recipient_id}/withdrawals'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, - 'withdrawal_id' => $withdrawalId, + 'recipient_id' => $recipientId, )); //validate and preprocess url @@ -782,20 +787,25 @@ public function getWithdrawById( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json' ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -839,22 +849,22 @@ public function getWithdrawById( } /** - * Updates the default bank account from a recipient + * Updates a recipient * - * @param string $recipientId Recipient id - * @param Models\UpdateRecipientBankAccountRequest $body Bank account data - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId Recipient id + * @param Models\UpdateRecipientRequest $body Recipient data + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateRecipientDefaultBankAccount( + public function updateRecipient( $recipientId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/default-bank-account'; + $_queryBuilder = '/recipients/{recipient_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -868,6 +878,7 @@ public function updateRecipientDefaultBankAccount( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -879,13 +890,13 @@ public function updateRecipientDefaultBankAccount( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -929,22 +940,22 @@ public function updateRecipientDefaultBankAccount( } /** - * Updates recipient metadata + * Creates an anticipation * - * @param string $recipientId Recipient id - * @param Models\UpdateMetadataRequest $body Metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId Recipient id + * @param Models\CreateAnticipationRequest $body Anticipation data + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateRecipientMetadata( + public function createAnticipation( $recipientId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/metadata'; + $_queryBuilder = '/recipients/{recipient_id}/anticipations'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -958,6 +969,7 @@ public function updateRecipientMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -969,13 +981,13 @@ public function updateRecipientMetadata( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1015,67 +1027,58 @@ public function updateRecipientMetadata( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationResponse'); } /** - * Gets a paginated list of transfers for the recipient + * Updates the default bank account from a recipient * - * @param string $recipientId Recipient id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $status (optional) Filter for transfer status - * @param DateTime $createdSince (optional) Filter for start range of transfer creation date - * @param DateTime $createdUntil (optional) Filter for end range of transfer creation date + * @param string $recipientId Recipient id + * @param Models\UpdateRecipientBankAccountRequest $body Bank account data + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getTransfers( + public function updateRecipientDefaultBankAccount( $recipientId, - $page = null, - $size = null, - $status = null, - $createdSince = null, - $createdUntil = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/transfers'; + $_queryBuilder = '/recipients/{recipient_id}/default-bank-account'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'status' => $status, - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1115,30 +1118,26 @@ public function getTransfers( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListTransferResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); } /** - * Creates a transfer for a recipient + * Retrieves recipient information * - * @param string $recipientId Recipient Id - * @param Models\CreateTransferRequest $body Transfer data - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $code Recipient code * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createTransfer( - $recipientId, - $body, - $idempotencyKey = null + public function getRecipientByCode( + $code ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/transfers'; + $_queryBuilder = '/recipients/{code}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'code' => $code, )); //validate and preprocess url @@ -1148,24 +1147,20 @@ public function createTransfer( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1205,30 +1200,38 @@ public function createTransfer( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetTransferResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); } /** - * CreateWithdraw + * Gets the anticipation limits for a recipient * - * @param string $recipientId TODO: type description here - * @param Models\CreateWithdrawRequest $body TODO: type description here + * @param string $recipientId Recipient id + * @param string $timeframe Timeframe + * @param DateTime $paymentDate Anticipation payment date * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createWithdraw( + public function getAnticipationLimits( $recipientId, - $body + $timeframe, + $paymentDate ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/withdrawals'; + $_queryBuilder = '/recipients/{recipient_id}/anticipation_limits'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'recipient_id' => $recipientId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'timeframe' => $timeframe, + 'payment_date' => DateTimeHelper::toRfc3339DateTime($paymentDate), + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1236,23 +1239,20 @@ public function createWithdraw( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json' + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1292,45 +1292,29 @@ public function createWithdraw( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetWithdrawResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationLimitResponse'); } /** - * Gets a paginated list of transfers for the recipient + * Retrieves paginated recipients information * - * @param string $recipientId TODO: type description here - * @param integer $page (optional) TODO: type description here - * @param integer $size (optional) TODO: type description here - * @param string $status (optional) TODO: type description here - * @param DateTime $createdSince (optional) TODO: type description here - * @param DateTime $createdUntil (optional) TODO: type description here + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getWithdrawals( - $recipientId, + public function getRecipients( $page = null, - $size = null, - $status = null, - $createdSince = null, - $createdUntil = null + $size = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/withdrawals'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, - )); + $_queryBuilder = '/recipients'; //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'status' => $status, - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + 'page' => $page, + 'size' => $size, )); //validate and preprocess url @@ -1339,7 +1323,8 @@ public function getWithdrawals( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -1392,32 +1377,24 @@ public function getWithdrawals( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListWithdrawals'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListRecipientResponse'); } /** - * Updates recipient metadata + * Creates a new recipient * - * @param string $recipientId Recipient id - * @param Models\UpdateAutomaticAnticipationSettingsRequest $body Metadata - * @param string $idempotencyKey (optional) TODO: type description - * here + * @param Models\CreateRecipientRequest $body Recipient data + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateAutomaticAnticipationSettings( - $recipientId, + public function createRecipient( $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/automatic-anticipation-settings'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, - )); + $_queryBuilder = '/recipients'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1426,6 +1403,7 @@ public function updateAutomaticAnticipationSettings( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -1437,13 +1415,13 @@ public function updateAutomaticAnticipationSettings( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1487,34 +1465,51 @@ public function updateAutomaticAnticipationSettings( } /** - * Gets an anticipation + * Gets a paginated list of transfers for the recipient * - * @param string $recipientId Recipient id - * @param string $anticipationId Anticipation id + * @param string $recipientId Recipient id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $status (optional) Filter for transfer status + * @param DateTime $createdSince (optional) Filter for start range of transfer creation date + * @param DateTime $createdUntil (optional) Filter for end range of transfer creation date * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getAnticipation( + public function getTransfers( $recipientId, - $anticipationId + $page = null, + $size = null, + $status = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/anticipations/{anticipation_id}'; + $_queryBuilder = '/recipients/{recipient_id}/transfers'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, - 'anticipation_id' => $anticipationId, + 'recipient_id' => $recipientId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'status' => $status, + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -1567,32 +1562,47 @@ public function getAnticipation( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListTransferResponse'); } /** - * UpdateRecipientTransferSettings + * Gets a paginated list of transfers for the recipient * - * @param string $recipientId Recipient Identificator - * @param Models\UpdateTransferSettingsRequest $body TODO: type description here - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $recipientId TODO: type description here + * @param integer $page (optional) TODO: type description here + * @param integer $size (optional) TODO: type description here + * @param string $status (optional) TODO: type description here + * @param DateTime $createdSince (optional) TODO: type description here + * @param DateTime $createdUntil (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateRecipientTransferSettings( + public function getWithdrawals( $recipientId, - $body, - $idempotencyKey = null + $page = null, + $size = null, + $status = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/transfer-settings'; + $_queryBuilder = '/recipients/{recipient_id}/withdrawals'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'status' => $status, + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1600,24 +1610,20 @@ public function updateRecipientTransferSettings( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1657,26 +1663,29 @@ public function updateRecipientTransferSettings( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListWithdrawals'); } /** - * Get balance information for a recipient + * Gets an anticipation * - * @param string $recipientId Recipient id + * @param string $recipientId Recipient id + * @param string $anticipationId Anticipation id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getBalance( - $recipientId + public function getAnticipation( + $recipientId, + $anticipationId ) { //prepare query string for API call - $_queryBuilder = '/recipients/{recipient_id}/balance'; + $_queryBuilder = '/recipients/{recipient_id}/anticipations/{anticipation_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'recipient_id' => $recipientId, + 'recipient_id' => $recipientId, + 'anticipation_id' => $anticipationId, )); //validate and preprocess url @@ -1685,7 +1694,8 @@ public function getBalance( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -1738,26 +1748,30 @@ public function getBalance( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetBalanceResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetAnticipationResponse'); } /** - * Retrieves recipient information + * UpdateRecipientTransferSettings * - * @param string $code Recipient code + * @param string $recipientId Recipient Identificator + * @param Models\UpdateTransferSettingsRequest $body TODO: type description here + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getRecipientByCode( - $code + public function updateRecipientTransferSettings( + $recipientId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/recipients/{code}'; + $_queryBuilder = '/recipients/{recipient_id}/transfer-settings'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'code' => $code, + 'recipient_id' => $recipientId, )); //validate and preprocess url @@ -1766,20 +1780,26 @@ public function getRecipientByCode( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1840,7 +1860,8 @@ public function getDefaultRecipient() //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters diff --git a/src/Controllers/SubscriptionsController.php b/src/Controllers/SubscriptionsController.php index fa79614..61780e0 100644 --- a/src/Controllers/SubscriptionsController.php +++ b/src/Controllers/SubscriptionsController.php @@ -72,6 +72,7 @@ public function updateSubscriptionCard( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -133,31 +134,27 @@ public function updateSubscriptionCard( } /** - * Deletes a usage + * Create Usage * - * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param string $usageId The usage id + * @param string $subscriptionId Subscription id + * @param string $itemId Item id * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteUsage( + public function createAnUsage( $subscriptionId, $itemId, - $usageId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = - '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}/usages'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, 'item_id' => $itemId, - 'usage_id' => $usageId, )); //validate and preprocess url @@ -167,6 +164,7 @@ public function deleteUsage( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); @@ -174,13 +172,13 @@ public function deleteUsage( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -224,22 +222,23 @@ public function deleteUsage( } /** - * Creates a discount + * Updates the payment method from a subscription * - * @param string $subscriptionId Subscription id - * @param Models\CreateDiscountRequest $body Request for creating a discount - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription id + * @param Models\UpdateSubscriptionPaymentMethodRequest $body Request for updating the paymentmethod + * from a subscription + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createDiscount( + public function updateSubscriptionPaymentMethod( $subscriptionId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/discounts'; + $_queryBuilder = '/subscriptions/{subscription_id}/payment-method'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -253,6 +252,7 @@ public function createDiscount( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -264,13 +264,13 @@ public function createDiscount( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -310,31 +310,30 @@ public function createDiscount( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetDiscountResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * Create Usage + * Creates a new Subscription item * - * @param string $subscriptionId Subscription id - * @param string $itemId Item id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription id + * @param Models\CreateSubscriptionItemRequest $body Request for creating a subscription item + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createAnUsage( + public function createSubscriptionItem( $subscriptionId, - $itemId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}/usages'; + $_queryBuilder = '/subscriptions/{subscription_id}/items'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'item_id' => $itemId, )); //validate and preprocess url @@ -344,9 +343,14 @@ public function createAnUsage( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); @@ -357,7 +361,7 @@ public function createAnUsage( } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -397,36 +401,24 @@ public function createAnUsage( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetUsageResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); } /** - * Lists all usages from a subscription item + * Get Subscription Item * - * @param string $subscriptionId The subscription id - * @param string $itemId The subscription item id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $code (optional) Identification code in the client system - * @param string $group (optional) Identification group in the client system - * @param DateTime $usedSince (optional) TODO: type description here - * @param DateTime $usedUntil (optional) TODO: type description here + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getUsages( + public function getSubscriptionItem( $subscriptionId, - $itemId, - $page = null, - $size = null, - $code = null, - $group = null, - $usedSince = null, - $usedUntil = null + $itemId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}/usages'; + $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -434,23 +426,14 @@ public function getUsages( 'item_id' => $itemId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'code' => $code, - 'group' => $group, - 'used_since' => DateTimeHelper::toRfc3339DateTime($usedSince), - 'used_until' => DateTimeHelper::toRfc3339DateTime($usedUntil), - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -503,27 +486,27 @@ public function getUsages( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListUsagesResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); } /** - * UpdateCurrentCycleStatus + * UpdateSubscriptionAffiliationId * - * @param string $subscriptionId Subscription Id - * @param Models\UpdateCurrentCycleStatusRequest $body Request for updating the end date of the - * subscription current status - * @param string $idempotencyKey (optional) TODO: type description here - * @return void response from the API call + * @param string $subscriptionId TODO: type description here + * @param Models\UpdateSubscriptionAffiliationIdRequest $body Request for updating a subscription + * affiliation id + * @param string $idempotencyKey (optional) TODO: type description here + * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateCurrentCycleStatus( + public function updateSubscriptionAffiliationId( $subscriptionId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/cycle-status'; + $_queryBuilder = '/subscriptions/{subscription_id}/gateway-affiliation-id'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -536,6 +519,8 @@ public function updateCurrentCycleStatus( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -590,32 +575,41 @@ public function updateCurrentCycleStatus( //handle errors defined at the API level $this->validateResponse($_httpResponse, $_httpContext); + + $mapper = $this->getJsonMapper(); + + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * Updates the payment method from a subscription + * GetIncrements * - * @param string $subscriptionId Subscription id - * @param Models\UpdateSubscriptionPaymentMethodRequest $body Request for updating the paymentmethod - * from a subscription - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionPaymentMethod( + public function getIncrements( $subscriptionId, - $body, - $idempotencyKey = null + $page = null, + $size = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/payment-method'; + $_queryBuilder = '/subscriptions/{subscription_id}/increments/'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -623,24 +617,20 @@ public function updateSubscriptionPaymentMethod( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -680,31 +670,30 @@ public function updateSubscriptionPaymentMethod( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListIncrementsResponse'); } /** - * Deletes a discount + * Updates the boleto due days from a subscription * - * @param string $subscriptionId Subscription id - * @param string $discountId Discount Id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription Id + * @param Models\UpdateSubscriptionDueDaysRequest $body TODO: type description here + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteDiscount( + public function updateSubscriptionDueDays( $subscriptionId, - $discountId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/discounts/{discount_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/boleto-due-days'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'discount_id' => $discountId, )); //validate and preprocess url @@ -714,20 +703,25 @@ public function deleteDiscount( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -767,76 +761,59 @@ public function deleteDiscount( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetDiscountResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * Get Subscription Items + * Updates the start at date from a subscription * - * @param string $subscriptionId The subscription id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $name (optional) The item name - * @param string $code (optional) Identification code in the client system - * @param string $status (optional) The item statis - * @param string $description (optional) The item description - * @param string $createdSince (optional) Filter for item's creation date start range - * @param string $createdUntil (optional) Filter for item's creation date end range + * @param string $subscriptionId The subscription id + * @param Models\UpdateSubscriptionStartAtRequest $body Request for updating the subscription start + * date + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscriptionItems( + public function updateSubscriptionStartAt( $subscriptionId, - $page = null, - $size = null, - $name = null, - $code = null, - $status = null, - $description = null, - $createdSince = null, - $createdUntil = null + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items'; + $_queryBuilder = '/subscriptions/{subscription_id}/start-at'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'name' => $name, - 'code' => $code, - 'status' => $status, - 'description' => $description, - 'created_since' => $createdSince, - 'created_until' => $createdUntil, - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -876,30 +853,29 @@ public function getSubscriptionItems( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListSubscriptionItemsResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * Creates a new Subscription item + * GetSubscriptionCycleById * - * @param string $subscriptionId Subscription id - * @param Models\CreateSubscriptionItemRequest $body Request for creating a subscription item - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param string $cycleId TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createSubscriptionItem( + public function getSubscriptionCycleById( $subscriptionId, - $body, - $idempotencyKey = null + $cycleId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items'; + $_queryBuilder = '/subscriptions/{subscription_id}/cycles/{cycleId}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'cycleId' => $cycleId, )); //validate and preprocess url @@ -909,24 +885,20 @@ public function createSubscriptionItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -966,29 +938,31 @@ public function createSubscriptionItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPeriodResponse'); } /** - * Get Subscription Item + * Deletes a discount * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id + * @param string $subscriptionId Subscription id + * @param string $discountId Discount Id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscriptionItem( + public function deleteDiscount( $subscriptionId, - $itemId + $discountId, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/discounts/{discount_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'item_id' => $itemId, + 'discount_id' => $discountId, )); //validate and preprocess url @@ -997,20 +971,22 @@ public function getSubscriptionItem( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1050,35 +1026,56 @@ public function getSubscriptionItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetDiscountResponse'); } /** - * Updates a subscription item + * Get Subscription Items * - * @param string $subscriptionId Subscription Id - * @param string $itemId Item id - * @param Models\UpdateSubscriptionItemRequest $body Request for updating a subscription item - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $name (optional) The item name + * @param string $code (optional) Identification code in the client system + * @param string $status (optional) The item statis + * @param string $description (optional) The item description + * @param string $createdSince (optional) Filter for item's creation date start range + * @param string $createdUntil (optional) Filter for item's creation date end range * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionItem( + public function getSubscriptionItems( $subscriptionId, - $itemId, - $body, - $idempotencyKey = null + $page = null, + $size = null, + $name = null, + $code = null, + $status = null, + $description = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/items'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'item_id' => $itemId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'name' => $name, + 'code' => $code, + 'status' => $status, + 'description' => $description, + 'created_since' => $createdSince, + 'created_until' => $createdUntil, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1086,24 +1083,20 @@ public function updateSubscriptionItem( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::put($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1143,81 +1136,61 @@ public function updateSubscriptionItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListSubscriptionItemsResponse'); } /** - * Gets all subscriptions + * Updates a subscription item * - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size - * @param string $code (optional) Filter for subscription's code - * @param string $billingType (optional) Filter for subscription's billing type - * @param string $customerId (optional) Filter for subscription's customer id - * @param string $planId (optional) Filter for subscription's plan id - * @param string $cardId (optional) Filter for subscription's card id - * @param string $status (optional) Filter for subscription's status - * @param DateTime $nextBillingSince (optional) Filter for subscription's next billing date start range - * @param DateTime $nextBillingUntil (optional) Filter for subscription's next billing date end range - * @param DateTime $createdSince (optional) Filter for subscription's creation date start range - * @param DateTime $createdUntil (optional) Filter for subscriptions creation date end range + * @param string $subscriptionId Subscription Id + * @param string $itemId Item id + * @param Models\UpdateSubscriptionItemRequest $body Request for updating a subscription item + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscriptions( - $page = null, - $size = null, - $code = null, - $billingType = null, - $customerId = null, - $planId = null, - $cardId = null, - $status = null, - $nextBillingSince = null, - $nextBillingUntil = null, - $createdSince = null, - $createdUntil = null + public function updateSubscriptionItem( + $subscriptionId, + $itemId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions'; + $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}'; //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - 'code' => $code, - 'billing_type' => $billingType, - 'customer_id' => $customerId, - 'plan_id' => $planId, - 'card_id' => $cardId, - 'status' => $status, - 'next_billing_since' => DateTimeHelper::toRfc3339DateTime($nextBillingSince), - 'next_billing_until' => DateTimeHelper::toRfc3339DateTime($nextBillingUntil), - 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), - 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), - )); + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'subscription_id' => $subscriptionId, + 'item_id' => $itemId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PUT, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::put($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1257,7 +1230,7 @@ public function getSubscriptions( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListSubscriptionsResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); } /** @@ -1283,6 +1256,7 @@ public function createSubscription( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -1344,26 +1318,25 @@ public function createSubscription( } /** - * Cancels a subscription + * GetDiscountById * - * @param string $subscriptionId Subscription id - * @param string $idempotencyKey (optional) TODO: type description here - * @param Models\CreateCancelSubscriptionRequest $body (optional) Request for cancelling a subscription + * @param string $subscriptionId The subscription id + * @param string $discountId TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function cancelSubscription( + public function getDiscountById( $subscriptionId, - $idempotencyKey = null, - $body = null + $discountId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/discounts/{discountId}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'discountId' => $discountId, )); //validate and preprocess url @@ -1373,24 +1346,20 @@ public function cancelSubscription( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1430,22 +1399,27 @@ public function cancelSubscription( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetDiscountResponse'); } /** - * Gets a subscription + * Updates the billing date from a subscription * - * @param string $subscriptionId Subscription id + * @param string $subscriptionId The subscription id + * @param Models\UpdateSubscriptionBillingDateRequest $body Request for updating the subscription + * billing date + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscription( - $subscriptionId + public function updateSubscriptionBillingDate( + $subscriptionId, + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/billing-date'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -1458,20 +1432,26 @@ public function getSubscription( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1515,22 +1495,23 @@ public function getSubscription( } /** - * Creates a increment + * UpdateLatestPeriodEndAt * - * @param string $subscriptionId Subscription id - * @param Models\CreateIncrementRequest $body Request for creating a increment - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId TODO: type description here + * @param Models\UpdateCurrentCycleEndDateRequest $body Request for updating the end date of the current + * signature cycle + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function createIncrement( + public function updateLatestPeriodEndAt( $subscriptionId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/increments'; + $_queryBuilder = '/subscriptions/{subscription_id}/periods/latest/end-at'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -1544,6 +1525,7 @@ public function createIncrement( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -1555,13 +1537,13 @@ public function createIncrement( Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1601,29 +1583,30 @@ public function createIncrement( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * GetDiscountById + * Creates a discount * - * @param string $subscriptionId The subscription id - * @param string $discountId TODO: type description here + * @param string $subscriptionId Subscription id + * @param Models\CreateDiscountRequest $body Request for creating a discount + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getDiscountById( + public function createDiscount( $subscriptionId, - $discountId + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/discounts/{discountId}'; + $_queryBuilder = '/subscriptions/{subscription_id}/discounts'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'discountId' => $discountId, )); //validate and preprocess url @@ -1632,20 +1615,26 @@ public function getDiscountById( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1689,27 +1678,31 @@ public function getDiscountById( } /** - * UpdateSubscriptionAffiliationId + * Deletes a usage * - * @param string $subscriptionId TODO: type description here - * @param Models\UpdateSubscriptionAffiliationIdRequest $body Request for updating a subscription - * affiliation id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param string $itemId The subscription item id + * @param string $usageId The usage id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionAffiliationId( + public function deleteUsage( $subscriptionId, - $body, + $itemId, + $usageId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/gateway-affiliation-id'; + $_queryBuilder = + '/subscriptions/{subscription_id}/items/{item_id}/usages/{usage_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'item_id' => $itemId, + 'usage_id' => $usageId, )); //validate and preprocess url @@ -1719,24 +1712,21 @@ public function updateSubscriptionAffiliationId( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1776,32 +1766,53 @@ public function updateSubscriptionAffiliationId( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetUsageResponse'); } /** - * Updates the metadata from a subscription + * Lists all usages from a subscription item * - * @param string $subscriptionId The subscription id - * @param Models\UpdateMetadataRequest $body Request for updating the subscrption metadata - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param string $itemId The subscription item id + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $code (optional) Identification code in the client system + * @param string $group (optional) Identification group in the client system + * @param DateTime $usedSince (optional) TODO: type description here + * @param DateTime $usedUntil (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionMetadata( + public function getUsages( $subscriptionId, - $body, - $idempotencyKey = null + $itemId, + $page = null, + $size = null, + $code = null, + $group = null, + $usedSince = null, + $usedUntil = null ) { //prepare query string for API call - $_queryBuilder = '/Subscriptions/{subscription_id}/metadata'; + $_queryBuilder = '/subscriptions/{subscription_id}/items/{item_id}/usages'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'item_id' => $itemId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + 'code' => $code, + 'group' => $group, + 'used_since' => DateTimeHelper::toRfc3339DateTime($usedSince), + 'used_until' => DateTimeHelper::toRfc3339DateTime($usedUntil), + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -1809,24 +1820,20 @@ public function updateSubscriptionMetadata( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1866,31 +1873,31 @@ public function updateSubscriptionMetadata( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListUsagesResponse'); } /** - * Deletes a increment + * UpdateCurrentCycleStatus * - * @param string $subscriptionId Subscription id - * @param string $incrementId Increment id - * @param string $idempotencyKey (optional) TODO: type description here - * @return mixed response from the API call + * @param string $subscriptionId Subscription Id + * @param Models\UpdateCurrentCycleStatusRequest $body Request for updating the end date of the + * subscription current status + * @param string $idempotencyKey (optional) TODO: type description here + * @return void response from the API call * @throws APIException Thrown if API call fails */ - public function deleteIncrement( + public function updateCurrentCycleStatus( $subscriptionId, - $incrementId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/increments/{increment_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}/cycle-status'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'increment_id' => $incrementId, )); //validate and preprocess url @@ -1899,21 +1906,25 @@ public function deleteIncrement( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -1950,32 +1961,29 @@ public function deleteIncrement( //handle errors defined at the API level $this->validateResponse($_httpResponse, $_httpContext); - - $mapper = $this->getJsonMapper(); - - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); } /** - * GetIncrementById + * Cancels a subscription * - * @param string $subscriptionId The subscription Id - * @param string $incrementId The increment Id + * @param string $subscriptionId Subscription id + * @param string $idempotencyKey (optional) TODO: type description here + * @param Models\CreateCancelSubscriptionRequest $body (optional) Request for cancelling a subscription * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getIncrementById( + public function cancelSubscription( $subscriptionId, - $incrementId + $idempotencyKey = null, + $body = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/increments/{increment_id}'; + $_queryBuilder = '/subscriptions/{subscription_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'increment_id' => $incrementId, )); //validate and preprocess url @@ -1984,20 +1992,26 @@ public function getIncrementById( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2037,58 +2051,58 @@ public function getIncrementById( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * GetSubscriptionCycles + * Creates a increment * - * @param string $subscriptionId Subscription Id - * @param string $page Page number - * @param string $size Page size + * @param string $subscriptionId Subscription id + * @param Models\CreateIncrementRequest $body Request for creating a increment + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscriptionCycles( + public function createIncrement( $subscriptionId, - $page, - $size + $body, + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/cycles'; + $_queryBuilder = '/subscriptions/{subscription_id}/increments'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, )); - //process optional query parameters - APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, - )); - //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', + 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2128,24 +2142,26 @@ public function getSubscriptionCycles( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCyclesResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); } /** - * RenewSubscription + * Updates the metadata from a subscription * - * @param string $subscriptionId TODO: type description here - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription id + * @param Models\UpdateMetadataRequest $body Request for updating the subscrption metadata + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function renewSubscription( + public function updateSubscriptionMetadata( $subscriptionId, + $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/cycles'; + $_queryBuilder = '/Subscriptions/{subscription_id}/metadata'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -2159,20 +2175,25 @@ public function renewSubscription( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2212,7 +2233,7 @@ public function renewSubscription( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetPeriodResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** @@ -2250,7 +2271,8 @@ public function getDiscounts( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -2307,23 +2329,23 @@ public function getDiscounts( } /** - * Updates the billing date from a subscription + * Atualização do valor mínimo da assinatura * - * @param string $subscriptionId The subscription id - * @param Models\UpdateSubscriptionBillingDateRequest $body Request for updating the subscription - * billing date - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription Id + * @param Models\UpdateSubscriptionMinimumPriceRequest $body Request da requisição com o valor mínimo + * que será configurado + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionBillingDate( + public function updateSubscriptionMiniumPrice( $subscriptionId, $body, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/billing-date'; + $_queryBuilder = '/subscriptions/{subscription_id}/minimum_price'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -2337,6 +2359,7 @@ public function updateSubscriptionBillingDate( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -2398,51 +2421,51 @@ public function updateSubscriptionBillingDate( } /** - * Deletes a subscription item + * UpdateSplitSubscription * - * @param string $subscriptionId Subscription id - * @param string $subscriptionItemId Subscription item id - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $id Subscription's id + * @param Models\UpdateSubscriptionSplitRequest $body TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function deleteSubscriptionItem( - $subscriptionId, - $subscriptionItemId, - $idempotencyKey = null + public function updateSplitSubscription( + $id, + $body ) { //prepare query string for API call - $_queryBuilder = - '/subscriptions/{subscription_id}/items/{subscription_item_id}'; + $_queryBuilder = '/subscriptions/{id}/split'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'subscription_id' => $subscriptionId, - 'subscription_item_id' => $subscriptionItemId, + 'id' => $id, )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); - //prepare headers - $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json', - 'idempotency-key' => $idempotencyKey + //prepare headers + $_headers = array ( + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json' ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::delete($_queryUrl, $_headers); + $response = Request::patch($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2482,36 +2505,59 @@ public function deleteSubscriptionItem( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); } /** - * GetIncrements + * Gets all subscriptions * - * @param string $subscriptionId The subscription id - * @param integer $page (optional) Page number - * @param integer $size (optional) Page size + * @param integer $page (optional) Page number + * @param integer $size (optional) Page size + * @param string $code (optional) Filter for subscription's code + * @param string $billingType (optional) Filter for subscription's billing type + * @param string $customerId (optional) Filter for subscription's customer id + * @param string $planId (optional) Filter for subscription's plan id + * @param string $cardId (optional) Filter for subscription's card id + * @param string $status (optional) Filter for subscription's status + * @param DateTime $nextBillingSince (optional) Filter for subscription's next billing date start range + * @param DateTime $nextBillingUntil (optional) Filter for subscription's next billing date end range + * @param DateTime $createdSince (optional) Filter for subscription's creation date start range + * @param DateTime $createdUntil (optional) Filter for subscriptions creation date end range * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getIncrements( - $subscriptionId, + public function getSubscriptions( $page = null, - $size = null + $size = null, + $code = null, + $billingType = null, + $customerId = null, + $planId = null, + $cardId = null, + $status = null, + $nextBillingSince = null, + $nextBillingUntil = null, + $createdSince = null, + $createdUntil = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/increments/'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'subscription_id' => $subscriptionId, - )); + $_queryBuilder = '/subscriptions'; //process optional query parameters APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( - 'page' => $page, - 'size' => $size, + 'page' => $page, + 'size' => $size, + 'code' => $code, + 'billing_type' => $billingType, + 'customer_id' => $customerId, + 'plan_id' => $planId, + 'card_id' => $cardId, + 'status' => $status, + 'next_billing_since' => DateTimeHelper::toRfc3339DateTime($nextBillingSince), + 'next_billing_until' => DateTimeHelper::toRfc3339DateTime($nextBillingUntil), + 'created_since' => DateTimeHelper::toRfc3339DateTime($createdSince), + 'created_until' => DateTimeHelper::toRfc3339DateTime($createdUntil), )); //validate and preprocess url @@ -2519,8 +2565,9 @@ public function getIncrements( //prepare headers $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -2573,26 +2620,22 @@ public function getIncrements( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListIncrementsResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListSubscriptionsResponse'); } /** - * Updates the boleto due days from a subscription + * Gets a subscription * - * @param string $subscriptionId Subscription Id - * @param Models\UpdateSubscriptionDueDaysRequest $body TODO: type description here - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionDueDays( - $subscriptionId, - $body, - $idempotencyKey = null + public function getSubscription( + $subscriptionId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/boleto-due-days'; + $_queryBuilder = '/subscriptions/{subscription_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( @@ -2606,24 +2649,20 @@ public function updateSubscriptionDueDays( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2667,27 +2706,27 @@ public function updateSubscriptionDueDays( } /** - * Updates the start at date from a subscription + * Deletes a increment * - * @param string $subscriptionId The subscription id - * @param Models\UpdateSubscriptionStartAtRequest $body Request for updating the subscription start - * date - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription id + * @param string $incrementId Increment id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionStartAt( + public function deleteIncrement( $subscriptionId, - $body, + $incrementId, $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/start-at'; + $_queryBuilder = '/subscriptions/{subscription_id}/increments/{increment_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'increment_id' => $incrementId, )); //validate and preprocess url @@ -2697,24 +2736,21 @@ public function updateSubscriptionStartAt( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'idempotency-key' => $idempotencyKey ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2754,31 +2790,29 @@ public function updateSubscriptionStartAt( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); } /** - * UpdateLatestPeriodEndAt + * GetIncrementById * - * @param string $subscriptionId TODO: type description here - * @param Models\UpdateCurrentCycleEndDateRequest $body Request for updating the end date of the current - * signature cycle - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId The subscription Id + * @param string $incrementId The increment Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateLatestPeriodEndAt( + public function getIncrementById( $subscriptionId, - $body, - $idempotencyKey = null + $incrementId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/periods/latest/end-at'; + $_queryBuilder = '/subscriptions/{subscription_id}/increments/{increment_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, + 'increment_id' => $incrementId, )); //validate and preprocess url @@ -2788,24 +2822,20 @@ public function updateLatestPeriodEndAt( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2845,33 +2875,38 @@ public function updateLatestPeriodEndAt( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetIncrementResponse'); } /** - * Atualização do valor mínimo da assinatura + * GetSubscriptionCycles * - * @param string $subscriptionId Subscription Id - * @param Models\UpdateSubscriptionMinimumPriceRequest $body Request da requisição com o valor mínimo - * que será configurado - * @param string $idempotencyKey (optional) TODO: type description here + * @param string $subscriptionId Subscription Id + * @param string $page Page number + * @param string $size Page size * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSubscriptionMiniumPrice( + public function getSubscriptionCycles( $subscriptionId, - $body, - $idempotencyKey = null + $page, + $size ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/minimum_price'; + $_queryBuilder = '/subscriptions/{subscription_id}/cycles'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, )); + //process optional query parameters + APIHelper::appendUrlWithQueryParameters($_queryBuilder, array ( + 'page' => $page, + 'size' => $size, + )); + //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -2879,24 +2914,20 @@ public function updateSubscriptionMiniumPrice( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'idempotency-key' => $idempotencyKey + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -2936,29 +2967,28 @@ public function updateSubscriptionMiniumPrice( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListCyclesResponse'); } /** - * GetSubscriptionCycleById + * RenewSubscription * - * @param string $subscriptionId The subscription id - * @param string $cycleId TODO: type description here + * @param string $subscriptionId TODO: type description here + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getSubscriptionCycleById( + public function renewSubscription( $subscriptionId, - $cycleId + $idempotencyKey = null ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{subscription_id}/cycles/{cycleId}'; + $_queryBuilder = '/subscriptions/{subscription_id}/cycles'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'subscription_id' => $subscriptionId, - 'cycleId' => $cycleId, )); //validate and preprocess url @@ -2967,20 +2997,22 @@ public function getSubscriptionCycleById( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -3024,26 +3056,28 @@ public function getSubscriptionCycleById( } /** - * GetUsageReport + * Deletes a subscription item * - * @param string $subscriptionId The subscription Id - * @param string $periodId The period Id + * @param string $subscriptionId Subscription id + * @param string $subscriptionItemId Subscription item id + * @param string $idempotencyKey (optional) TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getUsageReport( + public function deleteSubscriptionItem( $subscriptionId, - $periodId + $subscriptionItemId, + $idempotencyKey = null ) { //prepare query string for API call $_queryBuilder = - '/subscriptions/{subscription_id}/periods/{period_id}/usages/report'; + '/subscriptions/{subscription_id}/items/{subscription_item_id}'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'subscription_id' => $subscriptionId, - 'period_id' => $periodId, + 'subscription_id' => $subscriptionId, + 'subscription_item_id' => $subscriptionItemId, )); //validate and preprocess url @@ -3051,21 +3085,23 @@ public function getUsageReport( //prepare headers $_headers = array ( - 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'idempotency-key' => $idempotencyKey ); //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::DELETE, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::delete($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -3105,28 +3141,30 @@ public function getUsageReport( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetUsageReportResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionItemResponse'); } /** - * UpdateSplitSubscription + * GetUsageReport * - * @param string $id Subscription's id - * @param Models\UpdateSubscriptionSplitRequest $body TODO: type description here + * @param string $subscriptionId The subscription Id + * @param string $periodId The period Id * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function updateSplitSubscription( - $id, - $body + public function getUsageReport( + $subscriptionId, + $periodId ) { //prepare query string for API call - $_queryBuilder = '/subscriptions/{id}/split'; + $_queryBuilder = + '/subscriptions/{subscription_id}/periods/{period_id}/usages/report'; //process optional query parameters $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'id' => $id, + 'subscription_id' => $subscriptionId, + 'period_id' => $periodId, )); //validate and preprocess url @@ -3136,23 +3174,20 @@ public function updateSplitSubscription( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json' + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::PATCH, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::patch($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -3192,6 +3227,6 @@ public function updateSplitSubscription( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetSubscriptionResponse'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetUsageReportResponse'); } } diff --git a/src/Controllers/TokensController.php b/src/Controllers/TokensController.php index 722fa03..308f2d5 100644 --- a/src/Controllers/TokensController.php +++ b/src/Controllers/TokensController.php @@ -78,6 +78,7 @@ public function createToken( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, 'Content-Type' => 'application/json', 'idempotency-key' => $idempotencyKey ); @@ -173,7 +174,8 @@ public function getToken( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters diff --git a/src/Controllers/TransactionsController.php b/src/Controllers/TransactionsController.php index b13110d..3ed64de 100644 --- a/src/Controllers/TransactionsController.php +++ b/src/Controllers/TransactionsController.php @@ -66,7 +66,8 @@ public function getTransaction( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters diff --git a/src/Controllers/TransfersController.php b/src/Controllers/TransfersController.php index 7fbfa97..03dd2ce 100644 --- a/src/Controllers/TransfersController.php +++ b/src/Controllers/TransfersController.php @@ -42,23 +42,16 @@ public static function getInstance() } /** - * GetTransferById + * Gets all transfers * - * @param string $transferId TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getTransferById( - $transferId - ) { + public function getTransfers1() + { //prepare query string for API call - $_queryBuilder = '/transfers/{transfer_id}'; - - //process optional query parameters - $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( - 'transfer_id' => $transferId, - )); + $_queryBuilder = '/transfers'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -66,7 +59,8 @@ public function getTransferById( //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName ); //set HTTP basic auth parameters @@ -119,22 +113,27 @@ public function getTransferById( $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetTransfer'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListTransfers'); } /** - * CreateTransfer + * GetTransferById * - * @param Models\CreateTransfer $body TODO: type description here + * @param string $transferId TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function postCreateTransfer( - $body + public function getTransferById( + $transferId ) { //prepare query string for API call - $_queryBuilder = '/transfers/recipients'; + $_queryBuilder = '/transfers/{transfer_id}'; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'transfer_id' => $transferId, + )); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -143,23 +142,20 @@ public function postCreateTransfer( $_headers = array ( 'user-agent' => BaseController::USER_AGENT, 'Accept' => 'application/json', - 'Content-Type' => 'application/json' + 'ServiceRefererName' => Configuration::$serviceRefererName ); - //json encode body - $_bodyJson = Request\Body::Json($body); - //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::post($_queryUrl, $_headers, $_bodyJson); + $response = Request::get($_queryUrl, $_headers); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -203,16 +199,18 @@ public function postCreateTransfer( } /** - * Gets all transfers + * CreateTransfer * + * @param Models\CreateTransfer $body TODO: type description here * @return mixed response from the API call * @throws APIException Thrown if API call fails */ - public function getTransfers1() - { + public function postCreateTransfer( + $body + ) { //prepare query string for API call - $_queryBuilder = '/transfers'; + $_queryBuilder = '/transfers/recipients'; //validate and preprocess url $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); @@ -220,20 +218,25 @@ public function getTransfers1() //prepare headers $_headers = array ( 'user-agent' => BaseController::USER_AGENT, - 'Accept' => 'application/json' + 'Accept' => 'application/json', + 'ServiceRefererName' => Configuration::$serviceRefererName, + 'Content-Type' => 'application/json' ); + //json encode body + $_bodyJson = Request\Body::Json($body); + //set HTTP basic auth parameters Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); //call on-before Http callback - $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl); + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); if ($this->getHttpCallBack() != null) { $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); } //and invoke the API call request to fetch the response - $response = Request::get($_queryUrl, $_headers); + $response = Request::post($_queryUrl, $_headers, $_bodyJson); $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); $_httpContext = new HttpContext($_httpRequest, $_httpResponse); @@ -273,6 +276,6 @@ public function getTransfers1() $mapper = $this->getJsonMapper(); - return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\ListTransfers'); + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetTransfer'); } } diff --git a/src/PagarmeCoreApiClient.php b/src/PagarmeCoreApiClient.php index 1584404..af240d8 100644 --- a/src/PagarmeCoreApiClient.php +++ b/src/PagarmeCoreApiClient.php @@ -18,9 +18,11 @@ class PagarmeCoreApiClient * Constructor with authentication and configuration parameters */ public function __construct( + $serviceRefererName = null, $basicAuthUserName = null, $basicAuthPassword = null ) { + Configuration::$serviceRefererName = $serviceRefererName ? $serviceRefererName : Configuration::$serviceRefererName; Configuration::$basicAuthUserName = $basicAuthUserName ? $basicAuthUserName : Configuration::$basicAuthUserName; Configuration::$basicAuthPassword = $basicAuthPassword ? $basicAuthPassword : Configuration::$basicAuthPassword; } @@ -88,14 +90,6 @@ public function getTokens() { return Controllers\TokensController::getInstance(); } - /** - * Singleton access to Transactions controller - * @return Controllers\TransactionsController The *Singleton* instance - */ - public function getTransactions() - { - return Controllers\TransactionsController::getInstance(); - } /** * Singleton access to Transfers controller * @return Controllers\TransfersController The *Singleton* instance @@ -104,4 +98,12 @@ public function getTransfers() { return Controllers\TransfersController::getInstance(); } + /** + * Singleton access to Transactions controller + * @return Controllers\TransactionsController The *Singleton* instance + */ + public function getTransactions() + { + return Controllers\TransactionsController::getInstance(); + } } diff --git a/tests/TestHelper.php b/tests/TestHelper.php index 45a121e..8b15817 100644 --- a/tests/TestHelper.php +++ b/tests/TestHelper.php @@ -343,15 +343,15 @@ public static function getJsonMapper() { $mapper = new JsonMapper(); $mapper->arChildClasses['PagarmeCoreApiLib\\Models\\GetTransactionResponse'] = array( - 'PagarmeCoreApiLib\\Models\\GetBankTransferTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetSafetyPayTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetBankTransferTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetVoucherTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetBoletoTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetDebitCardTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetPrivateLabelTransactionResponse', 'PagarmeCoreApiLib\\Models\\GetCashTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetCreditCardTransactionResponse', - 'PagarmeCoreApiLib\\Models\\GetPixTransactionResponse' + 'PagarmeCoreApiLib\\Models\\GetBoletoTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetPixTransactionResponse', + 'PagarmeCoreApiLib\\Models\\GetCreditCardTransactionResponse' ); return $mapper; }