Class: Active::Services::ActiveWorks

Inherits:
IActivity
  • Object
show all
Defined in:
lib/services/active_works.rb

Instance Attribute Summary collapse

Attributes inherited from IActivity

#data, #online_registration

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IActivity

#validated_address

Constructor Details

#initialize(data = {}) ⇒ ActiveWorks

Returns a new instance of ActiveWorks.



13
14
15
16
17
18
19
# File 'lib/services/active_works.rb', line 13

def initialize(data={})
  # need to hold on to original data
  @data = HashWithIndifferentAccess.new(data) || HashWithIndifferentAccess.new
  @api_data_loaded = false
  @asset_type_id = "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1"
  get_app_api
end

Instance Attribute Details

#asset_type_idObject

Returns the value of attribute asset_type_id.



11
12
13
# File 'lib/services/active_works.rb', line 11

def asset_type_id
  @asset_type_id
end

Class Method Details

.find_by_id(id) ⇒ Object

EXAMPLE lazy load the data for some_crazy_method def some_crazy

return @some_crazy unless @some_crazy.nil?
@some_crazy = @data[:some_crazy_method_from_ats].split replace twist bla bla bla

end



116
117
118
# File 'lib/services/active_works.rb', line 116

def self.find_by_id(id) #local id
    return ActiveWorks.new({:id=>id})
end

Instance Method Details

#addressObject



58
59
60
61
62
63
64
65
66
# File 'lib/services/active_works.rb', line 58

def address
    @address = validated_address({
      :address => @data["eventDetailDto"]["addressLine1"],
      :city    => @data["eventDetailDto"]["addressCity"],
      :state   => @data["eventDetailDto"]["state"],
      :zip     => @data["eventDetailDto"]["addressPostalCode"],
      :country => @data["eventDetailDto"]["countryName"]
    })
end

#asset_idObject



25
26
27
28
29
# File 'lib/services/active_works.rb', line 25

def asset_id
  if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("id")
    @data["eventDetailDto"]["id"]
  end
end

#categoriesObject



50
51
52
# File 'lib/services/active_works.rb', line 50

def categories
  [@data["eventDetailDto"]["channels"]]
end

#categoryObject



97
98
99
# File 'lib/services/active_works.rb', line 97

def category
  primary_category
end

#contact_emailObject



88
89
90
# File 'lib/services/active_works.rb', line 88

def contact_email
  nil
end

#contact_nameObject



84
85
86
# File 'lib/services/active_works.rb', line 84

def contact_name
  nil
end

#descObject



101
102
103
104
105
106
# File 'lib/services/active_works.rb', line 101

def desc
  if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("description")
#          @data["eventDetailDto"]["description"].gsub('\"','"')
    sanitize @data["eventDetailDto"]["description"]
  end
end

#end_dateObject



76
77
78
# File 'lib/services/active_works.rb', line 76

def end_date
  DateTime.parse @data["eventDetailDto"]["endDateTime"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("endDateTime")
end

#end_timeObject



80
81
82
# File 'lib/services/active_works.rb', line 80

def end_time
  end_date
end

#event_image_urlObject



38
39
40
41
42
# File 'lib/services/active_works.rb', line 38

def event_image_url
  if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("logoUrl")
    @data["eventDetailDto"]["logoUrl"]
  end
end

#primary_categoryObject



54
55
56
# File 'lib/services/active_works.rb', line 54

def primary_category
  categories.first
end

#sourceObject



21
22
23
# File 'lib/services/active_works.rb', line 21

def source
  :active_works
end

#start_dateObject



68
69
70
# File 'lib/services/active_works.rb', line 68

def start_date
  DateTime.parse @data["eventDetailDto"]["startDateTimeWithTZ"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("startDateTimeWithTZ")
end

#start_timeObject



72
73
74
# File 'lib/services/active_works.rb', line 72

def start_time
  start_date
end

#titleObject



32
33
34
35
36
# File 'lib/services/active_works.rb', line 32

def title
  if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("name")
    @data["eventDetailDto"]["name"]
  end
end

#urlObject



44
45
46
47
48
# File 'lib/services/active_works.rb', line 44

def url
  if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("registrationUrl")
    @data["eventDetailDto"]["registrationUrl"]
  end
end

#userObject



92
93
94
# File 'lib/services/active_works.rb', line 92

def user
  User.new
end