lib/arux_app/api/config.rb in arux_app-1.0.0 vs lib/arux_app/api/config.rb in arux_app-3.0.0

- old
+ new

@@ -1,32 +1,38 @@ module AruxApp module API class Config - def self.server_uri - if AruxApp::API.standardmode? - "https://config.arux.app" - elsif AruxApp::API.testmode? - "https://config.arux.blue" - elsif AruxApp::API.devmode? - "http://config.#{HOSTNAME}" - end - end - attr_accessor :auth def initialize(options = {}) self.auth = options[:auth] raise API::InitializerError.new(:auth, "can't be blank") if self.auth.nil? raise API::InitializerError.new(:auth, "must be of class type AruxApp::API::Auth") if !self.auth.is_a?(AruxApp::API::Auth) end + def self.public_uri + AruxApp::API.uri(subdomain: "config") + end + + def public_uri + self.class.public_uri + end + + def self.api_uri + AruxApp::API.uri(subdomain: "config.api") + end + + def api_uri + self.class.api_uri + end + def get(subdomain_or_sn) - subdomain_or_sn = URI.escape(subdomain_or_sn.to_s) + subdomain_or_sn = AruxApp::API.uri_escape(subdomain_or_sn.to_s) request = HTTPI::Request.new - request.url = "#{self.class.server_uri}/v1/customers/#{subdomain_or_sn}" + request.url = "#{api_uri}/v1/customers/#{subdomain_or_sn}" request.headers = self.generate_headers response = HTTPI.get(request) if !response.error? @@ -35,14 +41,14 @@ raise(API::Error.new(response.code, response.body)) end end def get_by(key, value) - key = URI.escape(key.to_s) - value = URI.escape(value.to_s) + key = AruxApp::API.uri_escape(key.to_s) + value = AruxApp::API.uri_escape(value.to_s) request = HTTPI::Request.new - request.url = "#{self.class.server_uri}/v1/customers/by/#{key}/#{value}" + request.url = "#{api_uri}/v1/customers/by/#{key}/#{value}" request.headers = self.generate_headers response = HTTPI.get(request) if !response.error?