abra

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package abra provides a Go wrapper for the Australian Business Register

Index

Constants

View Source
const (
	BaseURL = "https://www.abn.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx/"

	GUIDEnvName      = "ABR_GUID"
	MissingGUIDError = "The ABR_GUID environment variable must be set"
)

Variables

View Source
var States = []State{
	State{Title: "Australian Capital Territory", ShortTitle: "ACT"},
	State{Title: "New South Wales", ShortTitle: "NSW"},
	State{Title: "Northern Territory", ShortTitle: "NT"},
	State{Title: "Queensland", ShortTitle: "QLD"},
	State{Title: "South Australia", ShortTitle: "SA"},
	State{Title: "Tasmania", ShortTitle: "TAS"},
	State{Title: "Victoria", ShortTitle: "VIC"},
	State{Title: "Western Australia", ShortTitle: "WA"},
}
View Source
var (
	// @TODO update this using linker flags during build
	Version = "dev"
)

Functions

func ValidateABN

func ValidateABN(abn string) (bool, error)

ValidateABN tests a string to see if it is a valid ABN

func ValidateACN

func ValidateACN(acn string) (bool, error)

ValidateACN tests a string to see if it is a valid ACN

Types

type ABN

type ABN struct {
	IdentifierValue         string  `xml:"identifierValue,omitempty"`
	IdentifierStatus        string  `xml:"identifierStatus,omitempty"`
	IsCurrentIndicator      string  `xml:"isCurrentIndicator,omitempty"`
	ReplacedIdentifierValue string  `xml:"replacedIdentifierValue,omitempty"`
	ReplacedFrom            abnDate `xml:"replacedFrom,omitempty"`
}

ABN represents an actual Australian Business Number

func (*ABN) IsValid

func (a *ABN) IsValid() (bool, error)

IsValid checks whether your ABN has a valid identifier (https://www.abr.business.gov.au/HelpAbnFormat.aspx)

func (*ABN) String

func (a *ABN) String() string

String returns the ABN as a formatted string

type ACN

type ACN struct {
	IdentifierValue         string  `xml:"identifierValue,omitempty"`
	IsCurrentIndicator      string  `xml:"isCurrentIndicator,omitempty"`
	ReplacedIdentifierValue string  `xml:"replacedIdentifierValue,omitempty"`
	ReplacedFrom            abnDate `xml:"replacedFrom,omitempty"`
}

ACN represents an actual Australian Company Number

type Abra

type Abra interface {
	Search(string) (*BusinessEntity, error)
	SearchByABN(string, bool) (*BusinessEntity, error)
	SearchByABNv201408(string, bool) (*BusinessEntity, error)
	SearchByACN(string, bool) (*BusinessEntity, error)
	SearchByASIC(string, bool) (*BusinessEntity, error)
	SearchByASICv201408(string, bool) (*BusinessEntity, error)
	SearchByName(string, *NameSearchParams) (*ResponseSearchResultsList, error)
	SearchByNameAdvancedSimpleProtocol2017(string, *NameSearchParams) (*ResponseSearchResultsList, error)
	SearchByNameBestGuess(string, *NameSearchParams) (*BusinessEntity, error)
}

Abra is the interface implemented by Client

type AddressDetails

type AddressDetails struct {
	StateCode string `xml:"stateCode,omitempty"`
	Postcode  string `xml:"postcode,omitempty"`

	EffectiveFrom abnDate `xml:"effectiveFrom,omitempty"`
	EffectiveTo   abnDate `xml:"effectiveTo,omitempty"`
}

Address details represents an address used by a BusinessEntity for a period of time

type BusinessEntity

type BusinessEntity struct {
	RecordLastUpdatedDate abnDate `xml:"recordLastUpdatedDate,omitempty"`

	// So many ways of naming a business!
	BusinessNames     []*BusinessName `xml:"businessName,omitempty"`
	HumanNames        []*HumanName    `xml:"legalName,omitempty"`
	MainNames         []*BusinessName `xml:"mainName,omitempty"`
	MainTradingNames  []*BusinessName `xml:"mainTradingName,omitempty"`
	OtherTradingNames []*BusinessName `xml:"otherTradingName,omitempty"`

	// Other details
	ABNs                 []*ABN                 `xml:"ABN,omitempty"`
	ASICNumber           string                 `xml:"ASICNumber,omitempty"`
	EntityStatuses       []*EntityStatus        `xml:"entityStatus,omitempty"`
	EntityType           *EntityType            `xml:"entityType,omitempty"`
	GSTRegisteredPeriods []*GSTRegisteredPeriod `xml:"goodsAndServicesTax,omitempty"`
	PhysicalAddresses    []*AddressDetails      `xml:"mainBusinessPhysicalAddress,omitempty"`
}

BusinessEntity represents a legal entity and encapsulates everything that the ABR knows about such an entity

func (*BusinessEntity) ABN

func (b *BusinessEntity) ABN() string

ABN returns the current ABN

func (*BusinessEntity) Name

func (b *BusinessEntity) Name() string

Name returns the most relevant name that is available

type BusinessName

type BusinessName struct {
	OrganisationName string  `xml:"organisationName"`
	EffectiveFrom    abnDate `xml:"effectiveFrom"`
	EffectiveTo      abnDate `xml:"effectiveTo"`
}

BusinessName represents some kind of name that was in use by a BusinessEntity at some point in history

type Client

type Client struct {
	BaseURL *url.URL
	GUID    string
	// contains filtered or unexported fields
}

Client provides a client connection to the ABR

func NewClient

func NewClient() (*Client, error)

NewClient returns a pointer to an initialized instance of a Client

func NewWithGuid

func NewWithGuid(guid string) (*Client, error)

NewWithGuid returns a pointer to an initalized instance of a Client, configured with a `guid`

func (*Client) Search

func (c *Client) Search(text string) (*BusinessEntity, error)

Search attempts to intelligently work out what you're looking for

func (*Client) SearchByABN

func (c *Client) SearchByABN(abn string, hist bool) (*BusinessEntity, error)

SearchByABN is an alias for SearchByABNv201408

func (*Client) SearchByABNv201408

func (c *Client) SearchByABNv201408(abn string, hist bool) (*BusinessEntity, error)

SearchByABNv201408 wraps the API call to query an ABN

func (*Client) SearchByACN

func (c *Client) SearchByACN(abn string, hist bool) (*BusinessEntity, error)

SearchByACN is an alias for SearchByASICv201408

func (*Client) SearchByASIC

func (c *Client) SearchByASIC(abn string, hist bool) (*BusinessEntity, error)

SearchByASIC is an alias for SearchByASICv201408

func (*Client) SearchByASICv201408

func (c *Client) SearchByASICv201408(acn string, hist bool) (*BusinessEntity, error)

SearchByASICv201408 wraps the API call to query an ACN

func (*Client) SearchByName

func (c *Client) SearchByName(name string, params *NameSearchParams) (*ResponseSearchResultsList, error)

SearchByName wraps the API call to query by `name` and other optional details

func (*Client) SearchByNameAdvancedSimpleProtocol2017

func (c *Client) SearchByNameAdvancedSimpleProtocol2017(name string, params *NameSearchParams) (*ResponseSearchResultsList, error)

SearchByNameAdvancedSimpleProtocol2017 wraps the SearchByNameAdvancedSimpleProtocol2017

func (*Client) SearchByNameBestGuess

func (c *Client) SearchByNameBestGuess(name string, params *NameSearchParams) (*BusinessEntity, error)

SearchByNameBestGuess takes the first result from the name search and returns an ABN search

type ClientAPI

type ClientAPI interface {
	SearchByABN(string, bool) (*BusinessEntity, error)
	SearchByABNv201408(string, bool) (*BusinessEntity, error)
	SearchByACN(string, bool) (*BusinessEntity, error)
	SearchByASIC(string, bool) (*BusinessEntity, error)
	SearchByASICv201408(string, bool) (*BusinessEntity, error)
	SearchByName(string, params *NameSearchParams) (*ResponseSearchResultsList, error)
	SearchByNameAdvancedSimpleProtocol2017(string, params *NameSearchParams) (*ResponseSearchResultsList, error)
}

ClientAPI provides and interface to enable mocking the service client's API operation.

type EntityStatus

type EntityStatus struct {
	EntityStatusCode string  `xml:"entityStatusCode,omitempty"`
	EffectiveFrom    abnDate `xml:"effectiveFrom,omitempty"`
	EffectiveTo      abnDate `xml:"effectiveTo,omitempty"`
}

EntityStatus represents the status of an entity (Active or Cancelled)

type EntityType

type EntityType struct {
	EntityTypeCode    string `xml:"entityTypeCode,omitempty"`
	EntityDescription string `xml:"entityDescription,omitempty"`
}

EntityType represents the type of an entity - individal, pty ltd, etc.

type GSTRegisteredPeriod

type GSTRegisteredPeriod struct {
	EffectiveFrom abnDate `xml:"effectiveFrom,omitempty"`
	EffectiveTo   abnDate `xml:"effectiveTo,omitempty"`
}

GSTRegisteredPeriod represents a period during which the entity was registered for GST

type HumanName

type HumanName struct {
	GivenName      string `xml:"givenName"`
	OtherGivenName string `xml:"otherGivenName"`
	FamilyName     string `xml:"familyName"`

	EffectiveFrom abnDate `xml:"effectiveFrom"`
	EffectiveTo   abnDate `xml:"effectiveTo"`
}

HumanName represents the name of a human that was in use by a BusinessEntity at some point in history

type MainBusinessPhysicalAddress

type MainBusinessPhysicalAddress struct {
	StateCode          string `xml:"stateCode,omitempty"`
	Postcode           string `xml:"postcode,omitempty"`
	IsCurrentIndicator string `xml:"isCurrentIndicator,omitempty"`
}

MainBusinessPhysicalAddress

type NameSearchParams

type NameSearchParams struct {
	ActiveABNsOnly   bool
	BusinessName     bool
	LegalName        bool
	MaxSearchResults int32
	MinimumScore     int32
	Postcode         string
	States           []State
	TradingName      bool
	TypicalSearch    bool
}

NameSearchParams

type Payload

type Payload struct {
	Response *Response `xml:"response,omitempty"`
}

Payload encapsulates a Response from the API

type Response

type Response struct {
	UsageStatement          string    `xml:"usageStatement,omitempty"`
	DateRegisterLastUpdated abnDate   `xml:"dateRegisterLastUpdated,omitempty"`
	DateTimeRetrieved       time.Time `xml:"dateTimeRetrieved,omitempty"`

	BusinessEntity       *BusinessEntity            `xml:"businessEntity,omitempty"`
	BusinessEntity200506 *BusinessEntity            `xml:"businessEntity200506,omitempty"`
	BusinessEntity200709 *BusinessEntity            `xml:"businessEntity200709,omitempty"`
	BusinessEntity201205 *BusinessEntity            `xml:"businessEntity201205,omitempty"`
	BusinessEntity201408 *BusinessEntity            `xml:"businessEntity201408,omitempty"`
	Exception            *ResponseException         `xml:"exception,omitempty"`
	AbnList              *ResponseABNList           `xml:"abnList,omitempty"`
	SearchResultsList    *ResponseSearchResultsList `xml:"searchResultsList,omitempty"`
}

Response represents the XML responses available via the ABRXMLSearch

type ResponseABNList

type ResponseABNList struct {
	NumberOfRecords int32    `xml:"numberOfRecords,omitempty"`
	Abn             []string `xml:"abn,omitempty"`
}

ResponseABNList

type ResponseException

type ResponseException struct {
	ExceptionDescription string `xml:"exceptionDescription,omitempty"`
	ExceptionCode        string `xml:"exceptionCode,omitempty"`
}

ResponseException returns the exception

type ResponseSearchResultsList

type ResponseSearchResultsList struct {
	NumberOfRecords int32  `xml:"numberOfRecords,omitempty"`
	ExceedsMaximum  string `xml:"exceedsMaximum,omitempty"`

	SearchResultsRecord []*SearchResultsRecord `xml:"searchResultsRecord,omitempty"`
}

ResponseSearchResultsList

type SearchResultName

type SearchResultName struct {
	OrganisationName   string `xml:"organisationName,omitempty"`
	FullName           string `xml:"fullName,omitempty"`
	Score              int32  `xml:"score,omitempty"`
	IsCurrentIndicator string `xml:"isCurrentIndicator,omitempty"`
}

MainName

type SearchResultsRecord

type SearchResultsRecord struct {
	ABN                         ABN                          `xml:"ABN,omitempty"`
	BusinessName                *SearchResultName            `xml:"businessName,omitempty"`
	LegalName                   *SearchResultName            `xml:"legalName,omitempty"`
	MainName                    *SearchResultName            `xml:"mainName,omitempty"`
	MainTradingName             *SearchResultName            `xml:"mainTradingName,omitempty"`
	OtherTradingName            *SearchResultName            `xml:"otherTradingName,omitempty"`
	MainBusinessPhysicalAddress *MainBusinessPhysicalAddress `xml:"mainBusinessPhysicalAddress,omitempty"`
}

SearchResultsRecord

func (*SearchResultsRecord) IsCurrentIndicator

func (r *SearchResultsRecord) IsCurrentIndicator() string

IsCurrentIndicator returns the IsCurrentIndicator flag for the Name returned in the search

func (*SearchResultsRecord) Name

func (r *SearchResultsRecord) Name() string

Name provides a Name for a `SearchResultName` based on the available types

func (*SearchResultsRecord) Score

func (r *SearchResultsRecord) Score() int32

Score returns the score for the Name returned in the search

type State

type State struct {
	Title      string
	ShortTitle string
}

State represents an actual Australian Company Number

func FindState

func FindState(shortTitle string) (*State, error)

func (*State) IsValid

func (s *State) IsValid() (bool, error)

IsValid checks whether your State is valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL