maropost 0.5.0 → 0.6.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
  SHA1:
3
- metadata.gz: aa4796e02a8b14d6dc9d9cfafa879a2a9ca193af
4
- data.tar.gz: bf551e4b26579e0183ad891af2a3a4a4476f4daf
3
+ metadata.gz: 41defb7d262138dbba118f97eff436b079e10e2e
4
+ data.tar.gz: 76b093084e65ef9686eac90049407218934ee468
5
5
  SHA512:
6
- metadata.gz: d32697c99f8768a40913ab4637fa1a64aa33a9c95e1f88c6fddfedcfaf5234d864fb6e8e8eed48cc82d7485ba1aa2de02f523508373bbada8a58606dbc1d3173
7
- data.tar.gz: 300107e26493f99c40001b45a6454a3a91303c846c5525c9d51f0f08563c2c9868b0e7d62350e17c9011ece32e3d398e6c20c7e1b4b1534f49eec5b22fc18246
6
+ metadata.gz: ab2429412117bf810f855ee73d2261881a68149d79b3b2419f9d9ac9b09eb369327e863b83146b8d182136adc01b6b99371132a515227d3e91a516117a7c5c64
7
+ data.tar.gz: a6934327a2cd254863573f4132fef86ff446477342a2f90d6f43c28fa139f19477284f8474e59bd708d1ca5a3bd9b699fb8de674be96c8cf426060a7292d0033
data/README.md CHANGED
@@ -32,6 +32,7 @@ To create or update a contact in Maropost:
32
32
  Maropost::Api.update_subscriptions(
33
33
  Maropost::Contact.new(
34
34
  email: email,
35
+ do_not_contact: false, # or possibly true to opt in to the DoNotMailList
35
36
  ama_rewards: ama_rewards,
36
37
  ama_membership: ama_membership,
37
38
  ama_insurance: ama_insurance,
@@ -45,7 +46,7 @@ To create or update a contact in Maropost:
45
46
  ama_vr_reminder_email: ama_vr_reminder_email,
46
47
  ama_vr_reminder_sms: ama_vr_reminder_sms,
47
48
  ama_vr_reminder_autocall: ama_vr_reminder_autocall,
48
- cell_phone_number: cell_phone_number.present? ? "1#{cell_phone_number}" : '',
49
+ cell_phone_number: cell_phone_number,
49
50
  phone: phone_number
50
51
  )
51
52
  )
@@ -65,4 +66,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/amaabc
65
66
  ## License
66
67
 
67
68
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
68
-
data/lib/maropost/api.rb CHANGED
@@ -20,11 +20,11 @@ module Maropost
20
20
  end
21
21
 
22
22
  def update_subscriptions(contact)
23
+ update_do_not_mail_list(contact)
23
24
  to_maropost(
24
25
  find(contact.email),
25
26
  contact
26
27
  )
27
- update_do_not_mail_list(contact)
28
28
  end
29
29
 
30
30
  def create(contact)
@@ -75,7 +75,7 @@ module Maropost
75
75
  end
76
76
 
77
77
  def update_do_not_mail_list(contact)
78
- if contact.subscribed_to_any_lists?
78
+ if contact.allow_emails? && contact.subscribed_to_any_lists?
79
79
  DoNotMailList.delete(contact)
80
80
  else
81
81
  DoNotMailList.create(contact)
@@ -3,6 +3,7 @@
3
3
  module Maropost
4
4
  class Contact
5
5
  ATTRIBUTES = %i[
6
+ do_not_contact
6
7
  id
7
8
  email
8
9
  phone_number
@@ -34,11 +35,16 @@ module Maropost
34
35
  self.email = data[:email]
35
36
  self.phone_number = data[:phone]
36
37
  self.cell_phone_number = data[:cell_phone_number]
38
+ self.do_not_contact = data.fetch(:do_not_contact, false)
37
39
  self.errors = []
38
40
  self.lists = {}
39
41
  initialize_lists(data)
40
42
  end
41
43
 
44
+ def allow_emails?
45
+ @allow_emails ||= email.present? && !do_not_contact && !DoNotMailList.exists?(self)
46
+ end
47
+
42
48
  def subscribed_to_any_lists?
43
49
  lists.values.any? { |v| v == '1' }
44
50
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Maropost
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maropost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van den Beuken
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2017-10-18 00:00:00.000000000 Z
22
+ date: 2017-10-19 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: rest-client