@@ -69,10 +69,63 @@ Watson Services and so on.
69
69
### Services
70
70
71
71
The Laravel Integration gives you 3 service classes that are bound to the IoC.
72
- - Bridge (The actual Bridge class for making requests to Watson)
73
- - Carpenter (Which can construct Bridge instances using your credentials and service URL)
74
- - BridgeStack (Essentially a store where you can keep all Bridges you constructed and retrieve them back.)
72
+ - FindBrok\WatsonBridge\ Bridge (The actual Bridge class for making requests to Watson)
73
+ - FindBrok\WatsonBridge\Support\ Carpenter (Which can construct Bridge instances using your credentials and service URL)
74
+ - FindBrok\WatsonBridge\Support\ BridgeStack (Essentially a store where you can keep all Bridges you constructed and retrieve them back.)
75
75
76
- ## Bridge
76
+ ### Bridge
77
77
78
- Bridge class will help you make requests to Watson API using the ``` get ``` , ``` post ``` , ``` put ``` , ``` patch ``` methods
78
+ ``` Bridge ``` class will help you make requests to Watson API using the ``` get ``` , ``` post ``` , ``` put ``` , ``` patch ``` methods
79
+
80
+ ``` php
81
+ $response = $bridge->get('uri', $queryParams);
82
+ ```
83
+
84
+ ### Carpenter
85
+
86
+ The ``` Carpenter ``` class can build any type of Bridge for you. Use the ``` constructBridge ``` method passing in the desired parameters like
87
+ credentials name, service to use and auth method and so on and the ``` Carpenter ``` will.
88
+
89
+ ``` php
90
+ $carpenter = app()->make(Carpenter::class);
91
+
92
+ $bridge = $carpenter->constructBridge('default', 'personality_insights');
93
+ ```
94
+
95
+ Remember that your credentials names, services and auth methods are all defined in the ``` watson-bridge.php ``` config file.
96
+
97
+ ### BridgeStack
98
+
99
+ The ``` BridgeStack ``` is a great place to keep all your Bridges so that you can retrieve them anytime in your app.
100
+ Use the ``` mountBridge ``` method to construct and keep any type of Bridge in the Stack.
101
+
102
+ ``` php
103
+ $stack = app()->make(BridgeStack::class);
104
+
105
+ $stack->mountBridge('myPIBridge', 'default', 'personality_insights');
106
+ $stack->mountBridge('myTABridge', 'default', 'tradeoff_analytics');
107
+
108
+ // Now use the Bridges stored in the Stack.
109
+ $response = $stack->conjure('myPIBridge')->post('/v3/profile', $dataToPost);
110
+ ```
111
+ The ``` BridgeStack ``` is essentially a Laravel Collection, thus you have access to all Collection methods.
112
+
113
+ ### Facades
114
+
115
+ If you are using Laravel version less than 5.4 you have access to 3 Facades for the 3 services Bridge, Carpenter and BridgeStack.
116
+ Since Laravel 5.4 added automatic Facades you won't be needing those classes.
117
+
118
+ - FindBrok\WatsonBridge\Facades\Bridge
119
+ - FindBrok\WatsonBridge\Facades\BridgeStack
120
+ - FindBrok\WatsonBridge\Facades\Carpenter
121
+
122
+ Remember that if you are resolving the Bridge directly from the IoC and not constructing it with the Carpenter class a default Bridge will
123
+ be resolved for you using the default credentials and auth methods from your watson-bridge config.
124
+
125
+ ## Credits
126
+
127
+ [ ![ Percy Mamedy] ( https://img.shields.io/badge/Author-Percy%20Mamedy-orange.svg )] ( https://twitter.com/PercyMamedy )
128
+
129
+ Twitter: [ @PercyMamedy ] ( https://twitter.com/PercyMamedy )
130
+ <br />
131
+ GitHub: [ percymamedy] ( https://github.com/percymamedy )
0 commit comments