lita-destiny 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1001acb2f432e2829d2350b9b135e21ed25e15cb
4
- data.tar.gz: 408334e7ac7d4c16764329f7eedbb0a68e24b231
3
+ metadata.gz: 4ea830396e445d516960ab39d3814072db20ff09
4
+ data.tar.gz: 3672eea695235e4e1bfb5e09efbf6f89c6298118
5
5
  SHA512:
6
- metadata.gz: b891fde418eace9f3d39800c42f9d0e5c6a3bf9eabf2013adc3387e19c4a46d82a0431326a150158aa0e67c56d791d269c250cd56c7b63be129ed853d2839eb6
7
- data.tar.gz: a492befaf6f8be623437c46105001f3abe2c57f9a361b9c2af74e11926c4e8056426bd38f32b845a3898c3bccff3e708498ab4ed9ff0f1203be0a4d9520c6097
6
+ metadata.gz: 55ea8d63db94359252f2a77ce88465b80546d5497ef1859d974e63ef13bff7eabe6ad2f8cb015e47ae7ebd1001fea0869af3269091f8c86fa0b70bb57bb5f32d
7
+ data.tar.gz: b63ea11f2e98dfc4e6f09652d1285ab1b6da82390c31f290fbb0d75d7f04fac21bbe23738b47fc87812ecca70fe9eb115465e4a1bd431a5423368f167651a4cc
@@ -1,5 +1,5 @@
1
1
  require 'httparty'
2
-
2
+ require 'pp'
3
3
  # DestinyAPI module wrapper
4
4
  module DestinyAPI
5
5
  # Base API Class
@@ -13,7 +13,7 @@ module DestinyAPI
13
13
  # Auto-parse responses from Bungie as JSON
14
14
  format :json
15
15
  # Set base uri
16
- base_uri 'www.bungie.net/platform/destiny/'
16
+ base_uri 'www.bungie.net/Platform/Destiny/'
17
17
 
18
18
 
19
19
  # Init the Destiny API with Bungie API stored in ENV variable
@@ -34,7 +34,7 @@ module DestinyAPI
34
34
  # destiny.advisors
35
35
  #
36
36
  def advisors
37
- raw_data = self.class.get('/advisors', headers: @headers)
37
+ raw_data = self.class.get('/Advisors', headers: @headers)
38
38
  parsed = raw_data.parsed_response['Response']['data']
39
39
  end
40
40
 
@@ -50,7 +50,7 @@ module DestinyAPI
50
50
  # raw: (Boolean)
51
51
  #
52
52
  def activity(activity_hash, raw=false)
53
- raw_data = self.class.get("/manifest/activity/#{activity_hash}").parsed_response['Response']['data']['activity']
53
+ raw_data = self.class.get("/Manifest/Activity/#{activity_hash}").parsed_response['Response']['data']['activity']
54
54
  skulls = []
55
55
  raw_data['skulls'].each do |skull|
56
56
  skulls << skull['displayName']
@@ -98,11 +98,42 @@ module DestinyAPI
98
98
  # No known endpoints.
99
99
  def arena(options={})
100
100
  end
101
+
102
+ def search_destiny_player(player_name, platform_type)
103
+ raw_data = self.class.get("/SearchDestinyPlayer/#{platform_type}/#{player_name}/").parsed_response['Response']['membershipId']
104
+ end
105
+
106
+ def get_destiny_account(player_name, platform_type)
107
+ member_id = self.search_destiny_player(player_name, platform_type)
108
+ raw_data = self.class.get("/#{platform_type}/Account/#{member_id}/").parsed_response['Response']['data']
109
+ end
110
+
111
+ def get_manifest_item(type_id, item_id)
112
+ raw_data = self.class.get("/Manifest/#{type_id}/#{item_id}").parsed_response['Response']['data']['inventoryItem']
113
+ end
101
114
 
102
115
  # WIP: Pull xur inventory
103
- # http://www.bungie.net/platform/destiny/advisors/xur/?definitions=true
104
- def xur
105
- raw_data = self.class.get('/advisors/xur/?definitions=true').parsed_response['Response']['definitions']
116
+ # http://www.bungie.net/platform/destiny/advisors/xur/
117
+ def xur(raw=false)
118
+ raw_data = self.class.get('/Advisors/Xur/').parsed_response['Response']['data']
119
+ vendor_hash = raw_data['vendorHash']
120
+ sale_items = {}
121
+
122
+ # Hacky? Probs.
123
+ raw_data['saleItemCategories'].each do |category|
124
+ items = { category['categoryTitle'] => category['saleItems'].map!{|item| {:item_hash => item['item']['itemHash'], :item_cost => item['costs'][0]['value'], :item_cost_hash => item['costs'][0]['itemHash']} } }
125
+ sale_items.merge!(items)
126
+ end
127
+
128
+ if raw
129
+ raw_data
130
+ else
131
+ sale_items
132
+ end
133
+ end
134
+
135
+ def vendor(vendor_hash)
136
+ raw_data = self.class.get("/Manifest/Vendor/#{vendor_hash}").parsed_response['Response']['data']['vendor']['summary']
106
137
  end
107
138
 
108
139
  # Pull the days bounties
@@ -118,7 +149,7 @@ module DestinyAPI
118
149
  # place_hash: (String)
119
150
  #
120
151
  def place(place_hash)
121
- raw data = self.class.get('/manifest/place/#{place_hash}').parsed_response['Response']['data']['place']
152
+ raw data = self.class.get('/Manifest/Place/#{place_hash}').parsed_response['Response']['data']['place']
122
153
  response = { place_name: raw_data['placeName'], place_desc: raw_data['placeDescription'] }
123
154
  end
124
155
 
@@ -131,7 +162,7 @@ module DestinyAPI
131
162
  # destination_hash: (String)
132
163
  #
133
164
  def destination(destination_hash)
134
- raw_data = self.class.get('/manifest/destination/#{destination_hash}').parsed_response['Response']['data']
165
+ raw_data = self.class.get('/Manifest/Destination/#{destination_hash}').parsed_response['Response']['data']
135
166
  response = { dest_name: raw_data['destinationName'], dest_desc: raw_data['destinationDescription'] }
136
167
  end
137
168
  end
@@ -73,8 +73,15 @@ module Lita
73
73
  def build_activity_message(activity, response)
74
74
  # Set activity
75
75
  activity_hash = activity
76
- # Send response
77
- response.reply("#{activity_hash[:activityName]}\n#{activity_hash[:activityDescription]}\nSkulls: #{activity_hash[:skulls].join(', ')}")
76
+ # Send response based on adapter
77
+ case robot.config.robot.adapter
78
+ when :slack
79
+ # Send response
80
+ response.reply("*#{activity_hash[:activityName]}*\n#{activity_hash[:activityDescription]}\n*Skulls:* #{activity_hash[:skulls].join(', ')}")
81
+ else
82
+ # Send response
83
+ response.reply("#{activity_hash[:activityName]}\n#{activity_hash[:activityDescription]}\nSkulls: #{activity_hash[:skulls].join(', ')}")
84
+ end
78
85
  end
79
86
 
80
87
  # Xur Response Method
@@ -86,13 +93,25 @@ module Lita
86
93
  destiny_client = DestinyAPI::Base.new(api_key)
87
94
  # Set xur to our clients xur method
88
95
  xur = destiny_client.xur
96
+
97
+ items = []
98
+ xur.each do |key, value|
99
+ value.each do |key, value|
100
+ item_name = destiny_client.get_manifest_item(6, key[:item_hash])['itemName']
101
+ item_cost = key[:item_cost]
102
+ item_cost_name = destiny_client.get_manifest_item(6, key[:item_cost_hash])['itemName']
103
+ constructed_item = "#{item_name}, #{item_cost} #{item_cost_name}"
104
+ items << constructed_item
105
+ end
106
+ end
107
+
89
108
  # Check vendorDetails to see if anything is availible.
90
- if xur[:vendorDetails].nil?
109
+ if xur.nil?
91
110
  # If nothing, send to chat that he isn't there.
92
- response.reply "Xur isn't in the tower right now."
111
+ response.reply "Xur isn't in game right now."
93
112
  else
94
- # If something, send to chat what he is selling.
95
- response.reply "Xur is selling: "
113
+ #If something, send to chat what he is selling.
114
+ response.reply "*Xur is selling:*\n#{items.join("\n")}"
96
115
  end
97
116
  end
98
117
  end
data/lita-destiny.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-destiny"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.1.4"
4
4
  spec.authors = ["PDaily"]
5
5
  spec.email = ["pat.irwin4@gmail.com"]
6
6
  spec.description = "Small lita.io handler for interacting with the Destiny API"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-destiny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PDaily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita