Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 27 lines (22 sloc) 1.091 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
require 'httparty'

module GemfindApi
  CLARITY_VALUES = %w(FL IF VVS1 VVS2 VS1 VS2 SI1 SI2 SI3 I1 I2 I3).freeze
  COLOR_VALUES = %w(D E F G H I J K L M N O P Q R S T U V W).freeze
  SHAPE_VALUES = %w(Round European Marquise Pear Oval Heart Trilliant Emerald Princess Baguette).freeze
  CERTIFICATE_VALUES = %w(GIA EGL AGS IGI HRD GUB AGL).freeze

  def self.value(options = {})
    raise 'Specify a Clarity' unless options['minimum_clarity'] && options['maximum_clarity']
    raise 'Specify a Color' unless options['minimum_color'] && options['maximum_color']
    raise 'Specify a Size' unless options['size']

    response = HTTParty.post("http://www.gemfind.net/getgfindex.asmx/GFIndex", :body => {
      'ClarityMin' => options['minimum_clarity'],
      'ClarityMax' => options['maximum_clarity'],
      'ColorMin' => options['minimum_color'],
      'ColorMax' => options['maximum_color'],
      'Size' => options['size'],
      'Shape' => options['shape'],
      'Certificate' => options['certificate']
    })

    response['string']
  end
end
Something went wrong with that request. Please try again.