Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ $client->accounts()->addDiscordMemberRole('acc_2', $role->id, $members[0]->id);
$client->accounts()->sendDiscordDm('acc_2', $members[0]->id, 'Welcome aboard');
```

## Google Business Profile

Manage a connected Business Profile location: the profile, attributes, food menus, services, photos, action links, verification and performance.

```php
$location = $client->googleBusiness()->getLocation('acc_1');
$client->googleBusiness()->updateLocation('acc_1', title: 'Corner Bakery', websiteUri: 'https://yourbrand.com');

// Photos come from your media library, JPEG or PNG.
$client->googleBusiness()->addMedia('acc_1', $mediaId, 'INTERIOR');

$client->googleBusiness()->createPlaceAction('acc_1', 'https://yourbrand.com/book', 'APPOINTMENT');

$metrics = $client->googleBusiness()->getPerformance('acc_1', '2026-09-01', '2026-09-30');
$terms = $client->googleBusiness()->getSearchKeywords('acc_1', '2026-08-01', '2026-09-01');
```

Responses relay Google's own shape as plain arrays. Reads need the `accounts` scope, writes `publish` as well. Every call fails with a 503 `configuration_error` until Google grants the deployment Business Profile API access.

## Account groups

```php
Expand Down
9 changes: 9 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Fopost\Sdk\Resource\AiResource;
use Fopost\Sdk\Resource\BroadcastsResource;
use Fopost\Sdk\Resource\ContactsResource;
use Fopost\Sdk\Resource\GoogleBusinessResource;
use Fopost\Sdk\Resource\InboxResource;
use Fopost\Sdk\Resource\ActivityResource;
use Fopost\Sdk\Resource\KnowledgeResource;
Expand Down Expand Up @@ -55,6 +56,7 @@ final class Client
private readonly AdsResource $ads;
private readonly MediaResource $media;
private readonly ValidateResource $validate;
private readonly GoogleBusinessResource $googleBusiness;

public function __construct(
?string $apiKey = null,
Expand Down Expand Up @@ -87,6 +89,7 @@ public function __construct(
$this->ads = new AdsResource($this->http);
$this->media = new MediaResource($this->http);
$this->validate = new ValidateResource($this->http);
$this->googleBusiness = new GoogleBusinessResource($this->http);
}

public function posts(): PostsResource
Expand Down Expand Up @@ -164,6 +167,12 @@ public function validate(): ValidateResource
return $this->validate;
}

/** Manage a connected Google Business Profile location. */
public function googleBusiness(): GoogleBusinessResource
{
return $this->googleBusiness;
}

public function baseUrl(): string
{
return $this->http->baseUrl();
Expand Down
18 changes: 12 additions & 6 deletions src/Http/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,25 @@ public function url(string $path, ?array $params = null): string
{
$url = str_contains($path, '://') ? $path : $this->baseUrl . '/' . ltrim($path, '/');

$clean = [];
$pairs = [];
foreach ($params ?? [] as $key => $value) {
if ($value === null) {
continue;
}
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
// A list repeats the bare parameter; http_build_query would index
// it as `key[0]=`, which the API reads as a different name.
foreach (is_array($value) ? $value : [$value] as $item) {
if (is_bool($item)) {
$item = $item ? 'true' : 'false';
}
// urlencode, not rawurlencode: http_build_query spelt a space
// as '+', and the existing callers' URLs are asserted that way.
$pairs[] = urlencode((string) $key) . '=' . urlencode((string) $item);
}
$clean[$key] = $value;
}

if ($clean !== []) {
$url .= (str_contains($url, '?') ? '&' : '?') . http_build_query($clean);
if ($pairs !== []) {
$url .= (str_contains($url, '?') ? '&' : '?') . implode('&', $pairs);
}

return $url;
Expand Down
Loading
Loading