Skip to content

Commit

Permalink
Merge pull request #29 from palpalani/bugfix/rules-images
Browse files Browse the repository at this point in the history
Bugfix images
  • Loading branch information
palpalani authored May 14, 2024
2 parents 99dbc7b + 592597f commit 303670d
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
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.

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 @@ public function getStoreFeatures(): StoreFeatureResource
{
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.

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();
}
}

0 comments on commit 303670d

Please sign in to comment.