R
R
Roquie2015-01-28 10:58:56
PHP
Roquie, 2015-01-28 10:58:56

Facade over API requests. How to collect objects, their information and pack them into one request?

There is an API wrapper for requests. They are built in such a way that in one http request you can send another batch inside for fetching, changing, creating data, etc.
I wanted to make a static facade, like this:

Users::find($user_id);
Users::create(['name' => 'foobar']);

$s = new Service($id);
$s->field = 'FooBar';
$s->update();

Reference::findByType(Type::ORGS);

Where each line is essentially a request to a remote server. Interested in how to collect common query parameters in these objects and send one in the last method?
What patterns exist for this case? The factory and the observer, it seems to me, do not fit. Yes, and I don’t want to fence the monstrous OOP, but to make a light facade, as in Laravel, for example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2015-01-28
@Roquie

Why mix everything up? Such scripts are usually built on the REST architecture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question