Class: Webhookdb::Replicator::IncreaseAppV1

Inherits:
Base
  • Object
show all
Includes:
Appydays::Loggable
Defined in:
lib/webhookdb/replicator/increase_app_v1.rb

Constant Summary

Constants inherited from Base

Base::MAX_INDEX_NAME_LENGTH

Constants included from DBAdapter::ColumnTypes

DBAdapter::ColumnTypes::BIGINT, DBAdapter::ColumnTypes::BIGINT_ARRAY, DBAdapter::ColumnTypes::BOOLEAN, DBAdapter::ColumnTypes::COLUMN_TYPES, DBAdapter::ColumnTypes::DATE, DBAdapter::ColumnTypes::DECIMAL, DBAdapter::ColumnTypes::DOUBLE, DBAdapter::ColumnTypes::FLOAT, DBAdapter::ColumnTypes::INTEGER, DBAdapter::ColumnTypes::INTEGER_ARRAY, DBAdapter::ColumnTypes::OBJECT, DBAdapter::ColumnTypes::TEXT, DBAdapter::ColumnTypes::TEXT_ARRAY, DBAdapter::ColumnTypes::TIMESTAMP, DBAdapter::ColumnTypes::UUID

Instance Attribute Summary

Attributes inherited from Base

#service_integration

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#_any_subscriptions_to_notify?, #_backfill_state_change_fields, #_backfillers, #_clear_backfill_information, #_clear_webook_information, #_coalesce_excluded_on_update, #_enqueue_backfill_jobs, #_extra_index_specs, #_fetch_enrichment, #_find_dependency_candidate, #_notify_dependents, #_parallel_backfill, #_prepare_for_insert, #_publish_rowupsert, #_resource_and_event, #_resource_to_data, #_store_enrichment_body?, #_timestamp_column_name, #_to_json, #_update_where_expr, #_upsert_update_expr, #_verify_backfill_err_msg, #_webhook_response, #_webhook_state_change_fields, #admin_dataset, #backfill, #backfill_not_supported_message, #calculate_and_backfill_state_machine, #calculate_dependency_state_machine_step, #calculate_preferred_create_state_machine, chunked_row_update_bounds, #clear_backfill_information, #clear_webhook_information, #create_table, #create_table_modification, #data_column, #dbadapter_table, #denormalized_columns, #descriptor, #dispatch_request_to, #documentation_url, #enqueue_sync_targets, #enrichment_column, #ensure_all_columns, #ensure_all_columns_modification, #find_dependent, #find_dependent!, #indices, #initialize, #on_dependency_webhook_upsert, #preferred_create_state_machine_method, #preprocess_headers_for_logging, #primary_key_column, #process_state_change, #process_webhooks_synchronously?, #qualified_table_sequel_identifier, #readonly_dataset, #remote_key_column, #requires_sequence?, #resource_name_plural, #resource_name_singular, #schema_and_table_symbols, #storable_columns, #synchronous_processing_response_body, #timestamp_column, #upsert_has_deps?, #upsert_webhook, #upsert_webhook_body, #verify_backfill_credentials, #webhook_endpoint

Constructor Details

This class inherits a constructor from Webhookdb::Replicator::Base

Class Method Details

.descriptorWebhookdb::Replicator::Descriptor



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 7

def self.descriptor
  return Webhookdb::Replicator::Descriptor.new(
    name: "increase_app_v1",
    ctor: self,
    feature_roles: [],
    resource_name_singular: "Increase App",
    resource_name_plural: "Increase App",
    supports_webhooks: true,
    supports_backfill: true,
    install_url: "#{Webhookdb.api_url}/increase",
    documentation_url: "https://docs.webhookdb.com/guides/increase/",
    description: "Replicate your Increase data to WebhookDB Cloud in one click using " \
                 "our [WebhookDB-Increase integration](https://docs.webhookdb.com/guides/increase).",
  )
end

Instance Method Details

#_denormalized_columnsObject



27
28
29
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 27

def _denormalized_columns
  return []
end

#_fetch_backfill_pageObject



42
43
44
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 42

def _fetch_backfill_page(*)
  return [], nil
end

#_remote_key_columnObject



23
24
25
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 23

def _remote_key_column
  return Webhookdb::Replicator::Column.new(:ignore_id, INTEGER)
end

#_upsert_webhook(request, **kw) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 31

def _upsert_webhook(request, **kw)
  raise Webhookdb::InvalidPrecondition, "can only handle event payloads" unless request.body.fetch("type") == "event"
  dispatchable = self.service_integration.dependents.select do |d|
    d.service_name == "increase_event_v1" || d.replicator.handle_event?(request.body)
  end
  dispatchable.each do |sint|
    sint.replicator.upsert_webhook(request, **kw)
  end
  return nil
end

#build_dependentsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 62

def build_dependents
  org = self.service_integration.organization
  parent_descr = self.descriptor
  sints = self.service_integration.organization.available_replicators.
    select { |dd| dd.dependency_descriptor == parent_descr }.
    map do |dd|
    Webhookdb::ServiceIntegration.create_disambiguated(
      dd.name,
      organization: org,
      depends_on: self.service_integration,
    )
  end
  sints.
    select { |sint| sint.replicator.descriptor.supports_backfill? }.
    each { |sint| sint.replicator._enqueue_backfill_jobs(incremental: false) }
end

#calculate_backfill_state_machineObject



54
55
56
57
58
59
60
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 54

def calculate_backfill_state_machine
  step = Webhookdb::Replicator::StateMachineStep.new
  step.output = %(This replicator is managed automatically using OAuth through Increase.
Head over to #{self.descriptor.install_url} to learn more.)
  step.completed
  return step
end

#calculate_webhook_state_machineObject



50
51
52
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 50

def calculate_webhook_state_machine
  return self.calculate_backfill_state_machine
end

#webhook_response(request) ⇒ Object



46
47
48
# File 'lib/webhookdb/replicator/increase_app_v1.rb', line 46

def webhook_response(request)
  return Webhookdb::Increase.webhook_response(request, Webhookdb::Increase.webhook_secret)
end