app/models/mautic/contact.rb in mautic-2.3.11 vs app/models/mautic/contact.rb in mautic-2.4.0

- old
+ new

@@ -115,9 +115,26 @@ alias remove_dnc remove_do_not_contact! # !endgroup + # @!group Campaigns + + # @return [Array<Mautic::Campaign>] + def campaigns + return @campaigns if @campaigns + + json = @connection.request(:get, "api/contacts/#{id}/campaigns") + + @campaigns = json["campaigns"].collect do |_campaign_id, campaign_attributes| + Mautic::Campaign.new @connection, campaign_attributes + end + rescue RequestError => _e + [] + end + + # !endgroup + private def clear_change super remove_instance_variable :@do_not_contact \ No newline at end of file