Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 26, 2024
2 parents 1f596f5 + 6c7038e commit 7f0af41
Show file tree
Hide file tree
Showing 21 changed files with 524 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: :vendor_name
github: Baspa
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/:vendor_name/:package_name/discussions/new?category=q-a
url: https://github.com/Baspa/energyzero-php-api/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/:vendor_name/:package_name/discussions/new?category=ideas
url: https://github.com/Baspa/energyzero-php-api/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/:vendor_name/:package_name/security/policy
url: https://github.com/Baspa/energyzero-php-api/security/policy
about: Learn how to notify us for sensitive bugs
26 changes: 0 additions & 26 deletions .github/workflows/fix-php-code-style-issues-cs-fixer.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PHPStan

on:
pull_request:
paths:
- "**.php"
- "phpstan.neon.dist"
push:
branches:
- main

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan analyse --error-format=github --debug
37 changes: 0 additions & 37 deletions .github/workflows/run-tests-phpunit.yml

This file was deleted.

File renamed without changes.
39 changes: 0 additions & 39 deletions .php-cs-fixer.dist.php

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog

All notable changes to `:package_name` will be documented in this file.
All notable changes to `energyzero-php-api` will be documented in this file.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) :vendor_name <author@domain.com>
Copyright (c) Baspa <hello@baspa.dev>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
112 changes: 91 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,103 @@
# :package_description

[![Latest Version on Packagist](https://img.shields.io/packagist/v/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
[![Tests](https://img.shields.io/github/actions/workflow/status/:vendor_slug/:package_slug/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/:vendor_slug/:package_slug/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/:vendor_slug/:package_slug.svg?style=flat-square)](https://packagist.org/packages/:vendor_slug/:package_slug)
<!--delete-->
---
This package can be used as to scaffold a framework agnostic package. Follow these steps to get started:

1. Press the "Use template" button at the top of this repo to create a new repo with the contents of this skeleton
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files
3. Have fun creating your package.
4. If you need help creating a package, consider picking up our <a href="https://laravelpackage.training">Laravel Package Training</a> video course.
---
<!--/delete-->
This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.
# PHP client for the dynamic prices from EnergyZero

[![Latest Version on Packagist](https://img.shields.io/packagist/v/baspa/energyzero-php-api.svg?style=flat-square)](https://packagist.org/packages/baspa/energyzero-php-api)
[![Tests](https://img.shields.io/github/actions/workflow/status/baspa/energyzero-php-api/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/baspa/energyzero-php-api/actions/workflows/run-tests.yml)
[![PHPStan](https://img.shields.io/github/actions/workflow/status/baspa/energyzero-php-api/phpstan.yml?branch=main&label=phpstan&style=flat-square)](https://github.com/baspa/energyzero-php-api/actions/workflows/phpstan.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/baspa/energyzero-php-api.svg?style=flat-square)](https://packagist.org/packages/baspa/energyzero-php-api)

This PHP package provides a client for fetching dynamic energy prices from the EnergyZero API. It allows you to retrieve energy prices for a specified date range with customizable intervals and VAT options.

## Installation

You can install the package via composer:

```bash
composer require :vendor_slug/:package_slug
composer require baspa/energyzero-php-api
```

## Usage

You can fetch the energy prices for a specific date range with a specific interval and VAT option. When the VAT option is not provided, it will default to `true`. Make sure you provide a date in the format `Y-m-d`.

```php
use Baspa\EnergyZero;

$prices = (new EnergyZero())->energyPrices(
startDate: '2024-01-01',
endDate: '2024-01-02',
interval: 4,
vat: true
);
```

The response will be an array of prices for the specified date range and also include the average price for the period.

### Get the lowest price for a period

```php
$lowestPrice = (new EnergyZero())->getLowestPriceForPeriod(
startDate: '2024-01-01',
endDate: '2024-01-02',
vat: true
);
```

### Get the highest price for a period

```php
$highestPrice = (new EnergyZero())->getHighestPriceForPeriod(
startDate: '2024-01-01',
endDate: '2024-01-02',
vat: true
);
```

### Get the prices above a threshold

```php
$prices = (new EnergyZero())->getPricesAboveThreshold(
startDate: '2024-01-01',
endDate: '2024-01-02',
threshold: 0.05,
vat: true
);
```

### Get the prices below a threshold

```php
$prices = (new EnergyZero())->getPricesBelowThreshold(
startDate: '2024-01-01',
endDate: '2024-01-02',
threshold: 0.05,
vat: true
);
```

### Get the peak hours

Get the top N peak hours for a period.

```php
$peakHours = (new EnergyZero())->getPeakHours(
startDate: '2024-01-01',
endDate: '2024-01-02',
topN: 5,
vat: true
);
```

### Get the valley hours

Get the top N valley hours for a period.

```php
$skeleton = new VendorName\Skeleton();
echo $skeleton->echoPhrase('Hello, VendorName!');
$valleyHours = (new EnergyZero())->getValleyHours(
startDate: '2024-01-01',
endDate: '2024-01-02',
topN: 5,
vat: true
);
```

## Testing
Expand All @@ -50,8 +120,8 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [:author_name](https://github.com/:author_username)
- [All Contributors](../../contributors)
- [Baspa](https://github.com/Baspa)
- [All Contributors](../../contributors)

## License

Expand Down
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
{
"name": ":vendor_slug/:package_slug",
"description": ":package_description",
"name": "baspa/energyzero-php-api",
"description": "PHP client for the dynamic prices from EnergyZero",
"keywords": [
":vendor_name",
":package_slug"
"Baspa",
"energyzero-php-api"
],
"homepage": "https://github.com/:vendor_slug/:package_slug",
"homepage": "https://github.com/baspa/energyzero-php-api",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": "author@domain.com",
"name": "Baspa",
"email": "hello@baspa.dev",
"role": "Developer"
}
],
"require": {
"php": "^8.1"
"php": "^8.1",
"guzzlehttp/guzzle": "^7.9"
},
"require-dev": {
:require_dev_testing,
:require_dev_codestyle,
"spatie/ray": "^1.28"
"pestphp/pest": "^2.0",
"laravel/pint": "^1.2",
"phpstan/phpstan": "^1.11"
},
"autoload": {
"psr-4": {
"VendorName\\Skeleton\\": "src"
"Baspa\\EnergyZero\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"VendorName\\Skeleton\\Tests\\": "tests"
"Baspa\\EnergyZero\\Tests\\": "tests"
}
},
"scripts": {
:scripts_testing,
:scripts_codestyle
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
"allow-plugins": {
:plugins_testing,
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
Expand Down
Loading

0 comments on commit 7f0af41

Please sign in to comment.