rokde / gsales-api-client
用于消费Sales API的SOAP客户端
Requires
- php: >=5.4
- ext-soap: *
Requires (Dev)
- symfony/console: v2.3.12
Suggests
- illuminate/config: Necessary for the use within laravel framework.
- illuminate/support: Allows using within laravel framework.
This package is auto-updated.
Last update: 2024-01-23 05:28:05 UTC
README
通用API客户端,用于gSales计费系统
我们支持API版本2.3(发布于2014年8月20日)。
目录
安装
在composer.json中添加以下行
"require": {
"rokde/gsales-api-client": "~1.0"
}
在原生PHP中使用
$wsdl = 'http://URL-TO-YOUR/api/api.php?wsdl';
$apikey = 'YOUR-API-KEY-HERE';
$client = new \Rokde\Gsales\Api\Client($wsdl, $apikey);
echo $client->customer()->count(); // returns number of customers
就这样。
上下文
您有很多上下文来分组API命令。
文章
所有与文章相关的命令都分组在Article
上下文中。
$client->article()->...;
以下方法可用于文章上下文
get($articleId)
all()
count()
create($article)
update($article)
delete($article)
创建文章
$article = new \Rokde\Gsales\Api\Types\Article\Base();
$article->setTitle('Projectmanagement')
->setRetailPrice(120);
$apiClient->article()->create($article);
认证
所有与认证相关的命令都分组在Authentication
上下文中。
$client->authentication()->...;
以下方法可用于认证上下文
passwordLost($customer)
changePassword($customer, $newPassword)
login($customer, $password)
enableLogin($customer)
enableLoginById($customer)
disableLogin($customer)
disableLoginById($customer)
评论
所有与评论相关的命令都分组在Comment
上下文中。
$client->comment()->...;
以下方法可用于评论上下文
get($commentId)
all($sub, $recordId)
create($comment)
delete($comment)
配置
所有与配置相关的命令都分组在Configuration
上下文中。
$client->configuration()->...;
以下方法可用于配置上下文
get($key)
合同
所有与合同相关的命令都分组在Contract
上下文中。
$client->contract()->...;
以下方法可用于合同上下文
get($contractId)
all()
repayable()
processRepayable()
processRepayableForCustomer($customer)
processRepayableContract($contract)
count()
enable($contract)
disable($contract)
createPosition($contract, $position)
更新位置(updatePosition($contract, $position))
删除位置(deletePosition($contract, $position))
删除(delete($contract))
为客户创建(createForCustomer($customer, $contract))
更新(update($contract, $data))
更新结束日期(updateEndDate($contract, $month, $year))
移除结束日期(removeEndDate($contract))
客户
所有与客户相关的命令都组织在 Customer
上下文中。
$client->customer()->...;
以下方法适用于客户上下文
获取(get($customerId))
all()
count()
repayable()
创建(create($customer))
更新(update($customer))
更新提案(updateProposal($customer))
删除(delete($customer))
获取客户数量
$apiClient->customer()->count();
获取所有客户
$apiClient->customer()->all()
文档
所有与文档相关的命令都组织在 Document
上下文中。
$client->document()->...;
以下方法适用于文档上下文
获取(get($documentId))
all()
文件(file($documentId))
发票
所有与发票相关的命令都组织在 Invoice
上下文中。
$client->invoice()->...;
以下方法适用于发票上下文
获取(get($invoiceId))
all()
count()
已支付(paid($invoice))
打开(open($invoice))
已取消(canceled($invoice))
为发票创建位置(createPosition($invoice, $position))
更新发票位置(updatePosition($invoice, $position))
删除发票位置(deletePosition($invoice, $position))
删除发票(delete($invoice))
为客户创建发票(createForCustomer($customer))
创建发票(create($invoice))
更新发票(update($invoice))
加入邮件池(addToMailspool($invoice))
PDF(pdf($invoice))
邮件池
所有与邮件池相关的命令都组织在 Mailspool
上下文中。
$client->mailspool()->...;
以下方法适用于邮件池上下文
发送(send())
获取(get($mailSpoolId))
all()
count()
复制(duplicate($mailspool))
批准(approve($mailspool))
移除批准(removeApproval($mailspool))
创建(create($mailspool))
更新(update($mailspool))
删除(delete($mailspool))
按收件人读取(readByRecipient($mailspool))
新闻通讯
所有与新闻通讯相关的命令都组织在 Newsletter
上下文中。
$client->newsletter()->...;
以下方法适用于新闻通讯上下文
获取(get($newsletterId))
all()
count()
收件人(recipients($newsletter))
创建(create($newsletter))
更新(update($newsletter))
删除(delete($newsletter))
添加收件人(addRecipient($newsletter, $recipient))
将客户添加为收件人(addCustomerAsRecipient($newsletter, $customer))
移除收件人(removeRecipient($newsletter, $recipient))
排队(spool($newsletter))
报价
所有与报价相关的命令都组织在 Offer
上下文中。
$client->offer()->...;
以下方法适用于报价上下文
获取(get($offerId))
all()
count()
接受(accept($offer))
拒绝(declined($offer))
打开(open($offer))
开账(billed($offer))
为报价创建位置(createPosition($offer, $position))
更新报价位置(updatePosition($offer, $position))
删除报价位置(deletePosition($offer, $position))
删除报价(delete($offer))
为客户创建发票(createForCustomer($customer))
创建报价(create($offer))
更新报价(update($offer))
加入邮件池(addToMailspool($offer))
PDF(pdf($offer))
转换为发票(convertToInvoice($offer, $invoiceApiContext))
转换为发票位置(convertToInvoicePositions($offer, $invoice, $invoiceApiContext))
队列
所有与队列相关的命令都组织在 Queue
上下文中。
$client->queue()->...;
以下方法适用于队列上下文
获取(get($queueId))
all()
count()
创建(create($queueEntry))
更新(update($queueEntry))
删除(delete($queueEntry))
自动(auto($queueEntry))
手动(manual($queueEntry))
无批准(noApproval($queueEntry))
为客户创建发票(createInvoice($customer))
创建发票(createInvoices())
创建队列条目
$queueEntry = new \Rokde\Gsales\Api\Types\Queue\Base();
$queueEntry->setPositionText('Test')
->setCustomerId(37)
->setPrice(1.23)
->setQuantity(1)
->setApproval(0)
->setUnit('x')
->setDiscount(0)
->setTax(0.19);
$apiClient->queue()->create($queueEntry);
退款
所有与退款相关的命令都被分组在 Refund
上下文中。
$client->refund()->...;
以下是在退款上下文中可用的方法:
get($refundId)
all()
count()
paid($refund)
canceled($refund)
open($refund)
createPosition($refund, $position)
updatePosition($refund, $position)
deletePosition($refund, $position)
delete($refund)
为客户创建发票(createForCustomer($customer))
create($refund)
update($refund)
addToMailspool($refund)
pdf($refund)
用户
所有与用户相关的命令都被分组在 User
上下文中。
$client->user()->...;
以下是在用户上下文中可用的方法:
get($userId)
all()
count()
create($user)
update($user)
delete($user)
lock($user)
unlock($user)
availableRoles()
roles($user)
addRole($user, $role)
removeRole($user, $role)
在框架中使用
在Laravel 4中使用
安装包后,您需要将以下行添加到您的app.php中的providers
数组:
'Rokde\Gsales\Api\Supports\Laravel\LaravelGsalesApiClientServiceProvider',
为了配置您的GsalesApiClient,请发布它的配置。
php artisan config:publish rokde/gsales-api-client
然后您可以将您的wsdl
和apikey
设置到已发布的配置文件中。
laravel的服务提供者会自动为您创建一个门面GsalesApiClient
。所以您可以从一开始就这样使用它
GsalesApiClient::queue()->all(); // get all queue entries
或者不使用门面
$apiClient = App::make('gsales-api-client');
$apiClient->queue()->all();
其他框架
我们目前还没有在其他框架中使用这个包。但请告诉我们当您需要在其他地方使用它时。或者将其分叉并开发您自己的版本。我们很高兴看到您的扩展 ;)