Class: Webhookdb::Replicator::Descriptor
- Inherits:
-
TypedStruct
- Object
- TypedStruct
- Webhookdb::Replicator::Descriptor
- Defined in:
- lib/webhookdb/replicator.rb
Overview
Statically describe a replicator.
Instance Attribute Summary collapse
-
#api_docs_url ⇒ Object
readonly
URL pointing to the provider (not-WebhookDB) docs for this integration.
-
#ctor ⇒ Object
Method invoked with the
Webhookdb::ServiceIntegration
, and should return a new instance of the integration. -
#dependency_descriptor ⇒ Object
The descriptor for the service this one depends on (the parent).
-
#description ⇒ Object
readonly
Markdown description of this replicator.
-
#documentation_url ⇒ Object
readonly
If this integration has specific documentation, link its url here.
-
#enterprise ⇒ Object
(also: #enterprise?)
readonly
Is this an enterprise-only replicator?.
-
#feature_roles ⇒ Object
Used for feature flagging functionality.
-
#install_url ⇒ Object
readonly
If this integration uses /v1/install to set up, or some other link like a marketplace URL, provide it here.
-
#name ⇒ Object
Name of the replicator, like ‘stripe_charge_v1’.
-
#resource_name_plural ⇒ Object
Defaults to resource_name_singular+s.
-
#resource_name_singular ⇒ Object
Name of the resource, like “Acme Sprocket” @return [String].
-
#supports_backfill ⇒ Object
(also: #supports_backfill?)
readonly
True if this integration supports user-driven backfilling, usually by paginating all resources.
-
#supports_webhooks ⇒ Object
(also: #supports_webhooks?)
readonly
True if this integration supports webhooks (real-time or user-built webhook payloads).
Instance Method Summary collapse
- #==(other) ⇒ Object
- #backfill_only? ⇒ Boolean
- #documentable? ⇒ Boolean
-
#initialize(name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil) ⇒ Descriptor
constructor
A new instance of Descriptor.
- #inspect ⇒ Object
- #supports_webhooks_and_backfill? ⇒ Boolean
- #webhooks_only? ⇒ Boolean
Methods inherited from TypedStruct
#[], #_apply, #_defaults, #as_json, #change
Constructor Details
#initialize(name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil) ⇒ Descriptor
Returns a new instance of Descriptor.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/webhookdb/replicator.rb', line 90 def initialize( name:, ctor:, resource_name_singular:, feature_roles:, supports_webhooks: false, supports_backfill: false, resource_name_plural: nil, dependency_descriptor: nil, api_docs_url: "", description: nil, enterprise: false, documentation_url: nil, install_url: nil, documentable: nil ) raise ArgumentError, "must support one or both of webhooks and backfill" unless supports_webhooks || supports_backfill super( name:, resource_name_singular:, feature_roles:, supports_webhooks:, supports_backfill:, dependency_descriptor:, documentation_url:, api_docs_url:, install_url:, enterprise: ) @ctor = ctor.is_a?(Class) ? ctor.method(:new) : ctor @resource_name_plural = resource_name_plural || "#{self.resource_name_singular}s" @description = description || "Replicate #{self.resource_name_plural} into your database." @documentable = documentable.nil? ? !self.name.start_with?("webhookdb_", "fake_", "theranest_") : documentable end |
Instance Attribute Details
#api_docs_url ⇒ Object (readonly)
URL pointing to the provider (not-WebhookDB) docs for this integration.
83 84 85 |
# File 'lib/webhookdb/replicator.rb', line 83 def api_docs_url @api_docs_url end |
#ctor ⇒ Object
Method invoked with the Webhookdb::ServiceIntegration
, and should return a new instance of the integration. Can also be an object that responds to ‘new`.
@return [Proc]
36 37 38 |
# File 'lib/webhookdb/replicator.rb', line 36 def ctor @ctor end |
#dependency_descriptor ⇒ Object
The descriptor for the service this one depends on (the parent).
@return [Webhookdb::Replicator::Descriptor]
60 61 62 |
# File 'lib/webhookdb/replicator.rb', line 60 def dependency_descriptor @dependency_descriptor end |
#description ⇒ Object (readonly)
Markdown description of this replicator.
80 81 82 |
# File 'lib/webhookdb/replicator.rb', line 80 def description @description end |
#documentation_url ⇒ Object (readonly)
If this integration has specific documentation, link its url here. It is used to build custom error messages, for example in case ‘backfill’ is called but not supported.
71 72 73 |
# File 'lib/webhookdb/replicator.rb', line 71 def documentation_url @documentation_url end |
#enterprise ⇒ Object (readonly) Also known as: enterprise?
Is this an enterprise-only replicator?
86 87 88 |
# File 'lib/webhookdb/replicator.rb', line 86 def enterprise @enterprise end |
#feature_roles ⇒ Object
Used for feature flagging functionality. Usually will be [], but other possible values are: -‘internal’ e.g. our fake integration -‘unreleased’ for works in progress -‘beta’ if we don’t want most people to have access
@return [Array<String>]
45 46 47 |
# File 'lib/webhookdb/replicator.rb', line 45 def feature_roles @feature_roles end |
#install_url ⇒ Object (readonly)
If this integration uses /v1/install to set up, or some other link like a marketplace URL, provide it here. Note that you can add a redirect to Webhookdb::Apps::REDIRECTS to provide a pretty, arbitrary URL.
77 78 79 |
# File 'lib/webhookdb/replicator.rb', line 77 def install_url @install_url end |
#name ⇒ Object
Name of the replicator, like ‘stripe_charge_v1’. Appears externally in many places, so must be meaningful.
@return [String]
30 31 32 |
# File 'lib/webhookdb/replicator.rb', line 30 def name @name end |
#resource_name_plural ⇒ Object
Defaults to resource_name_singular+s.
@return [String]
55 56 57 |
# File 'lib/webhookdb/replicator.rb', line 55 def resource_name_plural @resource_name_plural end |
#resource_name_singular ⇒ Object
Name of the resource, like “Acme Sprocket”
@return [String]
50 51 52 |
# File 'lib/webhookdb/replicator.rb', line 50 def resource_name_singular @resource_name_singular end |
#supports_backfill ⇒ Object (readonly) Also known as: supports_backfill?
True if this integration supports user-driven backfilling, usually by paginating all resources.
66 67 68 |
# File 'lib/webhookdb/replicator.rb', line 66 def supports_backfill @supports_backfill end |
#supports_webhooks ⇒ Object (readonly) Also known as: supports_webhooks?
True if this integration supports webhooks (real-time or user-built webhook payloads).
63 64 65 |
# File 'lib/webhookdb/replicator.rb', line 63 def supports_webhooks @supports_webhooks end |
Instance Method Details
#==(other) ⇒ Object
130 131 132 133 134 |
# File 'lib/webhookdb/replicator.rb', line 130 def ==(other) return self.class == other.class && self.name == other.name && self.resource_name_singular == other.resource_name_singular end |
#backfill_only? ⇒ Boolean
140 |
# File 'lib/webhookdb/replicator.rb', line 140 def backfill_only? = !self.supports_webhooks? && self.supports_backfill? |
#documentable? ⇒ Boolean
88 |
# File 'lib/webhookdb/replicator.rb', line 88 def documentable? = @documentable |
#inspect ⇒ Object
126 127 128 |
# File 'lib/webhookdb/replicator.rb', line 126 def inspect return "#{self.class.name}(name: #{self.name})" end |
#supports_webhooks_and_backfill? ⇒ Boolean
141 |
# File 'lib/webhookdb/replicator.rb', line 141 def supports_webhooks_and_backfill? = self.supports_webhooks? && self.supports_backfill? |
#webhooks_only? ⇒ Boolean
139 |
# File 'lib/webhookdb/replicator.rb', line 139 def webhooks_only? = self.supports_webhooks? && !self.supports_backfill? |