Class: Sunspot4R::ObjectServiceClient

Inherits:
BaseSunspotServiceClient show all
Defined in:
lib/sunspot4r/object_service_client.rb

Overview

Sunspot::ObjectServiceClient

TODO - Description

Instance Attribute Summary

Attributes inherited from BaseSunspotServiceClient

#base_uri

Instance Method Summary collapse

Methods inherited from BaseSunspotServiceClient

#initialize

Constructor Details

This class inherits a constructor from Sunspot4R::BaseSunspotServiceClient

Instance Method Details

#available_objects(association_guid, base_object) ⇒ Object

Returns a list of all Polaris objects accessible to the current user.

Response body XML (abbreviated):

<GetAvailableObjectsResponse xmlns="http://sunspot.arcsolutionsinc.com/Services">
   <GetAvailableObjectsResult xmlns:a="http://ARC.Polaris.Sunspot.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <ApiFaults xmlns="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API.Results" xmlns:b="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API"/>
      <Errors xmlns="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API.Results" xmlns:b="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.Types"/>
      <Exception i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API.Results" xmlns:b="http://schemas.datacontract.org/2004/07/System"/>
      <Success xmlns="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.API.Results">true</Success>
      <a:Objects xmlns:b="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.Types">
         <b:NameValuePair>
            <b:Name>Advertising Rate</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">AdvertisingRate</b:Value>
         </b:NameValuePair>
         <b:NameValuePair>
            <b:Name>Career Center Bundle Product</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">CareerCenterBundleProduct</b:Value>
         </b:NameValuePair>
         <b:NameValuePair>
            <b:Name>Career Center Coupon</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">CareerCenterCoupon</b:Value>
         </b:NameValuePair>
         <b:NameValuePair>
            <b:Name>Tax Product</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">TaxProduct</b:Value>
         </b:NameValuePair>
      </a:Objects>
      <a:_objects xmlns:b="http://schemas.datacontract.org/2004/07/ARC.Polaris.Common.Types">
         <b:NameValuePair>
            <b:Name>Advertising Rate</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">AdvertisingRate</b:Value>
         </b:NameValuePair>
         <b:NameValuePair>
            <b:Name>Career Center Bundle Product</b:Name>
            <b:Value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">CareerCenterBundleProduct</b:Value>
         </b:NameValuePair>
      </a:_objects>
   </GetAvailableObjectsResult>
</GetAvailableObjectsResponse>


55
56
57
58
59
60
61
62
63
64
# File 'lib/sunspot4r/object_service_client.rb', line 55

def available_objects(association_guid, base_object)
  response = call :get_available_objects! do |soap|
    soap.body = {
      "wsdl:associationGuid" => association_guid,
      "wsdl:baseObject" => base_object,
      :order! => ["wsdl:associationGuid", "wsdl:baseObject"]
    }
  end
  response.to_hash[:get_available_objects_response][:get_available_objects_result]
end

#describe_object(association_guid, base_object) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'lib/sunspot4r/object_service_client.rb', line 98

def describe_object(association_guid, base_object)
  response = call :describe_p_object! do |soap|
    soap.body = {
      "wsdl:associationGuid" => association_guid,
      "wsdl:objectName" => base_object,
      :order! => ["wsdl:associationGuid", "wsdl:objectName"]
    }
  end
  response.to_hash[:describe_p_object_response][:describe_p_object_result]
end

#get_all(association_guid, base_object) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/sunspot4r/object_service_client.rb', line 109

def get_all(association_guid, base_object)
  response = call :get_all! do |soap|
    soap.body = {
      "wsdl:associationGuid" => association_guid,
      "wsdl:objectName" => base_object,
      :order! => ["wsdl:associationGuid", "wsdl:objectName"]
    }
  end
  response.to_hash[:get_all_response][:get_all_result]
end

#query(association_guid, query, first = nil, max = nil) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/sunspot4r/object_service_client.rb', line 120

def query(association_guid, query, first = nil, max = nil)
  unless first.nil? || max.nil?
    response = call :query! do |soap|
      soap.body = {
        "wsdl:associationGuid" => association_guid,
        "wsdl:query" => query,
        "wsdl:firstResult" => first,
        "wsdl:maxResults" => max,
        :order! => ["wsdl:associationGuid", "wsdl:query", "wsdl:firstResult", "wsdl:maxResults"]
      }
    end
  else
    response = call :query! do |soap|
      soap.body = {
        "wsdl:associationGuid" => association_guid,
        "wsdl:query" => query,
        :order! => ["wsdl:associationGuid", "wsdl:query"]
      }
    end
  end
  response.to_hash[:query_response][:query_result]
  #response.to_xml
end

#query_by_guid(guid) ⇒ Object

Loads an object from the system by its GUID.

This operation will return either a single object or a null value back. Note that the security placed upon the logged in user is enforced through this operation – if you query an object that your logged in Sunspot account does not have access to, expect an API error to be returned.

This operation will return a single PolarisObject that represents the object you are looking for, or null if non were found.



76
77
78
79
80
81
82
83
# File 'lib/sunspot4r/object_service_client.rb', line 76

def query_by_guid(guid)
  response = call :query_by_guid! do |soap|
    soap.body = {
      "wsdl:guid" => guid
    }
  end
  response.to_hash[:query_by_guid_response][:query_by_guid_result]
end

#service_nameObject

Name of the Sunspot service. Used to build SOAPAction URLs dynamically.



11
12
13
# File 'lib/sunspot4r/object_service_client.rb', line 11

def service_name
  'ObjectService'
end

#upsertObject

#Upsert #Saves an object into the system, inserting it if it does not exist and updating it if it does. #This is your general purpose SaveOrUpdate operation that determines whether or not the object #exists and updates it if it does, inserts it if it doesn’t. The system uses the read-only #RepositoryKey property of the PolarisObject to determine whether or not it exists in the system. #This operation will return an updated version of the object that was saved. If the object was new, #then this updated version will contain the generated GUID and any other automatically generated information.



94
95
96
# File 'lib/sunspot4r/object_service_client.rb', line 94

def upsert

end