opwoco/gsales-api-client

用于消费Sales API的SOAP客户端

1.0.4 2015-07-07 13:43 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:09:33 UTC


README

Latest Stable Version Latest Unstable Version License Total Downloads

gSales计费系统的通用API客户端

我们支持API版本2.3(发布于2014年8月20日)。

API文档

目录

  1. 安装
  2. 上下文
  3. 文章
  4. 身份验证
  5. 评论
  6. 配置
  7. 合同
  8. 客户
  9. 文件
  10. 发票
  11. 邮件池
  12. 通讯
  13. 报价
  14. 队列
  15. 退款
  16. 用户
  17. 在框架中使用
  18. 在Laravel 4中使用
  19. 其他框架

安装

在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($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($offer)
  • convertToInvoice($offer, $invoiceApiContext)
  • convertToInvoicePositions($offer, $invoice, $invoiceApiContext)

队列

所有与队列相关的命令都分组在 Queue 上下文中。

$client->queue()->...;

队列上下文中可用的方法如下

  • get($queueId)
  • all()
  • count()
  • create($queueEntry)
  • update($queueEntry)
  • delete($queueEntry)
  • auto($queueEntry)
  • 手动($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

然后,您可以将您的 wsdlapikey 设置为已发布的配置文件。

服务提供者为 laravel 自动为您创建了一个门面 GsalesApiClient。因此,您可以从一开始就使用它,如下所示

GsalesApiClient::queue()->all(); // get all queue entries

或无门面

$apiClient = App::make('gsales-api-client');
$apiClient->queue()->all();

其他框架

我们尚未使用此包的任何其他框架。但请告诉我们您何时需要它。或者将其分叉并开发自己的。我们感谢您的扩展;)