Skip to content

Commit

Permalink
#154 creating ServiceRequestOperations
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsmelser committed Dec 29, 2017
1 parent fbeb5b2 commit 2f3d3e3
Show file tree
Hide file tree
Showing 18 changed files with 704 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.social.partnercenter.api.customer.user.AdminUserOperations;
import org.springframework.social.partnercenter.api.order.AdminOrderOperations;
import org.springframework.social.partnercenter.api.order.subscription.AdminSubscriptionOperations;
import org.springframework.social.partnercenter.api.support.SupportOperations;

public interface PartnerCenterAdmin extends PartnerCenter {
String PROVIDER_ID = "partner-center-admin";
Expand All @@ -14,4 +15,5 @@ public interface PartnerCenterAdmin extends PartnerCenter {
AdminOrderOperations getOrderOperations();
AdminSubscriptionOperations getSubscriptionOperations();
AnalyticsOperations getAnalyticsOperations();
SupportOperations getSupportOperations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.springframework.social.partnercenter.api.order.impl.AdminOrderTemplate;
import org.springframework.social.partnercenter.api.order.subscription.AdminSubscriptionOperations;
import org.springframework.social.partnercenter.api.order.subscription.impl.AdminSubscriptionTemplate;
import org.springframework.social.partnercenter.api.support.SupportOperations;
import org.springframework.social.partnercenter.api.support.impl.SupportTemplate;
import org.springframework.social.partnercenter.api.uri.UriProvider;
import org.springframework.social.partnercenter.http.client.RestClient;
import org.springframework.social.partnercenter.http.client.RestResource;
Expand All @@ -23,14 +25,16 @@ public class PartnerCenterAdminTemplate extends PartnerCenterTemplate implements
private final AdminOrderOperations adminOrderOperations;
private final AdminSubscriptionOperations adminSubscriptionOperations;
private final AnalyticsOperations analyticsOperations;
private final SupportOperations supportOperations;

public PartnerCenterAdminTemplate(UriProvider uriProvider, String accessToken, String version){
super(uriProvider, accessToken, version);
adminCustomerOperations = new AdminCustomerTemplate(createRestResource(uriProvider.partnerCenterCustomerUri().build().toUri()), isAuthorized());
adminUserOperations = new AdminUserTemplate(createRestResource(uriProvider.partnerCenterCustomerUri().build().toUri()), isAuthorized());
adminOrderOperations = new AdminOrderTemplate(createRestResource(uriProvider.partnerCenterCustomerUri().build().toUri()), isAuthorized());
adminSubscriptionOperations = new AdminSubscriptionTemplate(createRestResource(uriProvider.partnerCenterCustomerUri().build().toUri()), isAuthorized());
analyticsOperations = new AnalyticsTemplate(createRestResource(uriProvider.partnerAnalyticsUri().build().toUri()), isAuthorized());
analyticsOperations = new AnalyticsTemplate(createRestResource(uriProvider.partnerBaseUri().build().toUri()), isAuthorized());
supportOperations = new SupportTemplate(createRestResource(uriProvider.partnerBaseUri().build().toUri()), isAuthorized());
}

private RestResource createRestResource(URI baseUri){
Expand Down Expand Up @@ -61,4 +65,9 @@ public AdminSubscriptionOperations getSubscriptionOperations() {
public AnalyticsOperations getAnalyticsOperations() {
return analyticsOperations;
}

@Override
public SupportOperations getSupportOperations() {
return supportOperations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.springframework.social.partnercenter.api.support;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import org.springframework.social.partnercenter.api.ResourceAttributes;
import org.springframework.social.partnercenter.api.ResourceLinks;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(NON_NULL)
public class SupportContact {
private String supportTenantId;
private String supportMpnId;
private String name;
private ResourceLinks links;
private ResourceAttributes attributes;

public String getSupportTenantId() {
return supportTenantId;
}

public void setSupportTenantId(String supportTenantId) {
this.supportTenantId = supportTenantId;
}

public String getSupportMpnId() {
return supportMpnId;
}

public void setSupportMpnId(String supportMpnId) {
this.supportMpnId = supportMpnId;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public ResourceLinks getLinks() {
return links;
}

public void setLinks(ResourceLinks links) {
this.links = links;
}

public ResourceAttributes getAttributes() {
return attributes;
}

public void setAttributes(ResourceAttributes attributes) {
this.attributes = attributes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.springframework.social.partnercenter.api.support;

import org.springframework.http.ResponseEntity;
import org.springframework.social.partnercenter.api.PartnerCenterResponse;
import org.springframework.social.partnercenter.api.support.managedservice.ManagedService;
import org.springframework.social.partnercenter.api.support.servicerequest.ServiceRequest;

public interface SupportOperations {
ResponseEntity<SupportContact> getSupportContact(String customerId, String subscriptionId);
ResponseEntity<SupportContact> updateSupportContact(String customerId, String subscriptionId, SupportContact supportContact);
ResponseEntity<PartnerCenterResponse<ManagedService>> getManagedServices(String customerId);
ResponseEntity<PartnerCenterResponse<SupportTopic>> getSupportTopics();
ResponseEntity<PartnerCenterResponse<ServiceRequest>> getServiceRequests(String customerId);
ResponseEntity<ServiceRequest> updateServiceRequest(ServiceRequest request);
ResponseEntity<ServiceRequest> createServiceRequest(ServiceRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.springframework.social.partnercenter.api.support;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import org.springframework.social.partnercenter.api.ResourceAttributes;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(NON_NULL)
public class SupportTopic {
private String name;
private String description;
private int id;
private ResourceAttributes attribute;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public ResourceAttributes getAttribute() {
return attribute;
}

public void setAttribute(ResourceAttributes attribute) {
this.attribute = attribute;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.springframework.social.partnercenter.api.support.impl;

import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
import org.springframework.social.partnercenter.PartnerCenter;
import org.springframework.social.partnercenter.api.AbstractTemplate;
import org.springframework.social.partnercenter.api.PartnerCenterResponse;
import org.springframework.social.partnercenter.api.support.SupportContact;
import org.springframework.social.partnercenter.api.support.SupportOperations;
import org.springframework.social.partnercenter.api.support.SupportTopic;
import org.springframework.social.partnercenter.api.support.managedservice.ManagedService;
import org.springframework.social.partnercenter.api.support.servicerequest.ServiceRequest;
import org.springframework.social.partnercenter.http.client.RestResource;

public class SupportTemplate extends AbstractTemplate implements SupportOperations {
private static final String CUSTOMERS = "customers";
private static final String SUBSCRIPTIONS = "subscriptions";
private static final String SUPPORT_CONTACT = "supportcontact";
private static final String MANAGED_SERVICES = "managedservices";
private static final String SERVICE_REQUESTS = "servicerequests";

private final RestResource restResource;

public SupportTemplate(RestResource restResource, boolean isAuthorized) {
super(isAuthorized);
this.restResource = restResource;
}

@Override
public ResponseEntity<SupportContact> getSupportContact(String customerId, String subscriptionId) {
return restResource.request()
.pathSegment(CUSTOMERS, customerId, SUBSCRIPTIONS, subscriptionId, SUPPORT_CONTACT)
.get(SupportContact.class);
}

@Override
public ResponseEntity<SupportContact> updateSupportContact(String customerId, String subscriptionId, SupportContact supportContact) {
return restResource.request()
.pathSegment(CUSTOMERS, customerId, SUBSCRIPTIONS, subscriptionId, SUPPORT_CONTACT)
.put(supportContact, SupportContact.class);
}

@Override
public ResponseEntity<PartnerCenterResponse<ManagedService>> getManagedServices(String customerId) {
return restResource.request()
.pathSegment(CUSTOMERS, customerId, MANAGED_SERVICES)
.get(new ParameterizedTypeReference<PartnerCenterResponse<ManagedService>>() {});
}

@Override
public ResponseEntity<PartnerCenterResponse<SupportTopic>> getSupportTopics() {
return restResource.request()
.pathSegment(SERVICE_REQUESTS, "supporttopics")
.get(new ParameterizedTypeReference<PartnerCenterResponse<SupportTopic>>() {});
}

@Override
public ResponseEntity<PartnerCenterResponse<ServiceRequest>> getServiceRequests(String customerId) {
return restResource.request()
.pathSegment(CUSTOMERS, customerId, SERVICE_REQUESTS)
.get(new ParameterizedTypeReference<PartnerCenterResponse<ServiceRequest>>() {});
}

@Override
public ResponseEntity<ServiceRequest> updateServiceRequest(ServiceRequest request) {
return restResource.request()
.pathSegment(SERVICE_REQUESTS, request.getId())
.patch(request, ServiceRequest.class);
}

@Override
public ResponseEntity<ServiceRequest> createServiceRequest(ServiceRequest request) {
return restResource.request()
.pathSegment(SERVICE_REQUESTS)
.post(request, ServiceRequest.class);
}

@Override
protected String getProviderId() {
return PartnerCenter.PROVIDER_ID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.springframework.social.partnercenter.api.support.managedservice;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(NON_NULL)
public class ManagedService {
private String id;
private String name;
private String groupName;
private ManagedServiceLinks links;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getGroupName() {
return groupName;
}

public void setGroupName(String groupName) {
this.groupName = groupName;
}

public ManagedServiceLinks getLinks() {
return links;
}

public void setLinks(ManagedServiceLinks links) {
this.links = links;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.springframework.social.partnercenter.api.support.managedservice;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

import org.springframework.social.partnercenter.api.Link;
import org.springframework.social.partnercenter.api.ResourceAttributes;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(NON_NULL)
public class ManagedServiceLinks {
private Link adminService;
private Link serviceHealth;
private Link serviceTicket;
private ResourceAttributes attributes;

public Link getAdminService() {
return adminService;
}

public void setAdminService(Link adminService) {
this.adminService = adminService;
}

public Link getServiceHealth() {
return serviceHealth;
}

public void setServiceHealth(Link serviceHealth) {
this.serviceHealth = serviceHealth;
}

public Link getServiceTicket() {
return serviceTicket;
}

public void setServiceTicket(Link serviceTicket) {
this.serviceTicket = serviceTicket;
}

public ResourceAttributes getAttributes() {
return attributes;
}

public void setAttributes(ResourceAttributes attributes) {
this.attributes = attributes;
}
}
Loading

0 comments on commit 2f3d3e3

Please sign in to comment.