Module: Workarea::Emarsys
- Defined in:
- lib/workarea/emarsys.rb,
lib/workarea/emarsys/engine.rb,
app/services/emarsys/contact.rb,
lib/workarea/emarsys/version.rb,
app/lib/workarea/emarsys/gateway.rb,
app/models/emarsys/configuration.rb,
app/lib/workarea/emarsys/response.rb,
app/services/emarsys/contact/user.rb,
app/services/emarsys/contact/order.rb,
app/lib/workarea/emarsys/bogus_gateway.rb,
app/workers/workarea/emarsys/save_user.rb,
app/workers/workarea/emarsys/save_order.rb,
app/workers/workarea/emarsys/sync_orders.rb,
app/lib/workarea/emarsys/sales_data_gateway.rb,
app/workers/workarea/emarsys/save_email_signup.rb,
app/lib/workarea/emarsys/sales_data_bogus_gateway.rb
Defined Under Namespace
Classes: BogusGateway, Configuration, Contact, Engine, Gateway, Response, SalesDataBogusGateway, SalesDataGateway, SaveEmailSignup, SaveOrderContact, SaveUser, SyncOrders
Constant Summary
collapse
- VERSION =
"1.0.3"
Class Method Summary
collapse
Class Method Details
.api_token ⇒ Object
25
26
27
|
# File 'lib/workarea/emarsys.rb', line 25
def self.api_token
sales_data_credentials[:api_token]
end
|
.config ⇒ Object
33
34
35
|
# File 'lib/workarea/emarsys.rb', line 33
def self.config
Workarea.config.emarsys
end
|
.credentials ⇒ Object
13
14
15
|
# File 'lib/workarea/emarsys.rb', line 13
def self.credentials
(Rails.application.secrets.emarsys || {}).deep_symbolize_keys
end
|
.customer_id ⇒ Object
29
30
31
|
# File 'lib/workarea/emarsys.rb', line 29
def self.customer_id
credentials[:customer_id]
end
|
Conditionally use the real gateway when secrets are present. Otherwise, use the bogus gateway.
41
42
43
44
45
46
47
48
|
# File 'lib/workarea/emarsys.rb', line 41
def self.gateway
if credentials.present?
settings = Workarea::Emarsys::Configuration.current
Emarsys::Gateway.new(secret_key, settings.customer_id, { test: !settings.production? })
else
Emarsys::BogusGateway.new
end
end
|
.sales_data_credentials ⇒ Object
17
18
19
|
# File 'lib/workarea/emarsys.rb', line 17
def self.sales_data_credentials
(Rails.application.secrets.emarsys_sales || {}).deep_symbolize_keys
end
|
.sales_data_gateway ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/workarea/emarsys.rb', line 50
def self.sales_data_gateway
if credentials.present?
settings = Workarea::Emarsys::Configuration.current
Emarsys::SalesDataGateway.new(api_token, { merchant_id: settings.merchant_id })
else
Emarsys::SalesDataBogusGateway.new
end
end
|
.secret_key ⇒ Object
21
22
23
|
# File 'lib/workarea/emarsys.rb', line 21
def self.secret_key
credentials[:secret_key]
end
|