@@ -31,59 +31,29 @@ def initialize(params)
3131
3232 def set_manifest ( params )
3333
34- int_api_version = extract_integer_api_version ( params [ :api_base_url ] )
34+ api_version = extract_api_version ( params [ :api_base_url ] )
3535
3636 # Provide access to version specific API endpoints
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
40- @services = OSTSdk ::Saas ::V1Dot1 ::Services . new ( params )
41- elsif int_api_version >= v1_int_api_version
42- @services = OSTSdk ::Saas ::V1 ::Services . new ( params )
43- else
37+ if api_version == ''
4438 # puts("You are using an deprecated version of OST API. Please update to the latest version.")
4539 @services = OSTSdk ::Saas ::V0 ::Services . new ( params )
40+ elsif api_version == 'v1'
41+ @services = OSTSdk ::Saas ::V1 ::Services . new ( params )
42+ elsif api_version == 'v1.1'
43+ @services = OSTSdk ::Saas ::V1Dot1 ::Services . new ( params )
44+ else
45+ fail 'Api endpoint is invalid'
4646 end
4747
4848 end
4949
50- def extract_integer_api_version ( api_base_url )
50+ def extract_api_version ( api_base_url )
5151
5252 api_version = ( ( api_base_url || '' ) . split ( "/" ) [ 3 ] || '' ) . downcase
53- return v0_int_api_version if api_version == ''
54-
55- regex_match_rsp = /^v(\d {1,3})\. ?(\d {0,3})\. ?(\* |\d {0,3})$/ . match ( api_version )
56- fail "invalid version string #{ api_version } " if regex_match_rsp . nil?
57-
58- int_api_version = 0
59-
60- # add API major version
61- int_api_version += regex_match_rsp [ 1 ] . to_i * 1000000
62-
63- # add API minor version
64- int_api_version += ( regex_match_rsp [ 2 ] == '' ? 0 : regex_match_rsp [ 2 ] . to_i * 1000 )
53+ api_major_version = ( api_version . split ( '.' ) [ 0 ] || '' )
6554
66- # add API Patch Version
67- int_api_version += ( regex_match_rsp [ 3 ] == '' ? 0 : regex_match_rsp [ 3 ] . to_i )
68-
69- return int_api_version
70-
71- end
72-
73- def v0_int_api_version
74- 0
75- end
76-
77- def v1_int_api_version
78- 1000000
79- end
80-
81- def v1dot1_int_api_version
82- 1001000
83- end
55+ return api_major_version
8456
85- def v1dot2_int_api_version
86- 1002000
8757 end
8858
8959 end
0 commit comments