Skip to content

Commit

Permalink
Merge pull request #86 from square/release/19.1.1.20220616
Browse files Browse the repository at this point in the history
Generated PR for Release: 19.1.1.20220616
  • Loading branch information
Wolfgang Schuster authored Jun 24, 2022
2 parents 4996849 + d0317ec commit 337ebfe
Show file tree
Hide file tree
Showing 340 changed files with 389 additions and 5,252 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "square/square",
"description": "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.",
"version": "19.1.0.20220616",
"version": "19.1.1.20220616",
"type": "library",
"keywords": [
"Square",
Expand All @@ -22,8 +22,8 @@
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"apimatic/unirest-php": "^2.2.2",
"apimatic/jsonmapper": "^3.0.3"
"apimatic/unirest-php": "^2.3.0",
"apimatic/jsonmapper": "^3.0.4"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
Expand Down
4 changes: 2 additions & 2 deletions doc/apis/catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function createCatalogImage(

| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `request` | [`?CreateCatalogImageRequest`](../../doc/models/create-catalog-image-request.md) | Form, Optional | - |
| `request` | [`?CreateCatalogImageRequest`](../../doc/models/create-catalog-image-request.md) | Form (JSON-Encoded), Optional | - |
| `imageFile` | `?FileWrapper` | Form, Optional | - |

## Response Type
Expand Down Expand Up @@ -325,7 +325,7 @@ function updateCatalogImage(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `imageId` | `string` | Template, Required | The ID of the `CatalogImage` object to update the encapsulated image file. |
| `request` | [`?UpdateCatalogImageRequest`](../../doc/models/update-catalog-image-request.md) | Form, Optional | - |
| `request` | [`?UpdateCatalogImageRequest`](../../doc/models/update-catalog-image-request.md) | Form (JSON-Encoded), Optional | - |
| `imageFile` | `?FileWrapper` | Form, Optional | - |

## Response Type
Expand Down
2 changes: 1 addition & 1 deletion doc/apis/disputes.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function createDisputeEvidenceFile(
| Parameter | Type | Tags | Description |
| --- | --- | --- | --- |
| `disputeId` | `string` | Template, Required | The ID of the dispute you want to upload evidence for. |
| `request` | [`?CreateDisputeEvidenceFileRequest`](../../doc/models/create-dispute-evidence-file-request.md) | Form, Optional | Defines the parameters for a `CreateDisputeEvidenceFile` request. |
| `request` | [`?CreateDisputeEvidenceFileRequest`](../../doc/models/create-dispute-evidence-file-request.md) | Form (JSON-Encoded), Optional | Defines the parameters for a `CreateDisputeEvidenceFile` request. |
| `imageFile` | `?FileWrapper` | Form, Optional | - |

## Response Type
Expand Down
6 changes: 0 additions & 6 deletions doc/apis/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ function updateSubscription(string $subscriptionId, UpdateSubscriptionRequest $b
```php
$subscriptionId = 'subscription_id0';
$body = new Models\UpdateSubscriptionRequest;
$body->setSubscription(new Models\Subscription);
$body->getSubscription()->setTaxPercentage('null');
$body->getSubscription()->setPriceOverrideMoney(new Models\Money);
$body->getSubscription()->getPriceOverrideMoney()->setAmount(2000);
$body->getSubscription()->getPriceOverrideMoney()->setCurrency(Models\Currency::USD);
$body->getSubscription()->setVersion(1594155459464);

$apiResponse = $subscriptionsApi->updateSubscription($subscriptionId, $body);

Expand Down
27 changes: 3 additions & 24 deletions doc/models/list-bookings-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,9 @@

```json
{
"bookings": [
{
"appointment_segments": [
{
"duration_minutes": 60,
"service_variation_id": "RU3PBTZTK7DXZDQFCJHOK2MC",
"service_variation_version": 1599775456731,
"team_member_id": "TMXUrsBWWcHTt79t"
}
],
"created_at": "2020-10-28T15:47:41Z",
"customer_id": "EX2QSVGTZN4K1E5QE1CBFNVQ8M",
"customer_note": "",
"id": "zkras0xv0xwswx",
"location_id": "LEQHH0YY8B42M",
"seller_note": "",
"start_at": "2020-11-26T13:00:00Z",
"status": "ACCEPTED",
"updated_at": "2020-10-28T15:49:25Z",
"version": 1
}
],
"cursor": "null",
"errors": []
"bookings": null,
"cursor": null,
"errors": null
}
```

9 changes: 1 addition & 8 deletions doc/models/update-subscription-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ Defines input parameters in a request to the

```json
{
"subscription": {
"price_override_money": {
"amount": 2000,
"currency": "USD"
},
"tax_percentage": "null",
"version": 1594155459464
}
"subscription": null
}
```

151 changes: 24 additions & 127 deletions src/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,6 @@ public static function mapClass(
}
}

/**
* Try mapping the class onto the value,
* If mapping failed due to the invalid oneOf or anyOf types,
* throw ApiException
*
* @param array $json value to be verified against the types
* @param string $classname name of the class to map
* @param string $namespace namespace name for the model classes, Default: global namespace
*
* @throws InvalidArgumentException
*/
public static function verifyClass(
array $json,
string $classname,
string $namespace = 'Square\Models'
) {
try {
$value = empty($json) ? new stdClass() : json_decode(json_encode($json));
self::getJsonMapper()->mapClass($value, "$namespace\\$classname");
} catch (Exception $e) {
throw new InvalidArgumentException($e->getMessage());
}
}

/**
* Map the types onto the value,
* If mapping failed due to the invalid oneOf or anyOf types,
Expand Down Expand Up @@ -179,35 +155,43 @@ public static function mapTypes(
}

/**
* Try mapping the types onto the value,
* If mapping failed due to the invalid oneOf or anyOf types,
* throw InvalidArgumentException
* Checks if type of the given value is present in the type group, also updates the value when
* $serializationMethods for the value's type are given.
*
* @param mixed $value value to be verified against the types
* @param string $types types to be mapped in format OneOf(...) or AnyOf(...)
* @param string[] $serializationMethods Specify methods required for serialization instead of json_encode,
* should be a string path to the accessible method along with the type,
* separated by a space.
* @param string[] $facMethods Specify if any methods are required to map this value into any type
* @param string $namespace namespace name for the model classes, Default: global namespace
* @param mixed $value value to be verified against the types
* @param string $types types to be mapped in format OneOf(...) or AnyOf(...)
* @param string[] $serializationMethods Specify methods required for serialization of specific types in
* in the type group, should be an array in the format:
* ['path/to/method argumentType', ...]. Default: []
*
* @return mixed
* @throws InvalidArgumentException
*/
public static function verifyTypes(
$value,
string $types,
array $serializationMethods = [],
array $facMethods = [],
string $namespace = 'Square\Models'
array $serializationMethods = []
) {
try {
$value = self::applySerializationMethods($value, $serializationMethods);
self::getJsonMapper()->mapFor(json_decode(json_encode($value)), $types, $namespace, $facMethods);
return self::getJsonMapper()->checkTypeGroupFor($types, $value, $serializationMethods);
} catch (Exception $e) {
throw new InvalidArgumentException($e->getMessage());
}
return $value;
}

/**
* Serialize any given mixed value.
*
* @param mixed $value Any value to be serialized
*
* @return string|null serialized value
*/
public static function serialize($value): ?string
{
if (is_string($value) || is_null($value)) {
return $value;
}
return json_encode($value);
}

/**
Expand Down Expand Up @@ -235,93 +219,6 @@ public static function checkValueInEnum($value, string $enumName, array $enumVal
}
}

/**
* Extract type from any given value.
*
* @param mixed $value should be an array to be checked for inner type
* @param string $start string to be appended at the start of the extracted type, Default: ''
* @param string $end string to be appended at the end of the extracted type, Default: ''
*
* @return string Returns the type that could be mapped on the given value.
*/
private static function getType($value, string $start = '', string $end = ''): string
{
if (is_array($value)) {
if (self::isAssociative($value)) {
// if value is associative array
$start .= 'array<string,';
$end = '>' . $end;
} else {
// if value is indexed array
if (empty($value)) {
return 'array';
}
$end = '[]' . $end;
}
return self::getType(array_pop($value), $start, $end);
} elseif (is_object($value)) {
$type = get_class($value); // returns full path of class
$slashPos = strrpos($type, '\\');
if ($slashPos !== false) {
$slashPos++; // to get the type after last slash
} else {
$slashPos = 0; // if did not have any slashes
}
$type = substr($type, $slashPos);
return $start . $type . $end;
}
return $start . gettype($value) . $end;
}

/**
* Apply serialization methods onto any given value.
*
* @param mixed $value Any value to be serialized
* @param string[] $serializationMethods Specify methods required for serialization instead of json_encode,
* should be a string path to the accessible method along with the type,
* separated by a space.
* @return mixed value after applying serialization method if applicable
*/
public static function applySerializationMethods($value, array $serializationMethods)
{
$type = empty($serializationMethods) ? null : self::getType($value);
$error = null;
foreach ($serializationMethods as $method) {
$method = explode(' ', $method);
try {
if (is_callable($method[0]) && $type == $method[1]) {
return call_user_func($method[0], $value);
}
} catch (\Throwable $e) {
$error = $e;
}
}
if (is_array($value)) {
return array_map(function ($v) use ($serializationMethods) {
return self::applySerializationMethods($v, $serializationMethods);
}, $value);
}
if (isset($error)) {
throw new InvalidArgumentException($error->getMessage());
}
return $value;
}

/**
* Serialize any given mixed value.
*
* @param mixed $value Any value to be serialized
*
* @return string|null serialized value
*/
public static function serialize($value): ?string
{
if (is_string($value) || is_null($value)) {
return $value;
}
return json_encode($value);
}

/**
* Deserialize a Json string
*
Expand Down
2 changes: 1 addition & 1 deletion src/Apis/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BaseApi
*/
protected $internalUserAgent;

private static $userAgent = 'Square-PHP-SDK/19.1.0.20220616 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}';
private static $userAgent = 'Square-PHP-SDK/19.1.1.20220616 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}';

/**
* Constructor that sets the timeout of requests
Expand Down
2 changes: 1 addition & 1 deletion src/Apis/CardsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function listCards(
'include_disabled' => (null != $includeDisabled) ?
var_export($includeDisabled, true) : false,
'reference_id' => $referenceId,
'sort_order' => Models\SortOrder::checkValue($sortOrder),
'sort_order' => $sortOrder,
]);

//prepare headers
Expand Down
3 changes: 1 addition & 2 deletions src/Apis/CashDrawersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Square\Exceptions\ApiException;
use Square\ConfigurationInterface;
use Square\ApiHelper;
use Square\Models;
use Square\Http\ApiResponse;
use Square\Http\HttpRequest;
use Square\Http\HttpResponse;
Expand Down Expand Up @@ -57,7 +56,7 @@ public function listCashDrawerShifts(
//process query parameters
ApiHelper::appendUrlWithQueryParameters($_queryUrl, [
'location_id' => $locationId,
'sort_order' => Models\SortOrder::checkValue($sortOrder),
'sort_order' => $sortOrder,
'begin_time' => $beginTime,
'end_time' => $endTime,
'limit' => $limit,
Expand Down
8 changes: 4 additions & 4 deletions src/Apis/CustomersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function listCustomers(
ApiHelper::appendUrlWithQueryParameters($_queryUrl, [
'cursor' => $cursor,
'limit' => $limit,
'sort_field' => Models\CustomerSortField::checkValue($sortField),
'sort_order' => Models\SortOrder::checkValue($sortOrder),
'sort_field' => $sortField,
'sort_order' => $sortOrder,
]);

//prepare headers
Expand Down Expand Up @@ -272,8 +272,8 @@ public function searchCustomers(Models\SearchCustomersRequest $body): ApiRespons
}

/**
* Deletes a customer profile from a business. This operation also unlinks any associated cards on
* file.
* Deletes a customer profile from a business. This operation also unlinks any associated cards on file.
*
*
* As a best practice, you should include the `version` field in the request to enable [optimistic
* concurrency](https://developer.squareup.com/docs/working-with-apis/optimistic-concurrency) control.
Expand Down
4 changes: 2 additions & 2 deletions src/Apis/DevicesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function listDeviceCodes(
ApiHelper::appendUrlWithQueryParameters($_queryUrl, [
'cursor' => $cursor,
'location_id' => $locationId,
'product_type' => Models\ProductType::checkValue($productType),
'status' => Models\DeviceCodeStatus::checkValue($status),
'product_type' => $productType,
'status' => $status,
]);

//prepare headers
Expand Down
2 changes: 1 addition & 1 deletion src/Apis/DisputesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function listDisputes(
//process query parameters
ApiHelper::appendUrlWithQueryParameters($_queryUrl, [
'cursor' => $cursor,
'states' => Models\DisputeState::checkValue($states),
'states' => $states,
'location_id' => $locationId,
]);

Expand Down
3 changes: 1 addition & 2 deletions src/Apis/EmployeesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Square\Exceptions\ApiException;
use Square\ConfigurationInterface;
use Square\ApiHelper;
use Square\Models;
use Square\Http\ApiResponse;
use Square\Http\HttpRequest;
use Square\Http\HttpResponse;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function listEmployees(
//process query parameters
ApiHelper::appendUrlWithQueryParameters($_queryUrl, [
'location_id' => $locationId,
'status' => Models\EmployeeStatus::checkValue($status),
'status' => $status,
'limit' => $limit,
'cursor' => $cursor,
]);
Expand Down
4 changes: 2 additions & 2 deletions src/Apis/LocationsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function __construct(ConfigurationInterface $config, array $authManagers,
}

/**
* Provides details about all of the seller's [locations](https://developer.squareup.
* com/docs/locations-api),
* Provides details about all of the seller's [locations](https://developer.squareup.com/docs/locations-
* api),
* including those with an inactive status.
*
* @return ApiResponse Response from the API call
Expand Down
Loading

0 comments on commit 337ebfe

Please sign in to comment.