Crell / ApiProblem

A simple implementation of the api-problem specification. Includes PSR-15 support.
MIT License
239 stars 21 forks source link

Static function to create fromArray() #24

Closed dol closed 3 years ago

dol commented 5 years ago

The acme protocol returns in https://tools.ietf.org/html/draft-ietf-acme-acme-17#section-7.1.3 an error object which is in the format of RFC 7807. To get this informations into a ApiProblem we need to perform a json_decode of the payload. Extract 'error' and json_encode the data to be passed to ApiProblem::fromJson.

It would be easier to just have a static function like decompile named ApiProblem::fromArray() to perform the work.

Crell commented 5 years ago

They're actually naming a protcol ACME???

I'm a bit skeptical; from a quick glance it looks like just a portion of the ACME payload is a 7807 string? Are you suggesting an ACME-parsing function, or just something that is barely a step above deserialize, in essence?

If the latter, I guess I have no particular objection to it and would accept a PR for it. However, be aware of the refactoring going on in #23 so that you don't bump into it.

dol commented 5 years ago

Sorry, my intension was not clearly written. What I mean is the following https://github.com/dol/ApiProblem/commit/a340d921c104abf500ef45430fcb4285d3ef16ec change. The ACME protocol was only an example to ilustrate the usage of the new functionality. Because some ACME protocol responses contain Problem Details parts.

Crell commented 5 years ago

Ah, OK. Yeah, I'd take a PR for that. It looks like it wouldn't conflict with #23 either, which is good.

dol commented 5 years ago

If you give me some time I'll add some tests as well. Was only a PoC.

Crell commented 5 years ago

Hey @dol. Are you going to be following up on this issue or shall I close it?

datashaman commented 4 years ago

decompile is that method. Rename it and make it public, solved.