1 package com.atlassian.marketplace.client.model;
2
3 import java.net.URI;
4 import java.util.Map;
5
6 import com.atlassian.fugue.Option;
7 import com.atlassian.marketplace.client.api.AddonExternalLinkType;
8
9 import com.google.common.collect.ImmutableList;
10
11 import static com.atlassian.fugue.Option.none;
12 import static com.atlassian.fugue.Option.option;
13 import static com.atlassian.marketplace.client.model.Links.WEB_TYPE;
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class Addon extends AddonBase
28 {
29 Embedded _embedded;
30 Option<Boolean> enableAtlassianAnswers;
31 Map<String, URI> vendorLinks;
32 @ReadOnly Option<LegacyProperties> legacy;
33
34
35
36
37
38 public Option<ImageInfo> getBanner()
39 {
40 return _embedded.banner;
41 }
42
43 @Override
44 public Option<ImageInfo> getLogo()
45 {
46 return _embedded.logo;
47 }
48
49 @Override
50 public Iterable<AddonCategorySummary> getCategories()
51 {
52 return _embedded.categories;
53 }
54
55 @Override
56 public AddonDistributionSummary getDistribution()
57 {
58 return _embedded.distribution;
59 }
60
61 @Override
62 public AddonReviewsSummary getReviews()
63 {
64 return _embedded.reviews;
65 }
66
67 @Override
68 public Option<VendorSummary> getVendor()
69 {
70 return _embedded.vendor;
71 }
72
73
74
75
76
77
78
79
80 public Option<AddonVersion> getVersion()
81 {
82 return _embedded.version;
83 }
84
85
86
87
88 public Option<URI> getSupportDetailsPageUri()
89 {
90 return getLinks().getUri("support", WEB_TYPE);
91 }
92
93
94
95
96
97
98 public Option<HtmlString> getDescription()
99 {
100 for (LegacyProperties l: legacy)
101 {
102 return l.description;
103 }
104 return none();
105 }
106
107
108
109
110
111
112 public Option<URI> getExternalLinkUri(AddonExternalLinkType type)
113 {
114 if (type.canSetForNewAddons())
115 {
116 return option(vendorLinks.get(type.getKey()));
117 }
118 else
119 {
120 for (LegacyProperties l: legacy)
121 {
122 return option(l.vendorLinks.get(type.getKey()));
123 }
124 return none();
125 }
126 }
127
128
129
130
131
132 public Option<Boolean> isEnableAtlassianAnswers()
133 {
134 return enableAtlassianAnswers;
135 }
136
137 static final class Embedded
138 {
139 Option<ImageInfo> banner;
140 Option<ImageInfo> logo;
141 ImmutableList<AddonCategorySummary> categories;
142 AddonDistributionSummary distribution;
143 AddonReviewsSummary reviews;
144 Option<VendorSummary> vendor;
145 Option<AddonVersion> version;
146 }
147
148 static final class LegacyProperties
149 {
150 Option<HtmlString> description;
151 Map<String, URI> vendorLinks;
152 }
153 }