Class: Kenui::EmailNotificationService
- Inherits:
-
KillBillClient::Model::Resource
- Object
- KillBillClient::Model::Resource
- Kenui::EmailNotificationService
- Defined in:
- app/services/kenui/email_notification_service.rb
Overview
class where email notification services resides
Constant Summary collapse
- KILLBILL_EMAIL_NOTIFICATION_PREFIX =
'/plugins/killbill-email-notifications/v1'
Class Method Summary collapse
- .email_notification_plugin_available?(options = nil) ⇒ Boolean
- .get_configuration_per_account(account_id, options = {}) ⇒ Object
- .get_configurations(account_ids, options = {}) ⇒ Object
- .get_events_to_consider(options = {}) ⇒ Object
- .set_configuration_per_account(account_id, event_types, user = 'kenui', reason = nil, comment = nil, options = {}) ⇒ Object
Class Method Details
.email_notification_plugin_available?(options = nil) ⇒ Boolean
47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/kenui/email_notification_service.rb', line 47 def email_notification_plugin_available?( = nil) # inquire if the plugin is listening path = KILLBILL_EMAIL_NOTIFICATION_PREFIX KillBillClient::API.get path, nil, [true, nil] # Response error if email notification plugin is not listening rescue KillBillClient::API::ResponseError => e [false, e..to_s] end |
.get_configuration_per_account(account_id, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/services/kenui/email_notification_service.rb', line 24 def get_configuration_per_account(account_id, = {}) path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts/#{account_id}" response = KillBillClient::API.get path, {}, JSON.parse(response.body).map(&:symbolize_keys) rescue StandardError => e [false, e..to_s] end |
.get_configurations(account_ids, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/services/kenui/email_notification_service.rb', line 15 def get_configurations(account_ids, = {}) path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts" response = KillBillClient::API.get path, { kbAccountId: account_ids }, JSON.parse(response.body).map(&:symbolize_keys) rescue StandardError => e [false, e..to_s] end |
.get_events_to_consider(options = {}) ⇒ Object
9 10 11 12 13 |
# File 'app/services/kenui/email_notification_service.rb', line 9 def get_events_to_consider( = {}) path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/eventsToConsider" response = KillBillClient::API.get path, {}, JSON.parse(response.body) end |
.set_configuration_per_account(account_id, event_types, user = 'kenui', reason = nil, comment = nil, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/services/kenui/email_notification_service.rb', line 33 def set_configuration_per_account(account_id, event_types, user = 'kenui', reason = nil, comment = nil, = {}) path = "#{KILLBILL_EMAIL_NOTIFICATION_PREFIX}/accounts/#{account_id}" = {} [:user] = user [:reason] = reason unless reason.nil? [:comment] = comment unless comment.nil? KillBillClient::API.post path, event_types, {}, .merge() [true, "Email notifications for account #{account_id} was successfully updated"] rescue StandardError => e [false, e..to_s] end |