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



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

def get_service_request(id, options = {})
  merge_options!(options)
  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



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

def post_service_request(options = {})
  merge_options!(options, 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



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

def request_id_from_token(token_id, options = {})
  merge_options!(options)
  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 = {})
  merge_options!(options)
  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 = {})
  merge_options!(options)
  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
# File 'lib/open311/client/service.rb', line 43

def service_requests(options = {})
  merge_options!(options)
  response = get('requests', options)
  unpack_if_xml(response) do
    return [] unless response.service_requests.respond_to? :request
    response['service_requests']['request']
  end
end