Skip to content

Commit

Permalink
0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Jul 8, 2017
1 parent bcb460f commit 22e65c0
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 3 deletions.
32 changes: 32 additions & 0 deletions API/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Dfe\ZohoCRM\API;
use Dfe\ZohoCRM\Settings;
// 2017-07-08
/** @method Settings ss() */
final class Client extends \Df\Zoho\API\Client {
/**
* 2017-07-08
* https://www.zoho.eu/crm/help/api/getmodules.html#Request_URL
* @override
* @see \Df\API\Client::commonParams()
* @used-by \Df\API\Client::__construct()
* @param string $path
* @return array(string => mixed)
*/
final protected function commonParams($path) {return [
// 2017-07-08 «Encrypted alphanumeric string to authenticate your Zoho credentials»
'authtoken' => $this->ss()->token()
// 2017-07-08 «Specify the value as `crmapi`»
,'scope' => 'crmapi'
];}

/**
* 2017-07-08
* @override
* @see \Df\API\Client::uriBase()
* @used-by \Df\API\Client::__construct()
* @used-by \Df\API\Client::p()
* @return string
*/
protected function uriBase() {return "https://{$this->ss()->domain()}/crm/private/json";}
}
28 changes: 28 additions & 0 deletions API/Facade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace Dfe\ZohoCRM\API;
use Df\Core\Exception as DFE;
use Dfe\ZohoCRM\API\Client as C;
// 2017-07-08
final class Facade {
/**
* 2017-07-08 https://www.zoho.eu/crm/help/api/getmodules.html
* @return array(array(string => mixed))
*/
final function getModules() {return $this->p(__FUNCTION__, 'Info');}

/**
* 2017-07-08
* @param string $path
* @param string $ns [optional]
* @param array(string => mixed) $p [optional]
* @param string|null $method [optional]
* @return array(string => mixed)
* @throws DFE
*/
final function p($path, $ns = '', array $p = [], $method = null) {return C::i(
$this, df_cc_path($ns, $path), $p, $method
)->p();}

/** 2017-07-08 @return self */
public static function s() {static $r; return $r ? $r : $r = new self;}
}
9 changes: 8 additions & 1 deletion Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
namespace Dfe\ZohoCRM;
// 2017-07-05
/** @method static Settings s() */
final class Settings extends \Df\Zoho\Settings {}
final class Settings extends \Df\Zoho\Settings {
/**
* 2017-07-08
* @used-by \Dfe\ZohoCRM\API\Client::uriBase()
* @return string
*/
function domain() {return $this->v(null, null, $this->v('domain_custom'));}
}
22 changes: 22 additions & 0 deletions Source/Domain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Dfe\ZohoCRM\Source;
// 2017-07-08
final class Domain extends \Df\Config\Source {
/**
* 2017-07-08
* https://mage2.pro/t/4150
* https://www.quora.com/Where-are-ZOHO-Data-Centers-Cloud-Servers-located/answer/Neel-Gupta-3
* https://www.zoho.eu/crm/help/api/using-api-url.html
* @override
* @see \Df\Config\Source::map()
* @used-by \Df\Config\Source::toOptionArray()
* @return array(string => string)
*/
protected function map() {return
[0 => '-- select a value --']
+ dfa_combine_self(['crm.zoho.com', 'crm.zoho.eu', 'crm.zoho.com.cn', 'crm.zoho.co.jp'])
+ [self::OTHER => 'Other']
;}

const OTHER = 'other';
}
4 changes: 4 additions & 0 deletions T/Basic.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Dfe\ZohoCRM\T;
use Dfe\ZohoCRM\API\Facade as F;
use Dfe\ZohoCRM\Settings as S;
// 2017-07-05
final class Basic extends TestCase {
Expand All @@ -8,4 +9,7 @@ function t00() {}

/** 2017-07-05 */
function t01_token() {echo S::s()->token();}

/** @test 2017-07-08 */
function t02_getModules() {echo df_json_encode(F::s()->getModules());}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/zoho-crm"
,"version": "0.0.2"
,"version": "0.0.3"
,"description": "The «Zoho CRM» extension for Magento 2."
,"type": "magento2-module"
,"homepage": "https://github.com/mage2pro/zoho-crm"
Expand All @@ -11,7 +11,7 @@
"homepage": "https://mage2.pro/users/dmitry_fedyuk",
"role": "Developer"
}]
,"require": {"mage2pro/core": ">=2.7.40", "mage2pro/zoho": ">=0.0.5"}
,"require": {"mage2pro/core": ">=2.7.43", "mage2pro/zoho": ">=0.0.7"}
,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\ZohoCRM\\": ""}}
,"keywords": [
"CRM"
Expand Down
27 changes: 27 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,33 @@
</depends>
<validate>required-entry</validate>
</field>
<field
id='domain'
showInDefault='1' showInStore='1' showInWebsite='1'
sortOrder='3'
translate='label'
type='select'
>
<label>Your Zoho CRM domain</label>
<source_model>Dfe\ZohoCRM\Source\Domain</source_model>
<comment><![CDATA[You can find it out in your browser's address bar after logging into your Zoho CRM application.]]></comment>
<depends>
<field id='enable'>1</field>
</depends>
</field>
<field
id='domain_custom'
showInDefault='1' showInStore='1' showInWebsite='1'
sortOrder='4'
translate='label'
>
<label>Custom Domain</label>
<comment><![CDATA[]]></comment>
<depends>
<field id='enable'>1</field>
<field id='domain'>other</field>
</depends>
</field>
</group>
</section>
</system>
Expand Down

0 comments on commit 22e65c0

Please sign in to comment.