Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Last active October 23, 2015 20:41
Show Gist options
  • Select an option

  • Save ajsharp/f00a16a624c07eaa1eb1 to your computer and use it in GitHub Desktop.

Select an option

Save ajsharp/f00a16a624c07eaa1eb1 to your computer and use it in GitHub Desktop.
class Location < ActiveRecord::Base
# fields: name, street1, city, state, zip
end
class DateStep < ActiveRecord::Base
# fields: start_time
end
# The top-level keys are the names of remote API's from which we'd like to pull data.
# The second-level objects are local model names.
# The third-level objects are fields of those local models. The values they point to are "json object paths".
#
# EXAMPLE
# =======
# Assume stubhub returns an event payload that looks like this:
# {
# "event": {
# "venue": {
# "title" : "Staples Center",
# "city" : "Los Angeles",
# "state" : "CA"
# }
# }
# }
#
# What we want to do, is to be to easily, with static configuration, map the remote
# data into local objects, using something like this:
# Location.new(Integrations.stubhub_event("STUBHUB_EVENT_ID").location)
#
stubhub:
location:
name: event.venue.title
seatgeek:
location:
name: venue.title
fandango:
location:
name: theater.location.name
street1: theater.location.street1
zip: theater.location.postal_code
date_step:
start_time: showing.start_time
estimated_ticket_price: showing.tickets.price
tickets_available: showing.tickets.num_available
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment