Module: Webhookdb::Replicator::TransistorV1Mixin

Includes:
DBAdapter::ColumnTypes
Included in:
TransistorEpisodeStatsV1, TransistorEpisodeV1, TransistorShowV1
Defined in:
lib/webhookdb/replicator/transistor_v1_mixin.rb

Constant Summary

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 Method Summary collapse

Instance Method Details

#_remote_key_columnObject



11
12
13
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 11

def _remote_key_column
  return Webhookdb::Replicator::Column.new(:transistor_id, TEXT, data_key: "id")
end

#_resource_and_event(request) ⇒ Object



19
20
21
22
23
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 19

def _resource_and_event(request)
  body = request.body
  return body["data"], body if body.key?("data")
  return body, nil
end

#_timestamp_column_nameObject



15
16
17
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 15

def _timestamp_column_name
  return :updated_at
end

#_update_where_exprObject



25
26
27
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 25

def _update_where_expr
  return self.qualified_table_sequel_identifier[:updated_at] < Sequel[:excluded][:updated_at]
end

#_verify_backfill_401_err_msgObject



58
59
60
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 58

def _verify_backfill_401_err_msg
  return "It looks like that API Key is invalid. Please reenter the API Key you just created:"
end

#_verify_backfill_err_msgObject



62
63
64
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 62

def _verify_backfill_err_msg
  return "An error occurred. Please reenter the API Key you just created:"
end

#_webhook_response(_request) ⇒ Object



6
7
8
9
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 6

def _webhook_response(_request)
  # As of 9/15/21 there is no way to verify authenticity of these webhooks
  return Webhookdb::WebhookResponse.ok
end

#calculate_backfill_state_machineObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/webhookdb/replicator/transistor_v1_mixin.rb', line 29

def calculate_backfill_state_machine
  step = Webhookdb::Replicator::StateMachineStep.new
  if self.service_integration.backfill_key.blank?
    step.output = %(Great! We've created your #{self.resource_name_plural} integration.

Transistor does not support #{self.resource_name_singular} webhooks, so to fill your database,
we need to use the API to make requests, which requires your API Key.

From your Transistor dashboard, go to the "Your Account" page,
at https://dashboard.transistor.fm/account
On the left side of the bottom of the page you should be able to see your API key.

Copy that API key.
    )
    return step.secret_prompt("API Key").backfill_key(self.service_integration)
  end

  unless (result = self.verify_backfill_credentials).verified
    self.service_integration.replicator.clear_backfill_information
    step.output = result.message
    return step.secret_prompt("API Key").backfill_key(self.service_integration)
  end

  step.output = %(Great! We are going to start replicating your #{self.resource_name_plural}.
#{self._query_help_output}
  )
  return step.completed
end