From 0082cd7e5900ff86c205dd9be5a15ddb26cc4ea6 Mon Sep 17 00:00:00 2001 From: camaxtly Date: Sun, 18 Feb 2018 14:36:08 +0300 Subject: [PATCH 1/3] task#98 Add userfields support --- src/classes/crm/invoice/invoice.php | 119 +++++++++++++++--- src/classes/crm/invoice/status.php | 50 ++++++-- src/classes/crm/invoice/userfield.php | 172 ++++++++++++++++++++++++++ 3 files changed, 313 insertions(+), 28 deletions(-) create mode 100644 src/classes/crm/invoice/userfield.php diff --git a/src/classes/crm/invoice/invoice.php b/src/classes/crm/invoice/invoice.php index 8266cb7a..b7736fe7 100644 --- a/src/classes/crm/invoice/invoice.php +++ b/src/classes/crm/invoice/invoice.php @@ -19,22 +19,37 @@ class Invoice extends Bitrix24Entity /** * Get list of lead items. + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_list.php - * @param array $order - order of task items - * @param array $filter - filter array - * @param array $select - array of collumns to select - * @param integer $start - entity number to start from (usually returned in 'next' field of previous 'crm.invoice.list' API call) + * + * @param array $order - order of task items + * @param array $filter - filter array + * @param array $select - array of collumns to select + * @param integer $start - entity number to start from (usually returned in 'next' field of previous 'crm.invoice.list' API call) + * * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException */ public function getList($order = array(), $filter = array(), $select = array(), $start = 0) { $fullResult = $this->client->call( 'crm.invoice.list', array( - 'order' => $order, - 'filter'=> $filter, - 'select'=> $select, - 'start' => $start + 'order' => $order, + 'filter' => $filter, + 'select' => $select, + 'start' => $start ) ); return $fullResult; @@ -42,10 +57,23 @@ public function getList($order = array(), $filter = array(), $select = array(), /** * get invoice by id - * @var $invoiceId integer invoice identifier + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_get.php + * @var $invoiceId integer invoice identifier * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException +*/ public function get($invoiceId) { $fullResult = $this->client->call( @@ -57,10 +85,23 @@ public function get($invoiceId) /** * delete invoice by id - * @var $invoiceId integer invoice identifier + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_delete.php + * @var $invoiceId integer invoice identifier * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException +*/ public function delete($invoiceId) { $fullResult = $this->client->call( @@ -72,10 +113,24 @@ public function delete($invoiceId) /** * Add a new invoice to CRM + * * @param array $fields array of fields - * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_add.php + * * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_add.php +*/ public function add($fields = array()) { $fullResult = $this->client->call( @@ -87,11 +142,26 @@ public function add($fields = array()) /** * update invoice by id - * @var $invoiceId integer invoice identifier - * @var $invoiceFields array invoice fields to update + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_update.php + * + * @param $invoiceId + * @param $invoiceFields + * * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException +*/ public function update($invoiceId, $invoiceFields) { $fullResult = $this->client->call( @@ -106,9 +176,22 @@ public function update($invoiceId, $invoiceFields) /** * get list of invoice fields with description + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_fields.php * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException +*/ public function fields() { $fullResult = $this->client->call( diff --git a/src/classes/crm/invoice/status.php b/src/classes/crm/invoice/status.php index 7cf4db20..5b3c116c 100644 --- a/src/classes/crm/invoice/status.php +++ b/src/classes/crm/invoice/status.php @@ -6,22 +6,37 @@ class Status extends Bitrix24Entity { /** * Get list of Invoice.Status items. + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice_status/crm_invoice_status_list.php - * @param array $order - order of items - * @param array $filter - filter array - * @param array $select - array of columns to select - * @param integer $start - entity number to start from (usually returned in 'next' field of previous 'crm.invoice.status.list' API call) + * + * @param array $order - order of items + * @param array $filter - filter array + * @param array $select - array of columns to select + * @param integer $start - entity number to start from (usually returned in 'next' field of previous 'crm.invoice.status.list' API call) + * * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException */ public function getList($order = array(), $filter = array(), $select = array(), $start = 0) { $fullResult = $this->client->call( 'crm.invoice.status.list', array( - 'order' => $order, - 'filter'=> $filter, - 'select'=> $select, - 'start' => $start + 'order' => $order, + 'filter' => $filter, + 'select' => $select, + 'start' => $start ) ); return $fullResult; @@ -29,10 +44,25 @@ public function getList($order = array(), $filter = array(), $select = array(), /** * get by id + * * @link http://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_status_get.php - * @param integer $invoiceStatusId - invoice status identifier + * + * @param integer $invoiceStatusId - invoice status identifier + * * @return array - */ + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException +*/ public function get($invoiceStatusId) { $fullResult = $this->client->call( diff --git a/src/classes/crm/invoice/userfield.php b/src/classes/crm/invoice/userfield.php new file mode 100644 index 00000000..d4f08bd2 --- /dev/null +++ b/src/classes/crm/invoice/userfield.php @@ -0,0 +1,172 @@ +client->call( + 'crm.invoice.userfield.list', + array( + 'order' => $order, + 'filter' => $filter, + ) + ); + + return $fullResult; + } + + /** + * Get item userfield + * + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_userfield_get.php + * + * @param integer $userfieldId - invoice userfield id + * + * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + */ + public function get($userfieldId) + { + $fullResult = $this->client->call( + 'crm.invoice.userfield.get', + array('id' => $userfieldId) + ); + + return $fullResult; + } + + /** + * Delete userfield + * + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_userfield_delete.php + * + * @param integer $userfieldId - invoice userfield id + * + * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + */ + public function delete($userfieldId) + { + $fullResult = $this->client->call( + 'crm.invoice.userfield.delete', + array('id' => $userfieldId) + ); + + return $fullResult; + } + + /** + * Add a new userfield to invoice + * + * @param array $fields array of fields + * + * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_userfield_add.php + */ + public function add($fields = array()) + { + $fullResult = $this->client->call( + 'crm.invoice.userfield.add', + array('fields' => $fields) + ); + + return $fullResult; + } + + /** + * Update a new userfield to invoice + * + * @param int $userfieldId invoice userfield id + * @param array $fields array of fields + * + * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_invoice_userfield_update.php + */ + public function update($userfieldId, $fields = array()) + { + $fullResult = $this->client->call( + 'crm.invoice.userfield.update', + array( + 'id' => $userfieldId, + 'fields' => $fields, + ) + ); + + return $fullResult; + } +} \ No newline at end of file From d45008735bc5f0467ec506aa105e972b297d25db Mon Sep 17 00:00:00 2001 From: camaxtly Date: Sun, 18 Feb 2018 15:07:33 +0300 Subject: [PATCH 2/3] task#98 Add paysystem adm persontype support --- src/classes/crm/invoice/paysystem.php | 75 ++++++++++++++++++++++++++ src/classes/crm/invoice/persontype.php | 75 ++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 src/classes/crm/invoice/paysystem.php create mode 100644 src/classes/crm/invoice/persontype.php diff --git a/src/classes/crm/invoice/paysystem.php b/src/classes/crm/invoice/paysystem.php new file mode 100644 index 00000000..b3d8927b --- /dev/null +++ b/src/classes/crm/invoice/paysystem.php @@ -0,0 +1,75 @@ +client->call( + 'crm.paysystem.list', + array( + 'order' => $order, + 'filter' => $filter, + ) + ); + + return $fullResult; + } + + + /** + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_paysystem_fields.php + * + * @return array + * + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + * + */ + public function fields() + { + $fullResult = $this->client->call( + 'crm.paysystem.fields', + array() + ); + + return $fullResult; + } +} \ No newline at end of file diff --git a/src/classes/crm/invoice/persontype.php b/src/classes/crm/invoice/persontype.php new file mode 100644 index 00000000..a6090ffb --- /dev/null +++ b/src/classes/crm/invoice/persontype.php @@ -0,0 +1,75 @@ +client->call( + 'crm.persontype.list', + array( + 'order' => $order, + 'filter' => $filter, + ) + ); + + return $fullResult; + } + + + /** + * @link https://dev.1c-bitrix.ru/rest_help/crm/invoice/crm_persontype_fields.php + * + * @return array + * + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + * + */ + public function fields() + { + $fullResult = $this->client->call( + 'crm.persontype.fields', + array() + ); + + return $fullResult; + } +} \ No newline at end of file From a199411461fc8f696bbfbcd2541b64d7e10792f0 Mon Sep 17 00:00:00 2001 From: camaxtly Date: Sun, 25 Mar 2018 23:59:45 +0300 Subject: [PATCH 3/3] task#98 externalLink --- src/classes/crm/invoice/invoice.php | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/classes/crm/invoice/invoice.php b/src/classes/crm/invoice/invoice.php index b7736fe7..ff024aba 100644 --- a/src/classes/crm/invoice/invoice.php +++ b/src/classes/crm/invoice/invoice.php @@ -199,4 +199,34 @@ public function fields() ); return $fullResult; } + + /** + * get external link for invoice + * + * @param $id + * + * @return array + * @throws \Bitrix24\Exceptions\Bitrix24ApiException + * @throws \Bitrix24\Exceptions\Bitrix24EmptyResponseException + * @throws \Bitrix24\Exceptions\Bitrix24Exception + * @throws \Bitrix24\Exceptions\Bitrix24IoException + * @throws \Bitrix24\Exceptions\Bitrix24MethodNotFoundException + * @throws \Bitrix24\Exceptions\Bitrix24PaymentRequiredException + * @throws \Bitrix24\Exceptions\Bitrix24PortalDeletedException + * @throws \Bitrix24\Exceptions\Bitrix24PortalRenamedException + * @throws \Bitrix24\Exceptions\Bitrix24SecurityException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsExpiredException + * @throws \Bitrix24\Exceptions\Bitrix24TokenIsInvalidException + * @throws \Bitrix24\Exceptions\Bitrix24WrongClientException + */ + public function getExternalLink($id) + { + $fullResult = $this->client->call( + 'crm.invoice.getexternallink', + array( + 'id' => $id + ) + ); + return $fullResult; + } }