Skip to content

Commit

Permalink
Merge pull request #5 from gponty/addversion
Browse files Browse the repository at this point in the history
Add API version parameter
  • Loading branch information
gponty authored Oct 16, 2023
2 parents 926f35d + d05a01a commit 9fa55ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ This is a Symfony 6 Bundle helps you to use monday API v2 : https://developer.mo

``` shell
MONDAY_API_KEY=your_token
MONDAY_API_VERSION=2023-07

```

**3** Add to framework config file config/packages/framework.yml

``` shell
monday:
api_key: '%env(MONDAY_API_KEY)%'
api_version: '%env(MONDAY_API_VERSION)%'
```


Expand Down
3 changes: 2 additions & 1 deletion src/MondayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class MondayApi
{
public function __construct(private readonly string $mondayApiKey)
public function __construct(private readonly string $mondayApiKey, private readonly string $mondayApiVersion)
{
}

Expand All @@ -22,6 +22,7 @@ public function request(string $query, array $variables = []): bool|array
$headers = [
'Content-Type: application/json',
'User-Agent: Github.com/symfony-monday-api',
'API-Version: '.$this->mondayApiVersion,
'Authorization: '.$this->mondayApiKey,
];

Expand Down
2 changes: 2 additions & 0 deletions src/MondayBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
$container->services()
->get(MondayApi::class)
->arg('$mondayApiKey', $config['api_key'])
->arg('$mondayApiVersion', $config['api_version'])
;
}

Expand All @@ -25,6 +26,7 @@ public function configure(DefinitionConfigurator $definition): void
$definition->rootNode()
->children()
->scalarNode('api_key')->defaultValue('%env(MONDAY_API_KEY)%')->end()
->scalarNode('api_version')->defaultValue('%env(MONDAY_API_VERSION)%')->end()
->end()
;
}
Expand Down

0 comments on commit 9fa55ad

Please sign in to comment.