weclapp API
Links
https://wiki.bluesafety.com/books/weclapp/chapter/development https://www.weclapp.com/api/ https://github.com/geccomedia/weclapp
website # root directory of your site
├── app
│ ├── Http
│ │ ├── Controllers
│ │ │ ├── Weclapp
│ │ │ │ ├── TaskController.php
│ │ │ │ └── ...
│ │ │ ├── WeclappController.php
│ │ │ └── ...
│ │ └── ...
│ └── ...
├── composer.json
└── ...
2.1. Examples
- Model
- ModelHelper
- Client
- ApiService
use App\Models\Weclapp\Customer;
$customer = Customer::where('company', 'Artur Zeier')->firstOrFail();
2.1.4. Mass assignments
$customer = new \App\Models\Weclapp\Customer();
\App\Models\Weclapp\Customer::unguard();
$customer->fill(['partyType' => 'ORGANIZATION']);
\App\Models\Weclapp\Customer::reguard();
2.1.5. Sub Entities
$comments = Comment::whereEntity('customer', 123)->orderByDesc()->get();
2.1.6. Logging
use App\Http\Controllers\Weclapp\Connection;
app(Connection::class)->enableQueryLog();
\App\Models\Weclapp\Customer::create(['name' => 'Test'])
app(Connection::class)->getQueryLog();
use App\Http\Helpers\ModelHelper;
$modelClass = ModelHelper::getModelClass($model);
$model = new $modelClass();
$customer = $model->where($entity, $value)->firstOrFail();
// if fillable-part doesn't exist in models use `unguard()` and `reguard()` for writing
$model->unguard();
return $customer->update(
['phone' => '+4925192778540']
);
$model->reguard();
use App\Http\Controllers\Weclapp\ClientController as Client;
$client = new Client();
$response = $client->get('customer');
$customers = json_decode($response->getBody()->getContents(), true);
use App\Services\Weclapp\WeclappApiService;
use App\Services\Weclapp\WeclappApiException;
public function showCustomer(WeclappApiService $weclapp, int $id)
{
try {
$result = $weclapp->get("customer/id/{$id}");
return response()->json($result['json'] ?? [
'body' => $result['body'],
]);
} catch (WeclappApiException $e) {
return response()->json([
'message' => $e->getMessage(),
'status' => $e->getStatus(),
'body' => $e->getResponseBody(),
'json' => $e->getResponseJson(),
], $e->getStatus() ?: 500);
}
}