Class: Lpt::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/lpt/environment.rb

Constant Summary collapse

PRODUCTION =
90
DEMO =
80
STAGING =
60
SANDBOX =
50
NEXT =
40
IVV =
30
TEST =
20
DEV =
10
ENVIRONMENTS =
{
  "production" => PRODUCTION,
  "demo" => DEMO,
  "staging" => STAGING,
  "sandbox" => SANDBOX,
  "next" => NEXT,
  "ivv" => IVV,
  "test" => TEST,
  "dev" => DEV
}.freeze
BASE_DOMAINS =
{
  PRODUCTION => "lacorepayments.com",
  DEMO => "dmo.lacorepayments.com",
  STAGING => "lacorepayments.com",
  SANDBOX => "sbx.lacorepayments.com",
  NEXT => "nxt.lacorepayments.com",
  IVV => "ivv.lacorepayments.com",
  TEST => "test.lpt.local",
  DEV => "lpt.local"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_base: "", cx_base: "", cx_api_base: "", base_domain: "") ⇒ Environment

Returns a new instance of Environment.



38
39
40
41
42
43
# File 'lib/lpt/environment.rb', line 38

def initialize(api_base: "", cx_base: "", cx_api_base: "", base_domain: "")
  @api_base = api_base
  @cx_base = cx_base
  @cx_api_base = cx_api_base
  @base_domain = base_domain
end

Instance Attribute Details

#api_baseObject

Returns the value of attribute api_base.



36
37
38
# File 'lib/lpt/environment.rb', line 36

def api_base
  @api_base
end

#base_domainObject

Returns the value of attribute base_domain.



36
37
38
# File 'lib/lpt/environment.rb', line 36

def base_domain
  @base_domain
end

#cx_api_baseObject

Returns the value of attribute cx_api_base.



36
37
38
# File 'lib/lpt/environment.rb', line 36

def cx_api_base
  @cx_api_base
end

#cx_baseObject

Returns the value of attribute cx_base.



36
37
38
# File 'lib/lpt/environment.rb', line 36

def cx_base
  @cx_base
end

Class Method Details

.factory(environment: DEV) ⇒ Object



71
72
73
74
75
# File 'lib/lpt/environment.rb', line 71

def factory(environment: DEV)
  args = Lpt.base_addresses(environment: environment)
  args[:base_domain] = BASE_DOMAINS[environment]
  new(**args)
end

.productionObject



67
68
69
# File 'lib/lpt/environment.rb', line 67

def production
  factory(environment: PRODUCTION)
end

.stagingObject



63
64
65
# File 'lib/lpt/environment.rb', line 63

def staging
  factory(environment: STAGING)
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
48
# File 'lib/lpt/environment.rb', line 45

def ==(other)
  api_base == other.api_base && base_domain == other.base_domain &&
    cx_base == other.cx_base && cx_api_base == other.cx_api_base
end

#api_base_url(with_protocol: true) ⇒ Object



50
51
52
# File 'lib/lpt/environment.rb', line 50

def api_base_url(with_protocol: true)
  base_url(api_base, with_protocol: with_protocol)
end

#cx_api_base_urlObject



58
59
60
# File 'lib/lpt/environment.rb', line 58

def cx_api_base_url
  base_url(cx_api_base)
end

#cx_base_urlObject



54
55
56
# File 'lib/lpt/environment.rb', line 54

def cx_base_url
  base_url(cx_base)
end