Comments (4)
from haveibeenpwned.
@xsist10, I want to try to fix this issue.
Can you tell more details about the implementation?
Thanks.
from haveibeenpwned.
Hi @peter279k,
Firstly thank you for your interest in contributing.
For this issue I wanted to give some thought to the responses I return from the library. Currently I grab the JSON response and return it to the user. I was thinking that returning an object that encapsulated the response and provided helper functions would make it easier to use the response.
As example: https://haveibeenpwned.com/api/v2/breachedaccount/[email protected]
The response from this would return an array of breaches so, to know if an account was breached they'd need to do the following:
use xsist10\HaveIBeenPwned\HaveIBeenPwned;
$manager = new HaveIBeenPwned();
$response = $manager->checkAccount("[email protected]");
if (count($response)) {
echo "You've been breached!\n";
foreach ($response as $breach) {
echo " * " . $breach['Name'] . "\n";
}
}
Rather I would have it wrap the result in a response specific to the call to be something like this:
use xsist10\HaveIBeenPwned\HaveIBeenPwned;
$manager = new HaveIBeenPwned();
$response = $manager->checkAccount("[email protected]");
if ($response->hasBreaches())) {
echo "You've been breached!\n";
foreach ($response->getBreaches() as $breach) {
echo " * " . $breach->getName() . "\n";
}
}
For this I think we'd need the following Response
classes:
AccountResponse
BreachResponse
DataClassResponse
PasteResponse
PasswordResponse
And since it would change the interface we would also need to bump the major version.
Does this make sense?
from haveibeenpwned.
Hi @xsist10, thank you for your reply.
I think it makes sense and lets the different Response
objects for the different response.
I will follow that approach that you suggest to implement and I also send the related PR.
If Having any problems after sending the PR, please feel free to add the comment and set the request changes :-).
Thanks.
from haveibeenpwned.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haveibeenpwned.