distribution_wrappers 0.2.2

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 (38) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +102 -0
  3. data/Gemfile.lock +295 -0
  4. data/README.md +22 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/distribution_wrappers.gemspec +173 -0
  8. data/lib/config/key_chain.yml +70 -0
  9. data/lib/config/key_chain_dev.yml +71 -0
  10. data/lib/distribution_wrappers.rb +64 -0
  11. data/lib/distribution_wrappers/_base.rb +68 -0
  12. data/lib/distribution_wrappers/backstitch/backstitch.rb +267 -0
  13. data/lib/distribution_wrappers/email/_email.rb +48 -0
  14. data/lib/distribution_wrappers/email/template.html.haml +29 -0
  15. data/lib/distribution_wrappers/google/google.rb +129 -0
  16. data/lib/distribution_wrappers/hipchat/hipchat.rb +80 -0
  17. data/lib/distribution_wrappers/office365/office365.rb +51 -0
  18. data/lib/distribution_wrappers/sendgrid/sendgrid.rb +35 -0
  19. data/lib/distribution_wrappers/slack/slack.rb +87 -0
  20. data/lib/helpers/keys.rb +10 -0
  21. data/lib/helpers/text_helper.rb +9 -0
  22. data/lib/models/device_session_distro.rb +5 -0
  23. data/lib/models/distribution_channel_distro.rb +4 -0
  24. data/lib/models/feed_distro.rb +11 -0
  25. data/lib/models/organization_admin_distro.rb +5 -0
  26. data/lib/models/organization_distro.rb +10 -0
  27. data/lib/models/studio_post_version_contact_distro.rb +5 -0
  28. data/lib/models/studio_post_version_distro.rb +5 -0
  29. data/lib/models/team_distro.rb +13 -0
  30. data/lib/models/team_feed_distro.rb +5 -0
  31. data/lib/models/team_member_distro.rb +6 -0
  32. data/lib/models/topic_distro.rb +11 -0
  33. data/lib/models/topic_feed_distro.rb +5 -0
  34. data/lib/models/topic_subscription_distro.rb +9 -0
  35. data/lib/models/user_distro.rb +34 -0
  36. data/test/helper.rb +34 -0
  37. data/test/test_distribution_wrappers.rb +7 -0
  38. metadata +556 -0
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
@@ -0,0 +1,173 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: distribution_wrappers 0.2.2 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "distribution_wrappers"
9
+ s.version = "0.2.2"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["backstitch Inc."]
14
+ s.date = "2017-02-27"
15
+ s.description = "Contains the logic for distributing messages through third-party APIs"
16
+ s.email = "admin@backstit.ch"
17
+ s.extra_rdoc_files = [
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "distribution_wrappers.gemspec",
26
+ "lib/config/key_chain.yml",
27
+ "lib/config/key_chain_dev.yml",
28
+ "lib/distribution_wrappers.rb",
29
+ "lib/distribution_wrappers/_base.rb",
30
+ "lib/distribution_wrappers/backstitch/backstitch.rb",
31
+ "lib/distribution_wrappers/email/_email.rb",
32
+ "lib/distribution_wrappers/email/template.html.haml",
33
+ "lib/distribution_wrappers/google/google.rb",
34
+ "lib/distribution_wrappers/hipchat/hipchat.rb",
35
+ "lib/distribution_wrappers/office365/office365.rb",
36
+ "lib/distribution_wrappers/sendgrid/sendgrid.rb",
37
+ "lib/distribution_wrappers/slack/slack.rb",
38
+ "lib/helpers/keys.rb",
39
+ "lib/helpers/text_helper.rb",
40
+ "lib/models/device_session_distro.rb",
41
+ "lib/models/distribution_channel_distro.rb",
42
+ "lib/models/feed_distro.rb",
43
+ "lib/models/organization_admin_distro.rb",
44
+ "lib/models/organization_distro.rb",
45
+ "lib/models/studio_post_version_contact_distro.rb",
46
+ "lib/models/studio_post_version_distro.rb",
47
+ "lib/models/team_distro.rb",
48
+ "lib/models/team_feed_distro.rb",
49
+ "lib/models/team_member_distro.rb",
50
+ "lib/models/topic_distro.rb",
51
+ "lib/models/topic_feed_distro.rb",
52
+ "lib/models/topic_subscription_distro.rb",
53
+ "lib/models/user_distro.rb",
54
+ "test/helper.rb",
55
+ "test/test_distribution_wrappers.rb"
56
+ ]
57
+ s.homepage = "http://github.com/backstitch/distribution_wrappers"
58
+ s.licenses = ["Proprietary"]
59
+ s.rubygems_version = "2.4.5"
60
+ s.summary = "Library of distribution wrappers"
61
+
62
+ if s.respond_to? :specification_version then
63
+ s.specification_version = 4
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_runtime_dependency(%q<rack>, ["<= 1.6.4"])
67
+ s.add_runtime_dependency(%q<semantic_types>, [">= 0"])
68
+ s.add_runtime_dependency(%q<activerecord>, [">= 0"])
69
+ s.add_runtime_dependency(%q<activesupport>, ["<= 4.2.6"])
70
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
71
+ s.add_runtime_dependency(%q<oauth>, [">= 0"])
72
+ s.add_runtime_dependency(%q<oauth2>, [">= 0"])
73
+ s.add_runtime_dependency(%q<omniauth>, ["~> 1.4.2"])
74
+ s.add_runtime_dependency(%q<omniauth-oauth2>, [">= 0"])
75
+ s.add_runtime_dependency(%q<gmail>, [">= 0"])
76
+ s.add_runtime_dependency(%q<mail>, [">= 0"])
77
+ s.add_runtime_dependency(%q<gmail_xoauth>, [">= 0"])
78
+ s.add_runtime_dependency(%q<google-api-client>, [">= 0"])
79
+ s.add_runtime_dependency(%q<slack-ruby-client>, [">= 0"])
80
+ s.add_runtime_dependency(%q<hipchat>, [">= 0"])
81
+ s.add_runtime_dependency(%q<ruby_outlook>, [">= 0"])
82
+ s.add_runtime_dependency(%q<nokogiri>, ["= 1.6.7.1"])
83
+ s.add_runtime_dependency(%q<video_info>, ["<= 2.6.0"])
84
+ s.add_runtime_dependency(%q<sendgrid-ruby>, ["= 3.0.3"])
85
+ s.add_runtime_dependency(%q<tilt>, [">= 0"])
86
+ s.add_runtime_dependency(%q<pismo>, [">= 0"])
87
+ s.add_runtime_dependency(%q<pg>, ["~> 0.16.0"])
88
+ s.add_runtime_dependency(%q<elasticsearch>, ["~> 0.4.0"])
89
+ s.add_runtime_dependency(%q<builder>, ["~> 3.1.4"])
90
+ s.add_runtime_dependency(%q<macaddr>, ["= 1.6.1"])
91
+ s.add_runtime_dependency(%q<ruby-hmac>, [">= 0"])
92
+ s.add_runtime_dependency(%q<json>, [">= 0"])
93
+ s.add_runtime_dependency(%q<settingslogic>, [">= 0"])
94
+ s.add_runtime_dependency(%q<sanitize>, [">= 0"])
95
+ s.add_runtime_dependency(%q<domainatrix>, [">= 0"])
96
+ s.add_runtime_dependency(%q<curb>, [">= 0"])
97
+ s.add_runtime_dependency(%q<pushwoosh>, [">= 0"])
98
+ s.add_development_dependency(%q<rspec>, [">= 0"])
99
+ s.add_development_dependency(%q<jeweler>, ["= 2.1.2"])
100
+ else
101
+ s.add_dependency(%q<rack>, ["<= 1.6.4"])
102
+ s.add_dependency(%q<semantic_types>, [">= 0"])
103
+ s.add_dependency(%q<activerecord>, [">= 0"])
104
+ s.add_dependency(%q<activesupport>, ["<= 4.2.6"])
105
+ s.add_dependency(%q<haml>, [">= 0"])
106
+ s.add_dependency(%q<oauth>, [">= 0"])
107
+ s.add_dependency(%q<oauth2>, [">= 0"])
108
+ s.add_dependency(%q<omniauth>, ["~> 1.4.2"])
109
+ s.add_dependency(%q<omniauth-oauth2>, [">= 0"])
110
+ s.add_dependency(%q<gmail>, [">= 0"])
111
+ s.add_dependency(%q<mail>, [">= 0"])
112
+ s.add_dependency(%q<gmail_xoauth>, [">= 0"])
113
+ s.add_dependency(%q<google-api-client>, [">= 0"])
114
+ s.add_dependency(%q<slack-ruby-client>, [">= 0"])
115
+ s.add_dependency(%q<hipchat>, [">= 0"])
116
+ s.add_dependency(%q<ruby_outlook>, [">= 0"])
117
+ s.add_dependency(%q<nokogiri>, ["= 1.6.7.1"])
118
+ s.add_dependency(%q<video_info>, ["<= 2.6.0"])
119
+ s.add_dependency(%q<sendgrid-ruby>, ["= 3.0.3"])
120
+ s.add_dependency(%q<tilt>, [">= 0"])
121
+ s.add_dependency(%q<pismo>, [">= 0"])
122
+ s.add_dependency(%q<pg>, ["~> 0.16.0"])
123
+ s.add_dependency(%q<elasticsearch>, ["~> 0.4.0"])
124
+ s.add_dependency(%q<builder>, ["~> 3.1.4"])
125
+ s.add_dependency(%q<macaddr>, ["= 1.6.1"])
126
+ s.add_dependency(%q<ruby-hmac>, [">= 0"])
127
+ s.add_dependency(%q<json>, [">= 0"])
128
+ s.add_dependency(%q<settingslogic>, [">= 0"])
129
+ s.add_dependency(%q<sanitize>, [">= 0"])
130
+ s.add_dependency(%q<domainatrix>, [">= 0"])
131
+ s.add_dependency(%q<curb>, [">= 0"])
132
+ s.add_dependency(%q<pushwoosh>, [">= 0"])
133
+ s.add_dependency(%q<rspec>, [">= 0"])
134
+ s.add_dependency(%q<jeweler>, ["= 2.1.2"])
135
+ end
136
+ else
137
+ s.add_dependency(%q<rack>, ["<= 1.6.4"])
138
+ s.add_dependency(%q<semantic_types>, [">= 0"])
139
+ s.add_dependency(%q<activerecord>, [">= 0"])
140
+ s.add_dependency(%q<activesupport>, ["<= 4.2.6"])
141
+ s.add_dependency(%q<haml>, [">= 0"])
142
+ s.add_dependency(%q<oauth>, [">= 0"])
143
+ s.add_dependency(%q<oauth2>, [">= 0"])
144
+ s.add_dependency(%q<omniauth>, ["~> 1.4.2"])
145
+ s.add_dependency(%q<omniauth-oauth2>, [">= 0"])
146
+ s.add_dependency(%q<gmail>, [">= 0"])
147
+ s.add_dependency(%q<mail>, [">= 0"])
148
+ s.add_dependency(%q<gmail_xoauth>, [">= 0"])
149
+ s.add_dependency(%q<google-api-client>, [">= 0"])
150
+ s.add_dependency(%q<slack-ruby-client>, [">= 0"])
151
+ s.add_dependency(%q<hipchat>, [">= 0"])
152
+ s.add_dependency(%q<ruby_outlook>, [">= 0"])
153
+ s.add_dependency(%q<nokogiri>, ["= 1.6.7.1"])
154
+ s.add_dependency(%q<video_info>, ["<= 2.6.0"])
155
+ s.add_dependency(%q<sendgrid-ruby>, ["= 3.0.3"])
156
+ s.add_dependency(%q<tilt>, [">= 0"])
157
+ s.add_dependency(%q<pismo>, [">= 0"])
158
+ s.add_dependency(%q<pg>, ["~> 0.16.0"])
159
+ s.add_dependency(%q<elasticsearch>, ["~> 0.4.0"])
160
+ s.add_dependency(%q<builder>, ["~> 3.1.4"])
161
+ s.add_dependency(%q<macaddr>, ["= 1.6.1"])
162
+ s.add_dependency(%q<ruby-hmac>, [">= 0"])
163
+ s.add_dependency(%q<json>, [">= 0"])
164
+ s.add_dependency(%q<settingslogic>, [">= 0"])
165
+ s.add_dependency(%q<sanitize>, [">= 0"])
166
+ s.add_dependency(%q<domainatrix>, [">= 0"])
167
+ s.add_dependency(%q<curb>, [">= 0"])
168
+ s.add_dependency(%q<pushwoosh>, [">= 0"])
169
+ s.add_dependency(%q<rspec>, [">= 0"])
170
+ s.add_dependency(%q<jeweler>, ["= 2.1.2"])
171
+ end
172
+ end
173
+
@@ -0,0 +1,70 @@
1
+ appdotnet:
2
+ key: 'hqdaZHQ6kGk4hLkZJvueKV5KKraKkkwa'
3
+ secret: 'YdWck5VLrtR3Kg4r6Mym8dQWKg98cNGr'
4
+
5
+ facebook:
6
+ key: '346331192105453'
7
+ secret: 'f921189655a800f93d9a0d90945b6e78'
8
+
9
+ google:
10
+ api_key: 'AIzaSyAANDuZhr_ovOnE_sYjKXLk6djYwY2BVaw'
11
+ key: '294129192803.apps.googleusercontent.com'
12
+ secret: '1LxHLJNJ0xj2dLn3U7u1ppZ1'
13
+
14
+ instagram:
15
+ key: 'a2181d0d46424341b81fbd1315f61fe9'
16
+ secret: '0a7db69646e8414bb45bbc4386317e8c'
17
+
18
+ microsoft_graph:
19
+ client_id: 'ab02325d-26eb-4517-a574-6d6373288a97'
20
+ secret: '2kOb6B57mBpLArjGou2Zw1r'
21
+
22
+ office365:
23
+ secret: 'hiBFCW4BUKYwLMV7w00kSRw'
24
+ key: '7f9373e9-36e0-45a2-a880-fce25d23268a'
25
+
26
+ reddit:
27
+ key: 'bEDefewweihdFg'
28
+ secret: 'rMLMJX2d9tLscU8FZ3zXv-6USew'
29
+
30
+ sendgrid:
31
+ digest:
32
+ api_key: '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'
33
+ send_from_domain: 'digest.backstit.ch'
34
+ send_from_user: 'postmaster'
35
+ send_from_name: 'backstitch'
36
+ transactional:
37
+ api_key: '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'
38
+ send_from_domain: 'email.backstit.ch'
39
+ send_from_user: 'postmaster'
40
+ send_from_name: 'backstitch'
41
+ studio:
42
+ api_key: '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'
43
+ send_from_domain: 'studio.backstitch.io'
44
+ send_from_user: 'postmaster'
45
+ send_from_name: 'backstitch'
46
+ default:
47
+ api_key: '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'
48
+ send_from_domain: 'digest.backstit.ch'
49
+ send_from_user: 'postmaster'
50
+ send_from_name: 'backstitch'
51
+
52
+ slack:
53
+ client_id: '2687012780.65181250002'
54
+ secret: 'c0c6fc9a4348757b80bb2abb4fdec0ca'
55
+
56
+ tumblr:
57
+ key: 'bx39YoS42TwTAtntV0VNkqfZZIbWCEd0WUnb6bDQD5sYsjfIxI'
58
+ secret: 'UDqZK75rRcUFFhlki4NKQQAw9xIQHE7kC2wSAqzEivArMI4nFH'
59
+
60
+ twitter:
61
+ key: '8T53dRyHHHifvRBzYiwM9w'
62
+ secret: 'EOn20AtY0ZZWHz79UYBOgI39AM66K0HFG6FtVeklA'
63
+
64
+ vimeo:
65
+ client_id: 'cb5e2b895a44ce8a74336fc1dde69f2e9e2ca172'
66
+ secret: 'KlOz0ZDFBPdM9Hxt4pwP+6l0LJ4IXYq6itgRmtNBsA4T7QEOw8dG6FYlXc8SEm7Xu8wpP31w4kmKvrjJxH9dkIH28DMD0JeXSiq4IVLJ5y+EbIyh/CUaSLFJMWdwaA01'
67
+
68
+ yammer:
69
+ client_id: '4KG59f7YFS0JcYMBx3NRiQ'
70
+ secret: '80ceH9bE4taffadNONCRTr9BSZp9beGn7zzpRq6QSc'
@@ -0,0 +1,71 @@
1
+ appdotnet:
2
+ key: 'hqdaZHQ6kGk4hLkZJvueKV5KKraKkkwa'
3
+ secret: 'YdWck5VLrtR3Kg4r6Mym8dQWKg98cNGr'
4
+
5
+ facebook:
6
+ key: '251500254956094'
7
+ secret: '29854ba6ff2a19d28ea2a3ef8f2d0afd'
8
+
9
+ google:
10
+ api_key: 'AIzaSyAANDuZhr_ovOnE_sYjKXLk6djYwY2BVaw'
11
+ key: '294129192803.apps.googleusercontent.com'
12
+ secret: '1LxHLJNJ0xj2dLn3U7u1ppZ1'
13
+
14
+ instagram:
15
+ key: '89e5196897814b43bf3cb7512a77871c'
16
+ secret: '04f21ca8119b4f3dadafbd9b08f00707'
17
+
18
+ microsoft_graph:
19
+ client_id: 'ab02325d-26eb-4517-a574-6d6373288a97'
20
+ secret: '2kOb6B57mBpLArjGou2Zw1r'
21
+
22
+ office365:
23
+ key: 'cc499937-c991-4c90-b941-ffb4b50501d8'
24
+ secret: 'avZpunkeaDHeigDAjdaeCHF'
25
+
26
+ reddit:
27
+ key: 'BE4j53tGb7X5ng'
28
+ secret: 'IJT_K54FBD2mCVeYg8rXDVgg_WU'
29
+ redirect_uri: 'http://localhost:3000/auth/reddit/callback'
30
+
31
+ sendgrid:
32
+ digest:
33
+ api_key: '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'
34
+ send_from_domain: 'digest.backstit.ch'
35
+ send_from_user: 'postmaster'
36
+ send_from_name: 'backstitch'
37
+ transactional:
38
+ api_key: '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'
39
+ send_from_domain: 'email.backstit.ch'
40
+ send_from_user: 'postmaster'
41
+ send_from_name: 'backstitch'
42
+ studio:
43
+ api_key: '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'
44
+ send_from_domain: 'studio.backstitch.io'
45
+ send_from_user: 'postmaster'
46
+ send_from_name: 'backstitch'
47
+ default:
48
+ api_key: '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'
49
+ send_from_domain: 'digest.backstit.ch'
50
+ send_from_user: 'postmaster'
51
+ send_from_name: 'backstitch'
52
+
53
+ slack:
54
+ client_id: '2687012780.65181250002'
55
+ secret: 'c0c6fc9a4348757b80bb2abb4fdec0ca'
56
+
57
+ tumblr:
58
+ key: 'byREaNMYaLBIBSMXiODzlq9h5dAKIjCXrpPj7HW6xuyiNVsLin'
59
+ secret: 'rmzxbKiKLcL9IB0qi35Sbv52ESDuUF3gsZv0MQBDfdJFEzkyn2'
60
+
61
+ twitter:
62
+ key: '8T53dRyHHHifvRBzYiwM9w'
63
+ secret: 'EOn20AtY0ZZWHz79UYBOgI39AM66K0HFG6FtVeklA'
64
+
65
+ vimeo:
66
+ client_id: 'cb5e2b895a44ce8a74336fc1dde69f2e9e2ca172'
67
+ secret: 'KlOz0ZDFBPdM9Hxt4pwP+6l0LJ4IXYq6itgRmtNBsA4T7QEOw8dG6FYlXc8SEm7Xu8wpP31w4kmKvrjJxH9dkIH28DMD0JeXSiq4IVLJ5y+EbIyh/CUaSLFJMWdwaA01'
68
+
69
+ yammer:
70
+ client_id: '4KG59f7YFS0JcYMBx3NRiQ'
71
+ secret: '80ceH9bE4taffadNONCRTr9BSZp9beGn7zzpRq6QSc'
@@ -0,0 +1,64 @@
1
+ # Helpers
2
+ require "helpers/keys"
3
+ require "helpers/text_helper"
4
+
5
+ # Dependencies
6
+ require 'active_support'
7
+ require 'active_support/core_ext'
8
+ require 'httpclient'
9
+
10
+ require 'semantic_types'
11
+ require "settingslogic"
12
+ require 'sanitize'
13
+ require 'domainatrix'
14
+ require 'curb'
15
+ require 'pushwoosh'
16
+
17
+ require 'oauth'
18
+ require 'oauth2'
19
+
20
+ require 'google/apis/gmail_v1'
21
+ # require 'googleauth'
22
+ # require 'googleauth/stores/file_token_store'
23
+
24
+ require 'sendgrid-ruby'
25
+
26
+ require 'fileutils'
27
+ require 'haml'
28
+ require 'tilt/haml'
29
+ require 'video_info'
30
+ require 'pismo'
31
+
32
+ # API Helpers
33
+ require 'slack'
34
+ require 'hipchat'
35
+ require 'ruby_outlook'
36
+ require 'gmail'
37
+
38
+ require 'fileutils'
39
+
40
+ # Distribution Wrappers
41
+ require 'distribution_wrappers/_base'
42
+ require 'distribution_wrappers/email/_email'
43
+ require 'distribution_wrappers/google/google'
44
+ require 'distribution_wrappers/sendgrid/sendgrid'
45
+ require 'distribution_wrappers/office365/office365'
46
+ require 'distribution_wrappers/slack/slack'
47
+ require 'distribution_wrappers/backstitch/backstitch'
48
+ require 'distribution_wrappers/hipchat/hipchat'
49
+
50
+ # Activerecord Models
51
+ require 'models/device_session_distro'
52
+ require 'models/distribution_channel_distro'
53
+ require 'models/feed_distro'
54
+ require 'models/organization_admin_distro'
55
+ require 'models/organization_distro'
56
+ require 'models/studio_post_version_contact_distro'
57
+ require 'models/studio_post_version_distro'
58
+ require 'models/team_distro'
59
+ require 'models/team_feed_distro'
60
+ require 'models/team_member_distro'
61
+ require 'models/topic_distro'
62
+ require 'models/topic_feed_distro'
63
+ require 'models/topic_subscription_distro'
64
+ require 'models/user_distro'
@@ -0,0 +1,68 @@
1
+ module DistributionWrappers
2
+ class Base
3
+ # params: The parameters required by the service (a hash with symbolized keys)
4
+ # tracking: Tracking information to be attached to each result
5
+ # auth: Authentication required by the service
6
+ # baseline: Baseline used by the service (ex. since_id and since_time)
7
+
8
+ # name: A descriptive name for the service (based upon the parameters passed)
9
+ # icon: An (optional) image to identify the service by (might be based upon the parameters passed)
10
+ # banner: An (optional) descriptive image provided by the service
11
+ attr_accessor :params
12
+
13
+ def initialize(params={}, auth=nil)
14
+ @auth = auth
15
+ @params = params
16
+ end
17
+
18
+ protected
19
+
20
+ def send_message(recipient)
21
+ @version_contact = PostVersionContactDistro.new
22
+ @version_contact.studio_post_version_id = @params[:version_id]
23
+ @version_contact.distribution_contact_id = recipient['id']
24
+ @version_contact.save
25
+ @params[:version_contact_id] = @version_contact.id
26
+ @message = prepare(recipient['identifier'])
27
+ end
28
+
29
+ def redirect_links(doc, add_email=false)
30
+ if ENV['ENVIRONMENT'] == "development"
31
+ base_url = "http://localhost:3000"
32
+ regex = /.*localhost:3000/
33
+ else
34
+ base_url = "http://studio.backstit.ch"
35
+ regex = /.*backstit\.ch/
36
+ end
37
+
38
+ links = doc.search('a[href]').reject{ |n| n['href'][regex]}
39
+
40
+ email_placeholder = "&email=<<email_placeholder>>" if add_email
41
+
42
+ links.each do |link|
43
+ old_link = link.attributes['href'].value
44
+ link.attributes['href'].value = "#{base_url}/posts/#{@params[:post].id}/engagement/redirect_link?url=#{old_link}&contact_id=#{@version_contact.id}&version_id=#{@version_contact.studio_post_version_id}&organization_id=#{@params[:organization].id}#{email_placeholder}"
45
+ end
46
+
47
+ doc
48
+ end
49
+
50
+ def append_parameters(doc, add_email=false)
51
+ if ENV['ENVIRONMENT'] == 'production'
52
+ regex = /.*backstit\.ch/
53
+ else
54
+ regex = /.*localhost:3000/
55
+ end
56
+
57
+ backstitch_links = doc.search('a[href]').select{ |n| n['href'][regex]}
58
+
59
+ email_placeholder = "&email=<<email_placeholder>>" if add_email
60
+
61
+ backstitch_links.each do |link|
62
+ link.attributes['href'].value = "#{link.attributes['href'].value}&contact_id=#{@version_contact.id}&version_id=#{@version_contact.studio_post_version_id}&organization_id=#{@params[:organization].id}#{email_placeholder}"
63
+ end
64
+
65
+ doc
66
+ end
67
+ end
68
+ end