Skip to content

Latest commit

 

History

History
256 lines (197 loc) · 4.14 KB

File metadata and controls

256 lines (197 loc) · 4.14 KB

Address Suggestions API

Usage

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.addressSuggestions.getAddresses(...)

Tree-shakeable import

import { getClient, authorize } from '@epilot/sdk/address-suggestions'

const addressSuggestionsClient = getClient()
authorize(addressSuggestionsClient, () => '<token>')
const { data } = await addressSuggestionsClient.getAddresses(...)

Operations

Addresses API

Schemas

getAddresses

get addresses from file

GET /v1/public/suggestions

const { data } = await client.getAddresses({
  X-Epilot-Org-ID: 'example',
  s3FileUrl: 'example',
  fileId: 'example',
  countryCodeSearchTerm: 'example',
  postalCodeSearchTerm: 'example',
  streetSearchTerm: 'example',
})
Response
[
  {
    "country": "string",
    "postal_code": "string",
    "city": "string",
    "street": "string",
    "street_number": "string"
  }
]

checkAvailability

Check address availability

GET /v1/public/availability:check

const { data } = await client.checkAvailability({
  X-Epilot-Org-ID: 'example',
  files: 'example',
  countryCode: 'example',
  postalCode: 'example',
  street: 'example',
  streetNumber: 'example',
})
Response
{
  "fileId": "4e7b7d95-ced6-4f5f-9326-0c61f30dcadb"
}

validateAddressesFile

validate addresses file

GET /v1/addresses-files:validate

const { data } = await client.validateAddressesFile({
  fileId: 'example',
})
Response
{
  "status": "success",
  "rules_parsed_count": 0,
  "errors": [
    {
      "line": 0,
      "msg": "string",
      "data": "string"
    }
  ]
}

Schemas

AvailabilityLocation

type AvailabilityLocation = {
  street?: string
  street_number?: string
  postal_code?: string
  city?: string
  country?: string
}

AvailabilityResult

type AvailabilityResult = {
  fileId?: string
}

Error

type Error = {
  message: string
  status?: number
  cause?: string
}

AddressSuggestion

The address suggestions entity

type AddressSuggestion = {
  country?: string
  postal_code?: string
  city?: string
  street?: string
  street_number?: string
}

AddressSuggestions

The address suggestions entity array

type AddressSuggestions = Array<{
  country?: string
  postal_code?: string
  city?: string
  street?: string
  street_number?: string
}>

ValidateAddressSuggestionsFileResult

The availability map file result payload

type ValidateAddressSuggestionsFileResult = {
  status?: "success" | "error"
  rules_parsed_count?: number
  errors?: Array<{
    line?: number
    msg: string
    data?: string
  }>
}

ValidateAddressFileResult

The address file validation result payload

type ValidateAddressFileResult = {
  status?: "success" | "error"
  rules_parsed_count?: number
  errors?: Array<{
    line?: number
    msg: string
    data?: string
  }>
}

AddressSuggestionError

The availability rule error

type AddressSuggestionError = {
  line?: number
  msg: string
  data?: string
}

ValidateAddressFileError

The address rule error

type ValidateAddressFileError = {
  line?: number
  msg: string
  data?: string
}