Commit 2f7cd0d2 authored by Daniele Rosario's avatar Daniele Rosario
Browse files

Merge branch 'release/3.1.1'

Showing with 113 additions and 45 deletions
+113 -45
[![Latest Version on Packagist](https://img.shields.io/packagist/v/webleit/zohobooksapi.svg?style=flat-square)](https://packagist.org/packages/webleit/zohobooksapi)
[![Total Downloads](https://img.shields.io/packagist/dt/webleit/zohobooksapi.svg?style=flat-square)](https://packagist.org/packages/webleit/zohobooksapi)
# Zoho Books API v3 - PHP SDK
This Library is a SDK in PHP that simplifies the usage of the Zoho Books Api version 3 (https://www.zoho.com/books/api/v3/)
......
......@@ -102,7 +102,7 @@ class Client
/**
* @return string
*/
public function getOrganizationId ()
public function getOrganizationId()
{
return $this->organizationId;
}
......@@ -110,7 +110,7 @@ class Client
/**
* @return string
*/
public function getRegion ()
public function getRegion()
{
return $this->region;
}
......@@ -191,7 +191,7 @@ class Client
$url,
$this->getOptions([
'query' => $this->getParams($organizationId) + $params,
'form_params' => [ 'JSONString' => json_encode($data) ]
'form_params' => ['JSONString' => json_encode($data)]
])
));
}
......@@ -214,7 +214,8 @@ class Client
return $this->processResult($this->httpClient->put(
$url,
$this->getOptions([
'query' => $this->getParams($organizationId, $data) + $params,
'query' => $this->getParams($organizationId) + $params,
'form_params' => ['JSONString' => json_encode($data)]
])
));
}
......@@ -270,7 +271,7 @@ class Client
{
return array_merge([
'headers' => [
'Authorization' => 'Zoho-oauthtoken '.$this->oAuthClient->getAccessToken()
'Authorization' => 'Zoho-oauthtoken ' . $this->oAuthClient->getAccessToken()
]
], $params);
}
......
<?php
namespace Webleit\ZohoBooksApi\Modules;
/**
* Class Claimants
* @package Webleit\ZohoBooksApi\Modules
*/
class Claimants extends Module
{
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ class CustomerPayments extends Module
/**
* @return string
*/
protected function getResourceKey()
public function getResourceKey()
{
return 'customerpayments';
}
......@@ -50,4 +50,4 @@ class CustomerPayments extends Module
$className = $this->getModelClassName() . '\\Refund';
return $this->getPropertyList('refunds', $id, $className, 'payment_refunds', $this->refunds);
}
}
\ No newline at end of file
}
......@@ -187,6 +187,13 @@ abstract class Module implements \Webleit\ZohoBooksApi\Contracts\Module
}
/**
* Mark something with a status
*
* Note that as of 2019-11-27, Zoho Books API errors if you don't
* provide a JSONString param. It can't be empty.
*
* See https://github.com/Weble/ZohoBooksApi/issues/33
*
* @param $id
* @param $status
* @param string $key
......@@ -194,7 +201,11 @@ abstract class Module implements \Webleit\ZohoBooksApi\Contracts\Module
*/
public function markAs($id, $status, $key = 'status')
{
$this->client->post($this->getUrl() . '/' . $id . '/' . $key . '/' . $status);
$this->client->post(
$this->getUrl() . '/' . $id . '/' . $key . '/' . $status,
null,
["random" => "data"]
);
// If we arrive here without exceptions, everything went well
return true;
}
......
......@@ -36,4 +36,17 @@ class RecurringExpenses extends Documents
{
return $this->getPropertyList('expenses', $id);
}
}
\ No newline at end of file
/**
* Override returned key
*
* This overrides the key that is returned from zoho, as they
* send back 'recurring_expenses' instead of 'recurringexpenses'
*
* @return string
*/
public function getResourceKey()
{
return 'recurring_expenses';
}
}
......@@ -25,4 +25,17 @@ class RecurringInvoices extends Documents
{
return $this->markAs($id, 'resume');
}
}
\ No newline at end of file
/**
* Override returned key
*
* This overrides the key that is returned from zoho, as they
* send back 'recurring_invoices' instead of 'recurringinvoices'
*
* @return string
*/
public function getResourceKey()
{
return 'recurring_invoices';
}
}
......@@ -24,8 +24,8 @@ class ExchangeRates extends SubModule
/**
* @return string
*/
protected function getResourceKey()
public function getResourceKey()
{
return 'exchange_rates';
}
}
\ No newline at end of file
}
......@@ -32,7 +32,7 @@ class OpeningBalances extends Module
/**
* @return string
*/
protected function getResourceKey()
public function getResourceKey()
{
return 'opening_balance';
}
......@@ -56,4 +56,4 @@ class OpeningBalances extends Module
}
}
\ No newline at end of file
}
......@@ -26,4 +26,29 @@ class TaxAuthorities extends Module
{
return TaxAuthority::class;
}
}
\ No newline at end of file
/**
* Return Zoho API name
*
* This overrides getResourceKey in Module, which normally
* returns strtolower of name. However, Zoho returns "tax_authorities"
* instead of the expected 'taxauthorities' key.
*/
public function getResourceKey()
{
return "tax_authorities";
}
/**
* Return Zoho API Key Name
*
* This is the unique key used to return data. With the taxauthorities
* module, it returns the data as an array in 'tax_authorities' but the
* actual key is 'tax_authority_id', without the trailing s.
*/
public function getApiKeyName()
{
return "tax_authoritiy_id";
}
}
......@@ -2,6 +2,8 @@
namespace Webleit\ZohoBooksApi\Modules\Settings;
use Weble\ZohoClient\Exception\ApiError;
use Webleit\ZohoBooksApi\Models\Settings\TaxGroup;
use Webleit\ZohoBooksApi\Modules\Module;
/**
......@@ -10,6 +12,16 @@ use Webleit\ZohoBooksApi\Modules\Module;
*/
class TaxGroups extends Module
{
/**
* @param array $params
* @return \Illuminate\Support\Collection|void
* @throws ApiError
*/
public function getList($params = [])
{
throw new ApiError('The getList() api for TaxGroups is not implemented in Zoho APIs');
}
/**
* @return string
*/
......@@ -23,6 +35,6 @@ class TaxGroups extends Module
*/
public function getModelClassName()
{
return '\\Webleit\\ZohoBooksApi\\Models\\Settings\\TaxGroup';
return TaxGroup::class;
}
}
\ No newline at end of file
<?php
namespace Webleit\ZohoBooksApi\Modules;
/**
* Class Units
* @package Webleit\ZohoBooksApi\Modules
*/
class Units extends Module
{
protected $urlPath = 'settings/units';
}
\ No newline at end of file
......@@ -70,4 +70,17 @@ class VendorCredits extends Module
{
return $this->markAs($id, 'void');
}
}
\ No newline at end of file
/**
* Override returned key
*
* This overrides the key that is returned from zoho, as they
* send back 'vendor_credits' instead of 'vendorcredits'
*
* @return string
*/
public function getResourceKey()
{
return 'vendor_credits';
}
}
......@@ -31,7 +31,8 @@ use Webleit\ZohoBooksApi\Modules;
* @property-read Modules\Projects $projects
* @property-read Modules\Settings $settings
* @property-read Modules\Organizations $organizations
* @property-read Modules\Items $items;
* @property-read Modules\Items $items
* @property-read Modules\Users $users
*/
class ZohoBooks implements \Webleit\ZohoBooksApi\Contracts\ProvidesModules
{
......@@ -93,7 +94,8 @@ class ZohoBooks implements \Webleit\ZohoBooksApi\Contracts\ProvidesModules
'projects' => Modules\Projects::class,
'settings' => Modules\Settings::class,
'organizations' => Modules\Organizations::class,
'items' => Modules\Items::class
'items' => Modules\Items::class,
'users' => Modules\Users::class,
];
/**
......@@ -131,5 +133,4 @@ class ZohoBooks implements \Webleit\ZohoBooksApi\Contracts\ProvidesModules
$this->client->setOrganizationId($id);
return $this;
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment