tiloweb/quipu-bundle

关于此包的最新版本(v1.0)没有可用的许可证信息。

将自动化API集成作为Symfony服务

安装: 43

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

v1.0 2017-02-20 20:44 UTC

This package is auto-updated.

Last update: 2024-09-16 01:50:33 UTC


README

此Bundle将Quipu/Zyfro API v1集成到Symfony服务中。

要求

  • cURL
  • Symfony >= 3.1

安装

步骤1:下载Bundle

打开命令行控制台,进入您的项目目录,并执行以下命令以下载此Bundle的最新稳定版本

$ composer require tiloweb/quipu-bundle "dev-master"

此命令要求您全局安装Composer,如Composer文档中的安装章节所述。

步骤2:启用Bundle

然后,通过将其添加到项目中的app/AppKernel.php文件中注册的Bundle列表中,启用该Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Tiloweb\QuipuBundle\QuipuBundle(),
        );

        // ...
    }

    // ...
}

步骤3:配置Symfony

# app/config/config.yml

quipu:
    app: "yourAppID"
    secret: "yourAppSecretToken"

步骤4:享受!

现在,您可以通过Controller中的quipu服务或Symfony中的任何地方访问API。

文档

列出所有联系人

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->listContacts());
}

创建一个联系人

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->createContact(array(
        'name' => 'New Contact', // Required
        'email' => 'fakemail@test.com',
        'contry_code' => 'fr' // Required
    )));
}

获取一个联系人

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->getContact(13423);
}

更新一个联系人

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->updateContact(13423, array(
        'name' => 'New name',
        'email' => 'anotheremail@test.com'
    )));
}

列出所有发票

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->listInvoices());
}

列出联系人的所有发票

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->listInvoices(12345));
}

创建一个发票

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    $contactID = 12345;
    $datetime = new \DateTime();
    
    $invoice = array(
        'kind' => 'income', // Required 
        'issue_date' => $datetime->format('Y-m-d') // Required
    );
    
    $items = array(
        array(
            'concept' => 'Product 1',
            'unitary_amount' => "10",
            'quantity' => 30,
            'vat_percent' => 20,
            'retention_percent' => 0
        ),
        array(
            'concept' => 'Product 2',
            'unitary_amount' => "5",
            'quantity' => 10,
            'vat_percent' => 20,
            'retention_percent' => 0
        )
    );
    
    dump($quipu->createInvoice($contactID, $invoice, $items));
}

获取一个发票

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    dump($quipu->getInvoice(13423);
}

更新一个联系人

<?php
// src/AppBundle/Controller/DefaultController.php

public function quipuAction() {
    $quipu = $this->get("quipu");
    
    $datetime = new DateTime();
    
    dump($quipu->updateInvoice(13423, array(
        'paid_at' => $datetime->format('Y-m-d')
    )));
}