2017 © Pedro Peláez
 

project zuora-laravel-sdk

Lumen/Laravel service provider for interfacing with Zuora SOAP API

image

spira/zuora-laravel-sdk

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  • Tuesday, February 28, 2017
  • by iquitsugar
  • Repository
  • 7 Watchers
  • 0 Stars
  • 524 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

zuora-laravel-sdk

Lumen/Laravel service provider for interacting with Zuora SOAP API, (*1)

Build Status Coverage Status StyleCI, (*2)

Install and configuration

You can install this package via Composer., (*3)

Direct usage (framework agnostic)

For using Zuora API you should register an account and get credentials for accessing an API. All credentials are passed into API::__construct method in array with structure: ~~~ php [ 'wsdl' => '/path/to/zuora.wsdl', 'username' => 'user@example.com', 'password' => 'very-good-password', 'endpoint' => 'https://apisandbox.zuora.com/apps/services/a/74.0', ], (*4)

You can find sample config file in `storage/config.dist.php`

## Lumen\Laravel Service Provider

1. Register `ZuoraSdkServiceProvider` in your app
2. Create a config file named `zuora.php` in config folder and put there contents of `storage/config.dist.php`
3. Have fun

# Tests

This library is tested using PHPUnit and [Mockery](http://docs.mockery.io/en/latest/index.html).

If you want to run full set of integration tests you should fill your `storage/config.php` file, which is excluded from source tree and copied automatically from `config.dist.php` with Composer's `post-install-cmd`. Otherwise all tests making real api calls will be skipped. *Make sure you provided sandbox credentials!*

# Class Reference

All classes are located under `Spira\ZuoraSdk` namespace is omitted below.

## API

This class:
* Configures and stores `\SoapClient`, you can use `getClient()` and `setClient(\SoapClient $client)` methods for access
* Performs lazy authorization on first request 
* Provides methods for operating with `DataObject` entites
* Provides methods for selecting `DataObject` with ZOQL
* Converts Zuora API Errors to thrown `\Spira\ZuoraSdk\Exception\ApiException`

Current list of implemented methods:
* `create($objects)` - Create object in API. Accepts `DataObject|DataObject[]`
* `update($objects)` - Update object in API. Accepts `DataObject|DataObject[]`
* `delete($type, $ids)` - Delete objects of `$type` with IDs `int|array $ids`
* `query($query, $limit = null)` - Runs a query and returns objects of type was queried.
* `queryMore($limit)` - If resultset for `query()` has few pages use this method to get next pages of previous call.
* `hasMore()` - Check does last `query()` has next page of resultset.

## DataObject

`DataObject` is an object for storing data while operating with API. 

It extends `\Illuminate\Support\Fluent` so all data manipulation is done easilly in array- or object-like syntax.

## QueryBuilder

Zuora API provides [ZOQL](https://knowledgecenter.zuora.com/BC_Developers/SOAP_API/M_Zuora_Object_Query_Language) - simplified query language for querying objects from api.

QueryBuilder allows building such queries in fluent style:
~~~ php
$builder = new QueryBuilder('Products', ['Id', 'Name']);
$builder->where('Age', '=', $age)
    ->orWhere('Id', '=', $id);
echo $builder->toZoql(); // Output: SELECT Id, Name FROM Products WHERE Age = 18 OR Id = 1

Mostly it used for making queries in Zuora class described below., (*5)

Zuora

This class provides querying helpers and some part of common logic for using API., (*6)

  • getAll($table, array $columns, $limit = null, \Closure $filtered = null) - builds a query and returns an array of objects of type $table
  • getOne($table, array $columns, \Closure $filtered = null) - builds a query and returns one object of type $table
  • getOneById($table, $columns, $id) - pretty the same as getOne but with built-in filter by id.

Instance of QueryBuilder is passed into $filtered lambda for adding conditions to query if needed. While ZOQL does not support wildcards for columns you should provide list of them manually., (*7)

For some types of objects there are added custom methods:, (*8)

Products, (*9)

  • getAllProducts(array $columns = null, $limit = null, \Closure $filtered = null)
  • getOneProduct($id, array $columns = null)
  • getAllProductRatePlans(array $columns = null, $limit = null, \Closure $filtered = null)
  • getRatePlansForProduct($product, array $columns = null, $limit = null)
  • getOneProductRatePlan($id, array $columns = null)
  • getOneProductRatePlanActiveCurrencies($ratePlan)
  • getAllProductRatePlanCharges(array $columns = null, $limit = null, \Closure $filtered = null)
  • getChargesForProductRatePlan($ratePlan, array $columns = null, $limit = null)
  • getOneProductRatePlanCharge($id, array $columns = null)
  • getAllProductRatePlanChargeTiers(array $columns = null, $limit = null, \Closure $filtered = null)
  • getTiersForProductRatePlanCharge($ratePlanCharge, array $columns = null, $limit = null)
  • getOneProductRatePlanChargeTier($id, array $columns = null)

Accounts, (*10)

  • getAllAccounts(array $columns = null, $limit = null, \Closure $filtered = null)
  • getOneAccount($id, array $columns = null)
  • getContactsForAccount($account, array $columns = null, $limit = null)
  • getOneContact($id, array $columns = null)
  • getPaymentMethodsForAccount($account, array $columns = null, $limit = null)
  • getOnePaymentMethod($id, array $columns = null)
  • getAllPaymentMethods(array $columns = null, $limit = null, \Closure $filtered = null)
  • createAccount(Account $account, Contact $contact, PaymentMethod $paymentMethod = null)

Subscriptions, (*11)

  • getAllSubscriptions(array $columns = null, $limit = null, \Closure $filtered = null)
  • getOneSubscription($id, array $columns = null)
  • getSubscriptionsForAccount($account, array $columns = null, $limit = null)
  • subscribe(Account $account, Subscription $subscription, ProductRatePlan $ratePlan, ProductRatePlanCharge $ratePlanCharge = null, PaymentMethod $paymentMethod = null, Contact $contact = null, SubscribeOptions $subscribeOptions = null)

Payments & Invoices, (*12)

  • getAllPayments(array $columns = null, $limit = null, \Closure $filtered = null)
  • getOnePayment($id, array $columns = null)
  • getPaymentsForAccount($account, array $columns = null, $limit = null)
  • getAllInvoices(array $columns = null, $limit = null, \Closure $filtered = null)
  • getOneInvoice($id, array $columns = null)
  • getInvoicesForAccount($account, array $columns = null, $limit = null)

Usage Example

~~~ php use Monolog\Logger; use Spira\ZuoraSdk\API; use Spira\ZuoraSdk\Zuora; use Monolog\Handler\StreamHandler; use Spira\ZuoraSdk\DataObjects\Product;, (*13)

$config = require '/path/to/config.php'; $logger = new Logger('zuora', [new StreamHandler('path/to/zuora.log')]); // optional logger usage $api = new API($config, $logger); $zuora = new Zuora($api);, (*14)

// Create a new product, (*15)

$product = new Product(['Name' => 'My Product']); $api->create($product);, (*16)

// Get list of a products, (*17)

/** @var $products Product[] */ $products = $zuora->getAllProducts();, (*18)

// Delete product, (*19)

$api->delete('Product', [$product->Id]); ~~~, (*20)

You can find more samples in tests., (*21)

Contribution

All commits MUST follow PSR-2 coding style guide., (*22)

You may use the PHP-CS-Fixer manually or use git pre-commit hook supplied in hooks/pre-commit. Follow instructions in file and make sure it is executable., (*23)

The Versions

28/02 2017

dev-master

9999999-dev

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

28/02 2017

0.16

0.16.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

23/02 2017

dev-feature/additional-preview-options-for-termed

dev-feature/additional-preview-options-for-termed

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

19/12 2016

0.15

0.15.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

19/12 2016

dev-feature/create-payment

dev-feature/create-payment

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

24/11 2016

0.14

0.14.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

23/11 2016

0.13

0.13.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

08/11 2016

0.12

0.12.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

27/09 2016

0.11

0.11.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

27/09 2016

0.10

0.10.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

26/09 2016

0.9

0.9.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

03/06 2016

dev-0.8-disable-verify-peer

dev-0.8-disable-verify-peer

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

03/06 2016

0.8

0.8.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

03/06 2016

dev-feature/promo-code

dev-feature/promo-code

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

11/03 2016

dev-0.7-disable-verify-peer

dev-0.7-disable-verify-peer

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

03/03 2016

0.7

0.7.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

29/02 2016

0.6

0.6.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

07/02 2016

0.5.1

0.5.1.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

07/02 2016

0.5

0.5.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

04/02 2016

0.4

0.4.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

03/02 2016

0.3

0.3.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

28/01 2016

0.2

0.2.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora

27/01 2016

0.1

0.1.0.0

Lumen/Laravel service provider for interfacing with Zuora SOAP API

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel lumen sdk soap zuora