All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.jfermat.strava.api.SegmentEffortsApi Maven / Gradle / Ivy

package io.github.jfermat.strava.api;

import io.github.jfermat.strava.invoker.ApiClient;

import io.github.jfermat.strava.model.DetailedSegmentEffort;
import io.github.jfermat.strava.model.Fault;
import org.threeten.bp.OffsetDateTime;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

@Component("io.github.jfermat.strava.api.SegmentEffortsApi")
public class SegmentEffortsApi {
    private ApiClient apiClient;

    public SegmentEffortsApi() {
        this(new ApiClient());
    }

    @Autowired
    public SegmentEffortsApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * List Segment Efforts
     * Returns a set of the authenticated athlete's segment efforts for a given segment.  Requires subscription.
     * 

200 - List of segment efforts. *

0 - Unexpected error. * @param segmentId The identifier of the segment. * @param startDateLocal ISO 8601 formatted date time. * @param endDateLocal ISO 8601 formatted date time. * @param perPage Number of items per page. Defaults to 30. * @return List<DetailedSegmentEffort> * @throws RestClientException if an error occurs while attempting to invoke the API */ public List getEffortsBySegmentId(Integer segmentId, OffsetDateTime startDateLocal, OffsetDateTime endDateLocal, Integer perPage) throws RestClientException { Object postBody = null; // verify the required parameter 'segmentId' is set if (segmentId == null) { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'segmentId' when calling getEffortsBySegmentId"); } String path = UriComponentsBuilder.fromPath("/segment_efforts").build().toUriString(); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "segment_id", segmentId)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "start_date_local", startDateLocal)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "end_date_local", endDateLocal)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "per_page", perPage)); final String[] accepts = { "application/json" }; final List accept = apiClient.selectHeaderAccept(accepts); final String[] contentTypes = { }; final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); String[] authNames = new String[] { "strava_oauth" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Get Segment Effort * Returns a segment effort from an activity that is owned by the authenticated athlete. Requires subscription. *

200 - Representation of a segment effort. *

0 - Unexpected error. * @param id The identifier of the segment effort. * @return DetailedSegmentEffort * @throws RestClientException if an error occurs while attempting to invoke the API */ public DetailedSegmentEffort getSegmentEffortById(Long id) throws RestClientException { Object postBody = null; // verify the required parameter 'id' is set if (id == null) { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'id' when calling getSegmentEffortById"); } // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("id", id); String path = UriComponentsBuilder.fromPath("/segment_efforts/{id}").buildAndExpand(uriVariables).toUriString(); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); final String[] accepts = { "application/json" }; final List accept = apiClient.selectHeaderAccept(accepts); final String[] contentTypes = { }; final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); String[] authNames = new String[] { "strava_oauth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy