idealpostcodes

package module
v0.0.0-...-b52f448 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2016 License: MPL-2.0 Imports: 8 Imported by: 0

README

Codeship Status for AreaHQ/idealpostcodes-sdk

Postcodes SDK

SDK for ideal-postcodes.co.uk API.

Example usage:

package main

import(
	"net/http"

	postcodes "github.com/areatech/postcodes-sdk"
)

func main() {
	client := postcodes.NewClient(
		postcodes.Endpoint,
		"your_api_key",
		new(http.Client),
	)

	addresses, err := client.GetPostcode("ID11QD")

	// ...
}

Documentation

Index

Constants

View Source
const Endpoint = "https://api.ideal-postcodes.co.uk/v1"

Endpoint is the API base URI

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Postcode                string      `json:"postcode"`
	PostcodeInward          string      `json:"postcode_inward,omitempty"`
	PostcodeOutward         string      `json:"postcode_outward,omitempty"`
	PostTown                string      `json:"post_town,omitempty"`
	DependantLocality       string      `json:"dependant_locality,omitempty"`
	DoubleDependantLocality string      `json:"double_dependant_locality,omitempty"`
	Thoroughfare            string      `json:"thoroughfare,omitempty"`
	DependantThoroughfare   string      `json:"dependant_thoroughfare,omitempty"`
	BuildingNumber          string      `json:"building_number,omitempty"`
	BuildingName            string      `json:"building_name,omitempty"`
	SubBuildingName         string      `json:"sub_building_name,omitempty"`
	POBox                   string      `json:"po_box,omitempty"`
	DepartmentName          string      `json:"department_name,omitempty"`
	OrganisationName        string      `json:"organisation_name,omitempty"`
	UDPRN                   int64       `json:"udprn,omitempty"`
	PostcodeType            string      `json:"postcode_type,omitempty"`
	SuOrganisationIndicator string      `json:"su_organisation_indicator,omitempty"`
	DeliveryPointSuffix     string      `json:"delivery_point_suffix,omitempty"`
	Line1                   string      `json:"line_1"`
	Line2                   string      `json:"line_2,omitempty"`
	Line3                   string      `json:"line_3,omitempty"`
	Premise                 string      `json:"premise,omitempty"`
	Country                 string      `json:"country,omitempty"`
	County                  string      `json:"county,omitempty"`
	AdministrativeCounty    string      `json:"administrative_county,omitempty"`
	PostalCounty            string      `json:"postal_county,omitempty"`
	TraditionalCounty       string      `json:"traditional_county,omitempty"`
	District                string      `json:"district,omitempty"`
	Ward                    string      `json:"ward,omitempty"`
	Longitude               interface{} `json:"longitude,omitempty"` // number or empty string
	Latitude                interface{} `json:"latitude,omitempty"`  // number or empty string
	Eastings                interface{} `json:"eastings,omitempty"`  // number or empty string
	Northings               interface{} `json:"northings,omitempty"` // number or empty string
}

Address ...

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for https://ideal-postcodes.co.uk API

func NewClient

func NewClient(endpoint string, apiKey string, httpClient *http.Client) *Client

NewClient returns new Client instance

func (*Client) GetPostcode

func (c *Client) GetPostcode(postcode string) ([]*Address, error)

GetPostcode returns list of addresses matching a postcode

type ClientInterface

type ClientInterface interface {
	// Exported methods
	GetPostcode(postcode string) ([]*Address, error)
}

ClientInterface defines exported methods

type ClientMock

type ClientMock struct {
	mock.Mock
}

ClientMock is a mocked object implementing ServiceInterface

func (*ClientMock) GetPostcode

func (_m *ClientMock) GetPostcode(postcode string) ([]*Address, error)

GetPostcode just records the activity, and returns what the Mock object tells it to

type GetPostcodeResponse

type GetPostcodeResponse struct {
	Result  []*Address `json:"result"`
	Code    int        `json:"code"`
	Message string     `json:"message"`
}

GetPostcodeResponse ...

Jump to

Keyboard shortcuts

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