Sha256: 846e468c9e9ea135168eb5bc0db37b9afe2ad26ee16cdf88750ac0990514d6ff

Contents?: true

Size: 717 Bytes

Versions: 25

Compression:

Stored size: 717 Bytes

Contents

module Magento
  # http://www.magentocommerce.com/wiki/doc/webservices-api/api/directory_country
  class Country < Base
    class << self
      # directory_country.list
      # Retrieve list of countries.
      # 
      # Return: array.
      def list
        results = commit("list", nil)
        results.collect do |result|
          new(result)
        end
      end
      
      def all
        list
      end
      
      def find_by_id(id)
        list.select{ |c| c.id == id }.first
      end
      
      def find_by_iso(iso)
        list.select{ |c| [c.iso2_code, c.iso3_code].include? iso }.first
      end
    end
    
    def regions
      Magento::Region.find_by_country(self.iso2_code)
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
magentor-0.3.1 lib/magento/country.rb
magentor-0.3.0 lib/magento/country.rb
magentor-0.2.18 lib/magento/country.rb
magentor-0.2.17 lib/magento/country.rb
magentor-0.2.16 lib/magento/country.rb
magentor-0.2.15 lib/magento/country.rb
magentor-0.2.14 lib/magento/country.rb
magentor-0.2.13 lib/magento/country.rb
magentor-0.2.12 lib/magento/country.rb
magentor-0.2.11 lib/magento/country.rb
magentor-0.2.10 lib/magento/country.rb
magentor-0.2.9 lib/magento/country.rb
magentor-0.2.8 lib/magento/country.rb
magentor-0.2.7 lib/magento/country.rb
magentor-0.2.6 lib/magento/country.rb
magentor-0.2.5 lib/magento/country.rb
magentor-0.2.4 lib/magento/country.rb
magentor-0.2.3 lib/magento/country.rb
magentor-0.2.2 lib/magento/country.rb
magentor-0.2.1 lib/magento/country.rb