ractive_campaign 0.1.4 → 0.1.5

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: 138c40a5a3a11cfdaca62219657f9757cade906aadda7ec72d34c742370c0963
4
- data.tar.gz: 1dc92c8d3b8653899c9133485d094536266d6e8e452473229ec04ca464d50f65
3
+ metadata.gz: f0f3b24a31bfe00c8c7bbe97b2a480cb6c7d5ea0838e01b7beb79311e3ee5d43
4
+ data.tar.gz: 9ca59df1246b16a23d7640ce60552328a9e0802f438e645348e91e728cf9db66
5
5
  SHA512:
6
- metadata.gz: 44e8d36dda391fa212172e35f1b5059477e61f517906a23289accc539b516234593633526624d9904429ce15581a3f807e08d7c18f315ad15e965889cffbd009
7
- data.tar.gz: c1dffb39c97ad93b7d72004f0e625e4e09387d2b916c9d0792dde586deb8a57ebbda4e5e22b59949db9f30ff10fc1ea301b6580e9e801fb2a19254f674c47ec8
6
+ metadata.gz: 95566c3ad4cf971380b2486058f315c16cb0f8ad5263e145167d40d96ee30d22c85079a5d4ee8868b1effc8a37f7d32d2e1d30fc215f4db555bb6544f309b589
7
+ data.tar.gz: 0ea82c9eb5b94efb4e881b10b603e8c035f226630f67115f173c28dcdae4b202e011710bedf11e73df880c9118c67778a56c7efdab97619de6b18eb09335bcde
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.5] - 2021-11-19
4
+ ### Changed
5
+
6
+ - when adding a tag to a contact, create it if it doesn't exist
7
+
3
8
  ## [0.1.4] - 2021-11-19
4
9
  ### Changed
5
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ractive_campaign (0.1.4)
4
+ ractive_campaign (0.1.5)
5
5
  activemodel (~> 6.1.4)
6
6
  dry-configurable (~> 0.12.1)
7
7
  faraday (~> 1.8.0)
@@ -24,14 +24,22 @@ module ActiveCampaign
24
24
  ContactTag.get "#{self.class.endpoint}/#{id}/contactTags"
25
25
  end
26
26
 
27
- # @example Apply a tag to a contact.
27
+ # @example Add a tag to a contact.
28
28
  #
29
29
  # ActiveCampaign::Contact.find(1).add_tag "tag-name"
30
30
  #
31
- def add_tag(tag)
31
+ # Don't create the tag if it doesn't exist.
32
+ #
33
+ # ActiveCampaign::Contact.find(1).add_tag "tag-name", create_if_not_found: false
34
+ #
35
+ def add_tag(tag, create_if_not_found: true)
32
36
  tag_id = Tag.find_by(tag: tag)&.id
33
37
 
34
- ActiveCampaign::ContactTag.create contact: id, tag: tag_id if tag_id
38
+ tag_id = ActiveCampaign::Tag.create(tag: tag)&.id if !tag_id && create_if_not_found
39
+
40
+ return false unless tag_id
41
+
42
+ ActiveCampaign::ContactTag.create contact: id, tag: tag_id
35
43
  end
36
44
 
37
45
  # @example Remove a tag from a contact.
@@ -41,6 +49,8 @@ module ActiveCampaign
41
49
  def remove_tag(tag)
42
50
  tag_id = Tag.find_by(tag: tag)&.id
43
51
 
52
+ return false unless tag_id
53
+
44
54
  contact_tag = contact_tags.filter_map { |ct| ct if ct.tag == tag_id }.last
45
55
 
46
56
  contact_tag&.destroy
@@ -3,5 +3,11 @@
3
3
  module ActiveCampaign
4
4
  class Tag < Model # :nodoc:
5
5
  define_attributes :tag, :tagType, :description
6
+
7
+ def create
8
+ self.tagType ||= "contact"
9
+
10
+ super
11
+ end
6
12
  end
7
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCampaign
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ractive_campaign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wedson Lima
@@ -122,6 +122,7 @@ metadata:
122
122
  homepage_uri: https://github.com/wedsonlima/ractive_campaign
123
123
  source_code_uri: https://github.com/wedsonlima/ractive_campaign
124
124
  changelog_uri: https://github.com/wedsonlima/ractive_campaign/blob/main/CHANGELOG.md
125
+ documentation_uri: https://www.rubydoc.info/gems/ractive_campaign/0.1.5
125
126
  post_install_message:
126
127
  rdoc_options: []
127
128
  require_paths: