|
| 1 | +/* |
| 2 | + * Copyright 2025-present Coinbase Global, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.coinbase.prime.model.orders; |
| 18 | + |
| 19 | +import com.coinbase.core.errors.CoinbaseClientException; |
| 20 | +import com.coinbase.prime.common.PrimeListRequest; |
| 21 | +import com.coinbase.prime.model.common.Pagination; |
| 22 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 23 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 24 | + |
| 25 | +import static com.coinbase.core.utils.Utils.isNullOrEmpty; |
| 26 | + |
| 27 | +public class ListPortfolioFillsRequest extends PrimeListRequest { |
| 28 | + @JsonProperty("portfolio_id") |
| 29 | + @JsonIgnore |
| 30 | + private String portfolioId; |
| 31 | + |
| 32 | + @JsonProperty("start_date") |
| 33 | + @JsonIgnore |
| 34 | + private String startDate; |
| 35 | + |
| 36 | + @JsonProperty("end_date") |
| 37 | + @JsonIgnore |
| 38 | + private String endDate; |
| 39 | + |
| 40 | + public ListPortfolioFillsRequest() { |
| 41 | + } |
| 42 | + |
| 43 | + public ListPortfolioFillsRequest(Builder builder) { |
| 44 | + super(builder.cursor, builder.sortDirection, builder.limit); |
| 45 | + this.portfolioId = builder.portfolioId; |
| 46 | + this.startDate = builder.startDate; |
| 47 | + this.endDate = builder.endDate; |
| 48 | + } |
| 49 | + |
| 50 | + public String getPortfolioId() { |
| 51 | + return portfolioId; |
| 52 | + } |
| 53 | + |
| 54 | + public void setPortfolioId(String portfolioId) { |
| 55 | + this.portfolioId = portfolioId; |
| 56 | + } |
| 57 | + |
| 58 | + public String getStartDate() { |
| 59 | + return startDate; |
| 60 | + } |
| 61 | + |
| 62 | + public void setStartDate(String startDate) { |
| 63 | + this.startDate = startDate; |
| 64 | + } |
| 65 | + |
| 66 | + public String getEndDate() { |
| 67 | + return endDate; |
| 68 | + } |
| 69 | + |
| 70 | + public void setEndDate(String endDate) { |
| 71 | + this.endDate = endDate; |
| 72 | + } |
| 73 | + |
| 74 | + public static class Builder { |
| 75 | + private String portfolioId; |
| 76 | + private String startDate; |
| 77 | + private String endDate; |
| 78 | + private String cursor; |
| 79 | + private String sortDirection; |
| 80 | + private Integer limit; |
| 81 | + |
| 82 | + public Builder() { |
| 83 | + } |
| 84 | + |
| 85 | + public Builder portfolioId(String portfolioId) { |
| 86 | + this.portfolioId = portfolioId; |
| 87 | + return this; |
| 88 | + } |
| 89 | + |
| 90 | + public Builder startDate(String startDate) { |
| 91 | + this.startDate = startDate; |
| 92 | + return this; |
| 93 | + } |
| 94 | + |
| 95 | + public Builder endDate(String endDate) { |
| 96 | + this.endDate = endDate; |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + public Builder pagination(Pagination pagination) { |
| 101 | + this.cursor = pagination.getNextCursor(); |
| 102 | + this.sortDirection = pagination.getSortDirection(); |
| 103 | + return this; |
| 104 | + } |
| 105 | + |
| 106 | + public Builder limit(Integer limit) { |
| 107 | + this.limit = limit; |
| 108 | + return this; |
| 109 | + } |
| 110 | + |
| 111 | + public ListPortfolioFillsRequest build() throws CoinbaseClientException { |
| 112 | + this.validate(); |
| 113 | + return new ListPortfolioFillsRequest(this); |
| 114 | + } |
| 115 | + |
| 116 | + public void validate() { |
| 117 | + if (isNullOrEmpty(this.portfolioId)) { |
| 118 | + throw new CoinbaseClientException("PortfolioId is required"); |
| 119 | + } |
| 120 | + if (isNullOrEmpty(this.startDate)) { |
| 121 | + throw new CoinbaseClientException("StartDate is required"); |
| 122 | + } |
| 123 | + |
| 124 | + } |
| 125 | + } |
| 126 | +} |
0 commit comments