O
O
Oleg2019-11-08 15:56:44
PHP
Oleg, 2019-11-08 15:56:44

Am I able to properly organize API data processing using classes?

Greetings. Developed several classes for interacting with the Bitrix API. It was required to display statistics for each employee: the number of calls, transactions, and so on. Please rate and criticize my code. More details below
Link to github: https://github.com/afagorn/bitrix24-api
Class capabilities
For each "entity" of Bitrix (calls, bills, etc.), a separate class is created, where the necessary filter for Bitrix and "wrapper methods" are written , which set their own set of arguments and fill the array with user data. For example, the getInvoicesHistoryByEmployeesId() method, which accepts user IDs, date, and payment status. These wrappers are made

There is a base class Base, where common methods and variables are specified. An important variable is requestParameters (getRequestParameters getter), where data for a request to Bitrix is ​​specified in the child classes. And it also contains values ​​from the array of the requestData class. For example:

[
    "FILTER" => array(
      "STATUS_ID" => $this->requestData['statusId'],
      ">=PAY_VOUCHER_DATE" => $this->requestData['dateStart'],
      "<=PAY_VOUCHER_DATE" => $this->requestData['dateEnd'],
      'RESPONSIBLE_ID' => $this->requestData['employeesId'],
    ),
];

Client data is passed to makeRequest(), it is being processed (the date is converted into the required format for Bitrix) and merge with the $requestData class variable. Then the data is sent from the class variables.
The TipBitrix24 class is like a general class that creates objects in the form of a chain. An example can be found in the file Example. Made in order not to create each time an object for each class.
My doubts
. Did I correctly organize the addition of an array for Bitrix? More specifically, the getRequestParameters() method?
Or the fact that you need to prescribe the data initially in your own array? Through makeRequest()?
Did I make the general "entry point" correctly, that is, the TipBitrix24 class? Or shouldn't it be done at all?
PS Classes are written for Yii, so some Yii classes are used
I will be grateful for any feedback, criticism and advice

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question