Class: TripIt::BaseObject

Inherits:
Base
  • Object
show all
Defined in:
lib/trip_it/classes/objects/base_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#Boolean, #camelize, #chkAndPopulate, #chkObjAndPopulate, #convertDT, #to_hash, #to_json, #to_xml

Methods included from ParamUtil

#address_param, #airportcode_param, #array_param, #boolean_param, #boolean_read_param, #camelize, #date_param, #datetime_param, #exceptions, #float_param, #integer_param, #string_param, #time_param, #traveler_array_param, #traveler_param

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/trip_it/classes/objects/base_object.rb', line 3

def id
  @id
end

#is_client_travelerObject (readonly)

Returns the value of attribute is_client_traveler.



3
4
5
# File 'lib/trip_it/classes/objects/base_object.rb', line 3

def is_client_traveler
  @is_client_traveler
end

#relative_urlObject (readonly)

Returns the value of attribute relative_url.



3
4
5
# File 'lib/trip_it/classes/objects/base_object.rb', line 3

def relative_url
  @relative_url
end

Instance Method Details

#populate(info) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/trip_it/classes/objects/base_object.rb', line 8

def populate(info)
  return if info.nil? # Make sure we don't raise an error if info is nil
  @id                     = info["id"]
  @relative_url           = info["relative_url"]
  @trip_id                = info["trip_id"]
  @is_client_traveler     = Boolean(info["is_client_traveler"])
  @display_name           = info["display_name"]
  @image                  = []
  chkAndPopulate(@image, TripIt::Image, info["Image"])
end

#saveObject



19
20
21
22
23
24
25
# File 'lib/trip_it/classes/objects/base_object.rb', line 19

def save
  if @obj_id.nil?
    @client.create(self.to_xml)
  else
    @client.replace("/#{self.class.name.split("::").last.gsub("Object","").downcase}/id/#{@obj_id}", self.to_xml)
  end
end

#sequenceObject



27
28
29
# File 'lib/trip_it/classes/objects/base_object.rb', line 27

def sequence
  ["@trip_id","@display_name", "@image"]
end