Created
March 23, 2011 16:49
-
-
Save cfeduke/883453 to your computer and use it in GitHub Desktop.
Internal weather message for sponsorship stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Protocol | |
class WeatherServiceRequestMessage | |
include ActiveModel::Serialization | |
attr_accessor :client, :version, :format, :payload, :instructions | |
REQUIRED_PHONE_PROFILE_IDS = ["0", "9", "13"].freeze | |
def initialize | |
@client = Client::NODE_SMASHER | |
@version = Version::CURRENT_VERSION | |
@format = Format::DEFAULT | |
@payload = Payload.new(:weather) | |
@instructions = { } | |
@instructions.instance_eval do | |
def to_key_value | |
abbr_instructions = { } | |
self.each do |k,v| | |
if REQUIRED_PHONE_PROFILE_IDS.include? k | |
abbr_instructions[k] = v.map { |i| i.id } | |
end | |
end | |
"instructions: " + abbr_instructions.to_json | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment