Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix images #29

Merged
merged 4 commits into from
May 14, 2024
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ $activity = $bayRewards->createActivity()->post('<Store-Access-Token>', [
]);
```

### Update the BayReward Activity

```php
use Palpalani\BayRewards\BayRewards;

$bayRewards = BayRewards::client();
$activity = $bayRewards->updateActivity()->post('<Store-Access-Token>', [
"title" => "Title of the Activity name", //required
"icon" => "<Icon URL>", //required
"activity_id" => ******* //required
]);
```

### Update loyalty points

```php
Expand Down
6 changes: 6 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Palpalani\BayRewards\Resources\PointsResource;
use Palpalani\BayRewards\Resources\StoreFeatureResource;
use Palpalani\BayRewards\Resources\StoreResource;
use Palpalani\BayRewards\Resources\updateActivityResource;

Check failure on line 11 in src/Factory.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Palpalani\BayRewards\Resources\UpdateActivityResource referenced with incorrect case: Palpalani\BayRewards\Resources\updateActivityResource.
use Saloon\Http\Connector;

final class Factory extends Connector
Expand Down Expand Up @@ -58,4 +59,9 @@
{
return new StoreFeatureResource($this);
}

public function updateActivity(): updateActivityResource
{
return new UpdateActivityResource($this);

Check failure on line 65 in src/Factory.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Palpalani\BayRewards\Resources\UpdateActivityResource referenced with incorrect case: Palpalani\BayRewards\Resources\updateActivityResource.
}
}
51 changes: 51 additions & 0 deletions src/Requests/Store/UpdateActivityRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Palpalani\BayRewards\Requests\Store;

use Palpalani\BayRewards\Objects\Action;
use Palpalani\BayRewards\Responses\Store\GetActionResponse;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use Saloon\Traits\Plugins\AlwaysThrowOnErrors;

final class UpdateActivityRequest extends Request implements HasBody
{
use AlwaysThrowOnErrors;
use HasJsonBody;

protected Method $method = Method::POST;

public function __construct(protected string $access_token, protected array $data = [])
{
}

/**
* {@inheritDoc}
*/
public function resolveEndpoint(): string
{
return '/action/update';
}

protected function defaultHeaders(): array
{
return [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Store-Access-Token' => $this->access_token,
];
}

public function defaultBody(): array
{
return $this->data;
}

public function createDtoFromResponse(Response $response): Action
{
return GetActionResponse::make($response);
}
}
17 changes: 17 additions & 0 deletions src/Resources/UpdateActivityResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Palpalani\BayRewards\Resources;

use Palpalani\BayRewards\Objects\UpdateActivity;
use Palpalani\BayRewards\Requests\Store\UpdateActivityRequest;

final class UpdateActivityResource extends Resource
{
/**
* @return mixed|UpdateActivity
*/
public function post(string $access_token, array $data): mixed
{
return $this->connector->send(new UpdateActivityRequest($access_token, $data))->dto();
}
}
Loading