001/*
002 * Copyright (c) 2011-2017 Nexmo Inc
003 *
004 * Permission is hereby granted, free of charge, to any person obtaining a copy
005 * of this software and associated documentation files (the "Software"), to deal
006 * in the Software without restriction, including without limitation the rights
007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008 * copies of the Software, and to permit persons to whom the Software is
009 * furnished to do so, subject to the following conditions:
010 *
011 * The above copyright notice and this permission notice shall be included in
012 * all copies or substantial portions of the Software.
013 *
014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
020 * THE SOFTWARE.
021 */
022package com.nexmo.client.numbers;
023
024import com.fasterxml.jackson.annotation.JsonProperty;
025import org.apache.http.client.methods.RequestBuilder;
026
027public class ListNumbersFilter {
028    private Integer index;
029    private Integer size;
030    private String pattern;
031    private SearchPattern searchPattern;
032
033    public ListNumbersFilter() {
034        this(null, null, null, null);
035    }
036
037    public ListNumbersFilter(
038            @JsonProperty Integer index,
039            @JsonProperty Integer size,
040            @JsonProperty String pattern,
041            @JsonProperty SearchPattern searchPattern) {
042        this.index = index;
043        this.size = size;
044        this.pattern = pattern;
045        this.searchPattern = searchPattern;
046    }
047
048    public Integer getIndex() {
049        return index;
050    }
051
052    public void setIndex(Integer index) {
053        this.index = index;
054    }
055
056    public Integer getSize() {
057        return size;
058    }
059
060    public void setSize(Integer size) {
061        this.size = size;
062    }
063
064    public String getPattern() {
065        return pattern;
066    }
067
068    public void setPattern(String pattern) {
069        this.pattern = pattern;
070    }
071
072    public SearchPattern getSearchPattern() {
073        return searchPattern;
074    }
075
076    public void setSearchPattern(SearchPattern searchPattern) {
077        this.searchPattern = searchPattern;
078    }
079
080    public void addParams(RequestBuilder request) {
081        if (index != null) {
082            request.addParameter("index", index.toString());
083        }
084        if (size != null) {
085            request.addParameter("size", size.toString());
086        }
087        if (pattern != null) {
088            request.addParameter("pattern", pattern);
089        }
090        if (searchPattern != null) {
091            request.addParameter("search_pattern", Integer.toString(searchPattern.getValue()));
092        }
093    }
094
095}