multiwoven-integrations 0.1.65 → 0.1.66

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11fafa89e8f7adc1648906c3fa57fecb422d64a502d829e5fd437f7ed48169a2
4
- data.tar.gz: fc3646918312c3293349d47598f1067f17a8614b0f6dc926c05f581642098d30
3
+ metadata.gz: d41f10c87a8d9a6b6d5b3f04952afcc4c906266d79a2c0935b4468d6ccb4592e
4
+ data.tar.gz: 5a09773b98f94d2ecf401ee8c46affe0684704b65a5d0dd73838418dbcf2d78d
5
5
  SHA512:
6
- metadata.gz: e885c02a7fce0cd2032b2874a4ca0c0967f358e4a45ebf7b70d2c0211f75772e76432c9b8d9968d0bcd46d5d00c466d920043660ac3d9ce9db6f35722d9b4d23
7
- data.tar.gz: af7ef1ee3ab3c78c2378a0635d35acaaed0a0cbaa36a146391844bb1ca1fd436a0494ea0a96178b57cb03ee3bcc6ca377a4698ee85b29de222a14473c9db5890
6
+ metadata.gz: 3cff2743efecd6b06a1d7470d11ef3410adea1bd81ee5f028468d964a6630f8f3bafb4f5b7729aaa514afbb4608cacd0ee44723cb27863facc88dd0c5143c773
7
+ data.tar.gz: bbfc548d9a8e0df2efcf466a728fd3d13e6eb3a8fe49ed7844d7c55249764b515e57f5c1a915601ec3e570195835b8a3162d5f3b9bd08b092c652c0990e8e015
@@ -26,6 +26,8 @@ module Multiwoven
26
26
  }
27
27
  }.freeze
28
28
 
29
+ ZENDESK_URL_SUFFIX = "zendesk.com/api/v2/"
30
+
29
31
  FACEBOOK_AUDIENCE_GET_ALL_ACCOUNTS = "https://graph.facebook.com/v18.0/me/adaccounts?fields=id,name"
30
32
 
31
33
  AIRTABLE_URL_BASE = "https://api.airtable.com/v0/"
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Multiwoven
4
+ module Integrations
5
+ module Destination
6
+ module Zendesk
7
+ include Multiwoven::Integrations::Core
8
+ class Client < DestinationConnector
9
+ prepend Multiwoven::Integrations::Core::RateLimiter
10
+ def check_connection(connection_config)
11
+ connection_config = connection_config.with_indifferent_access
12
+ initialize_client(connection_config)
13
+ authenticate_client
14
+ success_status
15
+ rescue StandardError => e
16
+ handle_exception("ZENDESK:CHECK_CONNECTION:EXCEPTION", "error", e)
17
+ failure_status(e)
18
+ end
19
+
20
+ def discover(_connection_config = nil)
21
+ catalog = build_catalog(load_catalog)
22
+ catalog.to_multiwoven_message
23
+ rescue StandardError => e
24
+ handle_exception("ZENDESK:DISCOVER:EXCEPTION", "error", e)
25
+ failure_status(e)
26
+ end
27
+
28
+ def write(sync_config, records, action = "create")
29
+ @action = sync_config.stream.action || action
30
+ initialize_client(sync_config.destination.connection_specification)
31
+ process_records(records, sync_config.stream)
32
+ rescue StandardError => e
33
+ handle_exception("ZENDESK:WRITE:EXCEPTION", "error", e)
34
+ failure_status(e)
35
+ end
36
+
37
+ private
38
+
39
+ def initialize_client(connection_config)
40
+ connection_config = connection_config.with_indifferent_access
41
+ @client = ZendeskAPI::Client.new do |config|
42
+ config.url = "#{connection_config[:subdomain]}.#{ZENDESK_URL_SUFFIX}"
43
+ config.username = connection_config[:username]
44
+ config.password = connection_config[:password]
45
+ end
46
+ end
47
+
48
+ def authenticate_client
49
+ @client.tickets.page(1).per_page(1).fetch
50
+ rescue ZendeskAPI::Error => e
51
+ raise StandardError, "Authentication failed: #{e.message}"
52
+ end
53
+
54
+ def process_records(records, stream)
55
+ write_success = 0
56
+ write_failure = 0
57
+
58
+ records.each do |record|
59
+ zendesk_data = prepare_record_data(record, stream.name)
60
+ plural_stream_name = pluralize_stream_name(stream.name.downcase)
61
+
62
+ if @action == "create"
63
+ @client.send(plural_stream_name).create!(zendesk_data)
64
+ else
65
+ existing_record = @client.send(plural_stream_name).find(id: record[:id])
66
+ existing_record.update!(zendesk_data)
67
+ end
68
+
69
+ write_success += 1
70
+ rescue StandardError => e
71
+ handle_exception("ZENDESK:WRITE_RECORD:EXCEPTION", "error", e)
72
+ write_failure += 1
73
+ end
74
+
75
+ tracking_message(write_success, write_failure)
76
+ end
77
+
78
+ def pluralize_stream_name(name)
79
+ { "ticket" => "tickets", "user" => "users" }.fetch(name, name)
80
+ end
81
+
82
+ def prepare_record_data(record, type)
83
+ case type
84
+ when "Tickets"
85
+ {
86
+ subject: record[:subject],
87
+ comment: { body: record[:description] },
88
+ priority: record[:priority],
89
+ status: record[:status],
90
+ requester_id: record[:requester_id],
91
+ assignee_id: record[:assignee_id],
92
+ tags: record[:tags]
93
+ }
94
+ when "Users"
95
+ {
96
+ name: record[:name],
97
+ email: record[:email],
98
+ role: record[:role]
99
+ }
100
+ else
101
+ raise StandardError, "Unsupported record type: #{type}"
102
+ end
103
+ end
104
+
105
+ def load_catalog
106
+ read_json(CATALOG_SPEC_PATH)
107
+ end
108
+
109
+ def tracking_message(success, failure)
110
+ Multiwoven::Integrations::Protocol::TrackingMessage.new(
111
+ success: success, failed: failure
112
+ ).to_multiwoven_message
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,110 @@
1
+ {
2
+ "request_rate_limit": 700,
3
+ "request_rate_limit_unit": "minute",
4
+ "request_rate_concurrency": 10,
5
+ "streams": [
6
+ {
7
+ "name": "tickets",
8
+ "action": "create",
9
+ "json_schema": {
10
+ "type": "object",
11
+ "additionalProperties": true,
12
+ "properties": {
13
+ "id": {
14
+ "type": "integer"
15
+ },
16
+ "subject": {
17
+ "type": "string"
18
+ },
19
+ "description": {
20
+ "type": "string"
21
+ },
22
+ "status": {
23
+ "type": "string"
24
+ },
25
+ "priority": {
26
+ "type": "string"
27
+ },
28
+ "requester_id": {
29
+ "type": "integer"
30
+ },
31
+ "assignee_id": {
32
+ "type": "integer"
33
+ },
34
+ "tags": {
35
+ "type": "array",
36
+ "items": {
37
+ "type": "string"
38
+ }
39
+ },
40
+ "created_at": {
41
+ "type": "string",
42
+ "format": "date-time"
43
+ },
44
+ "updated_at": {
45
+ "type": "string",
46
+ "format": "date-time"
47
+ }
48
+ }
49
+ },
50
+ "supported_sync_modes": [
51
+ "incremental"
52
+ ],
53
+ "source_defined_cursor": true,
54
+ "default_cursor_field": [
55
+ "updated_at"
56
+ ],
57
+ "source_defined_primary_key": [
58
+ [
59
+ "id"
60
+ ]
61
+ ]
62
+ },
63
+ {
64
+ "name": "users",
65
+ "action": "create",
66
+ "json_schema": {
67
+ "type": "object",
68
+ "additionalProperties": true,
69
+ "properties": {
70
+ "id": {
71
+ "type": "integer"
72
+ },
73
+ "name": {
74
+ "type": "string"
75
+ },
76
+ "email": {
77
+ "type": "string"
78
+ },
79
+ "role": {
80
+ "type": "string"
81
+ },
82
+ "last_login_at": {
83
+ "type": "string",
84
+ "format": "date-time"
85
+ },
86
+ "created_at": {
87
+ "type": "string",
88
+ "format": "date-time"
89
+ },
90
+ "updated_at": {
91
+ "type": "string",
92
+ "format": "date-time"
93
+ }
94
+ }
95
+ },
96
+ "supported_sync_modes": [
97
+ "incremental"
98
+ ],
99
+ "source_defined_cursor": true,
100
+ "default_cursor_field": [
101
+ "updated_at"
102
+ ],
103
+ "source_defined_primary_key": [
104
+ [
105
+ "id"
106
+ ]
107
+ ]
108
+ }
109
+ ]
110
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "data": {
3
+ "name": "Zendesk",
4
+ "title": "Zendesk",
5
+ "connector_type": "destination",
6
+ "category": "Customer Support",
7
+ "documentation_url": "https://docs.mutliwoven.com",
8
+ "github_issue_label": "destination-zendesk",
9
+ "icon": "icon.svg",
10
+ "license": "MIT",
11
+ "release_stage": "alpha",
12
+ "support_level": "community",
13
+ "tags": [
14
+ "language:ruby",
15
+ "multiwoven"
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "documentation_url": "https://docs.multiwoven.com/destinations/customer-support/zendesk",
3
+ "stream_type": "static",
4
+ "connection_specification": {
5
+ "$schema": "http://json-schema.org/draft-07/schema#",
6
+ "title": "Zendesk",
7
+ "type": "object",
8
+ "required": [
9
+ "username",
10
+ "password",
11
+ "subdomain"
12
+ ],
13
+ "properties": {
14
+ "username": {
15
+ "type": "string",
16
+ "title": "Username",
17
+ "order": 0
18
+ },
19
+ "password": {
20
+ "type": "string",
21
+ "title": "Password",
22
+ "order": 1,
23
+ "multiwoven_secret": true
24
+ },
25
+ "subdomain": {
26
+ "type": "string",
27
+ "title": "Zendesk Subdomain (include https://)",
28
+ "order": 2
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,63 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
5
+ width="1280.000000pt" height="913.000000pt" viewBox="0 0 1280.000000 913.000000"
6
+ preserveAspectRatio="xMidYMid meet">
7
+
8
+ <g transform="translate(0.000000,913.000000) scale(0.100000,-0.100000)"
9
+ fill="#000000" stroke="none">
10
+ <path d="M2836 9058 c30 -442 184 -789 483 -1089 777 -776 2073 -593 2604 368
11
+ 118 214 182 435 203 706 l7 87 -1651 0 -1651 0 5 -72z"/>
12
+ <path d="M6670 7143 l0 -1988 24 25 c13 14 416 500 897 1080 480 580 1210
13
+ 1461 1621 1957 411 497 748 905 748 908 0 3 -740 5 -1645 5 l-1645 0 0 -1987z"/>
14
+ <path d="M5913 7440 c-116 -140 -855 -1031 -1641 -1980 l-1429 -1725 1640 -3
15
+ c902 -1 1642 -1 1644 1 2 2 2 894 1 1983 l-3 1979 -212 -255z"/>
16
+ <path d="M8137 5359 c-804 -93 -1430 -760 -1459 -1554 l-3 -80 1643 -3 c1417
17
+ -2 1643 0 1648 12 8 22 -14 228 -36 334 -114 549 -530 1024 -1055 1205 -245
18
+ 84 -500 114 -738 86z"/>
19
+ <path d="M6927 2433 c-4 -3 -7 -222 -7 -485 l0 -478 -72 61 c-82 68 -201 131
20
+ -298 156 -86 22 -270 22 -365 0 -312 -75 -535 -294 -621 -612 -25 -93 -30
21
+ -292 -10 -399 60 -318 275 -561 580 -655 57 -18 93 -21 228 -21 145 0 167 2
22
+ 236 26 99 33 181 83 260 158 l62 59 0 -111 0 -112 175 0 175 0 0 1210 0 1210
23
+ -168 0 c-93 0 -172 -3 -175 -7z m-383 -1088 c94 -25 166 -66 237 -135 210
24
+ -206 212 -534 4 -746 -201 -205 -534 -205 -740 1 -287 287 -155 774 238 880
25
+ 69 18 189 19 261 0z"/>
26
+ <path d="M11260 1230 l0 -1210 175 0 175 0 0 215 0 215 135 147 c75 82 139
27
+ 149 143 151 4 1 122 -162 262 -362 l255 -365 199 0 198 -1 -18 28 c-9 15 -150
28
+ 216 -312 447 -162 231 -303 432 -313 446 l-19 27 296 323 c163 178 308 336
29
+ 322 352 l26 27 -215 0 -214 0 -370 -407 -370 -406 -3 791 -2 792 -175 0 -175
30
+ 0 0 -1210z"/>
31
+ <path d="M2388 1695 c-432 -82 -721 -456 -695 -899 22 -371 231 -644 582 -763
32
+ 75 -25 93 -27 303 -31 216 -4 225 -3 314 23 50 14 126 44 168 66 82 42 210
33
+ 141 210 162 -1 6 -50 63 -109 126 l-108 114 -54 -40 c-194 -146 -470 -176
34
+ -677 -75 -106 51 -211 188 -229 297 l-6 35 647 0 646 0 0 93 c0 299 -120 583
35
+ -308 732 -76 61 -198 120 -297 145 -107 27 -286 34 -387 15z m262 -325 c123
36
+ -23 223 -95 278 -197 26 -51 62 -151 62 -175 0 -4 -205 -8 -454 -8 l-455 0 16
37
+ 53 c73 245 294 376 553 327z"/>
38
+ <path d="M4375 1704 c-78 -12 -181 -38 -236 -60 -157 -64 -289 -184 -358 -326
39
+ -77 -156 -75 -138 -79 -750 l-3 -548 180 0 181 0 0 489 c0 286 4 510 10 541
40
+ 15 80 55 159 107 212 141 143 433 153 584 20 44 -39 93 -130 108 -200 7 -35
41
+ 11 -227 11 -557 l0 -505 181 0 180 0 -4 553 c-3 493 -5 558 -21 612 -76 255
42
+ -274 436 -546 500 -67 15 -242 27 -295 19z"/>
43
+ <path d="M8370 1704 c-14 -2 -52 -9 -85 -15 -128 -23 -272 -94 -388 -193 -109
44
+ -91 -206 -244 -253 -401 -25 -82 -28 -104 -27 -245 0 -184 17 -264 87 -405
45
+ 103 -208 278 -349 521 -420 81 -23 102 -25 295 -25 192 0 214 2 294 25 131 38
46
+ 247 101 338 183 21 19 38 39 38 46 -1 6 -49 62 -109 125 l-108 113 -48 -36
47
+ c-238 -182 -604 -183 -790 -1 -55 53 -111 155 -122 218 l-6 37 647 0 646 0 0
48
+ 93 c0 448 -230 782 -604 877 -77 19 -272 34 -326 24z m200 -334 c123 -23 223
49
+ -95 278 -197 26 -51 62 -151 62 -175 0 -4 -205 -8 -454 -8 l-455 0 16 53 c46
50
+ 157 147 266 288 310 89 28 177 34 265 17z"/>
51
+ <path d="M10070 1695 c-365 -74 -562 -393 -420 -681 73 -149 225 -229 572
52
+ -303 228 -49 314 -84 343 -141 47 -91 -25 -216 -145 -254 -172 -55 -370 -6
53
+ -491 121 -31 32 -60 67 -67 78 -10 19 -18 16 -166 -60 -86 -44 -156 -84 -156
54
+ -90 0 -22 108 -152 165 -198 75 -61 196 -121 299 -147 104 -26 394 -29 490 -4
55
+ 213 54 387 222 427 411 29 144 -12 296 -106 387 -93 91 -203 137 -477 202
56
+ -232 54 -292 77 -340 124 -32 32 -38 44 -38 79 0 91 67 161 177 187 165 39
57
+ 323 -6 433 -122 l50 -53 145 80 c167 93 163 82 65 180 -145 146 -348 220 -594
58
+ 218 -55 0 -130 -7 -166 -14z"/>
59
+ <path d="M22 1513 l3 -158 483 -5 483 -5 -496 -504 -495 -505 0 -158 0 -158
60
+ 735 0 735 0 0 155 0 155 -500 0 c-275 0 -500 3 -500 6 0 3 223 232 495 507
61
+ l495 502 0 163 0 162 -720 0 -721 0 3 -157z"/>
62
+ </g>
63
+ </svg>
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.65"
5
+ VERSION = "0.1.66"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -25,6 +25,7 @@ module Multiwoven
25
25
  SalesforceConsumerGoodsCloud
26
26
  Sftp
27
27
  Postgresql
28
+ Zendesk
28
29
  Http
29
30
  ].freeze
30
31
  end
@@ -23,6 +23,7 @@ require "net/sftp"
23
23
  require "csv"
24
24
  require "securerandom"
25
25
  require "zip"
26
+ require "zendesk_api"
26
27
 
27
28
  # Service
28
29
  require_relative "integrations/config"
@@ -61,6 +62,7 @@ require_relative "integrations/destination/stripe/client"
61
62
  require_relative "integrations/destination/salesforce_consumer_goods_cloud/client"
62
63
  require_relative "integrations/destination/sftp/client"
63
64
  require_relative "integrations/destination/postgresql/client"
65
+ require_relative "integrations/destination/zendesk/client"
64
66
  require_relative "integrations/destination/http/client"
65
67
 
66
68
  module Multiwoven
@@ -53,6 +53,7 @@ Gem::Specification.new do |spec|
53
53
  spec.add_runtime_dependency "sequel"
54
54
  spec.add_runtime_dependency "slack-ruby-client"
55
55
  spec.add_runtime_dependency "stripe"
56
+ spec.add_runtime_dependency "zendesk_api"
56
57
 
57
58
  spec.add_development_dependency "byebug"
58
59
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.65
4
+ version: 0.1.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-13 00:00:00.000000000 Z
11
+ date: 2024-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -290,6 +290,20 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: zendesk_api
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
293
307
  - !ruby/object:Gem::Dependency
294
308
  name: byebug
295
309
  requirement: !ruby/object:Gem::Requirement
@@ -463,6 +477,11 @@ files:
463
477
  - lib/multiwoven/integrations/destination/stripe/config/meta.json
464
478
  - lib/multiwoven/integrations/destination/stripe/config/spec.json
465
479
  - lib/multiwoven/integrations/destination/stripe/icon.svg
480
+ - lib/multiwoven/integrations/destination/zendesk/client.rb
481
+ - lib/multiwoven/integrations/destination/zendesk/config/catalog.json
482
+ - lib/multiwoven/integrations/destination/zendesk/config/meta.json
483
+ - lib/multiwoven/integrations/destination/zendesk/config/spec.json
484
+ - lib/multiwoven/integrations/destination/zendesk/icon.svg
466
485
  - lib/multiwoven/integrations/protocol/protocol.json
467
486
  - lib/multiwoven/integrations/protocol/protocol.rb
468
487
  - lib/multiwoven/integrations/rollout.rb