@@ -36,14 +36,12 @@ public function __construct($app)
36
36
/**
37
37
* Get a airtable table instance.
38
38
*
39
- * @param string $name
39
+ * @param string $table
40
40
* @return \Airtable\Table
41
41
*/
42
- public function table ($ name = null )
42
+ public function table (string $ table )
43
43
{
44
- $ name = $ name ?: $ this ->getDefaultTable ();
45
-
46
- return $ this ->tables [$ name ] = $ this ->get ($ name );
44
+ return $ this ->resolve ($ table );
47
45
}
48
46
49
47
/**
@@ -91,41 +89,6 @@ public function setDefaultTable($name)
91
89
$ this ->app ['config ' ]['airtable.default ' ] = $ name ;
92
90
}
93
91
94
- /**
95
- * Return all of the created connections.
96
- *
97
- * @return array
98
- */
99
- public function getTables ()
100
- {
101
- return $ this ->tables ;
102
- }
103
-
104
- /**
105
- * Set the given table instance.
106
- *
107
- * @param string $name
108
- * @param mixed $table
109
- * @return $this
110
- */
111
- public function set ($ name , $ table )
112
- {
113
- $ this ->tables [$ name ] = $ table ;
114
-
115
- return $ this ;
116
- }
117
-
118
- /**
119
- * Attempt to get the table from the local cache.
120
- *
121
- * @param string $name
122
- * @return \Tapp\Airtable
123
- */
124
- protected function get ($ name )
125
- {
126
- return $ this ->tables [$ name ] ?? $ this ->resolve ($ name );
127
- }
128
-
129
92
/**
130
93
* Resolve the given table.
131
94
*
@@ -139,20 +102,26 @@ protected function resolve($name)
139
102
$ config = $ this ->getConfig ($ name );
140
103
141
104
if ($ config ) {
142
- return $ this ->createAirtable ($ config );
105
+ return $ this ->createAirtable ($ config[ ' name ' ] );
143
106
} else {
144
107
throw new InvalidArgumentException ("Table [ {$ name }] is not configured. " );
145
108
}
146
109
}
147
110
148
- protected function createAirtable ($ config )
111
+ protected function createAirtable ($ table )
149
112
{
150
113
$ base = $ this ->app ['config ' ]['airtable.base ' ];
151
114
$ access_token = $ this ->app ['config ' ]['airtable.key ' ];
152
115
153
- $ client = new AirtableApiClient ($ base , $ config , $ access_token );
116
+ if ($ this ->app ['config ' ]['airtable.log_http ' ]) {
117
+ $ httpLogFormat = $ this ->app ['config ' ]['airtable.log_http_format ' ];
118
+ } else {
119
+ $ httpLogFormat = null ;
120
+ }
121
+
122
+ $ client = new AirtableApiClient ($ base , $ table , $ access_token , $ httpLogFormat );
154
123
155
- return new Airtable ($ client , $ config );
124
+ return new Airtable ($ client , $ table );
156
125
}
157
126
158
127
/**
0 commit comments