@@ -10,12 +10,12 @@ class Client
1010 attr_reader :region , :host
1111 # Initialize "Contentstack" Client instance
1212 def initialize ( api_key , delivery_token , environment , options = { } )
13- raise Contentstack ::Error . new ( "Api Key is not valid" ) if api_key . class != String
14- raise Contentstack ::Error . new ( "Api Key Field Should not be Empty" ) if api_key . empty?
15- raise Contentstack ::Error . new ( "Delivery Token is not valid" ) if delivery_token . class != String
16- raise Contentstack ::Error . new ( "Delivery Token Field Should not be Empty" ) if delivery_token . empty?
17- raise Contentstack ::Error . new ( "Envirnoment Field is not valid" ) if environment . class != String
18- raise Contentstack ::Error . new ( "Envirnoment Field Should not be Empty" ) if environment . empty?
13+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: API_KEY_INVALID ) if api_key . class != String
14+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: API_KEY_REQUIRED ) if api_key . empty?
15+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: DELIVERY_TOKEN_INVALID ) if delivery_token . class != String
16+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: DELIVERY_TOKEN_REQUIRED ) if delivery_token . empty?
17+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: ENVIRONMENT_INVALID ) if environment . class != String
18+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: ENVIRONMENT_REQUIRED ) if environment . empty?
1919 @region = options [ :region ] . nil? ? Contentstack ::Region ::US : options [ :region ]
2020 # @host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host] #removed for not supporting custom host with regions
2121 @host = get_host_by_region ( @region , options ) # Added new method for custom host support with different regions
@@ -32,8 +32,8 @@ def initialize(api_key, delivery_token, environment, options={})
3232 "retryLimit" => @retryLimit ,
3333 "errorRetry" => @errorRetry
3434 }
35- raise Contentstack ::Error . new ( "Proxy URL Should not be Empty" ) if @proxy_details . present? && @proxy_details [ :url ] . empty?
36- raise Contentstack ::Error . new ( "Proxy Port Should not be Empty" ) if @proxy_details . present? && @proxy_details [ :port ] . empty?
35+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: PROXY_URL_REQUIRED ) if @proxy_details . present? && @proxy_details [ :url ] . empty?
36+ raise Contentstack ::Error . new ( Contentstack :: ErrorMessages :: PROXY_PORT_REQUIRED ) if @proxy_details . present? && @proxy_details [ :port ] . empty?
3737 API . init_api ( api_key , delivery_token , environment , @host , @branch , @live_preview , @proxy_details , retry_options )
3838 end
3939
0 commit comments