Created
April 29, 2012 15:39
-
-
Save bkenny/2551404 to your computer and use it in GitHub Desktop.
CRO API Services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CRO API Access by @bkenny | |
# | |
# Example, to search for a company use: CRO.new(email_address, api_key).companies("Starbucks") | |
# To search for a companies submissions: CRO.new(email_address, api_key).submissions("315499", "c") | |
require 'rubygems' | |
require 'httparty' | |
require 'hashie' | |
class CRO | |
def initialize(u, p) | |
@auth = {:username => u, :password => p} | |
end | |
def companies(company_name) | |
@results = HTTParty.get("https://services.cro.ie/cws/companies?company_name=" + company_name + "&searchType=3&format=json", :basic_auth => @auth) | |
@results.each do |result| | |
@json = Hashie::Mash.new(result) | |
end | |
end | |
def submissions(company_num, company_type) | |
@results = HTTParty.get("https://services.cro.ie/cws/submissions?company_bus_ind=" + company_type + "&company_num=" + company_num + "&format=json", :basic_auth => @auth) | |
@results.each do |result| | |
@json = Hashie::Mash.new(result) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment