Sha256: d44d29e9f8f40b5f465349f617d75f9ec47b9aef9386e11c842d8b2e8ac98151

Contents?: true

Size: 606 Bytes

Versions: 7

Compression:

Stored size: 606 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

    # TODO: Needs pagination
    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

7 entries across 7 versions & 1 rubygems

Version Path
vng-0.1.20 lib/vng/zip.rb
vng-0.1.19 lib/vng/zip.rb
vng-0.1.18 lib/vng/zip.rb
vng-0.1.17 lib/vng/zip.rb
vng-0.1.16 lib/vng/zip.rb
vng-0.1.15 lib/vng/zip.rb
vng-0.1.14 lib/vng/zip.rb