GithubHelp home page GithubHelp logo

jeffgreco13 / laravel-wave Goto Github PK

View Code? Open in Web Editor NEW

This project forked from subbe/waveapp

0.0 1.0 0.0 94 KB

A wrapper to use the WaveApp's graphql api in your laravel apps.

License: MIT License

PHP 100.00%

laravel-wave's Introduction

Laravel Wave

A wrapper to use the Wave's graphql api in your laravel apps. This package was forked from subbe/waveapp and adds some QOL improvements for Laravel devs.

Wave API documentation can be located at:

Application Setup

To use Laravel Wave, you will need to create an app on the developer portal.

After you have created a new app, click in to edit its settings. Create a new Full Access token and copy this to a save place. You will need this in your .env

OAuth flow is not supported by this package. Consider using the Socialite Wave Provider then pass the Access Token to the Wave class at runtime.

Installation

Require the package using composer:

composer require jeffgreco13/laravel-wave

Update your .env file to include:

WAVE_ACCESS_TOKEN= *your full access token*
WAVE_BUSINESS_ID= *ID for the business you wish to interact with*
WAVE_GRAPHQL_URI= *defaults to https://gql.waveapps.com/graphql/public*

If you do not know the ID for your business, you can use the following tinker command:

php artisan tinker
> (new \Jeffgreco13\Wave\Wave())->businesses()

Usage

Currency

A simple way to download Wave's currencies and cache them for use in your app:

First run the artisan command. This downloads the static currencies to a json file and saves them in your storage path:

php artisan wave:pull-currencies

You may now use the Currency class like so:

use Jeffgreco13\Wave\Currency;

$currencies = Currency::all(); // returns a Collection of Currency objects

$currency = Currency::firstWhere('code','ARS'); // returns a single Currency object if found, or null
echo $currency->name; // output: Argentinian peso

// Currency array attributes
array:5 [
  "code" => "ARS"
  "symbol" => "$"
  "name" => "Argentinian peso"
  "plural" => "Argentinian pesos"
  "exponent" => 2
]

All Queries

  • user
  • countries
  • country
  • businesses
  • business
  • currencies
  • currency
  • accountTypes
  • accountSubtypes
  • customerExists
  • customers
  • products
  • taxes

All Mutations

  • customerCreate

  • customerPatch

  • customerDelete

  • accountCreate

  • accountPatch

  • accountArchive

  • productCreate

  • productPatch

  • productArchive

  • salesTaxCreate

  • salesTaxPatch

  • salesTaxArchive

  • salesTaxRateCreate

  • moneyTransactionCreate

  • invoiceCreate

  • invoiceClone

  • invoiceDelete

  • invoiceSend

  • invoiceApprove

  • invoiceMarkSent

Usage

Query

$wave = new \Jeffgreco13\Wave\Wave();
$businesses = $wave->businesses();

or, with parameters...

$wave = new \Jeffgreco13\Wave\Wave();
$country = $wave->country(['code' => 'US']);

Pagination

Queries like businesses and customers may require pagination. You can easily build your own loop and increment the 'page' input, or you can use this shortcut:

$wave = new Wave();
$response = $wave->customers(['pageSize'=>20]);
do {
    foreach ($wave->getNodes() as $node) {
        echo "Hello, {$node->firstName}!";
    }
} while($response = $wave->paginate());

Mutation

$wave = new \Jeffgreco13\Wave\Wave();
$customer = [
    "input" => [
        "businessId" => null, // Optional. Will use the businessId from your config/env by default
        "name" => "Genevieve Heidenreich",
        "firstName" => "Genevieve",
        "lastName" => "Heidenreich",
        "displayId" => "Genevieve",
        "email" => "[email protected]",
        "mobile" => "011 8795",
        "phone" => "330 8738",
        "fax" => "566 5965",
        "tollFree" => "266 5698",
        "website" => "http://www.hermiston.com/architecto-commodi-possimus-esse-non-necessitatibus",
        "internalNotes" => "",
        "currency" => "USD",
        "address" => [
            "addressLine1" => "167 Iva Run",
            "addressLine2" => "Parker Mews, Monahanstad, 40778-7100",
            "city" => "West Tyrique",
            "postalCode" => "82271",
            "countryCode" => "EC",
       ],
       "shippingDetails" => [
            "name" => "Genevieve",
            "phone" => "011 8795",
            "instructions" => [
                "Delectus deleniti accusamus rerum voluptatem tempora.",
            ],
            "address" => [
                "addressLine1" => "167 Iva Run",
                "addressLine2" => "Parker Mews, Monahanstad, 40778-7100",
                "city" => "West Tyrique",
                "postalCode" => "82271",
                "countryCode" => "EC",
            ],
        ],
    ],
];

$newCustomer = $wave->customerCreate($customer);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

laravel-wave's People

Contributors

subbe avatar murraycollingwood avatar jeffgreco13 avatar mrpangak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.