Sha256: 8987c355a35e715762067bbb8f932daaed588ca83f3c51985f0ffd0223ad77f6

Contents?: true

Size: 1019 Bytes

Versions: 15

Compression:

Stored size: 1019 Bytes

Contents

module SugarCRM; class Connection
# Retrieves a collection of beans that are related 
# to the specified bean and, optionally, returns 
# relationship data
def get_relationships(module_name, id, related_to, opts={})
  login! unless logged_in?
  options = { 
    :query => '',
    :fields => [], 
    :link_fields => [], 
    :deleted => ''
  }.merge! opts  
  
  related_module = related_to.classify
  
  json = <<-EOF
    {
      \"session\": \"#{@session}\"\,
      \"module_name\": \"#{module_name}\"\,
      \"module_id\": \"#{id}\"\,
      \"link_field_name\": \"#{related_to.downcase}\"\,
      \"related_module_query\": \"#{options[:query]}\"\,
      \"related_fields\": #{resolve_fields(related_module, options[:fields])}\,
      \"related_module_link_name_to_fields_array\": #{options[:link_fields].to_json}\,
      \"deleted\": #{options[:deleted]}
    }
  EOF
  json.gsub!(/^\s{6}/,'')
  SugarCRM::Response.new(send!(:get_relationships, json)).to_obj
end

alias :get_relationship :get_relationships

end; end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sugarcrm-0.9.7 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.6 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.5 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.4 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.3 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.2 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.1 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.9.0 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.8.2 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.8.1 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.8.0 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.7.9 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.7.8 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.7.7 lib/sugarcrm/connection/api/get_relationships.rb
sugarcrm-0.7.2 lib/sugarcrm/connection/api/get_relationships.rb