Class: SynapsePayRest::Atm

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

Overview

Represents a public key record and holds methods for getting public key instances from API calls. This is built on top of the SynapsePayRest::Client class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Atm

Note:

Do not call directly. Use other class method to instantiate via API action.

Returns a new instance of Atm.



75
76
77
# File 'lib/synapse_pay_rest/models/atm/atm.rb', line 75

def initialize(**options)
  options.each { |key, value| instance_variable_set("@#{key}", value) }
end

Instance Attribute Details

#address_cityObject (readonly)

Returns the value of attribute address_city.



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

def address_city
  @address_city
end

#address_countryObject (readonly)

Returns the value of attribute address_country.



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

def address_country
  @address_country
end

#address_postal_codeObject (readonly)

Returns the value of attribute address_postal_code.



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

def address_postal_code
  @address_postal_code
end

#address_stateObject (readonly)

Returns the value of attribute address_state.



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

def address_state
  @address_state
end

#address_streetObject (readonly)

Returns the value of attribute address_street.



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

def address_street
  @address_street
end

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#distanceObject (readonly)

Returns the value of attribute distance.



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

def distance
  @distance
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#isAvailable24HoursObject (readonly)

Returns the value of attribute isAvailable24Hours.



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

def isAvailable24Hours
  @isAvailable24Hours
end

#isDepositAvailableObject (readonly)

Returns the value of attribute isDepositAvailable.



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

def isDepositAvailable
  @isDepositAvailable
end

#isHandicappedAccessibleObject (readonly)

Returns the value of attribute isHandicappedAccessible.



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

def isHandicappedAccessible
  @isHandicappedAccessible
end

#isOffPremiseObject (readonly)

Returns the value of attribute isOffPremise.



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

def isOffPremise
  @isOffPremise
end

#isSeasonalObject (readonly)

Returns the value of attribute isSeasonal.



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

def isSeasonal
  @isSeasonal
end

#languageTypeObject (readonly)

Returns the value of attribute languageType.



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

def languageType
  @languageType
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

#locationDescriptionObject (readonly)

Returns the value of attribute locationDescription.



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

def locationDescription
  @locationDescription
end

#logoNameObject (readonly)

Returns the value of attribute logoName.



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

def logoName
  @logoName
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



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

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.from_response(client, response) ⇒ Object

Note:

Shouldn’t need to call this directly.

Creates a client public key from a response hash.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/synapse_pay_rest/models/atm/atm.rb', line 14

def from_response(client, response)
  args = {
    client:                  client,
    address_city:            response['atmLocation']['address']['city'],
    address_country:         response['atmLocation']['address']['country'],
    address_postal_code:     response['atmLocation']['address']['postalCode'],
    address_state:           response['atmLocation']['address']['state'],
    address_street:          response['atmLocation']['address']['street'],
    latitude:                response['atmLocation']['coordinates']['latitude'],
    longitude:               response['atmLocation']['coordinates']['longitude'],
    id:                      response['atmLocation']['id'],
    isAvailable24Hours:      response['atmLocation']['isAvailable24Hours'],
    isDepositAvailable:      response['atmLocation']['isDepositAvailable'],
    isHandicappedAccessible: response['atmLocation']['isHandicappedAccessible'],
    isOffPremise:            response['atmLocation']['isOffPremise'],
    isSeasonal:              response['atmLocation']['isSeasonal'],
    languageType:            response['atmLocation']['languageType'],
    locationDescription:     response['atmLocation']['locationDescription'],
    logoName:                response['atmLocation']['logoName'],
    name:                    response['atmLocation']['name'],
    distance:                response['distance']
  }
  self.new(args)
end

.locate(client:, zip: nil, page: nil, per_page: nil, radius: nil, lat: nil, lon: nil) ⇒ SynapsePayRest::Atm

Locate ATMs near zip code

Parameters:

Returns:

Raises:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/synapse_pay_rest/models/atm/atm.rb', line 46

def locate(client:, zip: nil, page: nil, per_page: nil, radius: nil, lat: nil, lon: nil)
  raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
  [page, per_page].each do |arg|
    if arg && (!arg.is_a?(Integer) || arg < 1)
      raise ArgumentError, "#{arg} must be nil or an Integer >= 1"
    end
  end

  [zip, radius, lat, lon].each do |arg|
    if arg && !arg.is_a?(String)
      raise ArgumentError, "#{arg}must be a String"
    end
  end

  response = client.atms.locate(zip: zip, page: page, per_page: per_page, radius: radius, lat: lat, lon: lon)
  multiple_from_response(client, response['atms'])
end

.multiple_from_response(client, response) ⇒ Object

Calls from_response on each member of a response collection.



66
67
68
69
# File 'lib/synapse_pay_rest/models/atm/atm.rb', line 66

def multiple_from_response(client, response)
  return [] if response.empty?
  response.map { |atm_data| from_response(client.dup, atm_data)}
end