The following are steps an application will need to perform to be displayed in RepairCenter and/or retrieve data from the Partner API
The Mitchell Partner API uses the Microsoft OData (Open Data) protocol based on the popular REST (Representational State Transfer) protocol. For more information on OData, please visit the site at http://www.odata.org. This site contains protocol documentation, articles, videos and the OData SDK that allows programming platforms other than Microsoft.NET to easily consume OData.
The following are steps an application will need to perform to be displayed in RepairCenter and/or retrieve data from the Partner API. Which steps an application performs will depend on the type of application (noted in the steps below).
If the application is a visual or composite application, RepairCenter will send the following information in the initial web request header as query string parameter that is used internally for the application and for calls to the Partner API:
shop_id: Id of the shop that requests the information.
user_id: Id of the RC user who initiated the request. Call the RC Partner API User services to get detailed information on the user
job_id: If the user is calling the application from the Active Job tab within RepairCenter, the id of the active job will be sent (composite application only)
opportunity_id : If the user is calling the application from the Active Opportunity tab within RepairCenter , the id of the active opportunity will be sent (composite application only)
Example of extracting one of the query string values from the request:
string shopId = Request.QueryString["shop_id"] as string;
Partner applications can be configured to refresh as the user in RepairCenter moves from other tabs in RepairCenter to your partner tab after the initial load of the application page. This refresh information is sent as a query parameter that looks like this:
?refresh=2
The refresh value is the number times the user has moved back to the application tab (page).
Data applications will need to call the Mitchell PartnerAdminService to get the list of available shops and shop information for use in the application. Since PartnerAdminService is a SOAP service, the proxy classes included in PartnerAdminService.dll should be used to access it.
Include PartnerAdminService.dll and add its reference to your project. Make sure that the configuration for the service in the app.config or web.config looks like the example below:
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_PartnerAdminService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> <message clientCredentialType="UserName" algorithmSuite="Default"/> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="https://Api.repaircenter-uat.mitchell.com:8083/Partner/PartnerAdminService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PartnerAdminService" contract="Mitchell.Repair.Services.Partner.Core.PartnerAdminService" name="BasicHttpBinding_PartnerAdminService"/> </client> </system.serviceModel>
Replace the endpoint address with appropriate URL based on the environment you are using.
1. UAT: https://api.repaircenter-uat.mitchell.com:8083/Partner/PartnerAdminService.svc
2. Production: https://api.repaircenter.mitchell.com/Partner/PartnerAdminService.svc
Use the GetShopsForPartnerApp method in PartnerAdminService web service:
List<Shop> GetShopsForPartnerApp(int partnerAppId)
Pass the following value to this method in the query string:
-
AppId: The Mitchell generated Id of your application
Pass the application security key in the request header:
-
ApiKey: The security key received from Apigee during the registration process
The call will return a list of the Shop objects each containing the following data for the shops:
-
ShopId: Shop Id
-
ShopName: Name of the shop
public IEnumerable<Mitchell.Repair.Services.Partner.Core.Shop> GetShops() { //Change for forcing TLS 1.2 in service calls System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072; PartnerAdminServiceClient partnerAdminClient = new PartnerAdminServiceClient(); HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); httpRequestProperty.Headers.Add(ServiceHttpHeaders.HttpRequestHeaderApigeeApiKey,"yourApiKey"); using (OperationContextScope scope = new OperationContextScope((IContextChannel)partnerAdminClient.InnerChannel)) { OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; // Call GetShopsForPartnerApp var shops = partnerAdminClient.GetShopsForPartnerApp(Convert.ToInt32("yourAppId")); List<Mitchell.Repair.Services.Partner.Core.Shop> shopList = new List<Mitchell.Repair.Services.Partner.Core.Shop>(); foreach (Mitchell.Repair.Services.Partner.Core.Shop shop in shops) { shopList.Add(shop); } return shopList; } }
Sample Retrieving Shop List Code
This section applies to data and composite applications.
To construct the URL to the RC Partner API services, append the name of the service to be accessed to the end of the base URL. For example, to access Vehicle data for RepairOrder(s), append “RepairOrder/JobService.svc” and the RESTful query to the base URL (UAT - Api.repaircenter-uat.mitchell.com:8083 or Production - Api.repaircenter.mitchell.com):
string vehicleSvcUri = baseApiUri + (baseApiUri.EndsWith("/") ? string.Empty : "/") + "RepairOrder/JobService.svc/Vehicles";
Sample URL Construction Code
The following information will be sent in the Request Header to the RC Partner API:
shop_id: Id of the shop.
shop_country: The country code of the shop (US or CA)
apiKey: The security key received from Apigee during the registration process
Sample Setting Headers Code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(vehicleSvcUri); request.Headers.Add(“shop_id”, shopId); request.Headers.Add(“shop_country”, "US"); request.Headers.Add(“apiKey”, “yourApiKey");
Call the RC Partner API with the constructed URL and required headers. See the sample partner application and tips on the developer portal for more information.
Properly Requesting Repair Order or Opportunity Data via LINQ/ REST
It is important how LINQ/ REST queries are created so that proper SQL is created on the Mitchell SQL Servers. It is required when requesting data for a single Repair Order or Opportunity that both "keys" for the entity are passed via LINQ like this:
var jobList = (from j in jobsContext.Jobs where j.Id==500 & j.ShopId=="1002" select new { JobId = j.Id, RONumber = j.RONumber, SupplementNumber = j.SupplementNumber, Status = j.Status } ).ToList();
This results in a REST query like this:
https://Api.repaircenter-uat.mitchell.com:8083/api/2.2/RepairOrder/JobService.svc/Jobs(ShopId='1002',JobId=500)?select=Id,RONumber,SupplementNumber,Status
The complete list of keys for each entity can be found in Service Diagrams.
Retrieving Just the Data Needed
Using LINQ in .NET it's very easy to request data, such as Vehicle information like this:
var vi = (from v in vehicleCtx.Vehicles.Expand("Colors") where v.ShopId == "1002" & v.JobId == 5 select v ).FirstOrDefault();
This results in a REST query like this:
https://Api.repaircenter-uat.mitchell.com:8083/api/2.2/RepairOrder/VehicleService.svc/Vehicles(ShopId='1002',JobId=5)?$expand=Colors
Unless all data from Vehicles and Colors entities is required, only the specific properties should be requested in the query like this (this is required to pass the code validation process):
var vi = (from v in vehicleCtx.Vehicles where v.ShopId == "1002" & v.JobId == 5 select new { v.MakeDescription, v.Model, v.VIN, v.Color.Name } ).FirstOrDefault();
This results in a REST query like this:
https://Api.repaircenter-uat.mitchell.com:8083/api/2.2/RepairOrder/VehicleService.svc/Vehicles(ShopId='1002',JobId=5)?$expand=Color&$select=MakeDescription,Model,VIN,Color/Name
This query results in a much smaller payload across the internet, faster response time and allows back end servers to handle more requests.
In the response headers, returned will be the “data_expires” value, which will indicate for how long data retrieved can be stored. It is the applications responsibility to dispose of this data at the indicated date as defined in the Application Developer Platform License Agreement.