Sha256: c0a71fcaa0f840f53147acbfbc1ebeabef9c70cbae0a600cd1593a40096af21c

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 Bytes

Contents

module MonkeyParty
  class Subscriber
    attr_accessor :email, :merge_fields, :error

    def initialize(email, merge_fields = {})
      self.email = email
      self.merge_fields = merge_fields
      self.error = nil
    end

    def to_h
      {
        :email => self.email
      }.merge(self.merge_fields)
    end

    def to_mailchimp_hash
      chimp_hash = {}
      self.to_h.each do |key, value|
        chimp_hash[key.to_s.upcase[0..9]] = value
      end

      chimp_hash
    end

    def valid?
      self.error.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
monkey_party-0.3.1 lib/monkey_party/subscriber.rb
monkey_party-0.3.0 lib/monkey_party/subscriber.rb