mautic 2.6.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d46a059bc0ca2814a69988d070546a021dda7b0e75985ead3230e503bfb0262
4
- data.tar.gz: 97f5dbcc3c37d42d148903cc8f604d26016423eb128cb40ded8cb9bfc590c12a
3
+ metadata.gz: 302c26bf67f1bef5f7705398ddbde4df3eeb71d51dff49aa8a0b44dbdca8043c
4
+ data.tar.gz: 74c5ebb5ae9229402313741b8f5d96c284333ad9db3386d3e17dcc18da782bb1
5
5
  SHA512:
6
- metadata.gz: 53c9b9a777ec9cd835d36af42d4eb120831527afa1a147fd61dfa106e078bef5cef072398ef8e1f80bafc3253e916e9fab4438f273eb8c61149768bb7ee6b5bc
7
- data.tar.gz: 3b46074c6a05f4977666bee64655e5ef621fc023d8b58e8f13144d8d6d8d1358f90c942555ec9aefdc80c9b5b2949ee077749c9e49589fa00a2c865b7c75aac0
6
+ metadata.gz: 26aa3228402f52828b74b8eab9e32f061ee181227c5ff7d92cb06a1e932a5096f0da619bee2126c1923ded504de6a84b9f7f1a0bcb87ac9fd9a2db7e49edd7f9
7
+ data.tar.gz: 1b6b1a60985b493ce7c39dac9dd0ed6961c5748179aabbb275106353d02159b44b2337938d3252feadd59ee062cb09a44e5e25b67c5027352a917a803a17d23d
data/README.md CHANGED
@@ -4,13 +4,14 @@
4
4
 
5
5
  RoR helper / wrapper for Mautic API and forms
6
6
 
7
- *Rails 4.2.8+, 5.1+ compatible*
7
+ *Rails 6.0+ compatible*
8
+ *Ruby 3.1+ compatible*
8
9
 
9
10
  ## Installation
10
11
  Add this line to your application's Gemfile:
11
12
 
12
13
  ```ruby
13
- gem 'mautic', '~> 2.3'
14
+ gem "mautic", "~> 3.1"
14
15
  ```
15
16
 
16
17
  And then execute:
@@ -95,7 +95,7 @@ module Mautic
95
95
  end
96
96
 
97
97
  def try_to_refresh_and_parse(response)
98
- raise Mautic::TokenExpiredError, response if @try_to_refresh
98
+ raise Mautic::TokenExpiredError, response.response&.body if @try_to_refresh
99
99
 
100
100
  @try_to_refresh = true
101
101
  refresh!
@@ -27,6 +27,8 @@ module Mautic
27
27
  @connection = connection.refresh!
28
28
  update(token: @connection.token, refresh_token: @connection.refresh_token)
29
29
  @connection
30
+ rescue StandardError
31
+ raise ::Mautic::TokenExpiredError, "your refresh_token is probably expired - re-authorize your connection"
30
32
  end
31
33
 
32
34
  def request(type, path, params = {})
@@ -1,4 +1,5 @@
1
- class CreateMauticMauticConnections < Mautic::DummyMigrationClass
1
+ class CreateMauticMauticConnections < ActiveRecord::Migration[6.0]
2
+
2
3
  def change
3
4
  create_table :mautic_connections do |t|
4
5
  t.string :type
@@ -10,7 +11,8 @@ class CreateMauticMauticConnections < Mautic::DummyMigrationClass
10
11
  t.string :token
11
12
  t.string :refresh_token
12
13
 
13
- t.timestamps null: false
14
+ t.timestamps
14
15
  end
15
16
  end
16
- end
17
+
18
+ end
@@ -1,3 +1,5 @@
1
1
  module Mautic
2
- VERSION = '2.6.1'
2
+
3
+ VERSION = '3.1.0'
4
+
3
5
  end
data/lib/mautic.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "oauth2"
2
+ require "ostruct"
2
3
  require "mautic/engine"
3
4
 
4
5
  module Mautic
@@ -17,31 +18,39 @@ module Mautic
17
18
  @errors ||= []
18
19
  @response = response
19
20
  @request_url = response.response&.env&.url
21
+ unless message
22
+ json_body = parse_response(response)
23
+ message = Array(json_body['errors']).collect do |error|
24
+ msg = error['code'].to_s
25
+ msg << " (#{error['type']}):" if error['type']
26
+ msg << " #{error['message']}"
27
+ @errors << error['message']
28
+ msg
29
+ end.join(', ')
30
+ end
31
+
32
+ super("#{@request_url} => #{message}")
33
+ end
34
+
35
+ private
36
+
37
+ def parse_response(response)
20
38
  body = if response.body.start_with? "<!DOCTYPE html>"
21
39
  response.body.split("\n").last
22
40
  else
23
41
  response.body
24
42
  end
25
43
 
26
- json_body = begin
27
- JSON.parse(body)
28
- rescue JSON::ParserError
29
- { "errors" => [{ "code" => response.status, "message" => body }] }
30
- end
31
- message ||= Array(json_body['errors']).collect do |error|
32
- msg = error['code'].to_s
33
- msg << " (#{error['type']}):" if error['type']
34
- msg << " #{error['message']}"
35
- @errors << error['message']
36
- msg
37
- end.join(', ')
38
-
39
- super("#{@request_url} => #{message}")
44
+ begin
45
+ JSON.parse(body)
46
+ rescue JSON::ParserError
47
+ { "errors" => [{ "code" => response.status, "message" => body }] }
48
+ end
40
49
  end
41
50
 
42
51
  end
43
52
 
44
- class TokenExpiredError < RequestError
53
+ class TokenExpiredError < StandardError
45
54
  end
46
55
 
47
56
  class ValidationError < RequestError
@@ -69,6 +78,7 @@ module Mautic
69
78
  configure do |config|
70
79
  # This is URL of your application - its for oauth callbacks
71
80
  config.base_url = "http://localhost:3000"
81
+ # config.base_url = proc { |connection| magic magick }
72
82
 
73
83
  # *optional* This is your default mautic URL - used in form helper
74
84
  config.mautic_url = "https://mautic.my.app"
@@ -78,12 +88,4 @@ module Mautic
78
88
  end
79
89
  # Your code goes here...
80
90
 
81
- if Rails.version.start_with? "4"
82
- class DummyMigrationClass < ActiveRecord::Migration
83
- end
84
- else
85
- class DummyMigrationClass < ActiveRecord::Migration[4.2]
86
- end
87
- end
88
-
89
91
  end
data/spec/rails_helper.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
2
  require 'simplecov'
3
3
  SimpleCov.start do
4
- add_filter "/spec/"
4
+ add_filter '/spec/'
5
5
  end
6
6
 
7
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
8
8
  # Prevent database truncation if the environment is production
9
9
  abort('The Rails environment is running in production mode!') if Rails.env.production?
10
10
 
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,8 @@ Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each do |file|
12
12
  require file
13
13
  end
14
14
 
15
+ require_relative 'factories/factories'
16
+
15
17
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
18
  RSpec.configure do |config|
17
19
  # config.infer_spec_type_from_file_location!
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.6.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukáš Pokorný
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-21 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.8
19
+ version: 6.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 4.2.8
29
+ version: 6.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: oauth2
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,112 +50,14 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '2.0'
53
+ version: '2.1'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: sqlite3
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.4'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.4'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec-rails
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.9'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.9'
83
- - !ruby/object:Gem::Dependency
84
- name: factory_bot_rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '5.1'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '5.1'
97
- - !ruby/object:Gem::Dependency
98
- name: database_cleaner
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.7'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.7'
111
- - !ruby/object:Gem::Dependency
112
- name: faker
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '2.7'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '2.7'
125
- - !ruby/object:Gem::Dependency
126
- name: webmock
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3.7'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '3.7'
139
- - !ruby/object:Gem::Dependency
140
- name: pry-rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.3'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.3'
60
+ version: '2.1'
153
61
  description: Rails client for Mautic API. Provide wrapper for push to mautic form
154
62
  email:
155
63
  - pokorny@luk4s.cz
@@ -213,17 +121,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
121
  requirements:
214
122
  - - ">="
215
123
  - !ruby/object:Gem::Version
216
- version: '2.3'
124
+ version: '3.1'
217
125
  required_rubygems_version: !ruby/object:Gem::Requirement
218
126
  requirements:
219
127
  - - ">="
220
128
  - !ruby/object:Gem::Version
221
129
  version: '0'
222
130
  requirements: []
223
- rubygems_version: 3.1.4
131
+ rubygems_version: 3.4.22
224
132
  signing_key:
225
133
  specification_version: 4
226
134
  summary: Ruby on Rails Mautic integration
227
135
  test_files:
228
- - spec/spec_helper.rb
229
136
  - spec/rails_helper.rb
137
+ - spec/spec_helper.rb