Sha256: e7deedbb9f88b4c516743d8a7b950b4a4f81be5c559f954b2892ef05178ff928

Contents?: true

Size: 577 Bytes

Versions: 5

Compression:

Stored size: 577 Bytes

Contents

require 'vng/resource'

module Vng
  # Provides methods to interact with Vonigo ZIP codes.
  class Zip < Resource
    PATH = '/api/v1/resources/zips/'

    attr_reader :zip, :state, :zone_name

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vng-1.4.0 lib/vng/zip.rb
vng-1.3.0 lib/vng/zip.rb
vng-1.2.0 lib/vng/zip.rb
vng-1.1.0 lib/vng/zip.rb
vng-1.0.0 lib/vng/zip.rb