Class: JiraConnectSubscriptions::DestroyService
- Inherits:
-
Object
- Object
- JiraConnectSubscriptions::DestroyService
- Defined in:
- app/services/jira_connect_subscriptions/destroy_service.rb
Instance Attribute Summary collapse
-
#jira_user ⇒ Object
Returns the value of attribute jira_user.
-
#subscription ⇒ Object
Returns the value of attribute subscription.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(subscription, jira_user) ⇒ DestroyService
constructor
A new instance of DestroyService.
Constructor Details
#initialize(subscription, jira_user) ⇒ DestroyService
Returns a new instance of DestroyService.
7 8 9 10 |
# File 'app/services/jira_connect_subscriptions/destroy_service.rb', line 7 def initialize(subscription, jira_user) @subscription = subscription @jira_user = jira_user end |
Instance Attribute Details
#jira_user ⇒ Object
Returns the value of attribute jira_user.
5 6 7 |
# File 'app/services/jira_connect_subscriptions/destroy_service.rb', line 5 def jira_user @jira_user end |
#subscription ⇒ Object
Returns the value of attribute subscription.
5 6 7 |
# File 'app/services/jira_connect_subscriptions/destroy_service.rb', line 5 def subscription @subscription end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/jira_connect_subscriptions/destroy_service.rb', line 12 def execute unless subscription return ServiceResponse.error(message: _('Invalid JiraConnectSubscriptions'), reason: :unprocessable_entity) end return ServiceResponse.error(message: _('Forbidden'), reason: :forbidden) unless can_administer_jira? namespace_id = subscription.namespace_id if subscription.destroy deactivate_jira_cloud_app_integrations(namespace_id) return ServiceResponse.success end ServiceResponse.error( message: subscription.errors..to_sentence, reason: :unprocessable_entity ) end |