Skip to content

Commit

Permalink
feat: add client
Browse files Browse the repository at this point in the history
  • Loading branch information
brokeyourbike committed Oct 31, 2021
1 parent 86204f8 commit fbfc2a2
Show file tree
Hide file tree
Showing 19 changed files with 668 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Auto detect text files and perform LF normalization
* text=auto

.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.github/ export-ignore
tests/ export-ignore
phpunit.xml export-ignore
phpstan.neon export-ignore
psalm.xml export-ignore
18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: release-please

on:
push:
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: google-github-actions/release-please-action@v2
with:
release-type: php
- uses: actions/checkout@v2
if: ${{ steps.release.outputs.release_created }}
37 changes: 37 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: static analysis

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
php-version: [8.0]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
extensions: mbstring
tools: composer

- name: Download dependencies
run: composer update --no-interaction --no-progress

- name: Download PHPStan
run: composer bin phpstan require phpstan/phpstan

- name: Execute PHPStan
run: vendor/bin/phpstan analyze --no-progress
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
laravel-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
php-version: [8.0]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: pcov

- name: Install PHP dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Run PHPUnit
run: vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
with:
files: ./coverage.xml

- name: Upload coverage to codeclimate
uses: paambaati/codeclimate-action@v3.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
with:
coverageCommand: ''
coverageLocations: ./coverage.xml:clover
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/vendor/
/vendor-bin/
node_modules/
npm-debug.log
yarn-error.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot

# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot

storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache
composer.lock
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# fidelity-bank-api-client-php
# fidelity-bank-api-client

[![Latest Stable Version](https://img.shields.io/github/v/release/brokeyourbike/fidelity-bank-api-client-php)](https://github.com/brokeyourbike/fidelity-bank-api-client-php/releases)
[![Total Downloads](https://poser.pugx.org/brokeyourbike/fidelity-bank-api-client/downloads)](https://packagist.org/packages/brokeyourbike/fidelity-bank-api-client)
[![License: MPL-2.0](https://img.shields.io/badge/license-MPL--2.0-purple.svg)](https://github.com/brokeyourbike/fidelity-bank-api-client-php/blob/main/LICENSE)

[![Maintainability](https://api.codeclimate.com/v1/badges/ceea2bd24e191d6f91d7/maintainability)](https://codeclimate.com/github/brokeyourbike/fidelity-bank-api-client-php/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/ceea2bd24e191d6f91d7/test_coverage)](https://codeclimate.com/github/brokeyourbike/fidelity-bank-api-client-php/test_coverage)
[![tests](https://github.com/brokeyourbike/fidelity-bank-api-client-php/actions/workflows/tests.yml/badge.svg)](https://github.com/brokeyourbike/fidelity-bank-api-client-php/actions/workflows/tests.yml)

Fidelity Bank API Client for PHP

## Installation

```bash
composer require brokeyourbike/fidelity-bank-api-client
```

## Usage

```php
use BrokeYourBike\FidelityBank\Client;

$apiClient = new Client($config, $httpClient, $psrCache);
$apiClient->fetchAuthTokenRaw();
```

## License
[Mozilla Public License v2.0](https://github.com/brokeyourbike/fidelity-bank-api-client-php/blob/main/LICENSE)
44 changes: 44 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "brokeyourbike/fidelity-bank-api-client",
"description": "Fidelity Bank API Client for PHP",
"type": "library",
"license": "MPL-2.0",
"keywords": [
"api",
"api-client",
"fidelitybank",
"fidelity-bank"
],
"autoload": {
"psr-4": {
"BrokeYourBike\\FidelityBank\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"BrokeYourBike\\FidelityBank\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Ivan Stasiuk",
"email": "brokeyourbike@gmail.com",
"homepage": "https://github.com/brokeyourbike"
}
],
"minimum-stability": "stable",
"require": {
"php": "^8.0",
"brokeyourbike/http-client": "^1.0",
"brokeyourbike/resolve-uri": "^1.0",
"myclabs/php-enum": "^1.8",
"brokeyourbike/http-enums": "^1.0",
"brokeyourbike/has-source-model": "^2.0",
"nesbot/carbon": "^2"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"phpunit/phpunit": "^9",
"mockery/mockery": "^1.4"
}
}
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
level: max
paths:
- src
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">./tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
40 changes: 40 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

// Copyright (C) 2021 Ivan Stasiuk <brokeyourbike@gmail.com>.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

namespace BrokeYourBike\FidelityBank;

use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\ClientInterface;
use Carbon\Carbon;
use BrokeYourBike\ResolveUri\ResolveUriTrait;
use BrokeYourBike\HttpEnums\HttpMethodEnum;
use BrokeYourBike\HttpClient\HttpClientTrait;
use BrokeYourBike\HttpClient\HttpClientInterface;
use BrokeYourBike\HasSourceModel\SourceModelInterface;
use BrokeYourBike\HasSourceModel\HasSourceModelTrait;
use BrokeYourBike\HasSourceModel\HasSourceModelInterface;
use BrokeYourBike\FidelityBank\Interfaces\TransactionInterface;
use BrokeYourBike\FidelityBank\Interfaces\ConfigInterface;

/**
* @author Ivan Stasiuk <brokeyourbike@gmail.com>
*/
class Client implements HttpClientInterface, HasSourceModelInterface
{
use HttpClientTrait;
use ResolveUriTrait;
use HasSourceModelTrait;

private ConfigInterface $config;

public function __construct(ConfigInterface $config, ClientInterface $httpClient)
{
$this->config = $config;
$this->httpClient = $httpClient;
}
}
Loading

0 comments on commit fbfc2a2

Please sign in to comment.