forked from sumer5020/laravel-zoho-books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZohoBooksServiceProvider.php
127 lines (117 loc) · 6.78 KB
/
ZohoBooksServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
namespace Sumer5020\ZohoBooks;
use Illuminate\Support\ServiceProvider;
use Sumer5020\ZohoBooks\Console\Commands\ZohoBooksInit;
class ZohoBooksServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(): void
{
$this->publishConfig();
$this->publishMigrations();
$this->registerCommands();
}
/**
* Register the application services.
*
* @return void
*/
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/zohoBooks.php', 'zohoBooks');
$this->registerIsp();
$this->registerZohoBooks();
}
/**
* Bind interfaces to their implementations
*
* @return void
*/
private function registerIsp(): void
{
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\AuthenticationInterface::class, \Sumer5020\ZohoBooks\Services\AuthenticationService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ContactInterface::class, \Sumer5020\ZohoBooks\Services\ContactService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\BankAccountInterface::class, \Sumer5020\ZohoBooks\Services\BankAccountService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\BankRuleInterface::class, \Sumer5020\ZohoBooks\Services\BankRuleService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\BankTransactionInterface::class, \Sumer5020\ZohoBooks\Services\BankTransactionService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\BaseCurrencyAdjustmentInterface::class, \Sumer5020\ZohoBooks\Services\BaseCurrencyAdjustmentService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\BillInterface::class, \Sumer5020\ZohoBooks\Services\BillService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ChartOfAccountInterface::class, \Sumer5020\ZohoBooks\Services\ChartOfAccountService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ContactPersonInterface::class, \Sumer5020\ZohoBooks\Services\ContactPersonService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\CreditNoteInterface::class, \Sumer5020\ZohoBooks\Services\CreditNoteService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\CurrencyInterface::class, \Sumer5020\ZohoBooks\Services\CurrencyService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\CustomerPaymentInterface::class, \Sumer5020\ZohoBooks\Services\CustomerPaymentService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\CustomModuleInterface::class, \Sumer5020\ZohoBooks\Services\CustomModuleService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\EstimateInterface::class, \Sumer5020\ZohoBooks\Services\EstimateService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ExpenseInterface::class, \Sumer5020\ZohoBooks\Services\ExpenseService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\InvoiceInterface::class, \Sumer5020\ZohoBooks\Services\InvoiceService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ItemInterface::class, \Sumer5020\ZohoBooks\Services\ItemService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\JournalInterface::class, \Sumer5020\ZohoBooks\Services\JournalService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\OpeningBalanceInterface::class, \Sumer5020\ZohoBooks\Services\OpeningBalanceService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ProjectInterface::class, \Sumer5020\ZohoBooks\Services\ProjectService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\PurchaseOrderInterface::class, \Sumer5020\ZohoBooks\Services\PurchaseOrderService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\RecurringBillInterface::class, \Sumer5020\ZohoBooks\Services\RecurringBillService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\RecurringExpenseInterface::class, \Sumer5020\ZohoBooks\Services\RecurringExpenseService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\RecurringInvoiceInterface::class, \Sumer5020\ZohoBooks\Services\RecurringInvoiceService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\RetainerInvoiceInterface::class, \Sumer5020\ZohoBooks\Services\RetainerInvoiceService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\SalesOrderInterface::class, \Sumer5020\ZohoBooks\Services\SalesOrderService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\TaskInterface::class, \Sumer5020\ZohoBooks\Services\TaskService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\TaxInterface::class, \Sumer5020\ZohoBooks\Services\TaxService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\TimeEntryInterface::class, \Sumer5020\ZohoBooks\Services\TimeEntryService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\UserInterface::class, \Sumer5020\ZohoBooks\Services\UserService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\VendorCreditInterface::class, \Sumer5020\ZohoBooks\Services\VendorCreditService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\VendorPaymentInterface::class, \Sumer5020\ZohoBooks\Services\VendorPaymentService::class);
$this->app->singleton(\Sumer5020\ZohoBooks\Contracts\ZohoCrmIntegrationInterface::class, \Sumer5020\ZohoBooks\Services\ZohoCrmIntegrationService::class);
}
/**
* Registers zohoBooks.
*
* @return void
*/
private function registerZohoBooks(): void
{
$this->app->singleton('zohoBooks', function ($app) {
return new ZohoBooks($app);
});
}
/**
* Publish package's config file.
*
* @return void
*/
private function publishConfig(): void
{
$this->publishes([
__DIR__ . '/../config' => config_path(),
], 'zohoBooks.config');
}
/**
* Publish package's migrations.
*
* @return void
*/
private function publishMigrations(): void
{
$timestamp = date('Y_m_d_His', time());
$stub = __DIR__ . '/../database/migrations/create_zoho_tokens_tables.php';
$target = $this->app->databasePath() . '/migrations/' . $timestamp . '_create_zoho_tokens_tables.php';
$this->publishes([$stub => $target], 'zohoBooks.migrations');
}
/**
* Register console commands.
*
* @return void
*/
private function registerCommands(): void
{
if ($this->app->runningInConsole()) {
$this->commands([
ZohoBooksInit::class
]);
}
}
}