Class: Atm

Inherits:
Object
  • Object
show all
Defined in:
lib/capital_one/atm.rb

Class Method Summary collapse

Class Method Details

.apiKeyObject



11
12
13
# File 'lib/capital_one/atm.rb', line 11

def self.apiKey
  return Config.apiKey
end

.getAllObject

Returns all ATMs as a hash (first page only) Pagination was implemented to break up the size of the hash



21
22
23
24
25
# File 'lib/capital_one/atm.rb', line 21

def self.getAll
  url = "#{self.urlWithEntity}?key=#{self.apiKey}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
end

.getAllByLocation(lat, lng, rad) ⇒ Object

Get all ATMs withing a certain radius of a geocoordinate

Paremeters: latitude, longitude, radius

Accepts lat, lng, and rad as floats Returns an array of hashes within the radius of the geocoordinate. Each hash has an ATM.



44
45
46
47
48
# File 'lib/capital_one/atm.rb', line 44

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)
end

.getAllByLocationWithPage(lat, lng, rad, page) ⇒ Object

Returns all ATMs within a certain radius for a given response page

Parameters: lat, lng, and rad as floats; page as int

Returns a hash of ATM details



55
56
57
58
59
# File 'lib/capital_one/atm.rb', line 55

def self.getAllByLocationWithPage(lat, lng, rad, page)
  url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}&page=#{page}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
end

.getAllWithPage(page) ⇒ Object

Returns all ATMs for a given response page

Parameters: page as an integer

Returns a hash of ATM details



32
33
34
35
36
# File 'lib/capital_one/atm.rb', line 32

def self.getAllWithPage(page)
  url = "#{self.urlWithEntity}?key=#{self.apiKey}&page=#{page}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
end

.getOne(id) ⇒ Object

Gets one ATM for a given ID Parameters: AtmId Returns the ATM that has the given ID.



67
68
69
70
71
# File 'lib/capital_one/atm.rb', line 67

def self.getOne(id)
  url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
end

.urlObject



7
8
9
# File 'lib/capital_one/atm.rb', line 7

def self.url
  return Config.baseUrl
end

.urlWithEntityObject



3
4
5
# File 'lib/capital_one/atm.rb', line 3

def self.urlWithEntity
  return Config.baseUrl + "/atms"
end