001/*
002 *   Copyright 2020 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.numbers;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import org.apache.http.client.methods.RequestBuilder;
020
021public class ListNumbersFilter {
022    private Integer index;
023    private Integer size;
024    private String pattern;
025    private SearchPattern searchPattern;
026
027    public ListNumbersFilter() {
028        this(null, null, null, null);
029    }
030
031    public ListNumbersFilter(
032            @JsonProperty Integer index,
033            @JsonProperty Integer size,
034            @JsonProperty String pattern,
035            @JsonProperty SearchPattern searchPattern) {
036        this.index = index;
037        this.size = size;
038        this.pattern = pattern;
039        this.searchPattern = searchPattern;
040    }
041
042    public Integer getIndex() {
043        return index;
044    }
045
046    public void setIndex(Integer index) {
047        this.index = index;
048    }
049
050    public Integer getSize() {
051        return size;
052    }
053
054    public void setSize(Integer size) {
055        this.size = size;
056    }
057
058    public String getPattern() {
059        return pattern;
060    }
061
062    public void setPattern(String pattern) {
063        this.pattern = pattern;
064    }
065
066    public SearchPattern getSearchPattern() {
067        return searchPattern;
068    }
069
070    public void setSearchPattern(SearchPattern searchPattern) {
071        this.searchPattern = searchPattern;
072    }
073
074    public void addParams(RequestBuilder request) {
075        if (index != null) {
076            request.addParameter("index", index.toString());
077        }
078        if (size != null) {
079            request.addParameter("size", size.toString());
080        }
081        if (pattern != null) {
082            request.addParameter("pattern", pattern);
083        }
084        if (searchPattern != null) {
085            request.addParameter("search_pattern", Integer.toString(searchPattern.getValue()));
086        }
087    }
088
089}