• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #41

24 Aug 2023 04:59PM UTC coverage: 50.458% (+0.01%) from 50.444%
#41

push

github-actions

web-flow
Fix Checkstyle Violations in "Impl" Classes (#53)

241 of 241 new or added lines in 32 files covered. (100.0%)

3417 of 6772 relevant lines covered (50.46%)

0.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/src/main/java/com/smartsheet/api/internal/SightResourcesImpl.java
1
/*
2
 * #[license]
3
 * Smartsheet SDK for Java
4
 * %%
5
 * Copyright (C) 2023 Smartsheet
6
 * %%
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *      http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 * %[license]
19
 */
20

21
package com.smartsheet.api.internal;
22

23
import com.smartsheet.api.AuthorizationException;
24
import com.smartsheet.api.InvalidRequestException;
25
import com.smartsheet.api.ResourceNotFoundException;
26
import com.smartsheet.api.ServiceUnavailableException;
27
import com.smartsheet.api.ShareResources;
28
import com.smartsheet.api.SightResources;
29
import com.smartsheet.api.SmartsheetException;
30
import com.smartsheet.api.internal.util.QueryUtil;
31
import com.smartsheet.api.internal.util.Util;
32
import com.smartsheet.api.models.ContainerDestination;
33
import com.smartsheet.api.models.PagedResult;
34
import com.smartsheet.api.models.PaginationParameters;
35
import com.smartsheet.api.models.Sight;
36
import com.smartsheet.api.models.SightPublish;
37
import com.smartsheet.api.models.enums.SightInclusion;
38

39
import java.text.SimpleDateFormat;
40
import java.util.Date;
41
import java.util.EnumSet;
42
import java.util.HashMap;
43
import java.util.Map;
44

45
public class SightResourcesImpl extends AbstractResources implements SightResources {
46

47
    private ShareResources shares;
48

49
    private static final String SIGHTS = "sights";
50

51
    /**
52
     * Constructor.
53
     * <p>
54
     * Exceptions: - IllegalArgumentException : if any argument is null
55
     *
56
     * @param smartsheet the smartsheet
57
     */
58
    public SightResourcesImpl(SmartsheetImpl smartsheet) {
59
        super(smartsheet);
1✔
60
        this.shares = new ShareResourcesImpl(smartsheet, SIGHTS);
1✔
61
    }
1✔
62

63
    /**
64
     * Gets the list of all Sights where the User has access.
65
     * <p>
66
     * It mirrors to the following Smartsheet REST API method: GET /sights
67
     *
68
     * @return IndexResult object containing an array of Sight objects limited to the following attributes:
69
     *     id, name, accessLevel, permalink, createdAt, modifiedAt.
70
     * @throws IllegalArgumentException if any argument is null or empty string
71
     * @throws InvalidRequestException if there is any problem with the REST API request
72
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
73
     * @throws ResourceNotFoundException if the resource cannot be found
74
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
75
     * @throws SmartsheetException if there is any other error during the operation
76
     */
77
    public PagedResult<Sight> listSights(PaginationParameters paging, Date modifiedSince) throws SmartsheetException {
78
        String path = SIGHTS;
×
79

80
        Map<String, Object> parameters = new HashMap<>();
×
81
        if (paging != null) {
×
82
            parameters = paging.toHashMap();
×
83
        }
84
        if (modifiedSince != null) {
×
85
            String isoDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(modifiedSince);
×
86
            parameters.put("modifiedSince", isoDate);
×
87
        }
88
        path += QueryUtil.generateUrl(null, parameters);
×
89
        return this.listResourcesWithWrapper(path, Sight.class);
×
90
    }
91

92
    /**
93
     * Get a specified Sight.
94
     * <p>
95
     * It mirrors to the following Smartsheet REST API method: GET /sights/{sightId}
96
     *
97
     * @param sightId the Id of the Sight
98
     * @return the Sight resource.
99
     * @throws IllegalArgumentException if any argument is null or empty string
100
     * @throws InvalidRequestException if there is any problem with the REST API request
101
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
102
     * @throws ResourceNotFoundException if the resource cannot be found
103
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
104
     * @throws SmartsheetException if there is any other error during the operation
105
     */
106
    public Sight getSight(long sightId) throws SmartsheetException {
107
        return this.getSight(sightId, null, null);
×
108
    }
109

110
    /**
111
     * Get a specified Sight.
112
     * <p>
113
     * It mirrors to the following Smartsheet REST API method: GET /sights/{sightId}
114
     *
115
     * @param sightId the Id of the Sight
116
     * @param level compatibility level
117
     * @return the Sight resource.
118
     * @throws IllegalArgumentException if any argument is null or empty string
119
     * @throws InvalidRequestException if there is any problem with the REST API request
120
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
121
     * @throws ResourceNotFoundException if the resource cannot be found
122
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
123
     * @throws SmartsheetException if there is any other error during the operation
124
     */
125
    public Sight getSight(long sightId, Integer level) throws SmartsheetException {
126
        return this.getSight(sightId, null, level);
×
127
    }
128

129
    /**
130
     * Get a specified Sight.
131
     * <p>
132
     * It mirrors to the following Smartsheet REST API method: GET /sights/{sightId}
133
     *
134
     * @param sightId the Id of the Sight
135
     * @param level compatibility level
136
     * @param includes optional parameters to include
137
     * @return the Sight resource.
138
     * @throws IllegalArgumentException if any argument is null or empty string
139
     * @throws InvalidRequestException if there is any problem with the REST API request
140
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
141
     * @throws ResourceNotFoundException if the resource cannot be found
142
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
143
     * @throws SmartsheetException if there is any other error during the operation
144
     */
145
    public Sight getSight(long sightId, EnumSet<SightInclusion> includes, Integer level) throws SmartsheetException {
146
        String path = SIGHTS + "/" + sightId;
×
147

148
        Map<String, Object> parameters = new HashMap<>();
×
149
        parameters.put("level", level);
×
150
        parameters.put("include", QueryUtil.generateCommaSeparatedList(includes));
×
151
        path += QueryUtil.generateUrl(null, parameters);
×
152

153
        return this.getResource(path, Sight.class);
×
154
    }
155

156
    /**
157
     * Update a specified Sight.
158
     * <p>
159
     * It mirrors to the following Smartsheet REST API method: PUT /sights/{sightId}
160
     *
161
     * @param sight - the Sight to update
162
     * @return the updated Sight resource.
163
     * @throws IllegalArgumentException if any argument is null or empty string
164
     * @throws InvalidRequestException if there is any problem with the REST API request
165
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
166
     * @throws ResourceNotFoundException if the resource cannot be found
167
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
168
     * @throws SmartsheetException if there is any other error during the operation
169
     */
170
    public Sight updateSight(Sight sight) throws SmartsheetException {
171
        Util.throwIfNull(sight);
×
172
        return this.updateResource(SIGHTS + "/" + sight.getId(), Sight.class, sight);
×
173
    }
174

175
    /**
176
     * Delete a specified Sight.
177
     * <p>
178
     * It mirrors to the following Smartsheet REST API method: DELETE /sights/{sightId}
179
     *
180
     * @param sightId the Id of the Sight
181
     *
182
     * @throws IllegalArgumentException if any argument is null or empty string
183
     * @throws InvalidRequestException if there is any problem with the REST API request
184
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
185
     * @throws ResourceNotFoundException if the resource cannot be found
186
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
187
     * @throws SmartsheetException if there is any other error during the operation
188
     */
189
    public void deleteSight(long sightId) throws SmartsheetException {
190
        this.deleteResource(SIGHTS + "/" + sightId, Sight.class);
×
191
    }
×
192

193
    /**
194
     * Creates s copy of the specified Sight.
195
     * <p>
196
     * It mirrors to the following Smartsheet REST API method: POST /sights/{sightId}/copy
197
     *
198
     * @param sightId the Id of the Sight
199
     * @param destination the destination to copy to
200
     * @return the newly created Sight resource.
201
     * @throws IllegalArgumentException if any argument is null or empty string
202
     * @throws InvalidRequestException if there is any problem with the REST API request
203
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
204
     * @throws ResourceNotFoundException if the resource cannot be found
205
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
206
     * @throws SmartsheetException if there is any other error during the operation
207
     */
208
    public Sight copySight(long sightId, ContainerDestination destination) throws SmartsheetException {
209
        return this.createResource(SIGHTS + "/" + sightId + "/copy", Sight.class, destination);
×
210
    }
211

212
    /**
213
     * Creates s copy of the specified Sight.
214
     * <p>
215
     * It mirrors to the following Smartsheet REST API method: POST /sights/{sightId}/move
216
     *
217
     * @param sightId the Id of the Sight
218
     * @param destination the destination to copy to
219
     * @return the newly created Sight resource.
220
     * @throws IllegalArgumentException if any argument is null or empty string
221
     * @throws InvalidRequestException if there is any problem with the REST API request
222
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
223
     * @throws ResourceNotFoundException if the resource cannot be found
224
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
225
     * @throws SmartsheetException if there is any other error during the operation
226
     */
227
    public Sight moveSight(long sightId, ContainerDestination destination) throws SmartsheetException {
228
        return this.createResource(SIGHTS + "/" + sightId + "/move", Sight.class, destination);
×
229
    }
230

231
    /**
232
     * Get the publish status of a Sight.
233
     * <p>
234
     * It mirrors to the following Smartsheet REST API method: POST /sights/{sightId}/publish
235
     *
236
     * @param sightId the Id of the Sight
237
     * @return the Sight's publish status.
238
     * @throws IllegalArgumentException if any argument is null or empty string
239
     * @throws InvalidRequestException if there is any problem with the REST API request
240
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
241
     * @throws ResourceNotFoundException if the resource cannot be found
242
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
243
     * @throws SmartsheetException if there is any other error during the operation
244
     */
245
    public SightPublish getPublishStatus(long sightId) throws SmartsheetException {
246
        return this.getResource(SIGHTS + "/" + sightId + "/publish", SightPublish.class);
×
247
    }
248

249
    /**
250
     * Sets the publish status of a Sight and returns the new status, including the URLs of any enabled publishing.
251
     * <p>
252
     * It mirrors to the following Smartsheet REST API method: POST /sights/{sightId}/publish
253
     *
254
     * @param sightId the Id of the Sight
255
     * @param sightPublish the SightPublish object containing publish status
256
     * @return the Sight's publish status.
257
     * @throws IllegalArgumentException if any argument is null or empty string
258
     * @throws InvalidRequestException if there is any problem with the REST API request
259
     * @throws AuthorizationException if there is any problem with  the REST API authorization (access token)
260
     * @throws ResourceNotFoundException if the resource cannot be found
261
     * @throws ServiceUnavailableException if the REST API service is not available (possibly due to rate limiting)
262
     * @throws SmartsheetException if there is any other error during the operation
263
     */
264
    public SightPublish setPublishStatus(long sightId, SightPublish sightPublish) throws SmartsheetException {
265
        Util.throwIfNull(sightPublish);
×
266
        return this.updateResource(SIGHTS + "/" + sightId + "/publish", SightPublish.class, sightPublish);
×
267
    }
268

269
    /**
270
     * Return the ShareResources object that provides access to share resources associated with
271
     * Sight resources.
272
     *
273
     * @return the associated share resources
274
     */
275
    public ShareResources shareResources() {
276
        return this.shares;
×
277
    }
278

279
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc