@@ -34,15 +34,15 @@ def set_manifest(params)
3434 int_api_version = extract_integer_api_version ( params [ :api_base_url ] )
3535
3636 # Provide access to version specific API endpoints
37- if int_api_version == v0_int_api_version
38- # puts("You are using an deprecated version of OST API. Please update to the latest version.")
39- @services = OSTSdk ::Saas ::V0 ::Services . new ( params )
40- elsif int_api_version == v1_int_api_version
41- @services = OSTSdk ::Saas ::V1 ::Services . new ( params )
42- elsif int_api_version < v2_int_api_version
37+ if int_api_version >= v1dot2_int_api_version
38+ fail 'Unsupported API Version. Please check for new versions of SDK.'
39+ elsif int_api_version >= v1dot1_int_api_version
4340 @services = OSTSdk ::Saas ::V1Dot1 ::Services . new ( params )
41+ elsif int_api_version >= v1_int_api_version
42+ @services = OSTSdk ::Saas ::V1 ::Services . new ( params )
4443 else
45- fail 'Api endpoint is invalid'
44+ # puts("You are using an deprecated version of OST API. Please update to the latest version.")
45+ @services = OSTSdk ::Saas ::V0 ::Services . new ( params )
4646 end
4747
4848 end
@@ -58,15 +58,21 @@ def extract_integer_api_version(api_base_url)
5858 # exclude 'v'
5959 str_api_version = api_version [ 1 ..-1 ]
6060
61- # if str_api_version doesn't start with a integer value fail
62- fail "invalid version string #{ api_version } " if str_api_version . to_i == 0
61+ regex_match_rsp = /^(\d {1,3})\. ?(\d {0,3})\. ?(\* |\d {0,3})$/ . match ( str_api_version )
62+ fail "invalid version string #{ api_version } " if regex_match_rsp . nil?
63+
64+ int_api_version = 0
65+
66+ # add API major version
67+ int_api_version += regex_match_rsp [ 1 ] . to_i * 1000000
6368
64- buffer = str_api_version . split ( '.' )
69+ # add API minor version
70+ int_api_version += ( regex_match_rsp [ 2 ] == '' ? 0 : regex_match_rsp [ 2 ] . to_i * 1000 )
6571
66- # version can not have more than 2 '.' ie 1.1.1.2 is not allowed
67- fail "invalid version string #{ api_version } " if buffer . length > 3
72+ # add API Patch Version
73+ int_api_version += ( regex_match_rsp [ 3 ] == '' ? 0 : regex_match_rsp [ 3 ] . to_i )
6874
69- buffer [ 0 ] . to_i * 100 + ( buffer [ 1 ] || 0 ) . to_i * 10 + ( buffer [ 2 ] || 0 ) . to_i
75+ return int_api_version
7076
7177 end
7278
@@ -75,11 +81,15 @@ def v0_int_api_version
7581 end
7682
7783 def v1_int_api_version
78- 100
84+ 1000000
85+ end
86+
87+ def v1dot1_int_api_version
88+ 1001000
7989 end
8090
81- def v2_int_api_version
82- 200
91+ def v1dot2_int_api_version
92+ 1002000
8393 end
8494
8595 end
0 commit comments