Sha256: 60253642a49b0508654200137ddebfe89c869f6e90092c62a4aaea692e0d2ec1
Contents?: true
Size: 1.08 KB
Versions: 12
Compression:
Stored size: 1.08 KB
Contents
module Services module Hubspot module Webhooks class PauseActiveSubscriptions def initialize(app_id:) @app_id = app_id end def call return false if active_subscriptions.empty? inputs = active_subscriptions.map do |subscription| ::Hubspot::Webhooks::SubscriptionBatchUpdateRequest.new( id: subscription.id, active: false ) end batch_input_subscription_batch_update_request = ::Hubspot::Webhooks::BatchInputSubscriptionBatchUpdateRequest.new(inputs: inputs) ::Hubspot::Webhooks::SubscriptionsApi.new.update_batch( @app_id, batch_input_subscription_batch_update_request ) end private def active_subscriptions return @active_subscriptions if @active_subscriptions.present? subscriptions = ::Hubspot::Webhooks::SubscriptionsApi.new.get_all(@app_id).results @active_subscriptions = subscriptions.filter(&:active) end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems