Class: Vng::Zip

Inherits:
Resource show all
Defined in:
lib/vng/zip.rb

Overview

Provides methods to interact with Vonigo ZIP codes.

Constant Summary collapse

PATH =
'/api/v1/resources/zips/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zip:, state:, zone_name:) ⇒ Zip

Returns a new instance of Zip.



10
11
12
13
14
# File 'lib/vng/zip.rb', line 10

def initialize(zip:, state:, zone_name:)
  @zip = zip
  @state = state
  @zone_name = zone_name
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/vng/zip.rb', line 8

def state
  @state
end

#zipObject (readonly)

Returns the value of attribute zip.



8
9
10
# File 'lib/vng/zip.rb', line 8

def zip
  @zip
end

#zone_nameObject (readonly)

Returns the value of attribute zone_name.



8
9
10
# File 'lib/vng/zip.rb', line 8

def zone_name
  @zone_name
end

Class Method Details

.allObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vng/zip.rb', line 16

def self.all
  data = request path: PATH

  data['Zips'].map do |body|
    zip = body['zip']
    state = body['state']
    zone_name = body['zoneName']

    new zip: zip, state: state, zone_name: zone_name
  end
end