@@ -52,7 +52,15 @@ public Client(string host, Dictionary<string,string> requestHeaders = null, stri
52
52
53
53
private string BuildUrl ( string query_params = null )
54
54
{
55
- string endpoint = _host + "/" + _version + _urlPath ;
55
+ string endpoint = null ;
56
+ if ( _version != null )
57
+ {
58
+ endpoint = _host + "/" + _version + _urlPath ;
59
+ }
60
+ else
61
+ {
62
+ endpoint = _host + _urlPath ;
63
+ }
56
64
57
65
if ( query_params != null )
58
66
{
@@ -85,6 +93,11 @@ private Client BuildClient(string name = null)
85
93
return new Client ( _host , _requestHeaders , _version , endpoint ) ;
86
94
}
87
95
96
+ private void AddVersion ( string version )
97
+ {
98
+ _version = version ;
99
+ }
100
+
88
101
// Magic method to handle special cases
89
102
public Client _ ( string magic )
90
103
{
@@ -101,6 +114,13 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
101
114
// Catch final method call
102
115
public override bool TryInvokeMember ( InvokeMemberBinder binder , object [ ] args , out object result )
103
116
{
117
+ if ( binder . Name == "version" )
118
+ {
119
+ AddVersion ( args [ 0 ] . ToString ( ) ) ;
120
+ result = BuildClient ( ) ;
121
+ return true ;
122
+ }
123
+
104
124
var paramDict = new Dictionary < string , object > ( ) ;
105
125
string query_params = null ;
106
126
string request_body = null ;
0 commit comments