8000 Initial commit · amritms/waveapps-client-php@52caab6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52caab6

Browse files
committed
Initial commit
0 parents  commit 52caab6

File tree

9 files changed

+600
-0
lines changed

9 files changed

+600
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_STORE
2+
.idea
3+
composer.lock
4+
/vendor
5+
.history
6+
.vscode

README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# WaveApps Client PHP
2+
3+
A wrapper to use the [WaveApps][wave-apps]'s graphql api in your laravel SaaS application. This repo can manage webapps account on behalf of third party users.
4+
5+
**Note:** If you are looking to use waveapps on behalf of a single user then use [subbe/waveapp][subbe-waveapp]
6+
7+
The original documentation is available at:
8+
- [Wave - Developer Portal][wave-documentation-url]
9+
- [API Reference][wave-api-schema]
10+
- [API Playground][wave-api-playground]
11+
12+
To use WaveApps, you will need to [register][wave-create-an-app] on the developer portal.
13+
And create new application and fetch client_id, client_secret
14+
15+
## Requirement & Install
16+
Open you composer.json file and add
17+
```
18+
"amritms/waveapps-client-php":"0.1"
19+
```
20+
and go to the location of your composer file in terminal and run
21+
```
22+
composer update
23+
24+
php artisan vendor:publish
25+
```
26+
## Route
27+
```route
28+
Route::post('webapps/token', 'WebappsController@handleToken');
29+
```
30+
31+
Update your .env file to include
32+
```
33+
WAVE_CLIENT_ID=
34+
WAVE_CLIENT_SECRET=
35+
WAVE_GRAPHQL_AUTH_URI=https://api.waveapps.com/oauth2/token/
36+
WAVE_GRAPHQL_URI=https://gql.waveapps.com/graphql/public
37+
```
38+
39+
40+
41+
### Queries
42+
43+
- user
44+
- countries
45+
- country
46+
- customers
47+
- products
48+
- invoices
49+
- businesses
50+
- business
51+
- currencies
52+
- currency
53+
- accountTypes
54+
- accountSubyypes
55+
56+
### Mutations
57+
**Customer**
58+
- customerCreate
59+
- customerPatch
60+
- customerDelete
61+
62+
**Account**
63+
- accountCreate
64+
- accountPatch
65+
- accountArchive
66+
67+
**Product**
68+
- productCreate
69+
- productPatch
70+
- productArchive
71+
72+
**Sales**
73+
- salesTaxCreate
74+
- salesTaxPatch
75+
- salesTaxRateCreate
76+
- salesTaxArchive
77+
78+
**Money Transaction**
79+
- moneyTransactionCreate
80+
81+
**Invoice**
82+
- invoiceCreate
83+
- invoiceDelete
84+
- invoiceSend
85+
- invoiceApprove
86+
- invoiceMarkSent
87+
88+
### How to use
89+
90+
#### Query
91+
```
92+
$waveapp = new \Amritms\WaveappsClientPhp\Waveapps();
93+
$countries = $waveapp->countries();
94+
95+
--- OR ---
96+
97+
$country = $waveapp->country(['code' => 'US']);
98+
```
99+
100+
#### Mutation
101+
```
102+
$waveapp = new \Amritms\WaveappsClientPhp\Waveapps();
103+
$customer = [
104+
"input" => [
105+
"businessId" => "<REPLACE-THIS-WITH-THE-BUSINESS-ID>",
106+
"name" => "Lucifer Morningstar",
107+
"firstName" => "Lucifer",
108+
"lastName" => "Morningstar",
109+
"displayId" => "Lucifer",
110+
"email" => "lucifer.morningstar@hell.com",
111+
"mobile" => "6666666",
112+
"phone" => "6666666",
113+
"fax" => "",
114+
"address" => [
115+
"addressLine1" => "666 Diablo Street",
116+
"addressLine2" => "Hell's Kitchen",
117+
"city" => "New York",
118+
"postalCode" => "10018",
119+
"countryCode" => "US"
120+
],
121+
"tollFree" => "",
122+
"website" => "",
123+
"internalNotes" => "",
124+
"currency" => "USD",
125+
"shippingDetails" => [
126+
"name" => "Lucifer",
127+
"phone" => "6666666",
128+
"instructions" => "pray",
129+
"address" => [
130+
"addressLine1" => "666 Diablo Street",
131+
"addressLine2" => "Hell's Kitchen",
132+
"city" => "New York",
133+
"postalCode" => "10018",
134+
"countryCode" => "US"
135+
]
136+
]
137+
]
138+
];
139+
140+
$newCustomer = $waveapp->customerCreate($customer, "CustomerCreateInput");
141+
```
142+
143+
**Note:** This repo is based on [subbe/waveapp][subbe-waveapp]
144+
145+
[wave-apps]: https://www.waveapps.com/
146+
[wave-documentation-url]: https://developer.waveapps.com/hc/en-us/categories/360001114072
147+
[wave-api-schema]: https://developer.waveapps.com/hc/en-us/articles/360019968212-API-Reference
148+
[wave-api-playground]: https://developer.waveapps.com/hc/en-us/articles/360018937431-API-Playground
149+
[wave-create-an-app]: https://developer.waveapps.com/hc/en-us/sections/360003012132-Create-an-App
150+
[subbe-waveapp]:https://github.com/subbe/waveapp

composer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "amritms/waveapps-client-php",
3+
"description": "Laravel integration for Saas application to consume Wave's API which is built using GraphQL",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Amrit Man Shrestha",
9+
"email": "amritms@gmail.com"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"autoload": {
14+
"psr-4": {
15+
"Amritms\\WaveappsClientPhp\\": "src/"
16+
}
17+
},
18+
"require": {
19+
"guzzlehttp/guzzle": "~6.0"
20+
},
21+
"require-dev": {
22+
"phpunit/phpunit": "^9.1"
23+
},
24+
"extra": {
25+
"laravel": {
26+
"providers": [
27+
"Amritms\\WaveappsClientPhp\\WaveappsServiceProvider"
28+
],
29+
"aliases": {
30+
"Waveapps": "Amritms\\WaveappsClientPhp\\Waveapps"
31+
}
32+
}
33+
}
34+
}

config/config.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
return [
4+
'client_id' => env('WAVE_CLIENT_ID'),
5+
6+
'client_secret' => env('WAVE_CLIENT_SECRET'),
7+
8+
'graphql_auth_uri' => env('WAVE_GRAPHQL_AUTH_URI', 'https://api.waveapps.com/oauth2/token/'),
9+
10+
'graphql_uri' => env('WAVE_GRAPHQL_URI', 'https://gql.waveapps.com/graphql/public'),
11+
12+
'business_id' => env('WAVE_BUSINESS_ID', null),
13+
14+
'access_token' => null,
15+
16+
'refresh_token' => null
17+
18+
];

src/GraphQL/Mutation.php

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
3+
4+
namespace Amritms\WaveappsClientPhp\GraphQL;
5+
6+
7+
class Mutation
8+
{
9+
public static function customerCreate()
10+
{
11+
return <<<GQL
12+
mutation CustomerCreateInput(\$input: CustomerCreateInput!) { customerCreate(input: \$input) { customer { id name firstName lastName displayId email mobile phone fax website address { addressLine1 addressLine2 city country { code name } postalCode } createdAt modifiedAt } didSucceed inputErrors { path message code } } }
13+
GQL;
14+
}
15+
16+
public static function customerPatch()
17+
{
18+
return <<<GQL
19+
mutation CustomerPatchInput(\$input: CustomerPatchInput!) { customerPatch(input: \$input) { customer { id name firstName lastName address { addressLine1 addressLine2 city country { code } postalCode } displayId email mobile phone fax tollFree website internalNotes currency { code } shippingDetails { name address { addressLine1 addressLine2 city country { code } postalCode } phone instructions } } didSucceed inputErrors { message path code } } }
20+
GQL;
21+
}
22+
23+
public static function customerDelete()
24+
{
25+
return <<<GQL
26+
mutation CustomerDeleteInput(\$input: CustomerDeleteInput!) { customerDelete(input: \$input) { didSucceed inputErrors { message path code } } }
27+
GQL;
28+
}
29+
30+
public static function accountCreate()
31+
{
32+
return <<<GQL
33+
mutation AccountCreateInput(\$input: AccountCreateInput!) { accountCreate(input: \$input) { account { id name description displayId currency { code } type { name normalBalanceType value } subtype { name value type { name normalBalanceType value } } normalBalanceType isArchived sequence } didSucceed inputErrors { path message code } } }
34+
GQL;
35+
}
36+
37+
public static function accountPatch()
38+
{
39+
return <<<GQL
40+
mutation AccountPatchInput(\$input: AccountPatchInput!) { accountPatch(input: \$input) { account { id name description displayId currency { code } type { name normalBalanceType value } subtype { name value type { name normalBalanceType value } } normalBalanceType isArchived sequence } didSucceed inputErrors { path message code } } }
41+
GQL;
42+
}
43+
44+
public static function accountArchive()
45+
{
46+
return <<<GQL
47+
mutation AccountArchiveInput(\$input: AccountArchiveInput!) { accountArchive(input: \$input) { didSucceed inputErrors { path message code } } }
48+
GQL;
49+
}
50+
51+
public static function productCreate()
52+
{
53+
return <<<GQL
54+
mutation ProductCreateInput(\$input: ProductCreateInput!) { productCreate(input: \$input) { product { id name description unitPrice isSold isBought isArchived createdAt modifiedAt } } }
55+
GQL;
56+
}
57+
58+
public static function productPatch()
59+
{
60+
return <<<GQL
61+
mutation ProductPatchInput(\$input: ProductPatchInput!) { productPatch(input: \$input) { product { id name description unitPrice isSold isBought isArchived createdAt modifiedAt } didSucceed inputErrors { message path code } } }
62+
GQL;
63+
}
64+
65+
public static function productArchive()
66+
{
67+
return <<<GQL
68+
mutation ProductArchiveInput(\$input: ProductArchiveInput!) { productArchive(input: \$input) { product { id name description unitPrice isSold isBought isArchived createdAt modifiedAt } didSucceed inputErrors { path message code } } }
69+
GQL;
70+
}
71+
72+
public static function salesTaxCreate()
73+
{
74+
return <<<GQL
75+
mutation SalesTaxCreateInput(\$input: SalesTaxCreateInput!) { salesTaxCreate(input: \$input) { salesTax { id name abbreviation description taxNumber showTaxNumberOnInvoices rate rates { effective rate } isCompound isRecoverable isArchived createdAt modifiedAt } didSucceed inputErrors { path message code } } }
76+
GQL;
77+
}
78+
79+
public static function salesTaxPatch()
80+
{
81+
return <<<GQL
82+
mutation SalesTaxPatchInput(\$input: SalesTaxPatchInput!) { salesTaxPatch(input: \$input) { salesTax { id name abbreviation description taxNumber showTaxNumberOnInvoices rate rates { effective rate } isCompound isRecoverable isArchived createdAt modifiedAt } didSucceed inputErrors { path message code } } }
83+
GQL;
84+
}
85+
86+
public static function salesTaxArchive()
87+
{
88+
return <<<GQL
89+
mutation SalesTaxArchiveInput(\$input: SalesTaxArchiveInput!) { salesTaxArchive(input: \$input) { salesTax { id name abbreviation description taxNumber showTaxNumberOnInvoices rate rates { effective rate } isCompound isRecoverable isArchived createdAt modifiedAt } didSucceed inputErrors { path message code } } }
90+
GQL;
91+
}
92+
93+
public static function salesTaxRateCreate()
94+
{
95+
return <<<GQL
96+
mutation SalesTaxRateCreateInput(\$input: SalesTaxRateCreateInput!) { salesTaxRateCreate(input: \$input) { didSucceed inputErrors { path message code } } }
97+
GQL;
98+
}
99+
100+
public static function moneyTransactionCreate()
101+
{
102+
return <<<GQL
103+
mutation MoneyTransactionCreateInput(\$input: MoneyTransactionCreateInput!) { moneyTransactionCreate(input: \$input) { transaction { id } didSucceed inputErrors { path message code } } }
104+
GQL;
105+
106+
}
107+
108+
public static function invoiceCreate()
109+
{
110+
return <<<GQL
111+
mutation InvoiceCreateInput(\$input: InvoiceCreateInput!) { invoiceCreate(input: \$input) { didSucceed inputErrors { path message code } invoice { id createdAt modifiedAt pdfUrl viewUrl status title invoiceNumber invoiceDate }} }
112+
GQL;
113+
}
114+
115+
public static function invoiceDelete()
116+
{
117+
return <<<GQL
118+
mutation InvoiceDeleteInput(\$input: InvoiceDeleteInput!) { invoiceDelete(input: \$input) { didSucceed inputErrors { path message code } } }
119+
GQL;
120+
}
121+
122+
public static function invoiceSend()
123+
{
124+
return <<<GQL
125+
mutation InvoiceSendInput(\$input: InvoiceSendInput!) { invoiceSend(input: \$input) { didSucceed inputErrors { path message code } } }
126+
GQL;
127+
}
128+
129+
public static function invoiceApprove()
130+
{
131+
return <<<GQL
132+
mutation InvoiceApproveInput(\$input: InvoiceApproveInput!) { invoiceApprove(input: \$input) { didSucceed inputErrors { path message code } invoice { id createdAt modifiedAt source { __typename } pdfUrl viewUrl status title invoiceNumber invoiceDate } } }
133+
GQL;
134+
}
135+
136+
public static function invoiceMarkSent()
137+
{
138+
return <<<GQL
139+
mutation InvoiceMarkSentInput(\$input: InvoiceMarkSentInput!) { invoiceMarkSent(input: \$input) { invoice { id createdAt modifiedAt source { __typename } pdfUrl viewUrl status title subhead invoiceNumber poNumber invoiceDate dueDate amountDue { raw value currency { code symbol name plural exponent } } amountPaid { raw value currency { code symbol name plural exponent } } taxTotal { raw value currency { code symbol name plural exponent } } total { raw value currency { code symbol name plural exponent } } items { description quantity price subtotal { raw value currency { code symbol name plural exponent } } total { raw value currency { code symbol name plural exponent } } taxes { amount { raw value currency { code symbol name plural exponent } } rate salesTax { business { id name } id name abbreviation description taxNumber showTaxNumberOnInvoices rate rates { effective rate } isCompound isRecoverable isArchived createdAt modifiedAt } } normalBalanceType isArchived sequence } product { business { id name } incomeAccount { business { id name } id name description displayId currency { code symbol name plural exponent } type { name normalBalanceType value } subtype { name value type { name normalBalanceType value } } normalBalanceType isArchived sequence } expenseAccount { business { id name } id name description displayId currency { code symbol name plural exponent } type { name normalBalanceType value } subtype { name value type { name normalBalanceType value } } normalBalanceType isArchived sequence } id name description unitPrice isSold isBought isArchived createdAt modifiedAt } } memo footer disableCreditCardPayments disableBankPayments disableAmexPayments itemTitle unitTitle priceTitle amountTitle hideName hideDescription hideUnit hidePrice hideAmount lastSentAt lastSentVia lastViewedAt customer { business { id name } id name address { addressLine1 addressLine2 city country { code name currency { code symbol name plural exponent } nameWithArticle } postalCode } firstName lastName displayId email mobile phone fax tollFree website internalNotes currency { code symbol name plural exponent } shippingDetails { name address { addressLine1 addressLine2 city country { code name currency { code symbol name plural exponent } nameWithArticle } postalCode } phone instructions } createdAt modifiedAt } } didSucceed inputErrors { path message code } } }
140+
GQL;
141+
}
142+
}

0 commit comments

Comments
 (0)
0