mautic 2.3.5 → 2.3.6

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: af1f088355eb05f40c5b2d22ce36e6c6319ff7e0bc7b6e62b798762a2a400724
4
- data.tar.gz: 92867e40e6b9722094f2c174b4a40286cdac41e07c09553e11b38df4caaff4c6
3
+ metadata.gz: 78b5aecca30c838b83909bf68ad262c18f202b4a1f4ebb91d25b3e0db9ef6050
4
+ data.tar.gz: c0a942ada27b2ede12b190d59c72f1ad8eb902f476f172ed4fd1601a577c1efb
5
5
  SHA512:
6
- metadata.gz: 361320378ad1c77a3bd8b0a3600ad30fe5c5a95fc7aab7a934992a1fd591c23fd872b3c5aa0ebaf30e54e87997763bc3775119747ef2fa0f449a8252fd3626d2
7
- data.tar.gz: 5a630110651bd5fd915fd05570953bdf326c513cdea05d20f0040a6628a6b9b159bf55af5e0ffca6153dab32061a2fdd9dc0f30bd4c7d82401ccf098e9f4072f
6
+ metadata.gz: 983fef37892340a7f03754baf4de27c509ec14ea61d0d323427050f7e36992ef2025adbb8ab193cf3c2b75c9e8edd4a5d198597805c6dc8b3dcff9f42113d4b9
7
+ data.tar.gz: 2e34254779f1c5c651f93ce358462bd135e9da2df6e09676c815dd4b1deed7ebe431a6ca7f8e141ebd84354eb81160b30ed92846fd6173c26c586dda4afc6ee1
@@ -12,12 +12,39 @@ module Mautic
12
12
  "#{firstname} #{lastname}"
13
13
  end
14
14
 
15
+ # @param [Hash] hash
16
+ # option hash [Integer] :id
17
+ # option hash [String] :firstName
18
+ # option hash [String] :lastName
19
+ def owner=(hash)
20
+ raise ArgumentError, "must be a hash !" unless hash.is_a?(Hash)
21
+
22
+ @table["owner"] = hash["id"]
23
+ @owner = hash
24
+ end
25
+
26
+ # @return [Hash]
27
+ # @example {id: 12, firstName: "Joe", lastName: "Doe"}
28
+ def owner
29
+ @owner || {}
30
+ end
31
+
32
+ # Assign mautic User ID as owner - for example for update author of contact
33
+ # @see https://developer.mautic.org/#edit-contact set owner
34
+ # @param [Integer] int
35
+ def owner_id=(int)
36
+ @table["owner"] = int
37
+ end
38
+
15
39
  def assign_attributes(source = nil)
16
40
  super
41
+
17
42
  if source
43
+ self.owner = source['owner'] || {}
18
44
  self.attributes = {
19
45
  tags: (source['tags'] || []).collect { |t| Mautic::Tag.new(@connection, t) }.sort_by(&:name),
20
46
  doNotContact: source['doNotContact'] || [],
47
+ owner: owner['id'],
21
48
  }
22
49
  end
23
50
  end
@@ -32,6 +59,7 @@ module Mautic
32
59
  def do_not_contact?
33
60
  doNotContact.present?
34
61
  end
62
+
35
63
  alias dnc? do_not_contact?
36
64
 
37
65
  # @return [Array[Hash]]
@@ -64,6 +92,7 @@ module Mautic
64
92
 
65
93
  self.errors.blank?
66
94
  end
95
+
67
96
  alias add_dnc do_not_contact!
68
97
 
69
98
  def remove_do_not_contact!
@@ -77,6 +106,7 @@ module Mautic
77
106
 
78
107
  self.errors.blank?
79
108
  end
109
+
80
110
  alias remove_dnc remove_do_not_contact!
81
111
 
82
112
  # !endgroup
@@ -38,6 +38,7 @@ module Mautic
38
38
  end
39
39
 
40
40
  attr_reader :connection
41
+ attr_accessor :errors
41
42
 
42
43
  # @param [Mautic::Connection] connection
43
44
  def initialize(connection, hash = nil)
@@ -58,9 +59,10 @@ module Mautic
58
59
 
59
60
  def update(force = false)
60
61
  return false if changes.blank?
62
+
61
63
  begin
62
- json = @connection.request((force && :put || :patch), "api/#{endpoint}/#{id}/edit", { body: to_mautic })
63
- self.attributes = json[endpoint.singularize]
64
+ json = @connection.request((force && :put || :patch), "api/#{endpoint}/#{id}/edit", body: to_mautic)
65
+ assign_attributes json[endpoint.singularize]
64
66
  clear_changes
65
67
  rescue ValidationError => e
66
68
  self.errors = e.errors
@@ -69,10 +71,18 @@ module Mautic
69
71
  self.errors.blank?
70
72
  end
71
73
 
74
+ def update_columns(attributes = {})
75
+ json = @connection.request(:patch, "api/#{endpoint}/#{id}/edit", body: to_mautic(attributes))
76
+ assign_attributes json[endpoint.singularize]
77
+ clear_changes
78
+ rescue ValidationError => e
79
+ self.errors = e.errors
80
+ end
81
+
72
82
  def create
73
83
  begin
74
- json = @connection.request(:post, "api/#{endpoint}/#{id && "#{id}/"}new", { body: to_mautic })
75
- self.attributes = json[endpoint.singularize]
84
+ json = @connection.request(:post, "api/#{endpoint}/#{id && "#{id}/"}new", body: to_mautic)
85
+ assign_attributes json[endpoint.singularize]
76
86
  clear_changes
77
87
  rescue ValidationError => e
78
88
  self.errors = e.errors
@@ -106,8 +116,8 @@ module Mautic
106
116
  end
107
117
  end
108
118
 
109
- def to_mautic
110
- @table.each_with_object({}) do |(key,val), mem|
119
+ def to_mautic(data = @table)
120
+ data.each_with_object({}) do |(key, val), mem|
111
121
  mem[key] = val.is_a?(Array) ? val.join("|") : val
112
122
  end
113
123
  end
@@ -1,3 +1,3 @@
1
1
  module Mautic
2
- VERSION = '2.3.5'
2
+ VERSION = '2.3.6'
3
3
  end
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.5
4
+ version: 2.3.6
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-03-03 00:00:00.000000000 Z
11
+ date: 2020-06-10 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.6
225
+ rubygems_version: 3.0.8
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Ruby on Rails Mautic integration