etl-integrations 0.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +34 -0
  4. data/.ruby-version +1 -0
  5. data/.vscode/settings.json +5 -0
  6. data/CHANGELOG.md +38 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +105 -0
  10. data/Rakefile +12 -0
  11. data/lib/multiwoven/integrations/config.rb +13 -0
  12. data/lib/multiwoven/integrations/core/base_connector.rb +70 -0
  13. data/lib/multiwoven/integrations/core/constants.rb +46 -0
  14. data/lib/multiwoven/integrations/core/destination_connector.rb +14 -0
  15. data/lib/multiwoven/integrations/core/fullrefresher.rb +19 -0
  16. data/lib/multiwoven/integrations/core/http_client.rb +34 -0
  17. data/lib/multiwoven/integrations/core/query_builder.rb +27 -0
  18. data/lib/multiwoven/integrations/core/rate_limiter.rb +19 -0
  19. data/lib/multiwoven/integrations/core/source_connector.rb +38 -0
  20. data/lib/multiwoven/integrations/core/utils.rb +104 -0
  21. data/lib/multiwoven/integrations/destination/airtable/client.rb +153 -0
  22. data/lib/multiwoven/integrations/destination/airtable/config/catalog.json +6 -0
  23. data/lib/multiwoven/integrations/destination/airtable/config/meta.json +15 -0
  24. data/lib/multiwoven/integrations/destination/airtable/config/spec.json +22 -0
  25. data/lib/multiwoven/integrations/destination/airtable/icon.svg +6 -0
  26. data/lib/multiwoven/integrations/destination/airtable/schema_helper.rb +141 -0
  27. data/lib/multiwoven/integrations/destination/facebook_custom_audience/client.rb +124 -0
  28. data/lib/multiwoven/integrations/destination/facebook_custom_audience/config/catalog.json +42 -0
  29. data/lib/multiwoven/integrations/destination/facebook_custom_audience/config/meta.json +15 -0
  30. data/lib/multiwoven/integrations/destination/facebook_custom_audience/config/spec.json +27 -0
  31. data/lib/multiwoven/integrations/destination/facebook_custom_audience/icon.svg +23 -0
  32. data/lib/multiwoven/integrations/destination/google_sheets/client.rb +231 -0
  33. data/lib/multiwoven/integrations/destination/google_sheets/config/catalog.json +6 -0
  34. data/lib/multiwoven/integrations/destination/google_sheets/config/meta.json +15 -0
  35. data/lib/multiwoven/integrations/destination/google_sheets/config/spec.json +74 -0
  36. data/lib/multiwoven/integrations/destination/google_sheets/icon.svg +1 -0
  37. data/lib/multiwoven/integrations/destination/hubspot/client.rb +107 -0
  38. data/lib/multiwoven/integrations/destination/hubspot/config/catalog.json +351 -0
  39. data/lib/multiwoven/integrations/destination/hubspot/config/meta.json +15 -0
  40. data/lib/multiwoven/integrations/destination/hubspot/config/spec.json +17 -0
  41. data/lib/multiwoven/integrations/destination/hubspot/icon.svg +5 -0
  42. data/lib/multiwoven/integrations/destination/klaviyo/client.rb +116 -0
  43. data/lib/multiwoven/integrations/destination/klaviyo/config/catalog.json +103 -0
  44. data/lib/multiwoven/integrations/destination/klaviyo/config/meta.json +15 -0
  45. data/lib/multiwoven/integrations/destination/klaviyo/config/spec.json +22 -0
  46. data/lib/multiwoven/integrations/destination/klaviyo/icon.svg +6 -0
  47. data/lib/multiwoven/integrations/destination/postgresql/client.rb +123 -0
  48. data/lib/multiwoven/integrations/destination/postgresql/config/meta.json +15 -0
  49. data/lib/multiwoven/integrations/destination/postgresql/config/spec.json +68 -0
  50. data/lib/multiwoven/integrations/destination/postgresql/icon.svg +20 -0
  51. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/client.rb +114 -0
  52. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/catalog.json +6 -0
  53. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/meta.json +16 -0
  54. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/config/spec.json +49 -0
  55. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/icon.svg +16 -0
  56. data/lib/multiwoven/integrations/destination/salesforce_consumer_goods_cloud/schema_helper.rb +132 -0
  57. data/lib/multiwoven/integrations/destination/salesforce_crm/client.rb +117 -0
  58. data/lib/multiwoven/integrations/destination/salesforce_crm/config/catalog.json +320 -0
  59. data/lib/multiwoven/integrations/destination/salesforce_crm/config/meta.json +15 -0
  60. data/lib/multiwoven/integrations/destination/salesforce_crm/config/spec.json +43 -0
  61. data/lib/multiwoven/integrations/destination/salesforce_crm/icon.svg +16 -0
  62. data/lib/multiwoven/integrations/destination/sftp/client.rb +133 -0
  63. data/lib/multiwoven/integrations/destination/sftp/config/catalog.json +16 -0
  64. data/lib/multiwoven/integrations/destination/sftp/config/meta.json +16 -0
  65. data/lib/multiwoven/integrations/destination/sftp/config/spec.json +50 -0
  66. data/lib/multiwoven/integrations/destination/sftp/icon.svg +1 -0
  67. data/lib/multiwoven/integrations/destination/slack/client.rb +114 -0
  68. data/lib/multiwoven/integrations/destination/slack/config/catalog.json +22 -0
  69. data/lib/multiwoven/integrations/destination/slack/config/meta.json +15 -0
  70. data/lib/multiwoven/integrations/destination/slack/config/spec.json +22 -0
  71. data/lib/multiwoven/integrations/destination/slack/icon.svg +26 -0
  72. data/lib/multiwoven/integrations/destination/stripe/client.rb +82 -0
  73. data/lib/multiwoven/integrations/destination/stripe/config/catalog.json +128 -0
  74. data/lib/multiwoven/integrations/destination/stripe/config/meta.json +15 -0
  75. data/lib/multiwoven/integrations/destination/stripe/config/spec.json +17 -0
  76. data/lib/multiwoven/integrations/destination/stripe/icon.svg +10 -0
  77. data/lib/multiwoven/integrations/destination/tally/client.rb +151 -0
  78. data/lib/multiwoven/integrations/destination/tally/config/catalog.json +62 -0
  79. data/lib/multiwoven/integrations/destination/tally/config/meta.json +15 -0
  80. data/lib/multiwoven/integrations/destination/tally/config/spec.json +45 -0
  81. data/lib/multiwoven/integrations/destination/tally/icon.svg +7 -0
  82. data/lib/multiwoven/integrations/protocol/protocol.json +189 -0
  83. data/lib/multiwoven/integrations/protocol/protocol.rb +216 -0
  84. data/lib/multiwoven/integrations/rollout.rb +32 -0
  85. data/lib/multiwoven/integrations/service.rb +79 -0
  86. data/lib/multiwoven/integrations/source/bigquery/client.rb +98 -0
  87. data/lib/multiwoven/integrations/source/bigquery/config/meta.json +15 -0
  88. data/lib/multiwoven/integrations/source/bigquery/config/spec.json +82 -0
  89. data/lib/multiwoven/integrations/source/bigquery/icon.svg +1 -0
  90. data/lib/multiwoven/integrations/source/databricks/client.rb +98 -0
  91. data/lib/multiwoven/integrations/source/databricks/config/meta.json +16 -0
  92. data/lib/multiwoven/integrations/source/databricks/config/spec.json +56 -0
  93. data/lib/multiwoven/integrations/source/databricks/icon.svg +19 -0
  94. data/lib/multiwoven/integrations/source/postgresql/client.rb +109 -0
  95. data/lib/multiwoven/integrations/source/postgresql/config/meta.json +15 -0
  96. data/lib/multiwoven/integrations/source/postgresql/config/spec.json +69 -0
  97. data/lib/multiwoven/integrations/source/postgresql/icon.svg +20 -0
  98. data/lib/multiwoven/integrations/source/redshift/client.rb +109 -0
  99. data/lib/multiwoven/integrations/source/redshift/config/meta.json +15 -0
  100. data/lib/multiwoven/integrations/source/redshift/config/spec.json +71 -0
  101. data/lib/multiwoven/integrations/source/redshift/icon.svg +15 -0
  102. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/client.rb +123 -0
  103. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/config/catalog.json +6 -0
  104. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/config/meta.json +17 -0
  105. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/config/spec.json +50 -0
  106. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/icon.svg +16 -0
  107. data/lib/multiwoven/integrations/source/salesforce_consumer_goods_cloud/schema_helper.rb +130 -0
  108. data/lib/multiwoven/integrations/source/snowflake/client.rb +92 -0
  109. data/lib/multiwoven/integrations/source/snowflake/config/meta.json +15 -0
  110. data/lib/multiwoven/integrations/source/snowflake/config/spec.json +82 -0
  111. data/lib/multiwoven/integrations/source/snowflake/icon.svg +10 -0
  112. data/lib/multiwoven/integrations/source/zoho_books/client.rb +155 -0
  113. data/lib/multiwoven/integrations/source/zoho_books/config/meta.json +16 -0
  114. data/lib/multiwoven/integrations/source/zoho_books/config/spec.json +43 -0
  115. data/lib/multiwoven/integrations/source/zoho_books/icon.svg +16 -0
  116. data/lib/multiwoven/integrations.rb +71 -0
  117. data/multiwoven-integrations-0.1.68.gem +0 -0
  118. data/sig/multiwoven/integrations.rbs +6 -0
  119. metadata +515 -0
@@ -0,0 +1,16 @@
1
+ {
2
+ "data": {
3
+ "name": "Sftp",
4
+ "title": "SFTP",
5
+ "connector_type": "destination",
6
+ "connectorSubtype": "file",
7
+ "category": "File Storage",
8
+ "documentation_url": "https://docs.mutliwoven.com",
9
+ "github_issue_label": "destination-sftp",
10
+ "icon": "icon.svg",
11
+ "license": "MIT",
12
+ "release_stage": "alpha",
13
+ "support_level": "community",
14
+ "tags": ["language:ruby", "multiwoven"]
15
+ }
16
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/integrations/destination/klaviyo",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "SFTP",
7
+ "required": ["host", "username", "password", "destination_path"],
8
+ "properties": {
9
+ "host": {
10
+ "title": "Host",
11
+ "description": "Hostname of the SFTP server.",
12
+ "type": "string",
13
+ "order": 0
14
+ },
15
+ "port": {
16
+ "title": "Port",
17
+ "description": "Port of the SFTP server.",
18
+ "type": "integer",
19
+ "minimum": 0,
20
+ "maximum": 65536,
21
+ "default": 22,
22
+ "order": 1
23
+ },
24
+ "username": {
25
+ "title": "User Name",
26
+ "description": "Username to use to access the SFTP server.",
27
+ "type": "string",
28
+ "order": 2
29
+ },
30
+ "password": {
31
+ "title": "Password",
32
+ "description": "Password associated with the username.",
33
+ "type": "string",
34
+ "order": 3
35
+ },
36
+ "destination_path": {
37
+ "title": "Destination path",
38
+ "type": "string",
39
+ "description": "Path to the directory where files will be written.",
40
+ "order": 4
41
+ },
42
+ "file_name": {
43
+ "title": "File Name",
44
+ "type": "string",
45
+ "description": "Name of the file to be written.",
46
+ "order": 5
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="none"><g clip-path="url(#a)"><path fill="#615EFF" d="M200.745 218.706a12.051 12.051 0 0 1-3.483 8.475 11.837 11.837 0 0 1-8.4 3.514H62.072c-3.15 0-6.173-1.261-8.403-3.507a12.053 12.053 0 0 1-3.49-8.472V31.485a12.08 12.08 0 0 1 .903-4.593 11.996 11.996 0 0 1 2.578-3.894 11.875 11.875 0 0 1 3.86-2.6 11.791 11.791 0 0 1 4.552-.912h81.371l57.302 58.96v140.26Z"/><path fill="#fff" d="M83.868 156.832c-.142-1.429-.75-2.539-1.822-3.33-1.074-.792-2.53-1.187-4.37-1.187-1.25 0-2.305.177-3.166.531-.861.343-1.522.821-1.981 1.435a3.457 3.457 0 0 0-.673 2.09c-.023.65.112 1.217.407 1.701.307.484.725.903 1.256 1.258.53.342 1.144.643 1.84.903a19.02 19.02 0 0 0 2.229.638l3.255.779c1.58.354 3.03.827 4.352 1.417 1.32.591 2.464 1.317 3.431 2.179a9.057 9.057 0 0 1 2.247 3.047c.542 1.169.82 2.509.831 4.021-.011 2.22-.578 4.145-1.698 5.775-1.109 1.617-2.712 2.875-4.811 3.773-2.088.885-4.606 1.328-7.554 1.328-2.925 0-5.472-.449-7.642-1.346-2.158-.898-3.845-2.226-5.06-3.986-1.202-1.771-1.833-3.962-1.892-6.572h7.412c.082 1.217.43 2.232 1.044 3.047.625.803 1.456 1.411 2.494 1.825 1.05.401 2.235.602 3.555.602 1.298 0 2.424-.189 3.38-.567.966-.378 1.715-.903 2.246-1.576.53-.673.796-1.447.796-2.321 0-.815-.242-1.5-.725-2.055-.472-.555-1.168-1.027-2.088-1.417-.908-.39-2.022-.744-3.343-1.063l-3.945-.992c-3.054-.744-5.466-1.907-7.235-3.489-1.77-1.583-2.648-3.714-2.636-6.395-.012-2.196.572-4.116 1.751-5.757 1.192-1.641 2.825-2.923 4.9-3.844 2.076-.921 4.435-1.382 7.076-1.382 2.69 0 5.036.461 7.04 1.382 2.018.921 3.586 2.203 4.706 3.844 1.12 1.641 1.699 3.543 1.734 5.704h-7.341Zm12.988 25.844v-36.278h23.988v6.324h-16.328v8.645h14.736v6.324h-14.736v14.985h-7.66Zm27.76-29.954v-6.324h29.754v6.324h-11.091v29.954h-7.571v-29.954h-11.092Zm34.654 29.954v-36.278h14.294c2.748 0 5.089.526 7.023 1.577 1.934 1.039 3.408 2.486 4.422 4.34 1.026 1.842 1.539 3.968 1.539 6.377s-.519 4.535-1.557 6.377c-1.037 1.842-2.541 3.277-4.51 4.304-1.958 1.028-4.329 1.541-7.112 1.541h-9.11v-6.146h7.872c1.474 0 2.689-.254 3.644-.762.967-.52 1.686-1.234 2.158-2.143.484-.921.725-1.978.725-3.171 0-1.205-.241-2.256-.725-3.153-.472-.91-1.191-1.612-2.158-2.108-.967-.508-2.194-.762-3.679-.762h-5.166v30.007h-7.66Z"/><path fill="#1A194D" d="m149.75 76.907 50.996 49.177V78.101h-45.173a11.33 11.33 0 0 1-5.643-1.433l-.18.24Z" opacity=".3"/><path fill="#C5C4FF" d="M200.746 78.35h-45.297a11.836 11.836 0 0 1-8.399-3.514 12.055 12.055 0 0 1-3.484-8.475v-47.2l57.18 59.189Z"/></g><defs><clipPath id="a"><path fill="#fff" d="M50 19h151v212H50z"/></clipPath></defs></svg>
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module Slack
7
+ include Multiwoven::Integrations::Core
8
+
9
+ class Client < DestinationConnector
10
+ prepend Multiwoven::Integrations::Core::RateLimiter
11
+ attr_accessor :channel_id
12
+
13
+ def check_connection(connection_config)
14
+ configure_slack(connection_config[:api_token])
15
+ client = ::Slack::Web::Client.new
16
+ client.auth_test
17
+ success_status
18
+ rescue StandardError => e
19
+ failure_status(e)
20
+ end
21
+
22
+ def discover(_connection_config = nil)
23
+ catalog = build_catalog(load_catalog)
24
+ catalog.to_multiwoven_message
25
+ rescue StandardError => e
26
+ handle_exception("SLACK:DISCOVER:EXCEPTION", "error", e)
27
+ end
28
+
29
+ def write(sync_config, records, action = "create")
30
+ # Currently as we only create a message for each record in slack, we are not using actions.
31
+ # This will be changed in future.
32
+
33
+ @action = sync_config.stream.action || action
34
+ connection_config = sync_config.destination.connection_specification.with_indifferent_access
35
+ configure_slack(connection_config[:api_token])
36
+ @client = ::Slack::Web::Client.new
37
+ @channel_id = connection_config[:channel_id]
38
+ process_records(records, sync_config.stream)
39
+ rescue StandardError => e
40
+ handle_exception("SLACK:WRITE:EXCEPTION", "error", e)
41
+ end
42
+
43
+ private
44
+
45
+ def configure_slack(api_token)
46
+ ::Slack.configure do |config|
47
+ config.token = api_token
48
+ end
49
+ end
50
+
51
+ def process_records(records, stream)
52
+ write_success = 0
53
+ write_failure = 0
54
+ records.each do |record_object|
55
+ process_record(stream, record_object.with_indifferent_access)
56
+ write_success += 1
57
+ rescue StandardError => e
58
+ write_failure += 1
59
+ handle_exception("SLACK:CRM:WRITE:EXCEPTION", "error", e)
60
+ end
61
+ tracking_message(write_success, write_failure)
62
+ end
63
+
64
+ def process_record(stream, record)
65
+ send_data_to_slack(stream[:name], record)
66
+ end
67
+
68
+ def send_data_to_slack(stream_name, record = {})
69
+ args = build_args(stream_name, record)
70
+ @client.send(stream_name, **args)
71
+ end
72
+
73
+ def build_args(stream_name, record)
74
+ case stream_name
75
+ when "chat_postMessage"
76
+ { channel: channel_id, text: slack_code_block(record) }
77
+ else
78
+ raise "Stream name not found: #{stream_name}"
79
+ end
80
+ end
81
+
82
+ def slack_code_block(data)
83
+ longest_key = data.keys.map(&:to_s).max_by(&:length).length
84
+ table_str = "```\n"
85
+ data.each do |key, value|
86
+ table_str += "#{key.to_s.ljust(longest_key)} : #{value}\n"
87
+ end
88
+ table_str += "```"
89
+
90
+ table_str
91
+ end
92
+
93
+ def success_status
94
+ ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
95
+ end
96
+
97
+ def failure_status(error)
98
+ ConnectionStatus.new(status: ConnectionStatusType["failed"], message: error.message).to_multiwoven_message
99
+ end
100
+
101
+ def load_catalog
102
+ read_json(CATALOG_SPEC_PATH)
103
+ end
104
+
105
+ def tracking_message(success, failure)
106
+ Multiwoven::Integrations::Protocol::TrackingMessage.new(
107
+ success: success, failed: failure
108
+ ).to_multiwoven_message
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,22 @@
1
+ {
2
+ "streams": [
3
+ {
4
+ "name": "chat_postMessage",
5
+ "action": "create",
6
+ "json_schema": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "text": {
11
+ "type": ["string", "null"]
12
+ }
13
+ },
14
+ "oneOf": [{ "required": ["text"] }]
15
+ },
16
+ "supported_sync_modes": ["incremental"],
17
+ "request_rate_limit": 60,
18
+ "request_rate_limit_unit": "minute",
19
+ "request_rate_concurrency": 1
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "data": {
3
+ "name": "Slack",
4
+ "title": "Slack",
5
+ "connector_type": "destination",
6
+ "category": "Team Collaboration",
7
+ "documentation_url": "https://docs.mutliwoven.com",
8
+ "github_issue_label": "destination-slack",
9
+ "icon": "icon.svg",
10
+ "license": "MIT",
11
+ "release_stage": "alpha",
12
+ "support_level": "community",
13
+ "tags": ["language:ruby", "multiwoven"]
14
+ }
15
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/integrations/destination/slack",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "Slack",
7
+ "type": "object",
8
+ "required": ["api_token", "channel_id"],
9
+ "properties": {
10
+ "api_token": {
11
+ "type": "string",
12
+ "title": "API Token",
13
+ "order": 0
14
+ },
15
+ "channel_id": {
16
+ "type": "string",
17
+ "title": "Channel ID",
18
+ "order": 1
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,26 @@
1
+ <svg width="1025" height="1025" viewBox="0 0 1025 1025" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ d="M215.74 647.688C215.74 706.893 167.375 755.258 108.17 755.258C48.9648 755.258 0.600006 706.893 0.600006 647.688C0.600006 588.483 48.9648 540.118 108.17 540.118H215.74V647.688Z"
4
+ fill="#E01E5A" />
5
+ <path
6
+ d="M269.942 647.688C269.942 588.483 318.307 540.118 377.512 540.118C436.717 540.118 485.082 588.483 485.082 647.688V917.03C485.082 976.235 436.717 1024.6 377.512 1024.6C318.307 1024.6 269.942 976.235 269.942 917.03V647.688Z"
7
+ fill="#E01E5A" />
8
+ <path
9
+ d="M377.512 215.74C318.307 215.74 269.942 167.375 269.942 108.17C269.942 48.9648 318.307 0.600006 377.512 0.600006C436.717 0.600006 485.082 48.9648 485.082 108.17V215.74H377.512Z"
10
+ fill="#36C5F0" />
11
+ <path
12
+ d="M377.512 269.942C436.717 269.942 485.082 318.307 485.082 377.512C485.082 436.717 436.717 485.082 377.512 485.082H108.17C48.9648 485.082 0.600006 436.717 0.600006 377.512C0.600006 318.307 48.9648 269.942 108.17 269.942H377.512Z"
13
+ fill="#36C5F0" />
14
+ <path
15
+ d="M809.46 377.512C809.46 318.307 857.825 269.942 917.03 269.942C976.235 269.942 1024.6 318.307 1024.6 377.512C1024.6 436.717 976.235 485.082 917.03 485.082H809.46V377.512Z"
16
+ fill="#2EB67D" />
17
+ <path
18
+ d="M755.258 377.512C755.258 436.717 706.893 485.082 647.688 485.082C588.483 485.082 540.118 436.717 540.118 377.512V108.17C540.118 48.9648 588.483 0.600006 647.688 0.600006C706.893 0.600006 755.258 48.9648 755.258 108.17V377.512Z"
19
+ fill="#2EB67D" />
20
+ <path
21
+ d="M647.688 809.46C706.893 809.46 755.258 857.825 755.258 917.03C755.258 976.235 706.893 1024.6 647.688 1024.6C588.483 1024.6 540.118 976.235 540.118 917.03V809.46H647.688Z"
22
+ fill="#ECB22E" />
23
+ <path
24
+ d="M647.688 755.258C588.483 755.258 540.118 706.893 540.118 647.688C540.118 588.483 588.483 540.118 647.688 540.118H917.03C976.235 540.118 1024.6 588.483 1024.6 647.688C1024.6 706.893 976.235 755.258 917.03 755.258H647.688Z"
25
+ fill="#ECB22E" />
26
+ </svg>
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module Stripe
7
+ include Multiwoven::Integrations::Core
8
+
9
+ API_VERSION = "59.0"
10
+
11
+ class Client < DestinationConnector
12
+ prepend Multiwoven::Integrations::Core::RateLimiter
13
+ def check_connection(connection_config)
14
+ connection_config = connection_config.with_indifferent_access
15
+ initialize_client(connection_config)
16
+ authenticate_client
17
+ success_status
18
+ rescue StandardError => e
19
+ failure_status(e)
20
+ end
21
+
22
+ def discover(_connection_config = nil)
23
+ catalog = build_catalog(load_catalog)
24
+ catalog.to_multiwoven_message
25
+ rescue StandardError => e
26
+ handle_exception("STRIPE:CRM:DISCOVER:EXCEPTION", "error", e)
27
+ end
28
+
29
+ def write(sync_config, records, action = "create")
30
+ @action = sync_config.stream.action || action
31
+ initialize_client(sync_config.destination.connection_specification)
32
+ process_records(records, sync_config.stream)
33
+ rescue StandardError => e
34
+ handle_exception("STRIPE:CRM:WRITE:EXCEPTION", "error", e)
35
+ end
36
+
37
+ private
38
+
39
+ def initialize_client(config)
40
+ config = config.with_indifferent_access
41
+ ::Stripe.api_key = config[:api_key]
42
+ @client = ::Stripe
43
+ end
44
+
45
+ def process_records(records, stream)
46
+ write_success = 0
47
+ write_failure = 0
48
+ properties = stream.json_schema[:properties]
49
+ records.each do |record_object|
50
+ record = extract_data(record_object, properties)
51
+ klass = @client.const_get(stream.name)
52
+ klass.send(@action, record)
53
+ write_success += 1
54
+ rescue StandardError => e
55
+ handle_exception("STRIPE:CRM:WRITE:EXCEPTION", "error", e)
56
+ write_failure += 1
57
+ end
58
+ tracking_message(write_success, write_failure)
59
+ end
60
+
61
+ def authenticate_client
62
+ @client::Customer.list
63
+ end
64
+
65
+ def load_catalog
66
+ read_json(CATALOG_SPEC_PATH)
67
+ end
68
+
69
+ def tracking_message(success, failure)
70
+ Multiwoven::Integrations::Protocol::TrackingMessage.new(
71
+ success: success, failed: failure
72
+ ).to_multiwoven_message
73
+ end
74
+
75
+ def log_debug(message)
76
+ Multiwoven::Integrations::Service.logger.debug(message)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,128 @@
1
+ {
2
+ "request_rate_limit": 100000,
3
+ "request_rate_limit_unit": "day",
4
+ "request_rate_concurrency": 10,
5
+ "streams": [
6
+ {
7
+ "name": "Customer",
8
+ "action": "create",
9
+ "json_schema": {
10
+ "type": "object",
11
+ "additionalProperties": true,
12
+ "properties": {
13
+ "email": {
14
+ "type": "string"
15
+ },
16
+ "description": {
17
+ "type": "string"
18
+ },
19
+ "name": {
20
+ "type": "string"
21
+ },
22
+ "payment_method": {
23
+ "type": "string"
24
+ },
25
+ "metadata": {
26
+ "type": "object"
27
+ },
28
+ "phone": {
29
+ "type": "string"
30
+ },
31
+ "address": {
32
+ "type": "object",
33
+ "additionalProperties": true,
34
+ "properties": {
35
+ "city": {
36
+ "type": "string"
37
+ },
38
+ "country": {
39
+ "type": "string"
40
+ },
41
+ "line1": {
42
+ "type": "string"
43
+ },
44
+ "line2": {
45
+ "type": "string"
46
+ },
47
+ "postal_code": {
48
+ "type": "string"
49
+ },
50
+ "state": {
51
+ "type": "string"
52
+ }
53
+ }
54
+ },
55
+ "shipping": {
56
+ "type": "object",
57
+ "additionalProperties": true,
58
+ "properties": {
59
+ "address": {
60
+ "type": "object",
61
+ "additionalProperties": true,
62
+ "properties": {
63
+ "city": {
64
+ "type": "string"
65
+ },
66
+ "country": {
67
+ "type": "string"
68
+ },
69
+ "line1": {
70
+ "type": "string"
71
+ },
72
+ "line2": {
73
+ "type": "string"
74
+ },
75
+ "postal_code": {
76
+ "type": "string"
77
+ },
78
+ "state": {
79
+ "type": "string"
80
+ }
81
+ }
82
+ },
83
+ "name": {
84
+ "type": "string"
85
+ },
86
+ "phone": {
87
+ "type": "string"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "supported_sync_modes": ["incremental"],
94
+ "source_defined_cursor": true,
95
+ "default_cursor_field": ["updated"],
96
+ "source_defined_primary_key": [["Id"]]
97
+ },
98
+ {
99
+ "name": "Product",
100
+ "action": "create",
101
+ "json_schema": {
102
+ "type": "object",
103
+ "additionalProperties": true,
104
+ "required": ["name"],
105
+ "properties": {
106
+ "name": {
107
+ "type": "string"
108
+ },
109
+ "description": {
110
+ "type": "string"
111
+ },
112
+ "active": {
113
+ "type": "boolean"
114
+ },
115
+ "id": {
116
+ "type": "string"
117
+ },
118
+ "metadata": {
119
+ "type": "object"
120
+ }
121
+ }
122
+ },
123
+ "supported_sync_modes": ["incremental"],
124
+ "source_defined_cursor": true,
125
+ "default_cursor_field": ["updated"]
126
+ }
127
+ ]
128
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "data": {
3
+ "name": "Stripe",
4
+ "title": "Stripe",
5
+ "connector_type": "destination",
6
+ "category": "Payments",
7
+ "documentation_url": "https://docs.mutliwoven.com",
8
+ "github_issue_label": "destination-stripe",
9
+ "icon": "icon.svg",
10
+ "license": "MIT",
11
+ "release_stage": "alpha",
12
+ "support_level": "community",
13
+ "tags": ["language:ruby", "multiwoven"]
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/integrations/destination/payments/stripe",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "Stripe",
7
+ "type": "object",
8
+ "required": ["api_key"],
9
+ "properties": {
10
+ "api_key": {
11
+ "type": "string",
12
+ "title": "API Key",
13
+ "order": 0
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28.87 28.87" id="stripe">
2
+ <g data-name="Layer 2">
3
+ <g data-name="Layer 1">
4
+ <rect width="28.87" height="28.87" fill="#6772e5" rx="6.48" ry="6.48"></rect>
5
+ <path fill="#fff" fill-rule="evenodd"
6
+ d="M13.3 11.2c0-.69.57-1 1.49-1a9.84 9.84 0 0 1 4.37 1.13V7.24a11.6 11.6 0 0 0-4.36-.8c-3.56 0-5.94 1.86-5.94 5 0 4.86 6.68 4.07 6.68 6.17 0 .81-.71 1.07-1.68 1.07A11.06 11.06 0 0 1 9 17.25v4.19a12.19 12.19 0 0 0 4.8 1c3.65 0 6.17-1.8 6.17-5 .03-5.21-6.67-4.27-6.67-6.24z">
7
+ </path>
8
+ </g>
9
+ </g>
10
+ </svg>