Class: Active::Services::ActiveWorks
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
|
# File 'lib/services/active_works.rb', line 13
def initialize(data={})
@data = HashWithIndifferentAccess.new(data) || HashWithIndifferentAccess.new
@api_data_loaded = false
@asset_type_id = Activity::ACTIVE_WORKS_ASSET_TYPE_ID
end
|
Instance Attribute Details
#asset_type_id ⇒ Object
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
Finds an active works event by substitution url or returns nil
112
113
114
115
116
117
118
119
120
|
# File 'lib/services/active_works.rb', line 112
def self.find_by_id(id)
begin
doc = Nokogiri::XML(open("http://apij.active.com/activeworks/event/#{id}"))
ActiveWorks.new( Hash.from_xml(doc.to_s) )
rescue
return nil
end
end
|
Instance Method Details
#address ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/services/active_works.rb', line 57
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_id ⇒ Object
24
25
26
27
28
|
# File 'lib/services/active_works.rb', line 24
def asset_id
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("id")
@data["eventDetailDto"]["id"]
end
end
|
#categories ⇒ Object
49
50
51
|
# File 'lib/services/active_works.rb', line 49
def categories
[@data["eventDetailDto"]["channels"]]
end
|
#category ⇒ Object
95
96
97
|
# File 'lib/services/active_works.rb', line 95
def category
primary_category
end
|
87
88
89
|
# File 'lib/services/active_works.rb', line 87
def contact_email
nil
end
|
83
84
85
|
# File 'lib/services/active_works.rb', line 83
def contact_name
nil
end
|
#desc ⇒ Object
99
100
101
102
103
|
# File 'lib/services/active_works.rb', line 99
def desc
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("description")
sanitize( @data["eventDetailDto"]["description"] )
end
end
|
#end_date ⇒ Object
75
76
77
|
# File 'lib/services/active_works.rb', line 75
def end_date
DateTime.parse @data["eventDetailDto"]["endDateTime"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("endDateTime")
end
|
#end_time ⇒ Object
79
80
81
|
# File 'lib/services/active_works.rb', line 79
def end_time
end_date
end
|
#event_image_url ⇒ Object
37
38
39
40
41
|
# File 'lib/services/active_works.rb', line 37
def event_image_url
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("logoUrl")
@data["eventDetailDto"]["logoUrl"]
end
end
|
#primary_category ⇒ Object
53
54
55
|
# File 'lib/services/active_works.rb', line 53
def primary_category
categories.first
end
|
#registration_url ⇒ Object
105
106
107
108
109
|
# File 'lib/services/active_works.rb', line 105
def registration_url
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("registrationUrl")
@data["eventDetailDto"]["registrationUrl"]
end
end
|
#source ⇒ Object
20
21
22
|
# File 'lib/services/active_works.rb', line 20
def source
:active_works
end
|
#start_date ⇒ Object
67
68
69
|
# File 'lib/services/active_works.rb', line 67
def start_date
DateTime.parse @data["eventDetailDto"]["startDateTimeWithTZ"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("startDateTimeWithTZ")
end
|
#start_time ⇒ Object
71
72
73
|
# File 'lib/services/active_works.rb', line 71
def start_time
start_date
end
|
#title ⇒ Object
31
32
33
34
35
|
# File 'lib/services/active_works.rb', line 31
def title
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("name")
@data["eventDetailDto"]["name"]
end
end
|
#url ⇒ Object
43
44
45
46
47
|
# File 'lib/services/active_works.rb', line 43
def url
if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("registrationUrl")
@data["eventDetailDto"]["registrationUrl"]
end
end
|
#user ⇒ Object
91
92
93
|
# File 'lib/services/active_works.rb', line 91
def user
User.new
end
|