Module: Riaction::Riaction::Profile::InstanceMethods

Defined in:
lib/riaction/riaction.rb

Instance Method Summary collapse

Instance Method Details

#riaction_profile_achievements(filter_type = nil) ⇒ Object



278
279
280
281
282
283
284
285
286
# File 'lib/riaction/riaction.rb', line 278

def riaction_profile_achievements(filter_type=nil)
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_achievements(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_profile_challenges(filter_type = nil) ⇒ Object



288
289
290
291
292
293
294
295
296
# File 'lib/riaction/riaction.rb', line 288

def riaction_profile_challenges(filter_type=nil)
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_challenges(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_profile_display_nameObject



241
242
243
244
245
# File 'lib/riaction/riaction.rb', line 241

def riaction_profile_display_name
  riaction_resolve_param self.class.riaction_profile_keys.fetch(riaction_use_profile)[:display_name]
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
end

#riaction_profile_goals(filter_type = nil) ⇒ Object



298
299
300
301
302
303
304
305
306
# File 'lib/riaction/riaction.rb', line 298

def riaction_profile_goals(filter_type=nil)
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_goals(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, filter_type)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_profile_keysObject



224
225
226
227
228
229
230
231
232
233
# File 'lib/riaction/riaction.rb', line 224

def riaction_profile_keys
  resolved_hash = {}
  self.class.riaction_profile_keys.each_pair do |profile_type, opts|
    resolved_hash[profile_type] = {}
    opts.fetch(:identifiers, {}).each_pair do |identifier_type, value|
      resolved_hash[profile_type][identifier_type] = riaction_resolve_param(value)
    end
  end
  resolved_hash
end

#riaction_profile_notificationsObject



308
309
310
311
312
313
314
315
316
# File 'lib/riaction/riaction.rb', line 308

def riaction_profile_notifications
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_notifications(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_profile_points(point_type) ⇒ Object



318
319
320
321
322
323
324
325
326
# File 'lib/riaction/riaction.rb', line 318

def riaction_profile_points(point_type)
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_points(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, point_type)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_profile_summary(achievement_count = nil) ⇒ Object

API wrappers #



268
269
270
271
272
273
274
275
276
# File 'lib/riaction/riaction.rb', line 268

def riaction_profile_summary(achievement_count=nil)
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.set_object_wrapping(riaction_wrap_response).get_profile_summary(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, achievement_count)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_raw_dataObject



260
261
262
# File 'lib/riaction/riaction.rb', line 260

def riaction_raw_data
  riaction_wrap_response_data(false)
end

#riaction_set_profile(type) ⇒ Object

Raises:



235
236
237
238
239
# File 'lib/riaction/riaction.rb', line 235

def riaction_set_profile(type)
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{type}") unless riaction_profile_keys.has_key?(type)
  @riaction_use_profile = type
  self
end

#riaction_update_profile_points(point_type, amount, reason = "") ⇒ Object



328
329
330
331
332
333
334
335
336
# File 'lib/riaction/riaction.rb', line 328

def riaction_update_profile_points(point_type, amount, reason="")
  @iactionable_api ||= IActionable::Api.new
  keys = riaction_profile_keys.fetch(riaction_use_profile)
  @iactionable_api.update_profile_points(riaction_use_profile.to_s, keys.first[0].to_s, keys.first[1].to_s, point_type, amount, reason)
rescue KeyError => e
  raise RuntimeError.new("#{self.to_s} does not define a profile type #{riaction_use_profile}")
rescue IActionable::Error::BadRequest => e
  nil
end

#riaction_wrap_dataObject



256
257
258
# File 'lib/riaction/riaction.rb', line 256

def riaction_wrap_data
  riaction_wrap_response_data(true)
end

#riaction_wrap_response_data(bool) ⇒ Object



247
248
249
250
# File 'lib/riaction/riaction.rb', line 247

def riaction_wrap_response_data(bool)
  @riaction_wrap_response = !!bool
  self
end

#riaction_wrap_response_data?Boolean

Returns:

  • (Boolean)


252
253
254
# File 'lib/riaction/riaction.rb', line 252

def riaction_wrap_response_data?
  riaction_wrap_response
end