Sha256: b8197df0b1c8c165ef8a0079ab373125ee12358ad3bd02baefad357b55ca5a8f

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

#
# activity.rb
# ConstantContact
#
# Copyright (c) 2013 Constant Contact. All rights reserved.

module ConstantContact
  module Components
    class Activity < Component
      attr_accessor :id, :type, :status, :start_date, :finish_date, :file_name, :created_date,
                    :error_count, :errors, :warnings, :contact_count

      # Factory method to create an Activity object from a json string
      # @param [Hash] props - properties to create object from
      # @return [Activity]
      def self.create(props)
        obj = Activity.new
        if props
          props.each do |key, value|
            if key == 'errors'
              if value
                obj.errors = []
                value.each do |error|
                  obj.errors << Components::ActivityError.create(error)
                end
              end
            elsif key == 'warnings'
              if value
                obj.warnings = []
                value.each do |error|
                  obj.warnings << Components::ActivityError.create(error)
                end
              end
            else
              obj.send("#{key}=", value) if obj.respond_to? key
            end
          end
        end
        obj
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
constantcontact-4.0.0 lib/constantcontact/components/activities/activity.rb
constantcontact-3.0.0 lib/constantcontact/components/activities/activity.rb
constantcontact-2.2.1 lib/constantcontact/components/activities/activity.rb
constantcontact-ruby-2.2.1 lib/constantcontact/components/activities/activity.rb
constantcontact-ruby-2.2.0 lib/constantcontact/components/activities/activity.rb
constantcontact-2.2.0 lib/constantcontact/components/activities/activity.rb
constantcontact-2.1.0 lib/constantcontact/components/activities/activity.rb
constantcontact-2.0.1 lib/constantcontact/components/activities/activity.rb
constantcontact-2.0.0 lib/constantcontact/components/activities/activity.rb
constantcontact-1.3.2 lib/constantcontact/components/activities/activity.rb
constantcontact-1.2.0 lib/constantcontact/components/activities/activity.rb
constantcontact-1.1.2 lib/constantcontact/components/activities/activity.rb
constantcontact-1.1.1 lib/constantcontact/components/activities/activity.rb
constantcontact-1.1.0 lib/constantcontact/components/activities/activity.rb