class Merchant
Public Class Methods
apiKey()
click to toggle source
# File lib/capital_one/merchant.rb, line 11 def self.apiKey return Config.apiKey end
createMerchant(merchant)
click to toggle source
createMerchant¶ ↑
Creates a new Merchant
Parameters: MerchantHash¶ ↑
MerchantHash format is as follows: { "name": "string", "address": { "street_number": "string", "street_name": "string", "city": "string", "state": "string", "zip": "string", }, "geocode": { "lat": 0, "lng": 0, } } Returns http response code
# File lib/capital_one/merchant.rb, line 107 def self.createMerchant(merchant) merchantToCreate = merchant.to_json url = "#{self.urlWithEntity}/?key=#{self.apiKey}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'}) request.body = merchantToCreate resp = http.request(request) data = JSON.parse(resp.body) end
getAll()
click to toggle source
getAllByLocation(lat, lng, rad)
click to toggle source
getAllByLocation¶ ↑
Returns all Merchants within a given location range
Parameters: Latitude, Longitude, Radius¶ ↑
Accepts lat, lng, and rad as floats Returns an array of hashes
# File lib/capital_one/merchant.rb, line 32 def self.getAllByLocation(lat, lng, rad) url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}" resp = Net::HTTP.get_response(URI.parse(url)) data = JSON.parse(resp.body) return data end
getOne(merchId)
click to toggle source
getOne¶ ↑
Returns a single merchant for a given ID
Parameters: MerchantId¶ ↑
Returns a hash
# File lib/capital_one/merchant.rb, line 44 def self.getOne(merchId) url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}" resp = Net::HTTP.get_response(URI.parse(url)) data = JSON.parse(resp.body) return data end
updateMerchant(merchId, merchant)
click to toggle source
updateMerchant¶ ↑
Updates an existing Merchant
Parameters: MerchantId, MerchantHash¶ ↑
MerchantHash format is as follows: { "name": "string", "address": { "street_number": "string", "street_name": "string", "city": "string", "state": "string", "zip": "string", }, "geocode": { "lat": 0, "lng": 0, } } Returns http response code
# File lib/capital_one/merchant.rb, line 73 def self.updateMerchant(merchId, merchant) merchantToUpdate = merchant.to_json url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) key = "?key=#{self.apiKey}" request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'}) request.body = merchantToUpdate response = http.request(request) return JSON.parse(response.body) end
url()
click to toggle source
# File lib/capital_one/merchant.rb, line 7 def self.url return Config.baseUrl end
urlWithEntity()
click to toggle source
# File lib/capital_one/merchant.rb, line 3 def self.urlWithEntity return Config.baseUrl + "/merchants" end