Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-micro
Commits
32696c91
Commit
32696c91
authored
Aug 27, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[功能]添加shopify集合相关类文件
parent
0c883be6
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
272 additions
and
74 deletions
+272
-74
ShopifyApp.php
src/Shopify/ShopifyApp.php
+56
-5
AbstractShopify.php
src/Shopify/lib/AbstractShopify.php
+100
-69
Collect.php
src/Shopify/lib/Collect.php
+16
-0
Collection.php
src/Shopify/lib/Collection.php
+28
-0
CustomCollection.php
src/Shopify/lib/CustomCollection.php
+28
-0
Metafield.php
src/Shopify/lib/Metafield.php
+16
-0
SmartCollection.php
src/Shopify/lib/SmartCollection.php
+28
-0
No files found.
src/Shopify/ShopifyApp.php
View file @
32696c91
...
...
@@ -8,7 +8,13 @@
namespace
Meibuyu\Micro\Shopify
;
use
Exception
;
use
Meibuyu\Micro\Shopify\lib\AbstractShopify
;
use
Meibuyu\Micro\Shopify\lib\Collect
;
use
Meibuyu\Micro\Shopify\lib\Collection
;
use
Meibuyu\Micro\Shopify\lib\CustomCollection
;
use
Meibuyu\Micro\Shopify\lib\Metafield
;
use
Meibuyu\Micro\Shopify\lib\SmartCollection
;
use
Meibuyu\Micro\Shopify\lib\Webhook
;
/**
...
...
@@ -16,20 +22,46 @@ use Meibuyu\Micro\Shopify\lib\Webhook;
* @package Meibuyu\Shopify
*
* @property-read Webhook $Webhook
* @property-read Collect $Collect
* @property-read Collection $Collection
* @property-read CustomCollection $CustomCollection
* @property-read SmartCollection $SmartCollection
* @property-read Metafield $Metafield
*
* @method Webhook Webhook(integer $id = null)
* @method Collection Collection(integer $id = null)
* @method CustomCollection CustomCollection(integer $id = null)
* @method SmartCollection SmartCollection(integer $id = null)
* @method Metafield Metafield(integer $id = null)
*
*/
class
ShopifyApp
{
protected
$resources
=
[
'Webhook'
,
'Collect'
,
'Collection'
,
'CustomCollection'
,
'SmartCollection'
,
'Metafield'
,
];
protected
$childResources
=
array
(
'Fulfillment'
=>
'Order'
,
'FulfillmentEvent'
=>
'Fulfillment'
,
'OrderRisk'
=>
'Order'
,
'ProductImage'
=>
'Product'
,
'ProductVariant'
=>
'Product'
,
'DiscountCode'
=>
'PriceRule'
,
'Refund'
=>
'Order'
,
'Transaction'
=>
'Order'
,
);
public
$config
=
[];
public
$defaultApiVersion
=
'2020-07'
;
public
$timeAllowedForEachApiCall
=
.
5
;
/**
* ShopifyApp constructor.
* @param array $config
...
...
@@ -51,15 +83,34 @@ class ShopifyApp
* 返回AbstractShopify实例
* @param string $className 实现的类名
* @return AbstractShopify
* @throws
\
Exception
* @throws Exception
*/
public
function
__get
(
$className
)
{
return
$this
->
$className
();
}
/**
* 返回AbstractShopify实例
* @param string $className 实现的类名
* @param $arguments
* @return AbstractShopify
* @throws Exception
*/
public
function
__call
(
$className
,
$arguments
)
{
if
(
!
in_array
(
$className
,
$this
->
resources
))
{
throw
new
\Exception
(
"未知方法
$className
"
);
if
(
isset
(
$this
->
childResources
[
$className
]))
{
$message
=
"
$className
是属于
{
$this
->
childResources
[
$className
]
}
的子集, 无法直接访问"
;
}
else
{
$message
=
"未知类
$className
"
;
}
throw
new
Exception
(
$message
);
}
$resourceID
=
!
empty
(
$arguments
)
?
$arguments
[
0
]
:
null
;
$resourceClassName
=
__NAMESPACE__
.
"
\\
lib
\\
$className
"
;
return
new
$resourceClassName
(
$this
->
config
);
return
new
$resourceClassName
(
$this
->
config
,
$resourceID
);
}
public
function
setApiUrl
()
...
...
src/Shopify/lib/AbstractShopify.php
View file @
32696c91
This diff is collapsed.
Click to expand it.
src/Shopify/lib/Collect.php
0 → 100644
View file @
32696c91
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/24
* Time: 16:50
*/
namespace
Meibuyu\Micro\Shopify\lib
;
class
Collect
extends
AbstractShopify
{
protected
$resourceKey
=
'collect'
;
}
src/Shopify/lib/Collection.php
0 → 100644
View file @
32696c91
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/24
* Time: 16:50
*/
namespace
Meibuyu\Micro\Shopify\lib
;
/**
* Class Collection
* @package Meibuyu\Micro\Shopify\lib
*
* @property-read Metafield $Metafield
*
* @method Metafield Metafield(integer $id = null)
*/
class
Collection
extends
AbstractShopify
{
protected
$resourceKey
=
'collection'
;
protected
$childResource
=
[
'Metafield'
,
];
}
src/Shopify/lib/CustomCollection.php
0 → 100644
View file @
32696c91
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/22
* Time: 16:14
*/
namespace
Meibuyu\Micro\Shopify\lib
;
/**
* Class CustomCollection
* @package Meibuyu\Micro\Shopify\lib
*
* @property-read Metafield $Metafield
*
* @method Metafield Metafield(integer $id = null)
*/
class
CustomCollection
extends
AbstractShopify
{
protected
$resourceKey
=
'custom_collection'
;
protected
$childResource
=
[
'Metafield'
,
];
}
src/Shopify/lib/Metafield.php
0 → 100644
View file @
32696c91
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/26
* Time: 15:50
*/
namespace
Meibuyu\Micro\Shopify\lib
;
class
Metafield
extends
AbstractShopify
{
protected
$resourceKey
=
'metafield'
;
}
src/Shopify/lib/SmartCollection.php
0 → 100644
View file @
32696c91
<?php
/**
* Created by PhpStorm.
* User: Zero
* Date: 2020/8/24
* Time: 16:50
*/
namespace
Meibuyu\Micro\Shopify\lib
;
/**\
* Class SmartCollection
* @package Meibuyu\Micro\Shopify\lib
*
* @property-read Metafield $Metafield
*
* @method Metafield Metafield(integer $id = null)
*/
class
SmartCollection
extends
AbstractShopify
{
protected
$resourceKey
=
'smart_collection'
;
protected
$childResource
=
[
'Metafield'
,
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment