Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring up to date #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rubygems'
require 'lib/companies_house'
require_relative 'lib/companies_house'

begin
require 'spec'
Expand Down
6 changes: 6 additions & 0 deletions lib/companies_house.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'nokogiri'
require 'haml'
require 'yaml'
require 'debugger'

require File.dirname(__FILE__) + '/companies_house/request'
require File.dirname(__FILE__) + '/companies_house/exception'
Expand All @@ -33,6 +34,11 @@ def company_details number, options={}
get_response(xml)
end

def company_incorporation options={}
xml = CompaniesHouse::Request.company_incorporation_xml options
get_response(xml)
end

def sender_id= id
@sender_id = id
end
Expand Down
141 changes: 141 additions & 0 deletions lib/companies_house/company_incorporation.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
%Body
%NumberSearchRequest{ :request_ns=>'' }
%PartialCompanyNumber= company_number
%DataSet= data_set
%SearchRows= search_rows

%Body
%FormSubmission{xmlns: "http://xmlgw.companieshouse.gov.uk/Header", "xmlns:bs" => "http://xmlgw.companieshouse.gov.uk", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemalocation" => "http://xmlgw.companieshouse.gov.uk/Header http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/FormSubmission-v1-1.xsd"}
%Formheader
%CompanyName TEST INC COMPANY LTD
%PackageReference 1828
%FormIdentifier CompanyIncorporation
%SubmissionNumber SUB006
%Authority
%Designation AGENT
%DateSigned 2008-05-31
%Form
%CompanyIncorporation{xmlns: "http://xmlgw.companieshouse.gov.uk", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemalocation" => "http://xmlgw.companieshouse.gov.uk http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/CompanyIncorporation-v1-1.xsd"}
%SameDay false
%RegisteredOfficeAddress
%Premise 10
%Street The Street
%Thoroughfare Titchfield
%PostTown Fareham
%County Hants
%Country UK
%Postcode PO14 4HW
%CompanyType BYSHR
%CountryOfIncorporation EW
%Agent
%Person
%Forename Edwin
%Surname Crockford
%Address
%Premise 10
%Street The Street
%Thoroughfare
%PostTown Cardiff
%Postcode CF14 3UZ
%Appointment
%Authentication
%PersonalAttribute BIRTOWN
%PersonalData Sco
%Authentication
%PersonalAttribute PASSNO
%PersonalData 234
%Authentication
%PersonalAttribute EYE
%PersonalData Blu
%Director
%Address
%Premise 10
%Street The Street
%Thoroughfare
%PostTown Cardiff
%Postcode CF14 3UZ
%Person
%Surname Crockford
%Forename Phil
%Honours BEng
%DOB 1959-09-04
%Nationality British
%Occupation Hacker
%Appointment
%Authentication
%PersonalAttribute NATINS
%PersonalData YR1
%Authentication
%PersonalAttribute BIRTOWN
%PersonalData Sco
%Authentication
%PersonalAttribute PASSNO
%PersonalData 234
%Secretary
%Address
%Premise 10
%Street The Street
%PostTown Cardiff
%Postcode CF14 3UZ
%Corporate
%Forename Chris
%Surname Smith
%CorporateName The Nominee Corp
%AuthorisedCapital
%ShareClass Ordinary
%Currency GBP
%AuthorisedCapital 1000
%NumShares 5000
%ShareValue 0.2
%Subscribers
%TotalNumberShares 200
%Subscriber
%PersonalAuthenticationCode 040101
%NumShares 100
%Subscriber
%Corporate
%Forename Fred
%Surname Williams
%CorporateName The Investment Company
%Address
%Premise 10
%Street The Street
%Thoroughfare
%PostTown Cardiff
%Postcode CF14 3UZ
%Authentication
%PersonalAttribute NATINS
%PersonalData YR1
%Authentication
%PersonalAttribute BIRTOWN
%PersonalData Sco
%Authentication
%PersonalAttribute PASSNO
%PersonalData 234
%NumShares 100
%Declarant
%Person
%Forename Edwin
%Surname Crockford
%Address
%Premise 10
%Street The Street
%Thoroughfare
%PostTown Cardiff
%Postcode CF14 3UZ
%Authentication
%PersonalAttribute BIRTOWN
%PersonalData Sco
%Authentication
%PersonalAttribute PASSNO
%PersonalData 234
%Authentication
%PersonalAttribute EYE
%PersonalData Blu
%IncDesignation SOLICITOR
%Document
%Data TWVtb3JhbmR1bSBhbmQgQXJ0aWNsZXM=
%Date 2008-04-27
%Filename MemArts.pcl
%ContentType application/vnd.hp-pcl
%Category MEMARTS
4 changes: 4 additions & 0 deletions lib/companies_house/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def company_details_xml options
create default(options).merge(:request_type=>'CompanyDetails', :template=>'company_details')
end

def company_incorporation_xml options
create default(options).merge(request_type: 'FormSubmission', template: 'company_incorporation')
end

private

def default options
Expand Down
194 changes: 191 additions & 3 deletions spec/lib/companies_house/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@email = 'x@y'
CompaniesHouse.sender_id = @sender_id
CompaniesHouse.email = @email
CompaniesHouse.stub!(:create_transaction_id_and_digest).and_return [@transaction_id, @digest]
CompaniesHouse.stub(:create_transaction_id_and_digest).and_return [@transaction_id, @digest]

@name_search_type = 'NameSearch'
@company_name = 'millennium stadium plc'
Expand All @@ -32,6 +32,188 @@
<CompanyNumber>#{@company_number}</CompanyNumber>
<GiveMortTotals>1</GiveMortTotals>
</CompanyDetailsRequest>|

@company_incorporation_type = 'FormSubmission'
@company_incorporation_xml = expected_xml @company_incorporation_type, %Q|<NumberSearchRequest xmlns="http://xmlgw.companieshouse.gov.uk/v1-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema/FormSubmission.xsd">
<PartialCompanyNumber>03176906</PartialCompanyNumber>
<DataSet>LIVE</DataSet>
<SearchRows>20</SearchRows>
</NumberSearchRequest>
</Body>
<Body>
<FormSubmission xmlns:bs='http://xmlgw.companieshouse.gov.uk' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://xmlgw.companieshouse.gov.uk/Header' xsi:schemalocation='http://xmlgw.companieshouse.gov.uk/Header http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/FormSubmission-v1-1.xsd'>
<Formheader>
<CompanyName>TEST INC COMPANY LTD</CompanyName>
<PackageReference>1828</PackageReference>
<FormIdentifier>CompanyIncorporation</FormIdentifier>
<SubmissionNumber>SUB006</SubmissionNumber>
</Formheader>
<Authority>
<Designation>AGENT</Designation>
<DateSigned>2008-05-31</DateSigned>
</Authority>
<Form>
<CompanyIncorporation xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://xmlgw.companieshouse.gov.uk' xsi:schemalocation='http://xmlgw.companieshouse.gov.uk http://xmlgw.companieshouse.gov.uk/v1-0/schema/forms/CompanyIncorporation-v1-1.xsd'>
<SameDay>false</SameDay>
<RegisteredOfficeAddress>
<Premise>10</Premise>
<Street>The Street</Street>
<Thoroughfare>Titchfield</Thoroughfare>
<PostTown>Fareham</PostTown>
<County>Hants</County>
<Country>UK</Country>
<Postcode>PO14 4HW</Postcode>
</RegisteredOfficeAddress>
<CompanyType>BYSHR</CompanyType>
<CountryOfIncorporation>EW</CountryOfIncorporation>
<Agent>
<Person>
<Forename>Edwin</Forename>
<Surname>Crockford</Surname>
</Person>
<Address>
<Premise>10</Premise>
<Street>The Street</Street>
<Thoroughfare></Thoroughfare>
<PostTown>Cardiff</PostTown>
<Postcode>CF14 3UZ</Postcode>
</Address>
</Agent>
<Appointment>
<Authentication>
<PersonalAttribute>BIRTOWN</PersonalAttribute>
<PersonalData>Sco</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>PASSNO</PersonalAttribute>
<PersonalData>234</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>EYE</PersonalAttribute>
<PersonalData>Blu</PersonalData>
</Authentication>
<Director>
<Address>
<Premise>10</Premise>
<Street>The Street</Street>
<Thoroughfare></Thoroughfare>
<PostTown>Cardiff</PostTown>
<Postcode>CF14 3UZ</Postcode>
</Address>
<Person>
<Surname>Crockford</Surname>
<Forename>Phil</Forename>
<Honours>BEng</Honours>
<DOB>1959-09-04</DOB>
<Nationality>British</Nationality>
<Occupation>Hacker</Occupation>
</Person>
</Director>
</Appointment>
<Appointment>
<Authentication>
<PersonalAttribute>NATINS</PersonalAttribute>
<PersonalData>YR1</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>BIRTOWN</PersonalAttribute>
<PersonalData>Sco</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>PASSNO</PersonalAttribute>
<PersonalData>234</PersonalData>
</Authentication>
<Secretary>
<Address>
<Premise>10</Premise>
<Street>The Street</Street>
<PostTown>Cardiff</PostTown>
<Postcode>CF14 3UZ</Postcode>
</Address>
<Corporate>
<Forename>Chris</Forename>
<Surname>Smith</Surname>
<CorporateName>The Nominee Corp</CorporateName>
</Corporate>
</Secretary>
</Appointment>
<AuthorisedCapital>
<ShareClass>Ordinary</ShareClass>
<Currency>GBP</Currency>
<AuthorisedCapital>1000</AuthorisedCapital>
<NumShares>5000</NumShares>
<ShareValue>0.2</ShareValue>
</AuthorisedCapital>
<Subscribers>
<TotalNumberShares>200</TotalNumberShares>
<Subscriber>
<PersonalAuthenticationCode>040101</PersonalAuthenticationCode>
<NumShares>100</NumShares>
</Subscriber>
<Subscriber>
<Corporate>
<Forename>Fred</Forename>
<Surname>Williams</Surname>
<CorporateName>The Investment Company</CorporateName>
</Corporate>
<Address>
<Premise>10</Premise>
<Street>The Street</Street>
<Thoroughfare></Thoroughfare>
<PostTown>Cardiff</PostTown>
<Postcode>CF14 3UZ</Postcode>
</Address>
<Authentication>
<PersonalAttribute>NATINS</PersonalAttribute>
<PersonalData>YR1</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>BIRTOWN</PersonalAttribute>
<PersonalData>Sco</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>PASSNO</PersonalAttribute>
<PersonalData>234</PersonalData>
</Authentication>
<NumShares>100</NumShares>
</Subscriber>
</Subscribers>
<Declarant>
<Person>
<Forename>Edwin</Forename>
<Surname>Crockford</Surname>
</Person>
<Address>
<Premise>10</Premise>
<Street>The Street</Street>
<Thoroughfare></Thoroughfare>
<PostTown>Cardiff</PostTown>
<Postcode>CF14 3UZ</Postcode>
</Address>
<Authentication>
<PersonalAttribute>BIRTOWN</PersonalAttribute>
<PersonalData>Sco</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>PASSNO</PersonalAttribute>
<PersonalData>234</PersonalData>
</Authentication>
<Authentication>
<PersonalAttribute>EYE</PersonalAttribute>
<PersonalData>Blu</PersonalData>
</Authentication>
<IncDesignation>SOLICITOR</IncDesignation>
</Declarant>
</CompanyIncorporation>
</Form>
<Document>
<Data>TWVtb3JhbmR1bSBhbmQgQXJ0aWNsZXM=</Data>
<Date>2008-04-27</Date>
<Filename>MemArts.pcl</Filename>
<ContentType>application/vnd.hp-pcl</ContentType>
<Category>MEMARTS</Category>
</Document>
</FormSubmission>|
end

describe "when asked for name search request xml" do
Expand Down Expand Up @@ -102,9 +284,15 @@
end
end

describe "when incorporating a company request xml" do
it "should create xml correctly" do
request_xml = CompaniesHouse::Request.company_incorporation_xml :company_number => @company_number
request_xml.strip.should == @company_incorporation_xml.strip
end
end

def expected_xml request_type, body
%Q|<?xml version="1.0" encoding="UTF-8"?>
<GovTalkMessage xsi:schemaLocation="http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch.xsd" xmlns="http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:gt="http://www.govtalk.gov.uk/schemas/govtalk/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
%Q|<GovTalkMessage xsi:schemaLocation="http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader http://xmlgw.companieshouse.gov.uk/v1-0/schema/Egov_ch.xsd" xmlns="http://www.govtalk.gov.uk/schemas/govtalk/govtalkheader" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:gt="http://www.govtalk.gov.uk/schemas/govtalk/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EnvelopeVersion>1.0</EnvelopeVersion>
<Header>
<MessageDetails>
Expand Down
Loading