#
# Autogenerated by Thrift Compiler (0.8.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift'
require 'profile_types'

module UserStorage
  class Client
    include ::Thrift::Client

    def store(xuser)
      send_store(xuser)
      recv_store()
    end

    def send_store(xuser)
      send_message('store', Store_args, :xuser => xuser)
    end

    def recv_store()
      result = receive_message(Store_result)
      return
    end

    def retrieve(xuid)
      send_retrieve(xuid)
      return recv_retrieve()
    end

    def send_retrieve(xuid)
      send_message('retrieve', Retrieve_args, :xuid => xuid)
    end

    def recv_retrieve()
      result = receive_message(Retrieve_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'retrieve failed: unknown result')
    end

    def set_map(m)
      send_set_map(m)
      recv_set_map()
    end

    def send_set_map(m)
      send_message('set_map', Set_map_args, :m => m)
    end

    def recv_set_map()
      result = receive_message(Set_map_result)
      return
    end

    def last_map()
      send_last_map()
      return recv_last_map()
    end

    def send_last_map()
      send_message('last_map', Last_map_args)
    end

    def recv_last_map()
      result = receive_message(Last_map_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_map failed: unknown result')
    end

    def set_list(l)
      send_set_list(l)
      recv_set_list()
    end

    def send_set_list(l)
      send_message('set_list', Set_list_args, :l => l)
    end

    def recv_set_list()
      result = receive_message(Set_list_result)
      return
    end

    def last_list()
      send_last_list()
      return recv_last_list()
    end

    def send_last_list()
      send_message('last_list', Last_list_args)
    end

    def recv_last_list()
      result = receive_message(Last_list_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_list failed: unknown result')
    end

    def set_status(s)
      send_set_status(s)
      recv_set_status()
    end

    def send_set_status(s)
      send_message('set_status', Set_status_args, :s => s)
    end

    def recv_set_status()
      result = receive_message(Set_status_result)
      return
    end

    def last_status()
      send_last_status()
      return recv_last_status()
    end

    def send_last_status()
      send_message('last_status', Last_status_args)
    end

    def recv_last_status()
      result = receive_message(Last_status_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'last_status failed: unknown result')
    end

    def volume_up()
      send_volume_up()
      return recv_volume_up()
    end

    def send_volume_up()
      send_message('volume_up', Volume_up_args)
    end

    def recv_volume_up()
      result = receive_message(Volume_up_result)
      return result.success unless result.success.nil?
      raise result.exc unless result.exc.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'volume_up failed: unknown result')
    end

    def make_bitcoins()
      send_make_bitcoins()
    end

    def send_make_bitcoins()
      send_message('make_bitcoins', Make_bitcoins_args)
    end
    def add(a, b)
      send_add(a, b)
      return recv_add()
    end

    def send_add(a, b)
      send_message('add', Add_args, :a => a, :b => b)
    end

    def recv_add()
      result = receive_message(Add_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'add failed: unknown result')
    end

    def user_status()
      send_user_status()
      return recv_user_status()
    end

    def send_user_status()
      send_message('user_status', User_status_args)
    end

    def recv_user_status()
      result = receive_message(User_status_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_status failed: unknown result')
    end

    def set_user_status(stat)
      send_set_user_status(stat)
      recv_set_user_status()
    end

    def send_set_user_status(stat)
      send_message('set_user_status', Set_user_status_args, :stat => stat)
    end

    def recv_set_user_status()
      result = receive_message(Set_user_status_result)
      return
    end

    def user_relationship()
      send_user_relationship()
      return recv_user_relationship()
    end

    def send_user_relationship()
      send_message('user_relationship', User_relationship_args)
    end

    def recv_user_relationship()
      result = receive_message(User_relationship_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_relationship failed: unknown result')
    end

    def set_user_relationship(rel)
      send_set_user_relationship(rel)
      recv_set_user_relationship()
    end

    def send_set_user_relationship(rel)
      send_message('set_user_relationship', Set_user_relationship_args, :rel => rel)
    end

    def recv_set_user_relationship()
      result = receive_message(Set_user_relationship_result)
      return
    end

    def user_friends()
      send_user_friends()
      return recv_user_friends()
    end

    def send_user_friends()
      send_message('user_friends', User_friends_args)
    end

    def recv_user_friends()
      result = receive_message(User_friends_result)
      return result.success unless result.success.nil?
      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'user_friends failed: unknown result')
    end

    def set_user_friends(fr)
      send_set_user_friends(fr)
      recv_set_user_friends()
    end

    def send_set_user_friends(fr)
      send_message('set_user_friends', Set_user_friends_args, :fr => fr)
    end

    def recv_set_user_friends()
      result = receive_message(Set_user_friends_result)
      return
    end

  end

  class Processor
    include ::Thrift::Processor

    def process_store(seqid, iprot, oprot)
      args = read_args(iprot, Store_args)
      result = Store_result.new()
      @handler.store(args.xuser)
      write_result(result, oprot, 'store', seqid)
    end

    def process_retrieve(seqid, iprot, oprot)
      args = read_args(iprot, Retrieve_args)
      result = Retrieve_result.new()
      result.success = @handler.retrieve(args.xuid)
      write_result(result, oprot, 'retrieve', seqid)
    end

    def process_set_map(seqid, iprot, oprot)
      args = read_args(iprot, Set_map_args)
      result = Set_map_result.new()
      @handler.set_map(args.m)
      write_result(result, oprot, 'set_map', seqid)
    end

    def process_last_map(seqid, iprot, oprot)
      args = read_args(iprot, Last_map_args)
      result = Last_map_result.new()
      result.success = @handler.last_map()
      write_result(result, oprot, 'last_map', seqid)
    end

    def process_set_list(seqid, iprot, oprot)
      args = read_args(iprot, Set_list_args)
      result = Set_list_result.new()
      @handler.set_list(args.l)
      write_result(result, oprot, 'set_list', seqid)
    end

    def process_last_list(seqid, iprot, oprot)
      args = read_args(iprot, Last_list_args)
      result = Last_list_result.new()
      result.success = @handler.last_list()
      write_result(result, oprot, 'last_list', seqid)
    end

    def process_set_status(seqid, iprot, oprot)
      args = read_args(iprot, Set_status_args)
      result = Set_status_result.new()
      @handler.set_status(args.s)
      write_result(result, oprot, 'set_status', seqid)
    end

    def process_last_status(seqid, iprot, oprot)
      args = read_args(iprot, Last_status_args)
      result = Last_status_result.new()
      result.success = @handler.last_status()
      write_result(result, oprot, 'last_status', seqid)
    end

    def process_volume_up(seqid, iprot, oprot)
      args = read_args(iprot, Volume_up_args)
      result = Volume_up_result.new()
      begin
        result.success = @handler.volume_up()
      rescue RockTooHard => exc
        result.exc = exc
      end
      write_result(result, oprot, 'volume_up', seqid)
    end

    def process_make_bitcoins(seqid, iprot, oprot)
      args = read_args(iprot, Make_bitcoins_args)
      @handler.make_bitcoins()
      return
    end

    def process_add(seqid, iprot, oprot)
      args = read_args(iprot, Add_args)
      result = Add_result.new()
      result.success = @handler.add(args.a, args.b)
      write_result(result, oprot, 'add', seqid)
    end

    def process_user_status(seqid, iprot, oprot)
      args = read_args(iprot, User_status_args)
      result = User_status_result.new()
      result.success = @handler.user_status()
      write_result(result, oprot, 'user_status', seqid)
    end

    def process_set_user_status(seqid, iprot, oprot)
      args = read_args(iprot, Set_user_status_args)
      result = Set_user_status_result.new()
      @handler.set_user_status(args.stat)
      write_result(result, oprot, 'set_user_status', seqid)
    end

    def process_user_relationship(seqid, iprot, oprot)
      args = read_args(iprot, User_relationship_args)
      result = User_relationship_result.new()
      result.success = @handler.user_relationship()
      write_result(result, oprot, 'user_relationship', seqid)
    end

    def process_set_user_relationship(seqid, iprot, oprot)
      args = read_args(iprot, Set_user_relationship_args)
      result = Set_user_relationship_result.new()
      @handler.set_user_relationship(args.rel)
      write_result(result, oprot, 'set_user_relationship', seqid)
    end

    def process_user_friends(seqid, iprot, oprot)
      args = read_args(iprot, User_friends_args)
      result = User_friends_result.new()
      result.success = @handler.user_friends()
      write_result(result, oprot, 'user_friends', seqid)
    end

    def process_set_user_friends(seqid, iprot, oprot)
      args = read_args(iprot, Set_user_friends_args)
      result = Set_user_friends_result.new()
      @handler.set_user_friends(args.fr)
      write_result(result, oprot, 'set_user_friends', seqid)
    end

  end

  # HELPER FUNCTIONS AND STRUCTURES

  class Store_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    XUSER = 1

    FIELDS = {
      XUSER => {:type => ::Thrift::Types::STRUCT, :name => 'xuser', :class => UserProfile}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Store_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Retrieve_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    XUID = 1

    FIELDS = {
      XUID => {:type => ::Thrift::Types::I32, :name => 'xuid'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Retrieve_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserProfile}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_map_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    M = 1

    FIELDS = {
      M => {:type => ::Thrift::Types::MAP, :name => 'm', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_map_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_map_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_map_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_list_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    L = 1

    FIELDS = {
      L => {:type => ::Thrift::Types::LIST, :name => 'l', :element => {:type => ::Thrift::Types::STRING}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_list_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_list_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_list_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_status_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    S = 1

    FIELDS = {
      S => {:type => ::Thrift::Types::I32, :name => 's', :enum_class => Status}
    }

    def struct_fields; FIELDS; end

    def validate
      unless @s.nil? || Status::VALID_VALUES.include?(@s)
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field s!')
      end
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_status_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_status_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Last_status_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Status}
    }

    def struct_fields; FIELDS; end

    def validate
      unless @success.nil? || Status::VALID_VALUES.include?(@success)
        raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
      end
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Volume_up_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Volume_up_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0
    EXC = 1

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'},
      EXC => {:type => ::Thrift::Types::STRUCT, :name => 'exc', :class => RockTooHard}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Make_bitcoins_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Make_bitcoins_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Add_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    A = 1
    B = 2

    FIELDS = {
      A => {:type => ::Thrift::Types::I32, :name => 'a'},
      B => {:type => ::Thrift::Types::I32, :name => 'b'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Add_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_status_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_status_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserStatus}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_status_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    STAT = 1

    FIELDS = {
      STAT => {:type => ::Thrift::Types::STRUCT, :name => 'stat', :class => UserStatus}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_status_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_relationship_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_relationship_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserRelationship}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_relationship_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    REL = 1

    FIELDS = {
      REL => {:type => ::Thrift::Types::STRUCT, :name => 'rel', :class => UserRelationship}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_relationship_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_friends_args
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class User_friends_result
    include ::Thrift::Struct, ::Thrift::Struct_Union
    SUCCESS = 0

    FIELDS = {
      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => UserFriends}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_friends_args
    include ::Thrift::Struct, ::Thrift::Struct_Union
    FR = 1

    FIELDS = {
      FR => {:type => ::Thrift::Types::STRUCT, :name => 'fr', :class => UserFriends}
    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

  class Set_user_friends_result
    include ::Thrift::Struct, ::Thrift::Struct_Union

    FIELDS = {

    }

    def struct_fields; FIELDS; end

    def validate
    end

    ::Thrift::Struct.generate_accessors self
  end

end

