mautic 2.3.4 → 2.3.5
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 +4 -4
- data/README.md +12 -0
- data/app/models/mautic/contact.rb +68 -3
- data/lib/mautic/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af1f088355eb05f40c5b2d22ce36e6c6319ff7e0bc7b6e62b798762a2a400724
|
4
|
+
data.tar.gz: 92867e40e6b9722094f2c174b4a40286cdac41e07c09553e11b38df4caaff4c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361320378ad1c77a3bd8b0a3600ad30fe5c5a95fc7aab7a934992a1fd591c23fd872b3c5aa0ebaf30e54e87997763bc3775119747ef2fa0f449a8252fd3626d2
|
7
|
+
data.tar.gz: 5a630110651bd5fd915fd05570953bdf326c513cdea05d20f0040a6628a6b9b159bf55af5e0ffca6153dab32061a2fdd9dc0f30bd4c7d82401ccf098e9f4072f
|
data/README.md
CHANGED
@@ -88,6 +88,18 @@ mount Mautic::Engine => "/mautic"
|
|
88
88
|
contact.save # => false
|
89
89
|
contact.errors # => [{"code"=>400, "message"=>"email: This field is required.", "details"=>{"email"=>["This field is required."]}}]
|
90
90
|
```
|
91
|
+
Do not contact
|
92
|
+
```ruby
|
93
|
+
contact.do_not_contact? # => false
|
94
|
+
contact.do_not_contact! message: "Some reason"
|
95
|
+
contact.do_not_contact? # => true
|
96
|
+
```
|
97
|
+
Remove do not contact
|
98
|
+
```ruby
|
99
|
+
contact.do_not_contact? # => true
|
100
|
+
contact.remove_do_not_contact!
|
101
|
+
contact.do_not_contact? # => false
|
102
|
+
```
|
91
103
|
Of course you can use more than contact: `assets`, `emails`, `companies`, `forms`, `points` ...
|
92
104
|
### Gem provides simple Mautic form submit
|
93
105
|
There are two options of usage:
|
@@ -3,6 +3,7 @@ module Mautic
|
|
3
3
|
|
4
4
|
alias_attribute :first_name, :firstname
|
5
5
|
alias_attribute :last_name, :lastname
|
6
|
+
|
6
7
|
def self.in(connection)
|
7
8
|
Proxy.new(connection, endpoint, default_params: { search: '!is:anonymous' })
|
8
9
|
end
|
@@ -13,14 +14,78 @@ module Mautic
|
|
13
14
|
|
14
15
|
def assign_attributes(source = nil)
|
15
16
|
super
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
if source
|
18
|
+
self.attributes = {
|
19
|
+
tags: (source['tags'] || []).collect { |t| Mautic::Tag.new(@connection, t) }.sort_by(&:name),
|
20
|
+
doNotContact: source['doNotContact'] || [],
|
21
|
+
}
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def events
|
22
26
|
@proxy_events ||= Proxy.new(connection, "contacts/#{id}/events", klass: "Mautic::Event")
|
23
27
|
end
|
24
28
|
|
29
|
+
# @!group Do Not Contact
|
30
|
+
# @see https://developer.mautic.org/#add-do-not-contact
|
31
|
+
|
32
|
+
def do_not_contact?
|
33
|
+
doNotContact.present?
|
34
|
+
end
|
35
|
+
alias dnc? do_not_contact?
|
36
|
+
|
37
|
+
# @return [Array[Hash]]
|
38
|
+
def do_not_contact
|
39
|
+
return unless do_not_contact?
|
40
|
+
|
41
|
+
# Based on mautic docs => Contacts constants: Contacts::UNSUBSCRIBED (1), Contacts::BOUNCED (2), Contacts::MANUAL (3)
|
42
|
+
reason_list = { 1 => :unsubscribed, 2 => :bounced, 3 => :manual }
|
43
|
+
@do_not_contact ||= doNotContact.collect do |hsh|
|
44
|
+
{ reason_list[hsh["reason"]] => hsh["comments"] }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def bounced?
|
49
|
+
do_not_contact? && !!do_not_contact.detect { |dnc| dnc.key?(:bounced) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def unsubscribed?
|
53
|
+
do_not_contact? && !!do_not_contact.detect { |dnc| dnc.key?(:unsubscribed) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def do_not_contact!(comments: '')
|
57
|
+
begin
|
58
|
+
json = @connection.request(:post, "api/contacts/#{id}/dnc/email/add", body: { comments: comments })
|
59
|
+
self.attributes = { doNotContact: json[endpoint.singularize]["doNotContact"] }
|
60
|
+
clear_changes
|
61
|
+
rescue ValidationError => e
|
62
|
+
self.errors = e.errors
|
63
|
+
end
|
64
|
+
|
65
|
+
self.errors.blank?
|
66
|
+
end
|
67
|
+
alias add_dnc do_not_contact!
|
68
|
+
|
69
|
+
def remove_do_not_contact!
|
70
|
+
begin
|
71
|
+
json = @connection.request(:post, "api/contacts/#{id}/dnc/email/remove", body: {})
|
72
|
+
self.attributes = { doNotContact: json[endpoint.singularize]["doNotContact"] }
|
73
|
+
clear_changes
|
74
|
+
rescue ValidationError => e
|
75
|
+
self.errors = e.errors
|
76
|
+
end
|
77
|
+
|
78
|
+
self.errors.blank?
|
79
|
+
end
|
80
|
+
alias remove_dnc remove_do_not_contact!
|
81
|
+
|
82
|
+
# !endgroup
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def clear_change
|
87
|
+
super
|
88
|
+
remove_instance_variable :@do_not_contact
|
89
|
+
end
|
25
90
|
end
|
26
91
|
end
|
data/lib/mautic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mautic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukáš Pokorný
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.0.
|
225
|
+
rubygems_version: 3.0.6
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Ruby on Rails Mautic integration
|