Skip to content

Commit 575ab0a

Browse files
committed
[fern-generated] Update SDK
Generated by Fern CLI Version: unknown Generators: - fernapi/fern-php-sdk: 2.1.5
1 parent 64305ef commit 575ab0a

37 files changed

Lines changed: 4119 additions & 4 deletions

.fern/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
}
2424
}
2525
},
26-
"sdkVersion": "45.1.0.20260520"
26+
"sdkVersion": "45.2.0.20260520"
2727
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "square/square",
3-
"version": "45.1.0.20260520",
3+
"version": "45.2.0.20260520",
44
"description": "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.",
55
"keywords": [
66
"square",

reference.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16007,6 +16007,118 @@ $client->vendors->update(
1600716007
</dl>
1600816008

1600916009

16010+
</dd>
16011+
</dl>
16012+
</details>
16013+
16014+
## Reporting
16015+
<details><summary><code>$client-&gt;reporting-&gt;getMetadata() -> MetadataResponse</code></summary>
16016+
<dl>
16017+
<dd>
16018+
16019+
#### 📝 Description
16020+
16021+
<dl>
16022+
<dd>
16023+
16024+
<dl>
16025+
<dd>
16026+
16027+
Describes the data available to query: the cubes, views, measures, dimensions, and segments you can reference in a reporting query. Call this first to discover the schema, then pass the members you need to `load`.
16028+
</dd>
16029+
</dl>
16030+
</dd>
16031+
</dl>
16032+
16033+
#### 🔌 Usage
16034+
16035+
<dl>
16036+
<dd>
16037+
16038+
<dl>
16039+
<dd>
16040+
16041+
```php
16042+
$client->reporting->getMetadata();
16043+
```
16044+
</dd>
16045+
</dl>
16046+
</dd>
16047+
</dl>
16048+
16049+
16050+
</dd>
16051+
</dl>
16052+
</details>
16053+
16054+
<details><summary><code>$client-&gt;reporting-&gt;load($request) -> LoadResponse</code></summary>
16055+
<dl>
16056+
<dd>
16057+
16058+
#### 📝 Description
16059+
16060+
<dl>
16061+
<dd>
16062+
16063+
<dl>
16064+
<dd>
16065+
16066+
Runs a reporting query against the discovered schema and returns the aggregated results. Long-running queries may return a "Continue wait" response while processing — retry the same request until results are ready.
16067+
</dd>
16068+
</dl>
16069+
</dd>
16070+
</dl>
16071+
16072+
#### 🔌 Usage
16073+
16074+
<dl>
16075+
<dd>
16076+
16077+
<dl>
16078+
<dd>
16079+
16080+
```php
16081+
$client->reporting->load(
16082+
new LoadRequest([]),
16083+
);
16084+
```
16085+
</dd>
16086+
</dl>
16087+
</dd>
16088+
</dl>
16089+
16090+
#### ⚙️ Parameters
16091+
16092+
<dl>
16093+
<dd>
16094+
16095+
<dl>
16096+
<dd>
16097+
16098+
**$queryType:** `?string`
16099+
16100+
</dd>
16101+
</dl>
16102+
16103+
<dl>
16104+
<dd>
16105+
16106+
**$cache:** `?string`
16107+
16108+
</dd>
16109+
</dl>
16110+
16111+
<dl>
16112+
<dd>
16113+
16114+
**$query:** `?Query`
16115+
16116+
</dd>
16117+
</dl>
16118+
</dd>
16119+
</dl>
16120+
16121+
1601016122
</dd>
1601116123
</dl>
1601216124
</details>

src/Reporting/ReportingClient.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
namespace Square\Reporting;
4+
5+
use Psr\Http\Client\ClientInterface;
6+
use Square\Core\Client\RawClient;
7+
use Square\Types\MetadataResponse;
8+
use Square\Exceptions\SquareException;
9+
use Square\Exceptions\SquareApiException;
10+
use Square\Core\Json\JsonApiRequest;
11+
use Square\Environments;
12+
use Square\Core\Client\HttpMethod;
13+
use JsonException;
14+
use Psr\Http\Client\ClientExceptionInterface;
15+
use Square\Reporting\Requests\LoadRequest;
16+
use Square\Types\LoadResponse;
17+
18+
class ReportingClient
19+
{
20+
/**
21+
* @var array{
22+
* baseUrl?: string,
23+
* client?: ClientInterface,
24+
* maxRetries?: int,
25+
* timeout?: float,
26+
* headers?: array<string, string>,
27+
* } $options @phpstan-ignore-next-line Property is used in endpoint methods via HttpEndpointGenerator
28+
*/
29+
private array $options;
30+
31+
/**
32+
* @var RawClient $client
33+
*/
34+
private RawClient $client;
35+
36+
/**
37+
* @param RawClient $client
38+
* @param ?array{
39+
* baseUrl?: string,
40+
* client?: ClientInterface,
41+
* maxRetries?: int,
42+
* timeout?: float,
43+
* headers?: array<string, string>,
44+
* } $options
45+
*/
46+
public function __construct(
47+
RawClient $client,
48+
?array $options = null,
49+
) {
50+
$this->client = $client;
51+
$this->options = $options ?? [];
52+
}
53+
54+
/**
55+
* Describes the data available to query: the cubes, views, measures, dimensions, and segments you can reference in a reporting query. Call this first to discover the schema, then pass the members you need to `load`.
56+
*
57+
* @param ?array{
58+
* baseUrl?: string,
59+
* maxRetries?: int,
60+
* timeout?: float,
61+
* headers?: array<string, string>,
62+
* queryParameters?: array<string, mixed>,
63+
* bodyProperties?: array<string, mixed>,
64+
* } $options
65+
* @return MetadataResponse
66+
* @throws SquareException
67+
* @throws SquareApiException
68+
*/
69+
public function getMetadata(?array $options = null): MetadataResponse
70+
{
71+
$options = array_merge($this->options, $options ?? []);
72+
try {
73+
$response = $this->client->sendRequest(
74+
new JsonApiRequest(
75+
baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::Production->value,
76+
path: "reporting/v1/meta",
77+
method: HttpMethod::GET,
78+
),
79+
$options,
80+
);
81+
$statusCode = $response->getStatusCode();
82+
if ($statusCode >= 200 && $statusCode < 400) {
83+
$json = $response->getBody()->getContents();
84+
return MetadataResponse::fromJson($json);
85+
}
86+
} catch (JsonException $e) {
87+
throw new SquareException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e);
88+
} catch (ClientExceptionInterface $e) {
89+
throw new SquareException(message: $e->getMessage(), previous: $e);
90+
}
91+
throw new SquareApiException(
92+
message: 'API request failed',
93+
statusCode: $statusCode,
94+
body: $response->getBody()->getContents(),
95+
);
96+
}
97+
98+
/**
99+
* Runs a reporting query against the discovered schema and returns the aggregated results. Long-running queries may return a "Continue wait" response while processing — retry the same request until results are ready.
100+
*
101+
* @param LoadRequest $request
102+
* @param ?array{
103+
* baseUrl?: string,
104+
* maxRetries?: int,
105+
* timeout?: float,
106+
* headers?: array<string, string>,
107+
* queryParameters?: array<string, mixed>,
108+
* bodyProperties?: array<string, mixed>,
109+
* } $options
110+
* @return LoadResponse
111+
* @throws SquareException
112+
* @throws SquareApiException
113+
*/
114+
public function load(LoadRequest $request = new LoadRequest(), ?array $options = null): LoadResponse
115+
{
116+
$options = array_merge($this->options, $options ?? []);
117+
try {
118+
$response = $this->client->sendRequest(
119+
new JsonApiRequest(
120+
baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::Production->value,
121+
path: "reporting/v1/load",
122+
method: HttpMethod::POST,
123+
body: $request,
124+
),
125+
$options,
126+
);
127+
$statusCode = $response->getStatusCode();
128+
if ($statusCode >= 200 && $statusCode < 400) {
129+
$json = $response->getBody()->getContents();
130+
return LoadResponse::fromJson($json);
131+
}
132+
} catch (JsonException $e) {
133+
throw new SquareException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e);
134+
} catch (ClientExceptionInterface $e) {
135+
throw new SquareException(message: $e->getMessage(), previous: $e);
136+
}
137+
throw new SquareApiException(
138+
message: 'API request failed',
139+
statusCode: $statusCode,
140+
body: $response->getBody()->getContents(),
141+
);
142+
}
143+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
namespace Square\Reporting\Requests;
4+
5+
use Square\Core\Json\JsonSerializableType;
6+
use Square\Core\Json\JsonProperty;
7+
use Square\Types\CacheMode;
8+
use Square\Types\Query;
9+
10+
class LoadRequest extends JsonSerializableType
11+
{
12+
/**
13+
* @var ?string $queryType
14+
*/
15+
#[JsonProperty('queryType')]
16+
private ?string $queryType;
17+
18+
/**
19+
* @var ?value-of<CacheMode> $cache
20+
*/
21+
#[JsonProperty('cache')]
22+
private ?string $cache;
23+
24+
/**
25+
* @var ?Query $query
26+
*/
27+
#[JsonProperty('query')]
28+
private ?Query $query;
29+
30+
/**
31+
* @param array{
32+
* queryType?: ?string,
33+
* cache?: ?value-of<CacheMode>,
34+
* query?: ?Query,
35+
* } $values
36+
*/
37+
public function __construct(
38+
array $values = [],
39+
) {
40+
$this->queryType = $values['queryType'] ?? null;
41+
$this->cache = $values['cache'] ?? null;
42+
$this->query = $values['query'] ?? null;
43+
}
44+
45+
/**
46+
* @return ?string
47+
*/
48+
public function getQueryType(): ?string
49+
{
50+
return $this->queryType;
51+
}
52+
53+
/**
54+
* @param ?string $value
55+
*/
56+
public function setQueryType(?string $value = null): self
57+
{
58+
$this->queryType = $value;
59+
$this->_setField('queryType');
60+
return $this;
61+
}
62+
63+
/**
64+
* @return ?value-of<CacheMode>
65+
*/
66+
public function getCache(): ?string
67+
{
68+
return $this->cache;
69+
}
70+
71+
/**
72+
* @param ?value-of<CacheMode> $value
73+
*/
74+
public function setCache(?string $value = null): self
75+
{
76+
$this->cache = $value;
77+
$this->_setField('cache');
78+
return $this;
79+
}
80+
81+
/**
82+
* @return ?Query
83+
*/
84+
public function getQuery(): ?Query
85+
{
86+
return $this->query;
87+
}
88+
89+
/**
90+
* @param ?Query $value
91+
*/
92+
public function setQuery(?Query $value = null): self
93+
{
94+
$this->query = $value;
95+
$this->_setField('query');
96+
return $this;
97+
}
98+
}

0 commit comments

Comments
 (0)