Skip to content

Commit

Permalink
Draft of transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBaummann committed May 13, 2015
1 parent d50d5d5 commit ce040f7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/gw2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@
require "gw2/commerce/listings"
require "gw2/commerce/exchange"
require "gw2/commerce/prices"
require "gw2/commerce/transactions"
require "gw2/disabled"

module GW2
attr_accessor :key

BASE_URL_V1 = "https://api.guildwars2.com/v1"
BASE_URL_V2 = "https://api.guildwars2.com/v2"

def self.key
@key
end

def self.key=key
@key = key
end

end
2 changes: 1 addition & 1 deletion lib/gw2/commerce/prices.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GW2
module Commerce
module Listings
module Prices
extend Resource

def self.all
Expand Down
10 changes: 10 additions & 0 deletions lib/gw2/commerce/transactions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module GW2
module Commerce
module Transactions
extend Resource
def self.current(mode = "buys")
get("/commerce/transactions/current/#{mode}.json", headers: {Authorization: "Bearer #{GW2.key}"})
end
end
end
end
4 changes: 2 additions & 2 deletions lib/gw2/https.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def query_string(query_hash = {})
end

def request(end_point = "", attr = {})
puts "ATTRIBUTES"
puts attr
attr = DEFAULT_REQUEST.merge(attr)

if V1_ENDPOINTS.any? { |word| end_point.include?(word) }
Expand All @@ -24,12 +26,10 @@ def request(end_point = "", attr = {})
http.use_ssl = attr[:ssl]
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if attr[:ssl] # need to get a cert -_____-

net_http = Net::HTTP
request = Net::HTTP.const_get(attr[:action]).new(uri.request_uri)
attr[:headers].each { |key, value| request[key.to_s] = value } if attr[:headers]

request.set_form_data(attr[:form_data]) if attr[:form_data]

http.request(request)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gw2/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Resource
BASE_URL_V2 = "https://api.guildwars2.com/v2"

def get(endpoint, query = {})
parse(request(endpoint, query: query).body)
parse(request(endpoint, query).body)
end
end
end

0 comments on commit ce040f7

Please sign in to comment.