1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AdrianMejias\FactomApi; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
|
7
|
|
|
class FactomApiServiceProvider extends ServiceProvider |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Bootstrap the application services. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function boot() |
15
|
|
|
{ |
16
|
|
|
// merge our configuration |
17
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/factom-api.php', 'factom-api'); |
18
|
|
|
|
19
|
|
|
// publish our configuration |
20
|
|
|
$this->publishes([ |
21
|
|
|
__DIR__.'/../config/factom-api.php' => config_path('factom-api.php'), |
22
|
|
|
], 'config'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Register the application services. |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
public function register() |
31
|
|
|
{ |
32
|
|
|
// register our singletons |
33
|
|
|
|
34
|
|
|
// Factom Api |
35
|
|
|
$this->app->singleton(FactomApi::class, function () { |
36
|
|
|
$url = config('factom-api.url'); |
37
|
|
|
$ssl = config('factom-api.ssl.enable'); |
38
|
|
|
$certificate = config('factom-api.ssl.certificate'); |
39
|
|
|
$username = config('factom-api.username'); |
40
|
|
|
$password = config('factom-api.password'); |
41
|
|
|
|
42
|
|
|
return new FactomApi($url, $ssl, $certificate, $username, $password); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
// Factom Wallet Api |
46
|
|
|
$this->app->singleton(FactomWalletApi::class, function () { |
47
|
|
|
$url = config('factom-api.wallet.url'); |
48
|
|
|
$ssl = config('factom-api.wallet.ssl.enable'); |
49
|
|
|
$certificate = config('factom-api.wallet.ssl.certificate'); |
50
|
|
|
$username = config('factom-api.wallet.username'); |
51
|
|
|
$password = config('factom-api.wallet.password'); |
52
|
|
|
|
53
|
|
|
return new FactomWalletApi($url, $ssl, $certificate, $username, $password); |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
// Factom Debug Api |
57
|
|
|
$this->app->singleton(FactomDebugApi::class, function () { |
58
|
|
|
$url = config('factom-api.debug.url'); |
59
|
|
|
$ssl = config('factom-api.debug.ssl.enable'); |
60
|
|
|
$certificate = config('factom-api.debug.ssl.certificate'); |
61
|
|
|
$username = config('factom-api.debug.username'); |
62
|
|
|
$password = config('factom-api.debug.password'); |
63
|
|
|
|
64
|
|
|
return new FactomDebugApi($url, $ssl, $certificate, $username, $password); |
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
// register our alias |
68
|
|
|
$this->app->alias(FactomApi::class, 'FactomApi'); |
69
|
|
|
$this->app->alias(FactomWalletApi::class, 'FactomWalletApi'); |
70
|
|
|
$this->app->alias(FactomDebugApi::class, 'FactomDebugApi'); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|