diff --git a/includes/admin/class-api.php b/includes/admin/class-api.php index 8a66658..f6d46e8 100755 --- a/includes/admin/class-api.php +++ b/includes/admin/class-api.php @@ -55,7 +55,7 @@ public function issue_invoice( $order_ids = array() ) { $company_id = $this->get_company(); $issue_when_status = nfe_get_field( 'issue_when_status' ); - NFe::setApiKey( $key ); + NFe_io::setApiKey( $key ); foreach ( $order_ids as $order_id ) { @@ -123,7 +123,7 @@ public function download_pdf_invoice( $order_ids = array() ) { $key = $this->get_key(); $company_id = $this->get_company(); - NFe::setApiKey( $key ); + NFe_io::setApiKey( $key ); foreach ( $order_ids as $order_id ) { $nfe = get_post_meta( $order_id, 'nfe_issued', true ); diff --git a/includes/admin/class-settings.php b/includes/admin/class-settings.php index a5eca8d..215b64c 100755 --- a/includes/admin/class-settings.php +++ b/includes/admin/class-settings.php @@ -212,7 +212,7 @@ protected function get_companies() { return $company_list; } - NFe::setApiKey( $key ); + NFe_io::setApiKey( $key ); $companies = NFe_Company::search(); diff --git a/lib/client-php/CHANGELOG.MD b/lib/client-php/CHANGELOG.MD index 4a82c95..c3da440 100644 --- a/lib/client-php/CHANGELOG.MD +++ b/lib/client-php/CHANGELOG.MD @@ -1,3 +1,5 @@ +### 2.5 2017-01-22 +* Fix a conflict in the name of the main class ### 2.4 2016-08-31 * Fix strtolower on api resource diff --git a/lib/client-php/README.md b/lib/client-php/README.md index 049fb7a..518d3b3 100644 --- a/lib/client-php/README.md +++ b/lib/client-php/README.md @@ -50,9 +50,9 @@ ### Criar empresa ```php -NFe::setApiKey("c73d49f9649046eeba36dcf69f6334fd"); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) +NFe_io::setApiKey("c73d49f9649046eeba36dcf69f6334fd"); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) -NFe_Company::create( +$companyCreated = NFe_Company::create( array( 'federalTaxNumber' => 87502637000164, // Use esse gerador para testar: http://www.geradordecnpj.org/ 'name' => 'BANCO DO BRASIL SA', @@ -84,13 +84,15 @@ NFe_Company::create( ) ) ); + +echo($companyCreated->id); ``` ### Emitir nota fiscal ```php -NFe::setApiKey('c73d49f9649046eeba36dcf69f6334fd'); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) +NFe_io::setApiKey('c73d49f9649046eeba36dcf69f6334fd'); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) -NFe_ServiceInvoice::create( +$invoiceCreated = NFe_ServiceInvoice::create( // ID da empresa, você deve copiar exatamente como está no painel '64555e0ee340420fdc94ad09', // Dados da nota fiscal de serviço @@ -136,11 +138,13 @@ NFe_ServiceInvoice::create( ) ) ); + +echo($invoiceCreated->id); ``` ### Cancelar nota fiscal ```php -NFe::setApiKey("c73d49f9649046eeba36dcf69f6334fd"); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) +NFe_io::setApiKey("c73d49f9649046eeba36dcf69f6334fd"); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) $invoice = NFe_ServiceInvoice::fetch( '64555e0ee340420fdc94ad09', // ID da empresa, você deve copiar exatamente como está no painel @@ -154,7 +158,7 @@ if ( $invoice->status == 'Issued' ) { ### Download do PDF da nota fiscal ```php -NFe::setApiKey('c73d49f9649046eeba36dcf69f6334fd'); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) +NFe_io::setApiKey('c73d49f9649046eeba36dcf69f6334fd'); // Ache sua chave API no painel (https://app.nfe.io/account/apikeys) $url = NFe_ServiceInvoice::pdf( '64555e0ee340420fdc94ad09', // ID da empresa, você deve copiar exatamente como está no painel diff --git a/lib/client-php/VERSION b/lib/client-php/VERSION index 6b4950e..95e3ba8 100644 --- a/lib/client-php/VERSION +++ b/lib/client-php/VERSION @@ -1 +1 @@ -2.4 +2.5 diff --git a/lib/client-php/composer.json b/lib/client-php/composer.json index caf0ba9..8149273 100644 --- a/lib/client-php/composer.json +++ b/lib/client-php/composer.json @@ -2,7 +2,7 @@ "name": "nfe/nfe", "description": "NFe.io PHP Library", "homepage": "https://nfe.io", - "version": "2.4", + "version": "2.5", "keywords": [ "nfe", "nfse", diff --git a/lib/client-php/lib/NFe/APIRequest.php b/lib/client-php/lib/NFe/APIRequest.php index 215e63a..ba973e7 100644 --- a/lib/client-php/lib/NFe/APIRequest.php +++ b/lib/client-php/lib/NFe/APIRequest.php @@ -4,7 +4,7 @@ class NFe_APIRequest { public function __construct() {} private function _defaultHeaders( $headers = array() ) { - $headers[] = "Authorization: Basic " . NFe::getApiKey(); + $headers[] = "Authorization: Basic " . NFe_io::getApiKey(); $headers[] = "Content-Type: application/json"; $headers[] = "Accept: application/json"; $headers[] = "Accept-Charset: UTF-8"; @@ -17,12 +17,12 @@ private function _defaultHeaders( $headers = array() ) { public function request( $method, $url, $data = array() ) { global $last_api_response_code; - if ( NFe::getApiKey() == null ) { + if ( NFe_io::getApiKey() == null ) { NFe_Utilities::authFromEnv(); } - if ( NFe::getApiKey() == null ) { - return new NFeAuthenticationException("Chave de API não configurada. Utilize NFe::setApiKey(...) para configurar."); + if ( NFe_io::getApiKey() == null ) { + return new NFeAuthenticationException("Chave de API não configurada. Utilize NFe_io::setApiKey(...) para configurar."); } $headers = $this->_defaultHeaders(); @@ -86,7 +86,7 @@ private function requestWithCURL( $method, $url, $headers, $data = array() ) { $opts[CURLOPT_TIMEOUT] = 80; $opts[CURLOPT_CONNECTTIMEOUT] = 30; $opts[CURLOPT_HTTPHEADER] = $headers; - if ( NFe::$verifySslCerts == false ) { + if ( NFe_io::$verifySslCerts == false ) { $opts[CURLOPT_SSL_VERIFYPEER] = false; } $opts[CURLOPT_SSL_VERIFYHOST] = 2; @@ -107,7 +107,7 @@ private function requestWithCURL( $method, $url, $headers, $data = array() ) { curl_setopt_array($curl, $opts); // For debugging - if ( NFe::$debug == true ) { + if ( NFe_io::$debug == true ) { curl_setopt( $curl, CURLOPT_PROXY, "127.0.0.1:8888" ); curl_setopt( $curl, CURLOPT_VERBOSE, 1 ); } diff --git a/lib/client-php/lib/NFe/APIResource.php b/lib/client-php/lib/NFe/APIResource.php index ff94a72..7bb5237 100644 --- a/lib/client-php/lib/NFe/APIResource.php +++ b/lib/client-php/lib/NFe/APIResource.php @@ -54,7 +54,7 @@ public static function endpointAPI( $object = null, $uri_path = '' ) { $path = '/' . $object['id']; } - return strtolower( NFe::getBaseURI() . $uri_path . '/' . self::objectBaseURI() . $path ); + return strtolower( NFe_io::getBaseURI() . $uri_path . '/' . self::objectBaseURI() . $path ); } public static function url( $object = null ) { diff --git a/lib/client-php/lib/NFe/NFe.php b/lib/client-php/lib/NFe/NFe.php index 3da078a..6abe41f 100644 --- a/lib/client-php/lib/NFe/NFe.php +++ b/lib/client-php/lib/NFe/NFe.php @@ -1,6 +1,6 @@ >>>>>> Stashed changes //o-------------------------------o // Configure time as GMT