Module: AruxApp::API

Defined in:
lib/arux_app/api.rb,
lib/arux_app/api/auth.rb,
lib/arux_app/api/cart.rb,
lib/arux_app/api/config.rb,
lib/arux_app/api/account.rb,
lib/arux_app/api/checkout.rb,
lib/arux_app/api/bank_info.rb

Defined Under Namespace

Classes: Account, Auth, BankInfo, Cart, Checkout, Config, Error, InitializerError, RequirementError

Constant Summary collapse

DOMAINS =
{
  production: "arux.app",
  staging: "arux.blue",
  development: HOSTNAME,
  test: "arux.test"
}

Class Method Summary collapse

Class Method Details

.domainObject



22
23
24
25
# File 'lib/arux_app/api.rb', line 22

def domain
  raise "#{mode} is not a supported environment" unless DOMAINS.has_key?(mode)
  DOMAINS[mode]
end

.modeObject



11
12
13
14
# File 'lib/arux_app/api.rb', line 11

def mode
  raise "Environment is not set, i.e. ARUX_APP_GEM_MODE = :development" unless const_defined?(:ARUX_APP_GEM_MODE)
  ARUX_APP_GEM_MODE
end

.uri(subdomain:) ⇒ Object



16
17
18
19
20
# File 'lib/arux_app/api.rb', line 16

def uri(subdomain:)
  URI::HTTPS.build(
    host: [subdomain, domain].join('.'),
  )
end

.uri_escape(str) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/arux_app/api.rb', line 27

def uri_escape(str)
  # URI.escape was deprecated and removed in ruby
  # https://bugs.ruby-lang.org/issues/17309
  # The alternatives suggested were using URI::DEFAULT_PARSER
  # and CGI. This will use URI::DEFAULT_PARSER if it is defined and CGI
  # if not.
  if URI.respond_to?(:escape)
    URI.escape(str)
  elsif defined? URI::DEFAULT_PARSER
    URI::DEFAULT_PARSER.escape(str)
  else
    CGI.escape(str)
  end
end