Class: TrailerVote::Api::Place::Lookup

Inherits:
Object
  • Object
show all
Includes:
Composable::Common
Defined in:
lib/trailer_vote/api/place/lookup.rb

Overview

Looks up a place by a concatenated authority and identifier string

Examples:

lookup a place by vista authority


result = TrailerVote::Api.configure(...).place.lookup.call(url: '')
result.place
# => { "title": "" }

Constant Summary collapse

SUCCESS =
MediaTypes::Place.to_constructable.version(2)
FAILURE =
MediaTypes::Errors.to_constructable.version(1)
ACCEPT =
[SUCCESS.to_s, FAILURE.to_s(0.1)].join(', ').freeze

Instance Method Summary collapse

Methods included from Composable::Common

included

Constructor Details

#initialize(configuration:) ⇒ Lookup

Returns a new instance of Lookup.



42
43
44
# File 'lib/trailer_vote/api/place/lookup.rb', line 42

def initialize(configuration:)
  self.configuration = configuration
end

Instance Method Details

#backTrailerVote::Api::Place

Returns api to deal with places.

Returns:



47
48
49
# File 'lib/trailer_vote/api/place/lookup.rb', line 47

def back
  configuration.place
end

#call(authority:, identifier:) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/trailer_vote/api/place/lookup.rb', line 51

def call(authority:, identifier:)
  url = resolve_url(authority: authority, identifier: identifier)
  guard_network_errors do
    branch(
      resolve_client.headers(Headers::ACCEPT => ACCEPT).get(url, body: nil)
    )
  end
end