Module: Nzcoapi
- Includes:
- HTTParty, Nokogiri
- Defined in:
- lib/nzcoapi.rb,
lib/nzcoapi/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"- @@access_key =
"J5zFrdfHu5Bbg2iw"- @@secret_key =
"fin39USzsZGHSJGVUwzkUJWgL2yUDQ1C0n6NBtv2"- @@timestamp =
Time.now.rfc2822 + " GMT"
Class Method Summary collapse
- .find_company(id) ⇒ Object
- .find_director(string) ⇒ Object
- .search_for_company(string) ⇒ Object
- .tagged(tag) ⇒ Object
Class Method Details
.find_company(id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nzcoapi.rb', line 48 def self.find_company(id) headers "Timestamp" => Time.now.rfc2822 + " GMT" @@timestamp = Time.now.rfc2822 + " GMT" stringtosign = "GET" + "\n" + "www.businessdata.govt.nz" + "\n" + "/data/app/ws/rest/companies/entity/v2.0/#{id}" + "\n" + @@timestamp + "\n" + @@access_key + "\n" + "application/xml" + "\n" headers "Authorization" => @@access_key + ":" + Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', @@secret_key, stringtosign)) Nokogiri::XML((get("/data/app/ws/rest/companies/entity/v2.0/#{id}").body), 'UTF-8') end |
.find_director(string) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nzcoapi.rb', line 36 def self.find_director(string) headers "Timestamp" => Time.now.rfc2822 + " GMT" @@timestamp = Time.now.rfc2822 + " GMT" stringtosign = "GET" + "\n" + "www.businessdata.govt.nz" + "\n" + "/data/app/ws/rest/companies/role/search/v1.0/size/200/type/DIR/#{string}" + "\n" + @@timestamp + "\n" + @@access_key + "\n" + "application/xml" + "\n" headers "Authorization" => @@access_key + ":" + Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', @@secret_key, stringtosign)) Nokogiri::XML((get("/data/app/ws/rest/companies/role/search/v1.0/size/200/type/DIR/#{string}").body), 'UTF-8') end |
.search_for_company(string) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nzcoapi.rb', line 24 def self.search_for_company(string) headers "Timestamp" => Time.now.rfc2822 + " GMT" @@timestamp = Time.now.rfc2822 + " GMT" stringtosign = "GET" + "\n" + "www.businessdata.govt.nz" + "\n" + "/data/app/ws/rest/companies/entity/search/v2.0/#{string}" + "\n" + @@timestamp + "\n" + @@access_key + "\n" + "application/xml" + "\n" headers "Authorization" => @@access_key + ":" + Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', @@secret_key, stringtosign)) headers "Timestamp" => Time.now.rfc2822 + " GMT" Nokogiri::XML((get("/data/app/ws/rest/companies/entity/search/v2.0/#{string}").body), 'UTF-8') end |
.tagged(tag) ⇒ Object
62 63 64 |
# File 'lib/nzcoapi.rb', line 62 def self.tagged(tag) retrieve_url get("/#{tag}.json") end |