maropost 0.6.0 → 0.7.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: 41defb7d262138dbba118f97eff436b079e10e2e
4
- data.tar.gz: 76b093084e65ef9686eac90049407218934ee468
3
+ metadata.gz: a96b51fcc2cf29e3e393dee5c3e94b577add066b
4
+ data.tar.gz: e66ccd7a68abf57ad2e6e790884ef7f0278c2807
5
5
  SHA512:
6
- metadata.gz: ab2429412117bf810f855ee73d2261881a68149d79b3b2419f9d9ac9b09eb369327e863b83146b8d182136adc01b6b99371132a515227d3e91a516117a7c5c64
7
- data.tar.gz: a6934327a2cd254863573f4132fef86ff446477342a2f90d6f43c28fa139f19477284f8474e59bd708d1ca5a3bd9b699fb8de674be96c8cf426060a7292d0033
6
+ metadata.gz: 64d0a1efc1f82d8ba7ad4df2bb8cf6338c3f2d122bc9ebb4317c81e01af3fd1ae74ecda850c01f9863839a4849e37410e4b696dddc73d1130b63d25cd5d03cf7
7
+ data.tar.gz: d4c377258d87e1af223709719538b1fcd5b24eaa618d944d799d7b29ab35952f09a3eff21a6a2177d28d29ddba569c43fb7d1eca74086161d5b142322e3e7f3d
@@ -75,7 +75,7 @@ module Maropost
75
75
  end
76
76
 
77
77
  def update_do_not_mail_list(contact)
78
- if contact.allow_emails? && contact.subscribed_to_any_lists?
78
+ if contact.allow_emails?
79
79
  DoNotMailList.delete(contact)
80
80
  else
81
81
  DoNotMailList.create(contact)
@@ -3,7 +3,7 @@
3
3
  module Maropost
4
4
  class Contact
5
5
  ATTRIBUTES = %i[
6
- do_not_contact
6
+ allow_emails
7
7
  id
8
8
  email
9
9
  phone_number
@@ -35,14 +35,14 @@ module Maropost
35
35
  self.email = data[:email]
36
36
  self.phone_number = data[:phone]
37
37
  self.cell_phone_number = data[:cell_phone_number]
38
- self.do_not_contact = data.fetch(:do_not_contact, false)
38
+ self.allow_emails = data.fetch(:allow_emails) { !DoNotMailList.exists?(self) }
39
39
  self.errors = []
40
40
  self.lists = {}
41
41
  initialize_lists(data)
42
42
  end
43
43
 
44
44
  def allow_emails?
45
- @allow_emails ||= email.present? && !do_not_contact && !DoNotMailList.exists?(self)
45
+ allow_emails
46
46
  end
47
47
 
48
48
  def subscribed_to_any_lists?
@@ -14,9 +14,8 @@ module Maropost
14
14
  )
15
15
  response = JSON.parse(service.execute!.body)
16
16
  response['id'].present?
17
- rescue RestClient::ResourceNotFound, RestClient::BadRequest => e
18
- contact.errors << "Unexpected error occurred. Error: #{e.message}"
19
- contact
17
+ rescue RestClient::ResourceNotFound, RestClient::BadRequest
18
+ false
20
19
  end
21
20
 
22
21
  def create(contact)
@@ -27,10 +26,8 @@ module Maropost
27
26
  payload: payload
28
27
  )
29
28
  service.execute!
30
- contact
31
- rescue RestClient::UnprocessableEntity, RestClient::BadRequest => e
32
- contact.errors << "Unable to subscribe contact. Error: #{e.message}"
33
- contact
29
+ rescue RestClient::UnprocessableEntity, RestClient::BadRequest
30
+ false
34
31
  end
35
32
 
36
33
  def delete(contact)
@@ -42,10 +39,8 @@ module Maropost
42
39
  }
43
40
  )
44
41
  service.execute!
45
- contact
46
- rescue RestClient::UnprocessableEntity, RestClient::BadRequest => e
47
- contact.errors << "Unable to unsubscribe contact. Error: #{e.message}"
48
- contact
42
+ rescue RestClient::UnprocessableEntity, RestClient::BadRequest
43
+ false
49
44
  end
50
45
  end
51
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Maropost
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.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.6.0
4
+ version: 0.7.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-19 00:00:00.000000000 Z
22
+ date: 2017-10-20 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: rest-client