open311

package module
v0.0.0-...-654add0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: MIT Imports: 7 Imported by: 0

README

go-open311

A golang client for talking to Open311's API.

Warning

This package is a work in a progress and will be changing in backward incompatible ways without warning.

Example

package main

import "github.com/transitorykris/go-open311"

func main() {
    client := open311.New(
        "yourapikey",
        "sfgov.org",
        "http://mobile311-dev.sfgov.org/open311/v2",
    )
}

Documentation

See https://godoc.org/github.com/transitorykris/go-keywords

License

Copyright (c) 2017 Ahead by a Century, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const (
	Poop = iota
	Needles
	Garbage
)

ReqType is a required attribute for creating a service request

View Source
const Cleanup = "518d5892601827e3880000c5"

Cleanup is the service code for cleaning things in SF

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Variable            bool       `json:"variable"`
	Code                string     `json:"code"`
	DataType            string     `json:"datatype"`
	Required            bool       `json:"required"`
	DataTypeDescription string     `json:"string"`
	Order               int        `json:"order"`
	Description         string     `json:"description"`
	Values              []KeyValue `json:"values"`
}

Attributes are the metadata of a service

type Client

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

Client is used for communicating with an Open311 API

func New

func New(key string, jurisdiction string, apiURL string) *Client

New creates a brand new Client

func (*Client) GetServiceDefinition

func (c *Client) GetServiceDefinition(code string) (ServiceDefinition, error)

GetServiceDefinition returns details about a type of service request This call is only necessary if the Service selected has metadata set as true from the GET Services response

func (*Client) GetServiceRequest

func (c *Client) GetServiceRequest(id string) (ServiceRequestResponse, error)

GetServiceRequest returns details for a specific service request

func (*Client) GetServiceRequestID

func (c *Client) GetServiceRequestID(token string) (string, error)

GetServiceRequestID returns a service request ID given a token XXX SF311 uses the token as the request ID XXX this endpoint does not return the correct format http://wiki.open311.org/GeoReport_v2/#get-service_request_id-from-a-token

func (*Client) GetServiceRequests

func (c *Client) GetServiceRequests(opts ServiceRequestOpts) ([]ServiceRequestResponse, error)

GetServiceRequests returns all service requests in the jurisdiction's database

func (*Client) PostServiceRequest

func (c *Client) PostServiceRequest(code string, reqType int, req ServiceRequest) (ServiceRequestCreation, error)

PostServiceRequest creates a new service request loc is lat/long or address_string or address_id attr is an array of key/values

type KeyValue

type KeyValue struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

KeyValue is used for arbitrary key/value parameters

type Location

type Location struct {
	Lat       float64 `json:"lat"`
	Long      float64 `json:"long"`
	Address   string  `json:"address_string"`
	AddressID string  `json:"address_id"`
}

Location is the location for a service request. Either: Lat/Long or Address or AddressID is required.

type Service

type Service struct {
	ServiceCode string   `json:"service_code"`
	ServiceName string   `json:"service_name"`
	Description string   `json:"description"`
	Metadata    bool     `json:"metadata"`
	Type        string   `json:"type"`
	Keywords    []string `json:"keywords"`
	Group       string   `json:"group"`
}

Service are categories that requests can be submitted to

type ServiceDefinition

type ServiceDefinition struct {
	ServiceCode string       `json:"service_code"`
	Definition  []Attributes `json:"attributes"`
}

ServiceDefinition describes a service's metadata

type ServiceRequest

type ServiceRequest struct {
	Lat       float64 `json:"lat" url:"lat,omitempty"`
	Long      float64 `json:"long" url:"long,omitempty"`
	Address   string  `json:"address_string" url:"address_string,omitempty"`
	AddressID string  `json:"address_id" url:"address_id,omitempty"`

	Email       string `json:"email" url:"email"`
	DeviceID    string `json:"device_id" url:"device_id"`
	AccountID   string `json:"account_id" url:"account_id"`
	FirstName   string `json:"first_name" url:"first_name"`
	LastName    string `json:"last_name" url:"last_name"`
	Phone       string `json:"phone" url:"phone"`
	Description string `json:"description" url:"description"`
	MediaURL    string `json:"media_url" url:"media_url"`
}

ServiceRequest is used to create a new service request

type ServiceRequestCreation

type ServiceRequestCreation struct {
	ID            string `json:"service_request_id"`
	Token         string `json:"token"`
	ServiceNotice string `json:"service_notice"`
	AccountID     string `json:"account_id"`
}

ServiceRequestCreation contains the response for a service request

type ServiceRequestID

type ServiceRequestID struct {
	ID    string `json:"service_request_id"`
	Token string `json:"token"`
}

ServiceRequestID is returned when looking up with a token

type ServiceRequestOpts

type ServiceRequestOpts struct {
	ServiceRequestID string    `json:"service_request_id"`
	ServiceCode      string    `json:"service_code"`
	StartDate        time.Time `json:"start_date"`
	EndData          time.Time `json:"end_date"`
	Status           string    `json:"status"`
}

ServiceRequestOpts contains optional arguments when getting service requests

type ServiceRequestResponse

type ServiceRequestResponse struct {
	ServiceRequestID  string    `json:"service_request_id"`
	Status            string    `json:"status"`
	StatusNotes       string    `json:"status_notes"`
	ServiceName       string    `json:"service_name"`
	ServiceCode       string    `json:"service_code"`
	Description       string    `json:"description"`
	AgencyResponsible string    `json:"agency_responsible"`
	ServiceNotice     string    `json:"service_notice"`
	RequestedTime     time.Time `json:"requested_datetime"`
	UpdateTime        time.Time `json:"updated_datetime"`
	ExpectedTime      time.Time `json:"expected_datetime"`
	Zipcode           string    `json:"zipcode"`
	Location
}

ServiceRequestResponse is returned after opening a service request

Jump to

Keyboard shortcuts

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