1 package com.atlassian.marketplace.client.impl;
2
3 import com.atlassian.fugue.Option;
4 import com.atlassian.marketplace.client.MpacException;
5 import com.atlassian.marketplace.client.api.Page;
6 import com.atlassian.marketplace.client.api.PageReference;
7 import com.atlassian.marketplace.client.api.VendorId;
8 import com.atlassian.marketplace.client.api.VendorQuery;
9 import com.atlassian.marketplace.client.api.Vendors;
10 import com.atlassian.marketplace.client.model.Vendor;
11 import com.atlassian.marketplace.client.model.VendorSummary;
12 import com.atlassian.marketplace.client.util.UriBuilder;
13
14 final class VendorsImpl extends ApiImplBase implements Vendors
15 {
16 VendorsImpl(ApiHelper apiHelper, InternalModel.MinimalLinks root) throws MpacException
17 {
18 super(apiHelper, root, "vendors");
19 }
20
21 @Override
22 public Option<Vendor> getById(VendorId id) throws MpacException
23 {
24 return apiHelper.getOptionalEntity(id.getUri(), Vendor.class);
25 }
26
27 @Override
28 public Vendor createVendor(Vendor vendor) throws MpacException
29 {
30 return genericCreate(getApiRoot(), vendor);
31 }
32
33 @Override
34 public Vendor updateVendor(Vendor original, Vendor updated) throws MpacException
35 {
36 return genericUpdate(original.getSelfUri(), original, updated);
37 }
38
39 @Override
40 public Page<VendorSummary> find(VendorQuery query) throws MpacException
41 {
42 UriBuilder uri = fromApiRoot();
43 ApiHelper.addVendorQueryParams(query, uri);
44 return apiHelper.getMore(new PageReference<VendorSummary>(
45 uri.build(), query.getBounds(), pageReader(InternalModel.Vendors.class)));
46 }
47 }