webhookdb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (364) hide show
  1. checksums.yaml +7 -0
  2. data/data/messages/layouts/blank.email.liquid +10 -0
  3. data/data/messages/layouts/minimal.email.liquid +28 -0
  4. data/data/messages/layouts/standard.email.liquid +28 -0
  5. data/data/messages/partials/button.liquid +15 -0
  6. data/data/messages/partials/environment_banner.liquid +9 -0
  7. data/data/messages/partials/footer.liquid +22 -0
  8. data/data/messages/partials/greeting.liquid +3 -0
  9. data/data/messages/partials/logo_header.liquid +18 -0
  10. data/data/messages/partials/signoff.liquid +1 -0
  11. data/data/messages/styles/v1.liquid +346 -0
  12. data/data/messages/templates/errors/icalendar_fetch.email.liquid +29 -0
  13. data/data/messages/templates/invite.email.liquid +15 -0
  14. data/data/messages/templates/new_customer.email.liquid +24 -0
  15. data/data/messages/templates/org_database_migration_finished.email.liquid +7 -0
  16. data/data/messages/templates/org_database_migration_started.email.liquid +9 -0
  17. data/data/messages/templates/specs/_field_partial.liquid +1 -0
  18. data/data/messages/templates/specs/basic.email.liquid +2 -0
  19. data/data/messages/templates/specs/basic.fake.liquid +1 -0
  20. data/data/messages/templates/specs/with_field.email.liquid +2 -0
  21. data/data/messages/templates/specs/with_field.fake.liquid +1 -0
  22. data/data/messages/templates/specs/with_include.email.liquid +2 -0
  23. data/data/messages/templates/specs/with_partial.email.liquid +1 -0
  24. data/data/messages/templates/verification.email.liquid +14 -0
  25. data/data/messages/templates/verification.sms.liquid +1 -0
  26. data/data/messages/web/install-customer-login.liquid +48 -0
  27. data/data/messages/web/install-error.liquid +17 -0
  28. data/data/messages/web/install-success.liquid +35 -0
  29. data/data/messages/web/install.liquid +20 -0
  30. data/data/messages/web/partials/footer.liquid +4 -0
  31. data/data/messages/web/partials/form_error.liquid +1 -0
  32. data/data/messages/web/partials/header.liquid +3 -0
  33. data/data/messages/web/styles.liquid +134 -0
  34. data/data/windows_tz.txt +461 -0
  35. data/db/migrations/001_testing_pixies.rb +13 -0
  36. data/db/migrations/002_initial.rb +132 -0
  37. data/db/migrations/003_ux_overhaul.rb +20 -0
  38. data/db/migrations/004_incremental_backfill.rb +9 -0
  39. data/db/migrations/005_log_webhooks.rb +24 -0
  40. data/db/migrations/006_generalize_roles.rb +29 -0
  41. data/db/migrations/007_org_dns.rb +12 -0
  42. data/db/migrations/008_webhook_subscriptions.rb +19 -0
  43. data/db/migrations/009_nonunique_stripe_subscription_customer.rb +16 -0
  44. data/db/migrations/010_drop_integration_soft_delete.rb +14 -0
  45. data/db/migrations/011_webhook_subscriptions_created_at.rb +10 -0
  46. data/db/migrations/012_webhook_subscriptions_created_by.rb +9 -0
  47. data/db/migrations/013_default_org_membership.rb +30 -0
  48. data/db/migrations/014_webhook_subscription_deliveries.rb +26 -0
  49. data/db/migrations/015_dependent_integrations.rb +9 -0
  50. data/db/migrations/016_encrypted_columns.rb +9 -0
  51. data/db/migrations/017_skip_verification.rb +9 -0
  52. data/db/migrations/018_sync_targets.rb +25 -0
  53. data/db/migrations/019_org_schema.rb +9 -0
  54. data/db/migrations/020_org_database_migrations.rb +25 -0
  55. data/db/migrations/021_no_default_org_schema.rb +14 -0
  56. data/db/migrations/022_database_document.rb +15 -0
  57. data/db/migrations/023_sync_target_schema.rb +9 -0
  58. data/db/migrations/024_org_semaphore_jobs.rb +9 -0
  59. data/db/migrations/025_integration_backfill_cursor.rb +9 -0
  60. data/db/migrations/026_undo_integration_backfill_cursor.rb +9 -0
  61. data/db/migrations/027_sync_target_http_sync.rb +12 -0
  62. data/db/migrations/028_logged_webhook_path.rb +24 -0
  63. data/db/migrations/029_encrypt_columns.rb +97 -0
  64. data/db/migrations/030_org_sync_target_timeout.rb +9 -0
  65. data/db/migrations/031_org_max_query_rows.rb +9 -0
  66. data/db/migrations/032_remove_db_defaults.rb +12 -0
  67. data/db/migrations/033_backfill_jobs.rb +26 -0
  68. data/db/migrations/034_backfill_job_criteria.rb +9 -0
  69. data/db/migrations/035_synchronous_backfill.rb +9 -0
  70. data/db/migrations/036_oauth.rb +26 -0
  71. data/db/migrations/037_oauth_used.rb +9 -0
  72. data/lib/amigo/durable_job.rb +416 -0
  73. data/lib/pry/clipboard.rb +111 -0
  74. data/lib/sequel/advisory_lock.rb +65 -0
  75. data/lib/webhookdb/admin.rb +4 -0
  76. data/lib/webhookdb/admin_api/auth.rb +36 -0
  77. data/lib/webhookdb/admin_api/customers.rb +63 -0
  78. data/lib/webhookdb/admin_api/database_documents.rb +20 -0
  79. data/lib/webhookdb/admin_api/entities.rb +66 -0
  80. data/lib/webhookdb/admin_api/message_deliveries.rb +61 -0
  81. data/lib/webhookdb/admin_api/roles.rb +15 -0
  82. data/lib/webhookdb/admin_api.rb +34 -0
  83. data/lib/webhookdb/aggregate_result.rb +63 -0
  84. data/lib/webhookdb/api/auth.rb +122 -0
  85. data/lib/webhookdb/api/connstr_auth.rb +36 -0
  86. data/lib/webhookdb/api/db.rb +188 -0
  87. data/lib/webhookdb/api/demo.rb +14 -0
  88. data/lib/webhookdb/api/entities.rb +198 -0
  89. data/lib/webhookdb/api/helpers.rb +253 -0
  90. data/lib/webhookdb/api/install.rb +296 -0
  91. data/lib/webhookdb/api/me.rb +53 -0
  92. data/lib/webhookdb/api/organizations.rb +254 -0
  93. data/lib/webhookdb/api/replay.rb +64 -0
  94. data/lib/webhookdb/api/service_integrations.rb +402 -0
  95. data/lib/webhookdb/api/services.rb +27 -0
  96. data/lib/webhookdb/api/stripe.rb +22 -0
  97. data/lib/webhookdb/api/subscriptions.rb +67 -0
  98. data/lib/webhookdb/api/sync_targets.rb +232 -0
  99. data/lib/webhookdb/api/system.rb +37 -0
  100. data/lib/webhookdb/api/webhook_subscriptions.rb +96 -0
  101. data/lib/webhookdb/api.rb +92 -0
  102. data/lib/webhookdb/apps.rb +93 -0
  103. data/lib/webhookdb/async/audit_logger.rb +38 -0
  104. data/lib/webhookdb/async/autoscaler.rb +84 -0
  105. data/lib/webhookdb/async/job.rb +18 -0
  106. data/lib/webhookdb/async/job_logger.rb +45 -0
  107. data/lib/webhookdb/async/scheduled_job.rb +18 -0
  108. data/lib/webhookdb/async.rb +142 -0
  109. data/lib/webhookdb/aws.rb +98 -0
  110. data/lib/webhookdb/backfill_job.rb +107 -0
  111. data/lib/webhookdb/backfiller.rb +107 -0
  112. data/lib/webhookdb/cloudflare.rb +39 -0
  113. data/lib/webhookdb/connection_cache.rb +177 -0
  114. data/lib/webhookdb/console.rb +71 -0
  115. data/lib/webhookdb/convertkit.rb +14 -0
  116. data/lib/webhookdb/crypto.rb +66 -0
  117. data/lib/webhookdb/customer/reset_code.rb +94 -0
  118. data/lib/webhookdb/customer.rb +347 -0
  119. data/lib/webhookdb/database_document.rb +72 -0
  120. data/lib/webhookdb/db_adapter/column_types.rb +37 -0
  121. data/lib/webhookdb/db_adapter/default_sql.rb +187 -0
  122. data/lib/webhookdb/db_adapter/pg.rb +96 -0
  123. data/lib/webhookdb/db_adapter/snowflake.rb +137 -0
  124. data/lib/webhookdb/db_adapter.rb +208 -0
  125. data/lib/webhookdb/dbutil.rb +92 -0
  126. data/lib/webhookdb/demo_mode.rb +100 -0
  127. data/lib/webhookdb/developer_alert.rb +51 -0
  128. data/lib/webhookdb/email_octopus.rb +21 -0
  129. data/lib/webhookdb/enumerable.rb +18 -0
  130. data/lib/webhookdb/fixtures/backfill_jobs.rb +72 -0
  131. data/lib/webhookdb/fixtures/customers.rb +65 -0
  132. data/lib/webhookdb/fixtures/database_documents.rb +27 -0
  133. data/lib/webhookdb/fixtures/faker.rb +41 -0
  134. data/lib/webhookdb/fixtures/logged_webhooks.rb +56 -0
  135. data/lib/webhookdb/fixtures/message_deliveries.rb +59 -0
  136. data/lib/webhookdb/fixtures/oauth_sessions.rb +24 -0
  137. data/lib/webhookdb/fixtures/organization_database_migrations.rb +37 -0
  138. data/lib/webhookdb/fixtures/organization_memberships.rb +54 -0
  139. data/lib/webhookdb/fixtures/organizations.rb +32 -0
  140. data/lib/webhookdb/fixtures/reset_codes.rb +23 -0
  141. data/lib/webhookdb/fixtures/service_integrations.rb +42 -0
  142. data/lib/webhookdb/fixtures/subscriptions.rb +33 -0
  143. data/lib/webhookdb/fixtures/sync_targets.rb +32 -0
  144. data/lib/webhookdb/fixtures/webhook_subscriptions.rb +35 -0
  145. data/lib/webhookdb/fixtures.rb +15 -0
  146. data/lib/webhookdb/formatting.rb +56 -0
  147. data/lib/webhookdb/front.rb +49 -0
  148. data/lib/webhookdb/github.rb +22 -0
  149. data/lib/webhookdb/google_calendar.rb +29 -0
  150. data/lib/webhookdb/heroku.rb +21 -0
  151. data/lib/webhookdb/http.rb +114 -0
  152. data/lib/webhookdb/icalendar.rb +17 -0
  153. data/lib/webhookdb/id.rb +17 -0
  154. data/lib/webhookdb/idempotency.rb +90 -0
  155. data/lib/webhookdb/increase.rb +42 -0
  156. data/lib/webhookdb/intercom.rb +23 -0
  157. data/lib/webhookdb/jobs/amigo_test_jobs.rb +118 -0
  158. data/lib/webhookdb/jobs/backfill.rb +32 -0
  159. data/lib/webhookdb/jobs/create_mirror_table.rb +18 -0
  160. data/lib/webhookdb/jobs/create_stripe_customer.rb +17 -0
  161. data/lib/webhookdb/jobs/customer_created_notify_internal.rb +22 -0
  162. data/lib/webhookdb/jobs/demo_mode_sync_data.rb +19 -0
  163. data/lib/webhookdb/jobs/deprecated_jobs.rb +19 -0
  164. data/lib/webhookdb/jobs/developer_alert_handle.rb +14 -0
  165. data/lib/webhookdb/jobs/durable_job_recheck_poller.rb +17 -0
  166. data/lib/webhookdb/jobs/emailer.rb +15 -0
  167. data/lib/webhookdb/jobs/icalendar_enqueue_syncs.rb +25 -0
  168. data/lib/webhookdb/jobs/icalendar_sync.rb +23 -0
  169. data/lib/webhookdb/jobs/logged_webhook_replay.rb +17 -0
  170. data/lib/webhookdb/jobs/logged_webhook_resilient_replay.rb +15 -0
  171. data/lib/webhookdb/jobs/message_dispatched.rb +16 -0
  172. data/lib/webhookdb/jobs/organization_database_migration_notify_finished.rb +21 -0
  173. data/lib/webhookdb/jobs/organization_database_migration_notify_started.rb +21 -0
  174. data/lib/webhookdb/jobs/organization_database_migration_run.rb +24 -0
  175. data/lib/webhookdb/jobs/prepare_database_connections.rb +22 -0
  176. data/lib/webhookdb/jobs/process_webhook.rb +47 -0
  177. data/lib/webhookdb/jobs/renew_watch_channel.rb +24 -0
  178. data/lib/webhookdb/jobs/replication_migration.rb +24 -0
  179. data/lib/webhookdb/jobs/reset_code_create_dispatch.rb +23 -0
  180. data/lib/webhookdb/jobs/scheduled_backfills.rb +77 -0
  181. data/lib/webhookdb/jobs/send_invite.rb +15 -0
  182. data/lib/webhookdb/jobs/send_test_webhook.rb +25 -0
  183. data/lib/webhookdb/jobs/send_webhook.rb +20 -0
  184. data/lib/webhookdb/jobs/sync_target_enqueue_scheduled.rb +16 -0
  185. data/lib/webhookdb/jobs/sync_target_run_sync.rb +38 -0
  186. data/lib/webhookdb/jobs/trim_logged_webhooks.rb +15 -0
  187. data/lib/webhookdb/jobs/webhook_resource_notify_integrations.rb +30 -0
  188. data/lib/webhookdb/jobs/webhook_subscription_delivery_attempt.rb +29 -0
  189. data/lib/webhookdb/jobs.rb +4 -0
  190. data/lib/webhookdb/json.rb +113 -0
  191. data/lib/webhookdb/liquid/expose.rb +27 -0
  192. data/lib/webhookdb/liquid/filters.rb +16 -0
  193. data/lib/webhookdb/liquid/liquification.rb +26 -0
  194. data/lib/webhookdb/liquid/partial.rb +12 -0
  195. data/lib/webhookdb/logged_webhook/resilient.rb +95 -0
  196. data/lib/webhookdb/logged_webhook.rb +194 -0
  197. data/lib/webhookdb/message/body.rb +25 -0
  198. data/lib/webhookdb/message/delivery.rb +127 -0
  199. data/lib/webhookdb/message/email_transport.rb +133 -0
  200. data/lib/webhookdb/message/fake_transport.rb +54 -0
  201. data/lib/webhookdb/message/liquid_drops.rb +29 -0
  202. data/lib/webhookdb/message/template.rb +89 -0
  203. data/lib/webhookdb/message/transport.rb +43 -0
  204. data/lib/webhookdb/message.rb +150 -0
  205. data/lib/webhookdb/messages/error_icalendar_fetch.rb +42 -0
  206. data/lib/webhookdb/messages/invite.rb +23 -0
  207. data/lib/webhookdb/messages/new_customer.rb +14 -0
  208. data/lib/webhookdb/messages/org_database_migration_finished.rb +23 -0
  209. data/lib/webhookdb/messages/org_database_migration_started.rb +24 -0
  210. data/lib/webhookdb/messages/specs.rb +57 -0
  211. data/lib/webhookdb/messages/verification.rb +23 -0
  212. data/lib/webhookdb/method_utilities.rb +82 -0
  213. data/lib/webhookdb/microsoft_calendar.rb +36 -0
  214. data/lib/webhookdb/nextpax.rb +14 -0
  215. data/lib/webhookdb/oauth/front.rb +58 -0
  216. data/lib/webhookdb/oauth/intercom.rb +58 -0
  217. data/lib/webhookdb/oauth/session.rb +24 -0
  218. data/lib/webhookdb/oauth.rb +80 -0
  219. data/lib/webhookdb/organization/alerting.rb +35 -0
  220. data/lib/webhookdb/organization/database_migration.rb +151 -0
  221. data/lib/webhookdb/organization/db_builder.rb +429 -0
  222. data/lib/webhookdb/organization.rb +506 -0
  223. data/lib/webhookdb/organization_membership.rb +58 -0
  224. data/lib/webhookdb/phone_number.rb +38 -0
  225. data/lib/webhookdb/plaid.rb +23 -0
  226. data/lib/webhookdb/platform.rb +27 -0
  227. data/lib/webhookdb/plivo.rb +52 -0
  228. data/lib/webhookdb/postgres/maintenance.rb +166 -0
  229. data/lib/webhookdb/postgres/model.rb +82 -0
  230. data/lib/webhookdb/postgres/model_utilities.rb +382 -0
  231. data/lib/webhookdb/postgres/testing_pixie.rb +16 -0
  232. data/lib/webhookdb/postgres/validations.rb +46 -0
  233. data/lib/webhookdb/postgres.rb +176 -0
  234. data/lib/webhookdb/postmark.rb +20 -0
  235. data/lib/webhookdb/redis.rb +35 -0
  236. data/lib/webhookdb/replicator/atom_single_feed_v1.rb +116 -0
  237. data/lib/webhookdb/replicator/aws_pricing_v1.rb +488 -0
  238. data/lib/webhookdb/replicator/base.rb +1185 -0
  239. data/lib/webhookdb/replicator/column.rb +482 -0
  240. data/lib/webhookdb/replicator/convertkit_broadcast_v1.rb +69 -0
  241. data/lib/webhookdb/replicator/convertkit_subscriber_v1.rb +200 -0
  242. data/lib/webhookdb/replicator/convertkit_tag_v1.rb +66 -0
  243. data/lib/webhookdb/replicator/convertkit_v1_mixin.rb +65 -0
  244. data/lib/webhookdb/replicator/docgen.rb +167 -0
  245. data/lib/webhookdb/replicator/email_octopus_campaign_v1.rb +84 -0
  246. data/lib/webhookdb/replicator/email_octopus_contact_v1.rb +159 -0
  247. data/lib/webhookdb/replicator/email_octopus_event_v1.rb +244 -0
  248. data/lib/webhookdb/replicator/email_octopus_list_v1.rb +101 -0
  249. data/lib/webhookdb/replicator/fake.rb +453 -0
  250. data/lib/webhookdb/replicator/front_conversation_v1.rb +45 -0
  251. data/lib/webhookdb/replicator/front_marketplace_root_v1.rb +55 -0
  252. data/lib/webhookdb/replicator/front_message_v1.rb +45 -0
  253. data/lib/webhookdb/replicator/front_v1_mixin.rb +22 -0
  254. data/lib/webhookdb/replicator/github_issue_comment_v1.rb +58 -0
  255. data/lib/webhookdb/replicator/github_issue_v1.rb +83 -0
  256. data/lib/webhookdb/replicator/github_pull_v1.rb +84 -0
  257. data/lib/webhookdb/replicator/github_release_v1.rb +47 -0
  258. data/lib/webhookdb/replicator/github_repo_v1_mixin.rb +250 -0
  259. data/lib/webhookdb/replicator/github_repository_event_v1.rb +45 -0
  260. data/lib/webhookdb/replicator/icalendar_calendar_v1.rb +465 -0
  261. data/lib/webhookdb/replicator/icalendar_event_v1.rb +334 -0
  262. data/lib/webhookdb/replicator/increase_account_number_v1.rb +77 -0
  263. data/lib/webhookdb/replicator/increase_account_transfer_v1.rb +61 -0
  264. data/lib/webhookdb/replicator/increase_account_v1.rb +63 -0
  265. data/lib/webhookdb/replicator/increase_ach_transfer_v1.rb +78 -0
  266. data/lib/webhookdb/replicator/increase_check_transfer_v1.rb +64 -0
  267. data/lib/webhookdb/replicator/increase_limit_v1.rb +78 -0
  268. data/lib/webhookdb/replicator/increase_transaction_v1.rb +74 -0
  269. data/lib/webhookdb/replicator/increase_v1_mixin.rb +121 -0
  270. data/lib/webhookdb/replicator/increase_wire_transfer_v1.rb +61 -0
  271. data/lib/webhookdb/replicator/intercom_contact_v1.rb +36 -0
  272. data/lib/webhookdb/replicator/intercom_conversation_v1.rb +38 -0
  273. data/lib/webhookdb/replicator/intercom_marketplace_root_v1.rb +69 -0
  274. data/lib/webhookdb/replicator/intercom_v1_mixin.rb +105 -0
  275. data/lib/webhookdb/replicator/oauth_refresh_access_token_mixin.rb +65 -0
  276. data/lib/webhookdb/replicator/plivo_sms_inbound_v1.rb +102 -0
  277. data/lib/webhookdb/replicator/postmark_inbound_message_v1.rb +94 -0
  278. data/lib/webhookdb/replicator/postmark_outbound_message_event_v1.rb +107 -0
  279. data/lib/webhookdb/replicator/schema_modification.rb +42 -0
  280. data/lib/webhookdb/replicator/shopify_customer_v1.rb +58 -0
  281. data/lib/webhookdb/replicator/shopify_order_v1.rb +64 -0
  282. data/lib/webhookdb/replicator/shopify_v1_mixin.rb +161 -0
  283. data/lib/webhookdb/replicator/signalwire_message_v1.rb +169 -0
  284. data/lib/webhookdb/replicator/sponsy_customer_v1.rb +54 -0
  285. data/lib/webhookdb/replicator/sponsy_placement_v1.rb +34 -0
  286. data/lib/webhookdb/replicator/sponsy_publication_v1.rb +125 -0
  287. data/lib/webhookdb/replicator/sponsy_slot_v1.rb +41 -0
  288. data/lib/webhookdb/replicator/sponsy_status_v1.rb +35 -0
  289. data/lib/webhookdb/replicator/sponsy_v1_mixin.rb +165 -0
  290. data/lib/webhookdb/replicator/state_machine_step.rb +69 -0
  291. data/lib/webhookdb/replicator/stripe_charge_v1.rb +77 -0
  292. data/lib/webhookdb/replicator/stripe_coupon_v1.rb +62 -0
  293. data/lib/webhookdb/replicator/stripe_customer_v1.rb +60 -0
  294. data/lib/webhookdb/replicator/stripe_dispute_v1.rb +77 -0
  295. data/lib/webhookdb/replicator/stripe_invoice_item_v1.rb +82 -0
  296. data/lib/webhookdb/replicator/stripe_invoice_v1.rb +116 -0
  297. data/lib/webhookdb/replicator/stripe_payout_v1.rb +67 -0
  298. data/lib/webhookdb/replicator/stripe_price_v1.rb +60 -0
  299. data/lib/webhookdb/replicator/stripe_product_v1.rb +60 -0
  300. data/lib/webhookdb/replicator/stripe_refund_v1.rb +101 -0
  301. data/lib/webhookdb/replicator/stripe_subscription_item_v1.rb +56 -0
  302. data/lib/webhookdb/replicator/stripe_subscription_v1.rb +75 -0
  303. data/lib/webhookdb/replicator/stripe_v1_mixin.rb +116 -0
  304. data/lib/webhookdb/replicator/transistor_episode_stats_v1.rb +141 -0
  305. data/lib/webhookdb/replicator/transistor_episode_v1.rb +169 -0
  306. data/lib/webhookdb/replicator/transistor_show_v1.rb +68 -0
  307. data/lib/webhookdb/replicator/transistor_v1_mixin.rb +65 -0
  308. data/lib/webhookdb/replicator/twilio_sms_v1.rb +156 -0
  309. data/lib/webhookdb/replicator/webhook_request.rb +5 -0
  310. data/lib/webhookdb/replicator/webhookdb_customer_v1.rb +74 -0
  311. data/lib/webhookdb/replicator.rb +224 -0
  312. data/lib/webhookdb/role.rb +42 -0
  313. data/lib/webhookdb/sentry.rb +35 -0
  314. data/lib/webhookdb/service/auth.rb +138 -0
  315. data/lib/webhookdb/service/collection.rb +91 -0
  316. data/lib/webhookdb/service/entities.rb +97 -0
  317. data/lib/webhookdb/service/helpers.rb +270 -0
  318. data/lib/webhookdb/service/middleware.rb +124 -0
  319. data/lib/webhookdb/service/types.rb +30 -0
  320. data/lib/webhookdb/service/validators.rb +32 -0
  321. data/lib/webhookdb/service/view_api.rb +63 -0
  322. data/lib/webhookdb/service.rb +219 -0
  323. data/lib/webhookdb/service_integration.rb +332 -0
  324. data/lib/webhookdb/shopify.rb +35 -0
  325. data/lib/webhookdb/signalwire.rb +13 -0
  326. data/lib/webhookdb/slack.rb +68 -0
  327. data/lib/webhookdb/snowflake.rb +90 -0
  328. data/lib/webhookdb/spec_helpers/async.rb +122 -0
  329. data/lib/webhookdb/spec_helpers/citest.rb +88 -0
  330. data/lib/webhookdb/spec_helpers/integration.rb +121 -0
  331. data/lib/webhookdb/spec_helpers/message.rb +41 -0
  332. data/lib/webhookdb/spec_helpers/postgres.rb +220 -0
  333. data/lib/webhookdb/spec_helpers/service.rb +432 -0
  334. data/lib/webhookdb/spec_helpers/shared_examples_for_columns.rb +56 -0
  335. data/lib/webhookdb/spec_helpers/shared_examples_for_replicators.rb +915 -0
  336. data/lib/webhookdb/spec_helpers/whdb.rb +139 -0
  337. data/lib/webhookdb/spec_helpers.rb +63 -0
  338. data/lib/webhookdb/sponsy.rb +14 -0
  339. data/lib/webhookdb/stripe.rb +37 -0
  340. data/lib/webhookdb/subscription.rb +203 -0
  341. data/lib/webhookdb/sync_target.rb +491 -0
  342. data/lib/webhookdb/tasks/admin.rb +49 -0
  343. data/lib/webhookdb/tasks/annotate.rb +36 -0
  344. data/lib/webhookdb/tasks/db.rb +82 -0
  345. data/lib/webhookdb/tasks/docs.rb +42 -0
  346. data/lib/webhookdb/tasks/fixture.rb +35 -0
  347. data/lib/webhookdb/tasks/message.rb +50 -0
  348. data/lib/webhookdb/tasks/regress.rb +87 -0
  349. data/lib/webhookdb/tasks/release.rb +27 -0
  350. data/lib/webhookdb/tasks/sidekiq.rb +23 -0
  351. data/lib/webhookdb/tasks/specs.rb +64 -0
  352. data/lib/webhookdb/theranest.rb +15 -0
  353. data/lib/webhookdb/transistor.rb +13 -0
  354. data/lib/webhookdb/twilio.rb +13 -0
  355. data/lib/webhookdb/typed_struct.rb +44 -0
  356. data/lib/webhookdb/version.rb +5 -0
  357. data/lib/webhookdb/webhook_response.rb +50 -0
  358. data/lib/webhookdb/webhook_subscription/delivery.rb +82 -0
  359. data/lib/webhookdb/webhook_subscription.rb +226 -0
  360. data/lib/webhookdb/windows_tz.rb +32 -0
  361. data/lib/webhookdb/xml.rb +92 -0
  362. data/lib/webhookdb.rb +224 -0
  363. data/lib/webterm/apps.rb +45 -0
  364. metadata +1129 -0
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "appydays/configurable"
4
+
5
+ module Webhookdb::EmailOctopus
6
+ include Appydays::Configurable
7
+
8
+ configurable(:email_octopus) do
9
+ setting :http_timeout, 30
10
+ setting :page_size, 100
11
+ setting :cron_expression, "0 */4 * * *"
12
+ end
13
+
14
+ def self.verify_webhook(data, hmac_header, webhook_secret)
15
+ calculated_hmac = Webhookdb::Crypto.bin2hex(
16
+ OpenSSL::HMAC.digest("sha256", webhook_secret, data),
17
+ )
18
+ verified = ActiveSupport::SecurityUtils.secure_compare("sha256=#{calculated_hmac}", hmac_header)
19
+ return verified
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb" unless defined?(Webhookdb)
4
+
5
+ module Webhookdb::Enumerable
6
+ module_function def group_and_count_by(enumerable)
7
+ result = Hash.new(0)
8
+ enumerable.each do |item|
9
+ key = yield(item)
10
+ result[key] += 1
11
+ end
12
+ return result
13
+ end
14
+
15
+ module_function def group_and_count(enumerable)
16
+ return group_and_count_by(enumerable) { |k| k }
17
+ end
18
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb"
4
+ require "webhookdb/fixtures"
5
+
6
+ module Webhookdb::Fixtures::BackfillJobs
7
+ extend Webhookdb::Fixtures
8
+
9
+ fixtured_class Webhookdb::BackfillJob
10
+
11
+ base :backfill_job do
12
+ self.incremental = false if self.incremental.nil?
13
+ end
14
+
15
+ before_saving do |instance|
16
+ instance.service_integration ||= Webhookdb::Fixtures.service_integration.create
17
+ instance
18
+ end
19
+
20
+ after_saving do |instance|
21
+ instance.setup_recursive if instance._fixture_cascade
22
+ instance
23
+ end
24
+
25
+ decorator :for do |sint={}|
26
+ sint = Webhookdb::Fixtures.service_integration.create(sint) unless sint.is_a?(Webhookdb::ServiceIntegration)
27
+ self.service_integration = sint
28
+ end
29
+
30
+ decorator :cascade do |v=true|
31
+ self._fixture_cascade = v
32
+ end
33
+
34
+ decorator :incremental do |v=true|
35
+ self.incremental = v
36
+ end
37
+
38
+ decorator :plus_sign do |part=nil|
39
+ part ||= SecureRandom.hex(8)
40
+ local, domain = self.email.split("@")
41
+ self.email = "#{local}+#{part}@#{domain}"
42
+ end
43
+
44
+ decorator :admin, presave: true do
45
+ self.add_role(Webhookdb::Role.admin_role)
46
+ end
47
+
48
+ decorator :with_role, presave: true do |role|
49
+ role ||= Faker::Lorem.word
50
+ role = Webhookdb::Role.find_or_create(name: role) if role.is_a?(String)
51
+ self.add_role(role)
52
+ end
53
+
54
+ decorator :with_email do |username=nil|
55
+ self.email = (username || Faker::Internet.username) + "@example.com"
56
+ end
57
+
58
+ decorator :verified_in_org, presave: true do |org={}|
59
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
60
+ Webhookdb::Fixtures.organization_membership.verified.create(customer: self, organization: org)
61
+ end
62
+
63
+ decorator :admin_in_org, presave: true do |org={}|
64
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
65
+ Webhookdb::Fixtures.organization_membership.verified.admin.create(customer: self, organization: org)
66
+ end
67
+
68
+ decorator :invited_to_org, presave: true do |org={}|
69
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
70
+ Webhookdb::Fixtures.organization_membership.invite.create(customer: self, organization: org)
71
+ end
72
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+ require "securerandom"
5
+
6
+ require "webhookdb"
7
+ require "webhookdb/fixtures"
8
+
9
+ module Webhookdb::Fixtures::Customers
10
+ extend Webhookdb::Fixtures
11
+
12
+ PASSWORD = "webhookdb1234"
13
+
14
+ fixtured_class Webhookdb::Customer
15
+
16
+ base :customer do
17
+ self.name ||= Faker::Name.name
18
+ self.email ||= Faker::Internet.email
19
+ self.password_digest ||= Webhookdb::Customer::PLACEHOLDER_PASSWORD_DIGEST
20
+ end
21
+
22
+ before_saving do |instance|
23
+ instance
24
+ end
25
+
26
+ decorator :password do |pwd=nil|
27
+ pwd ||= PASSWORD
28
+ self.password = pwd
29
+ end
30
+
31
+ decorator :plus_sign do |part=nil|
32
+ part ||= SecureRandom.hex(8)
33
+ local, domain = self.email.split("@")
34
+ self.email = "#{local}+#{part}@#{domain}"
35
+ end
36
+
37
+ decorator :admin, presave: true do
38
+ self.add_role(Webhookdb::Role.admin_role)
39
+ end
40
+
41
+ decorator :with_role, presave: true do |role|
42
+ role ||= Faker::Lorem.word
43
+ role = Webhookdb::Role.find_or_create(name: role) if role.is_a?(String)
44
+ self.add_role(role)
45
+ end
46
+
47
+ decorator :with_email do |username=nil|
48
+ self.email = (username || Faker::Internet.username) + "@example.com"
49
+ end
50
+
51
+ decorator :verified_in_org, presave: true do |org={}|
52
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
53
+ Webhookdb::Fixtures.organization_membership.verified.create(customer: self, organization: org)
54
+ end
55
+
56
+ decorator :admin_in_org, presave: true do |org={}|
57
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
58
+ Webhookdb::Fixtures.organization_membership.verified.admin.create(customer: self, organization: org)
59
+ end
60
+
61
+ decorator :invited_to_org, presave: true do |org={}|
62
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
63
+ Webhookdb::Fixtures.organization_membership.invite.create(customer: self, organization: org)
64
+ end
65
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+
5
+ require "webhookdb/fixtures"
6
+
7
+ module Webhookdb::Fixtures::DatabaseDocuments
8
+ extend Webhookdb::Fixtures
9
+
10
+ fixtured_class Webhookdb::DatabaseDocument
11
+
12
+ base :database_document do
13
+ self.content_type ||= "text/plain"
14
+ self.content ||= Faker::Lorem.paragraph
15
+ self.key ||= Faker::File.file_name(dir: Faker::File.dir)
16
+ end
17
+
18
+ decorator :xml do |c="<a><b>hello</b></a>"|
19
+ self.content_type = "application/xml"
20
+ self.content = c
21
+ end
22
+
23
+ decorator :html do |c="<html><body><div><strong>hello</strong></div></body></html>"|
24
+ self.content_type = "text/html"
25
+ self.content = c
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+
5
+ module Faker::Webhookdb
6
+ class << self
7
+ def s3_url(opts={})
8
+ opts[:region] ||= ["us-east-2.", ""].sample
9
+ host = "potato.s3.#{opts[:region]}amazonaws.com"
10
+ return self.image_url(host:)
11
+ end
12
+
13
+ def image_url(opts={})
14
+ opts[:protocol] ||= ["https", "http"].sample
15
+ opts[:host] ||= ["facebook.com", "flickr.com", "mysite.com"].sample
16
+ opts[:path] ||= "fld"
17
+ opts[:filename] ||= Faker::Lorem.word
18
+ opts[:ext] ||= ["png", "jpg", "jpeg"].sample
19
+ return "#{opts[:protocol]}://#{opts[:host]}/#{opts[:path]}/#{opts[:filename]}.#{opts[:ext]}"
20
+ end
21
+
22
+ def us_phone
23
+ s = +"1"
24
+ # First char is never 0 in US area codes
25
+ s << Faker::Number.between(from: 1, to: 9).to_s
26
+ Array.new(9) do
27
+ s << Faker::Number.between(from: 0, to: 9).to_s
28
+ end
29
+ return s
30
+ end
31
+
32
+ def pg_connection(user: nil, password: nil, host: nil, port: nil, dbname: nil)
33
+ user ||= Faker::Internet.username
34
+ password ||= Faker::Internet.password
35
+ host ||= Faker::Internet.ip_v4_address
36
+ port ||= Faker::Number.between(from: 2000, to: 50_000)
37
+ dbname ||= Faker::Lorem.word
38
+ return "postgres://#{user}:#{password}@#{host}:#{port}/#{dbname}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ require "webhookdb"
6
+ require "webhookdb/fixtures"
7
+
8
+ module Webhookdb::Fixtures::LoggedWebhooks
9
+ extend Webhookdb::Fixtures
10
+
11
+ fixtured_class Webhookdb::LoggedWebhook
12
+
13
+ base :logged_webhook do
14
+ self.request_body ||= "{}"
15
+ self.request_headers ||= {}
16
+ self.request_method ||= "POST"
17
+ self.response_status ||= 0
18
+ self.service_integration_opaque_id ||= SecureRandom.hex(2)
19
+ end
20
+
21
+ before_saving do |instance|
22
+ instance.request_path ||= "/v1/service_integrations/#{instance.service_integration_opaque_id}"
23
+ instance
24
+ end
25
+
26
+ decorator :ancient do
27
+ self.inserted_at = Faker::Number.between(from: 200, to: 300).days.ago
28
+ end
29
+
30
+ decorator :success do
31
+ self.response_status = 202
32
+ end
33
+
34
+ decorator :failure do
35
+ self.response_status = rand(400..599)
36
+ end
37
+
38
+ decorator :with_organization do |org={}|
39
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
40
+ self.organization = org
41
+ end
42
+
43
+ decorator :for_service_integration do |sint={}|
44
+ sint = Webhookdb::Fixtures.service_integration.create(sint) unless sint.is_a?(Webhookdb::ServiceIntegration)
45
+ self.organization = sint.organization
46
+ self.service_integration_opaque_id = sint.opaque_id
47
+ end
48
+
49
+ decorator :body do |b|
50
+ self.request_body = b.is_a?(String) ? b : b.to_json
51
+ end
52
+
53
+ decorator :headers do |h|
54
+ self.request_headers.merge!(h)
55
+ end
56
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+
5
+ require "webhookdb/fixtures"
6
+
7
+ module Webhookdb::Fixtures::MessageDeliveries
8
+ extend Webhookdb::Fixtures
9
+
10
+ fixtured_class Webhookdb::Message::Delivery
11
+
12
+ depends_on(:customers)
13
+
14
+ base :message_delivery do
15
+ self.template ||= "fixture"
16
+ self.transport_type ||= "fake"
17
+ self.transport_service ||= "fixture"
18
+ self.to ||= "fixture-to"
19
+ end
20
+
21
+ decorator :email, presave: true do |to=nil|
22
+ self.transport_type = "email"
23
+ self.to = to || self.recipient&.email || Faker::Internet.email
24
+ self.add_body(mediatype: "subject", content: Faker::Lorem.sentence)
25
+ self.add_body(mediatype: "text/plain", content: Faker::Lorem.paragraph)
26
+ self.add_body(mediatype: "text/html", content: "<html><body><p>#{Faker::Lorem.sentence}</p></body></html>")
27
+ end
28
+
29
+ decorator :to do |recipient=nil|
30
+ recipient = self.transport!.recipient(recipient)
31
+ self.to = recipient.to
32
+ self.recipient = recipient.customer
33
+ end
34
+
35
+ decorator :with_recipient do |customer={}|
36
+ customer = Webhookdb::Fixtures.customer.create(customer) unless customer.is_a?(Webhookdb::Customer)
37
+ self.recipient = customer
38
+ end
39
+
40
+ decorator :with_body, presave: true do |body={}|
41
+ body[:mediatype] ||= Faker::Lorem.word
42
+ body[:content] ||= Faker::Lorem.sentences
43
+ self.add_body(body)
44
+ end
45
+
46
+ decorator :via do |transport|
47
+ self.transport_type = transport
48
+ self.to = self.transport!.recipient(self.recipient).to if self.recipient
49
+ end
50
+
51
+ decorator :sent do |at=nil|
52
+ at ||= Time.now
53
+ self.sent_at = at
54
+ end
55
+
56
+ decorator :extra do |k, v|
57
+ self.extra_fields[k.to_s] = v
58
+ end
59
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ require "webhookdb"
6
+ require "webhookdb/fixtures"
7
+ require "webhookdb/oauth/session"
8
+
9
+ module Webhookdb::Fixtures::OauthSessions
10
+ extend Webhookdb::Fixtures
11
+
12
+ fixtured_class Webhookdb::Oauth::Session
13
+
14
+ base :oauth_session do
15
+ self.oauth_state ||= SecureRandom.hex(16)
16
+ self.peer_ip ||= Faker::Internet.ip_v4_address
17
+ self.user_agent ||= "(unset)"
18
+ end
19
+
20
+ decorator :for_customer, presave: true do |c={}|
21
+ c = Webhookdb::Fixtures.customer.create(c) unless c.is_a?(Webhookdb::Customer)
22
+ self.customer ||= c
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb"
4
+ require "webhookdb/fixtures"
5
+
6
+ module Webhookdb::Fixtures::OrganizationDatabaseMigrations
7
+ extend Webhookdb::Fixtures
8
+
9
+ fixtured_class Webhookdb::Organization::DatabaseMigration
10
+
11
+ base :organization_database_migration do
12
+ end
13
+
14
+ before_saving do |instance|
15
+ instance.organization ||= Webhookdb::Fixtures.organization.create
16
+ instance
17
+ end
18
+
19
+ decorator :started do |t=Time.now|
20
+ self.started_at = t
21
+ end
22
+
23
+ decorator :finished do |t=Time.now|
24
+ self.started_at ||= t
25
+ self.finished_at = t
26
+ end
27
+
28
+ decorator :with_organization do |org={}|
29
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
30
+ self.organization = org
31
+ end
32
+
33
+ decorator :with_urls do
34
+ self.source_admin_connection_url ||= "postgres://oldadmin:pass@oldhost.db:5432/old_db"
35
+ self.destination_admin_connection_url ||= "postgres://newadmin:pass@newhost.db:5432/new_db"
36
+ end
37
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ require "webhookdb"
6
+ require "webhookdb/fixtures"
7
+
8
+ module Webhookdb::Fixtures::OrganizationMembership
9
+ extend Webhookdb::Fixtures
10
+
11
+ fixtured_class Webhookdb::OrganizationMembership
12
+
13
+ base :organization_membership do
14
+ end
15
+
16
+ before_saving do |instance|
17
+ raise "Must call :invite or :verified" if instance.verified.nil?
18
+ instance.customer ||= Webhookdb::Fixtures.customer.create
19
+ instance.organization ||= Webhookdb::Fixtures.organization.create
20
+ instance.membership_role ||= Webhookdb::Role.non_admin_role
21
+ instance
22
+ end
23
+
24
+ decorator :org do |o={}|
25
+ o = Webhookdb::Fixtures.organization(o).create unless o.is_a?(Webhookdb::Organization)
26
+ self.organization = o
27
+ end
28
+
29
+ decorator :customer do |c={}|
30
+ c = Webhookdb::Fixtures.customer(c).create unless c.is_a?(Webhookdb::Customer)
31
+ self.customer = c
32
+ end
33
+
34
+ decorator :invite do
35
+ self.invitation_code ||= "code-" + SecureRandom.hex(4)
36
+ self.verified = false
37
+ end
38
+
39
+ decorator :verified do
40
+ self.verified = true
41
+ end
42
+
43
+ decorator :admin do
44
+ self.membership_role = Webhookdb::Role.admin_role
45
+ end
46
+
47
+ decorator :default do
48
+ self.is_default = true
49
+ end
50
+
51
+ decorator :code do |c|
52
+ self.invitation_code = c
53
+ end
54
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ require "webhookdb"
6
+ require "webhookdb/fixtures"
7
+
8
+ module Webhookdb::Fixtures::Organizations
9
+ extend Webhookdb::Fixtures
10
+
11
+ fixtured_class Webhookdb::Organization
12
+
13
+ base :organization do
14
+ self.name ||= Faker::Company.name + SecureRandom.hex(2)
15
+ self.stripe_customer_id = "cus_" + SecureRandom.hex(8)
16
+ end
17
+
18
+ decorator :with_member, presave: true do |c={}|
19
+ c = Webhookdb::Fixtures.customer.create(c) unless c.is_a?(Webhookdb::Customer)
20
+ Webhookdb::Fixtures.organization_membership.verified.create(customer: c, organization: self)
21
+ end
22
+
23
+ decorator :with_invite, presave: true do |c={}|
24
+ c = Webhookdb::Fixtures.customer.create(c) unless c.is_a?(Webhookdb::Customer)
25
+ Webhookdb::Fixtures.organization_membership.invite.create(customer: c, organization: self)
26
+ end
27
+
28
+ decorator :with_urls do |admin: nil, readonly: nil|
29
+ self.admin_connection_url_raw ||= admin || Faker::Webhookdb.pg_connection
30
+ self.readonly_connection_url_raw ||= readonly || Faker::Webhookdb.pg_connection
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb"
4
+ require "webhookdb/fixtures"
5
+
6
+ module Webhookdb::Fixtures::ResetCodes
7
+ extend Webhookdb::Fixtures
8
+
9
+ fixtured_class Webhookdb::Customer::ResetCode
10
+
11
+ base :reset_code do
12
+ self.transport ||= ["email"].sample
13
+ end
14
+
15
+ before_saving do |instance|
16
+ instance.customer ||= Webhookdb::Fixtures.customer.create
17
+ instance
18
+ end
19
+
20
+ decorator :email do
21
+ self.transport = "email"
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ require "webhookdb"
6
+ require "webhookdb/fixtures"
7
+
8
+ module Webhookdb::Fixtures::ServiceIntegrations
9
+ extend Webhookdb::Fixtures
10
+
11
+ fixtured_class Webhookdb::ServiceIntegration
12
+
13
+ base :service_integration do
14
+ self.service_name ||= "fake_v1"
15
+ self.api_url ||= "https://fake-url.com"
16
+ end
17
+
18
+ before_saving do |instance|
19
+ instance.table_name ||= "#{instance.service_name}_#{SecureRandom.hex(2)}"
20
+ instance.organization ||= Webhookdb::Fixtures.organization.create
21
+ instance
22
+ end
23
+
24
+ decorator :depending_on do |other|
25
+ self.depends_on = other
26
+ end
27
+
28
+ STABLE_ENC_SECRET = "6vHQcB8xlVSmHO2Wxsqk713k7oi_SpIWirUG0YTGUa4="
29
+ decorator :stable_encryption_secret do
30
+ self.data_encryption_secret = STABLE_ENC_SECRET
31
+ end
32
+
33
+ decorator :with_encryption_secret do
34
+ self.data_encryption_secret = Webhookdb::Crypto.encryption_key.base64
35
+ end
36
+
37
+ decorator :with_secrets do
38
+ self.webhook_secret = "fake_whsecret"
39
+ self.backfill_key = "fake_bfkey"
40
+ self.backfill_secret = "fake_bfsecret"
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faker"
4
+ require "securerandom"
5
+
6
+ require "webhookdb"
7
+ require "webhookdb/fixtures"
8
+
9
+ module Webhookdb::Fixtures::Subscriptions
10
+ extend Webhookdb::Fixtures
11
+
12
+ fixtured_class Webhookdb::Subscription
13
+
14
+ base :subscription do
15
+ self.stripe_id ||= "sub_" + SecureRandom.hex(8)
16
+ self.stripe_customer_id ||= "cus_" + SecureRandom.hex(8)
17
+ self.stripe_json ||= {}
18
+ self.stripe_json.merge!("plan" => {"nickname" => "fixtured plan"})
19
+ end
20
+
21
+ decorator :active do
22
+ self.stripe_json.merge!("status" => "active")
23
+ end
24
+
25
+ decorator :canceled do
26
+ self.stripe_json.merge!("status" => "canceled")
27
+ end
28
+
29
+ decorator :for_org, presave: true do |org={}|
30
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
31
+ self.stripe_customer_id = org.stripe_customer_id
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb"
4
+ require "webhookdb/fixtures"
5
+
6
+ module Webhookdb::Fixtures::SyncTargets
7
+ extend Webhookdb::Fixtures
8
+
9
+ fixtured_class Webhookdb::SyncTarget
10
+
11
+ base :sync_target do
12
+ self.period_seconds ||= Faker::Number.between(from: 30.seconds.to_i, to: 24.hours.to_i)
13
+ self.connection_url ||= Webhookdb::Postgres::Model.uri
14
+ end
15
+
16
+ before_saving do |instance|
17
+ instance.service_integration ||= Webhookdb::Fixtures.service_integration.create
18
+ instance
19
+ end
20
+
21
+ decorator :postgres do
22
+ self.connection_url = Webhookdb::Postgres::Model.uri
23
+ end
24
+
25
+ decorator :snowflake do
26
+ self.connection_url = Webhookdb::Snowflake.test_url
27
+ end
28
+
29
+ decorator :https do |url=nil|
30
+ self.connection_url = url || Faker::Internet.url
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "webhookdb"
4
+ require "webhookdb/fixtures"
5
+
6
+ module Webhookdb::Fixtures::WebhookSubscriptions
7
+ extend Webhookdb::Fixtures
8
+
9
+ fixtured_class Webhookdb::WebhookSubscription
10
+
11
+ base :webhook_subscription do
12
+ self.opaque_id ||= SecureRandom.hex(8)
13
+ self.webhook_secret ||= "wh_secret_" + SecureRandom.hex(2)
14
+ self.deliver_to_url ||= Faker::Internet.url
15
+ end
16
+
17
+ before_saving do |instance|
18
+ unless instance.organization.present?
19
+ instance.service_integration ||= Webhookdb::Fixtures.service_integration.create
20
+ end
21
+ instance
22
+ end
23
+
24
+ decorator :for_org do |org={}|
25
+ org = Webhookdb::Fixtures.organization.create(org) unless org.is_a?(Webhookdb::Organization)
26
+ self.service_integration = nil
27
+ self.organization = org
28
+ end
29
+
30
+ decorator :for_service_integration do |sint={}|
31
+ sint = Webhookdb::Fixtures.service_integration.create(sint) unless sint.is_a?(Webhookdb::ServiceIntegration)
32
+ self.organization = nil
33
+ self.service_integration = sint
34
+ end
35
+ end