model

package
v0.0.0-...-4bf8642 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProviders

func CreateProviders(resp NppesResponse) error

CreateProviders persists NppesResponse to db in form of ProviderRecord as rows

func CreateSearchRecord

func CreateSearchRecord(s SearchFields) error

CreateSearchRecord stores NewSearch query to database

Types

type NppesResponse

type NppesResponse struct {
	ResultCount int              `json:"result_count"`
	Results     []ProviderResult `json:"results"`
}

NppesResponse is the typical API response from NPPES endpoint for valid query

type ProviderRecord

type ProviderRecord struct {
	ProviderNumber int
	Result         json.RawMessage
	CreatedAt      time.Time
	UpdatedAt      time.Time
	DeletedAt      time.Time
}

ProviderRecord is model for providers table

type ProviderResult

type ProviderResult struct {
	Number    int `json:"number"`
	Addresses []struct {
		Address1        string `json:"address_1"`
		Address2        string `json:"address_2"`
		AddressPurpose  string `json:"address_purpose"`
		AddressType     string `json:"address_type"`
		City            string `json:"city"`
		CountryCode     string `json:"country_code"`
		CountryName     string `json:"country_name"`
		FaxNumber       string `json:"fax_number"`
		PostalCode      string `json:"postal_code"`
		State           string `json:"state"`
		TelephoneNumber string `json:"telephone_number"`
	} `json:"addresses"`
	Basic struct {
		Credential      string `json:"credential"`
		EnumerationDate string `json:"enumeration_date"`
		FirstName       string `json:"first_name"`
		Gender          string `json:"gender"`
		LastName        string `json:"last_name"`
		LastUpdated     string `json:"last_updated"`
		MiddleName      string `json:"middle_name"`
		Name            string `json:"name"`
		NamePrefix      string `json:"name_prefix"`
		SoleProprietor  string `json:"sole_proprietor"`
		Status          string `json:"status"`
	} `json:"basic"`
	CreatedEpoch    int    `json:"created_epoch"`
	EnumerationType string `json:"enumeration_type"`
	Identifiers     []struct {
		Code       string `json:"code"`
		Desc       string `json:"desc"`
		Identifier string `json:"identifier"`
		Issuer     string `json:"issuer"`
		State      string `json:"state"`
	} `json:"identifiers"`
	LastUpdatedEpoch int `json:"last_updated_epoch"`

	OtherNames []interface{} `json:"other_names"`
	Taxonomies []struct {
		Code    string `json:"code"`
		Desc    string `json:"desc"`
		License string `json:"license"`
		Primary bool   `json:"primary"`
		State   string `json:"state"`
	} `json:"taxonomies"`
}

ProviderResult contains all provider details as returned from NPPES endpoint and database

type SearchFields

type SearchFields struct {
	Number           int    `json:"number"`
	EnumerationType  string `json:"enumerationType"`
	TaxonomyDesc     string `json:"taxonomyDesc"`
	FirstName        string `json:"firstName"`
	LastName         string `json:"lastName "`
	OrganizationName string `json:"organizationName"`
	AddressPurpose   string `json:"addressPurpose"`
	City             string `json:"city"`
	State            string `json:"state"`
	PostalCode       string `json:"postalCode"`
	CountryCode      string `json:"countryCode"`
	Limit            int    `json:"limit"`
	Skip             int    `json:"skip"`
	Pretty           bool   `json:"pretty"`
}

SearchFields are query fields for NPPES API

Jump to

Keyboard shortcuts

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