Module: Open311::Client::Service

Included in:
Open311::Client
Defined in:
lib/open311/client/service.rb

Instance Method Summary collapse

Instance Method Details

#get_service_request(id, options = {}) ⇒ Object

Returns Hash.

Parameters:

  • id

    String of the service request id

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • Hash

See Also:

Supported formats:

  • :xml

Requires API key:

  • false



74
75
76
77
78
79
80
# File 'lib/open311/client/service.rb', line 74

def get_service_request(id, options={})
  options.merge!(:jurisdiction_id => jurisdiction)
  response = get("requests/#{id}", options)
  unpack_if_xml(response) do
    response['service_requests']['request']
  end
end

#post_service_request(options = {}) ⇒ Object

Returns Hash.

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • Hash

See Also:

Supported formats:

  • :xml

Requires API key:

  • true



59
60
61
62
63
64
65
# File 'lib/open311/client/service.rb', line 59

def post_service_request(options={})
  options.merge!(:jurisdiction_id => jurisdiction, :api_key => api_key)
  response = post("requests", options)
  unpack_if_xml(response) do
    response['service_requests']['request']
  end
end

#request_id_from_token(token_id, options = {}) ⇒ Object

Returns Array.

Parameters:

  • token_id

    A token included in the response to .service_response request

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • Array

See Also:

Supported formats:

  • :xml

Requires API key:

  • false



89
90
91
92
93
94
95
# File 'lib/open311/client/service.rb', line 89

def request_id_from_token(token_id, options = {})
  options.merge!(:jurisdiction_id => jurisdiction)
  response = get("tokens/#{token_id}", options)
  unpack_if_xml(response) do
    response['service_requests']['request']
  end
end

#service_definition(id, options = {}) ⇒ Object

Returns Hash.

Examples:

define attributes associated with a service code, i.e. 033

Open311.service_definition

Parameters:

  • id

    String the service code

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • Hash

See Also:

Supported formats:

  • :xml

Requires API key:

  • false



29
30
31
32
33
34
35
# File 'lib/open311/client/service.rb', line 29

def service_definition(id, options={})
  options.merge!(:jurisdiction_id => jurisdiction)
  response = get("services/#{id}", options)
  unpack_if_xml(response) do
    response['service_definition']
  end
end

#service_list(options = {}) ⇒ Array

Provide a list of acceptable 311 service request types and their associated service codes

Examples:

Provide a list of acceptable 311 service request types and their associated service codes

Open311.service_list

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Array)

See Also:

Supported formats:

  • :xml

Requires API key:

  • false



13
14
15
16
17
18
19
# File 'lib/open311/client/service.rb', line 13

def service_list(options={})
  options.merge!(:jurisdiction_id => jurisdiction)
  response = get('services', options)
  unpack_if_xml(response) do
    response['services']['service']
  end
end

#service_requests(options = {}) ⇒ Array

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Array)

See Also:

Supported formats:

  • :xml

Requires API key:

  • false



43
44
45
46
47
48
49
50
51
# File 'lib/open311/client/service.rb', line 43

def service_requests(options={})
  options.merge!(:jurisdiction_id => jurisdiction)
  response = get("requests", options)
  unpack_if_xml(response) do
    response.service_requests.request.map do |request|
      response['service_requests']['request']
    end
  end
end