Module: Destiny::Advisors

Included in:
Client
Defined in:
lib/destiny_rb/advisors.rb

Instance Method Summary collapse

Instance Method Details

#activity_search(activity_hash, raw = false) ⇒ Object

GET the activity information from ‘/manifest/activity/activity_hash/’

Raw argument will return an unmodified respons from Bungie.

Usage:

client.activity('3508129769', false)

Arguments:

activity_hash: (String)
raw: (Boolean)

Returns:

A JSON object containing activity information based on the activity hash supplied with:
  activityName: (String)
  activityDescription: (String)
  skulls: (Array)(Strings)

If raw = true, returns whole response back from bungie.


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/destiny_rb/advisors.rb', line 36

def activity_search(activity_hash, raw=false)
  raw_data = self.class.get("/Manifest/Activity/#{activity_hash}", headers: @headers).parsed_response['Response']['data']['activity']
  skulls = []
  raw_data['skulls'].each do |skull|
    skulls << skull['displayName']
  end
  if raw
    raw_data
  else
    parsed_data = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
  end
end

#arena(level = 32) ⇒ Object

GET the weekly prison of elders pulled info from ‘/advisors’ endpoint Without any arguments, only returns the level 32 information.

Usage:

client.arena(34)

Arguments:

level: (integer)


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/destiny_rb/advisors.rb', line 89

def arena(level=32)
  arenas = self.daily_report['arena']
  case level
   when 32
     arenas[0]
   when 34
     arenas[1]
   when 35
     arenas[2]
  end
end

#daily_reportObject

GET the days advisor report from www.bungie.net/platform/destiny/advisors/

Usage:

Destiny::Advisors.report

Returns:

A JSON object containing activity hashes, end times, and special events.


12
13
14
15
# File 'lib/destiny_rb/advisors.rb', line 12

def daily_report
  raw_data = self.class.get('/Advisors', headers: @headers)
  parsed = raw_data.parsed_response['Response']['data']
end

#nightfall(raw = false) ⇒ Object

GET the weekly nightfall info from ‘/manifest/activity/#activity_hash’

Optional boolean argument.

Usage:

client.nightfall(true)

Arguments:

raw: (boolean)


59
60
61
62
# File 'lib/destiny_rb/advisors.rb', line 59

def nightfall(raw=false)
  nightfall_activity_hash = self.daily_report['nightfallActivityHash']
  activity_search(nightfall_activity_hash, raw)
end

#weekly_strike(raw = false) ⇒ Object

GET the weekly strike info from ‘/manifest/activity/#activity_hash’ Returns an array of three items, only need one for the skulls and location.

Optional boolean argument, defaults to false from activity method to return basic information for Lita bot.

Usage:

client.weekly_strike(false)

Arguments:

raw: (boolean)


75
76
77
78
# File 'lib/destiny_rb/advisors.rb', line 75

def weekly_strike(raw=false)
  heroic_strike_hashes = self.daily_report['heroicStrikeHashes']
  activity_search(heroic_strike_hashes[0], raw)
end