001
002package com.commercetools.api.models.error;
003
004import java.time.*;
005import java.util.*;
006
007import com.fasterxml.jackson.annotation.JsonCreator;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.*;
010
011import io.vrap.rmf.base.client.ModelBase;
012import io.vrap.rmf.base.client.utils.Generated;
013
014import org.apache.commons.lang3.builder.EqualsBuilder;
015import org.apache.commons.lang3.builder.HashCodeBuilder;
016
017/**
018 *  <p>Returned when an Associate is missing a Permission on a B2B resource.</p>
019 */
020@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
021public class AssociateMissingPermissionErrorImpl implements AssociateMissingPermissionError, ModelBase {
022
023    private String code;
024
025    private String message;
026
027    private Map<String, java.lang.Object> values;
028
029    private com.commercetools.api.models.customer.CustomerResourceIdentifier associate;
030
031    private com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier businessUnit;
032
033    private com.commercetools.api.models.customer.CustomerResourceIdentifier associateOnBehalf;
034
035    private java.util.List<com.commercetools.api.models.associate_role.Permission> permissions;
036
037    /**
038     * create instance with all properties
039     */
040    @JsonCreator
041    AssociateMissingPermissionErrorImpl(@JsonProperty("message") final String message,
042            @JsonProperty("values") final Map<String, java.lang.Object> values,
043            @JsonProperty("associate") final com.commercetools.api.models.customer.CustomerResourceIdentifier associate,
044            @JsonProperty("businessUnit") final com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier businessUnit,
045            @JsonProperty("associateOnBehalf") final com.commercetools.api.models.customer.CustomerResourceIdentifier associateOnBehalf,
046            @JsonProperty("permissions") final java.util.List<com.commercetools.api.models.associate_role.Permission> permissions) {
047        this.message = message;
048        this.values = values;
049        this.associate = associate;
050        this.businessUnit = businessUnit;
051        this.associateOnBehalf = associateOnBehalf;
052        this.permissions = permissions;
053        this.code = ASSOCIATE_MISSING_PERMISSION;
054    }
055
056    /**
057     * create empty instance
058     */
059    public AssociateMissingPermissionErrorImpl() {
060        this.code = ASSOCIATE_MISSING_PERMISSION;
061    }
062
063    /**
064     *
065     */
066
067    public String getCode() {
068        return this.code;
069    }
070
071    /**
072     *  <ul>
073     *   <li>When an action is performed by an Associate: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li>
074     *   <li>When an action is performed for another Associate, like viewing their Cart: <code>"Associate '$idOfAssociate' has no rights to $action for customer '$idOfCustomer' in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredPermission'."</code></li>
075     *   <li>When viewing an entity: <code>"Associate '$idOfAssociate' has no rights to $action in business-unit '$idOrKeyOfBusinessUnit'. Needs '$requiredViewMyPermission' or '$requiredViewOthersPermission'."</code></li>
076     *  </ul>
077     */
078
079    public String getMessage() {
080        return this.message;
081    }
082
083    /**
084     *  <p>Error-specific additional fields.</p>
085     */
086
087    public Map<String, java.lang.Object> values() {
088        return values;
089    }
090
091    /**
092     *  <p>ResourceIdentifier to the Associate that tried to perform the action.</p>
093     */
094
095    public com.commercetools.api.models.customer.CustomerResourceIdentifier getAssociate() {
096        return this.associate;
097    }
098
099    /**
100     *  <p>ResourceIdentifier to the BusinessUnit.</p>
101     */
102
103    public com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier getBusinessUnit() {
104        return this.businessUnit;
105    }
106
107    /**
108     *  <p>ResourceIdentifier of the Associate on whose behalf the action is performed.</p>
109     */
110
111    public com.commercetools.api.models.customer.CustomerResourceIdentifier getAssociateOnBehalf() {
112        return this.associateOnBehalf;
113    }
114
115    /**
116     *  <p>The Permissions that the Associate performing the action lacks. At least one of these Permissions is needed.</p>
117     */
118
119    public java.util.List<com.commercetools.api.models.associate_role.Permission> getPermissions() {
120        return this.permissions;
121    }
122
123    public void setMessage(final String message) {
124        this.message = message;
125    }
126
127    public void setValue(String key, java.lang.Object value) {
128        if (values == null) {
129            values = new HashMap<>();
130        }
131        values.put(key, value);
132    }
133
134    public void setAssociate(final com.commercetools.api.models.customer.CustomerResourceIdentifier associate) {
135        this.associate = associate;
136    }
137
138    public void setBusinessUnit(
139            final com.commercetools.api.models.business_unit.BusinessUnitResourceIdentifier businessUnit) {
140        this.businessUnit = businessUnit;
141    }
142
143    public void setAssociateOnBehalf(
144            final com.commercetools.api.models.customer.CustomerResourceIdentifier associateOnBehalf) {
145        this.associateOnBehalf = associateOnBehalf;
146    }
147
148    public void setPermissions(final com.commercetools.api.models.associate_role.Permission... permissions) {
149        this.permissions = new ArrayList<>(Arrays.asList(permissions));
150    }
151
152    public void setPermissions(
153            final java.util.List<com.commercetools.api.models.associate_role.Permission> permissions) {
154        this.permissions = permissions;
155    }
156
157    @Override
158    public boolean equals(Object o) {
159        if (this == o)
160            return true;
161
162        if (o == null || getClass() != o.getClass())
163            return false;
164
165        AssociateMissingPermissionErrorImpl that = (AssociateMissingPermissionErrorImpl) o;
166
167        return new EqualsBuilder().append(code, that.code)
168                .append(message, that.message)
169                .append(values, that.values)
170                .append(associate, that.associate)
171                .append(businessUnit, that.businessUnit)
172                .append(associateOnBehalf, that.associateOnBehalf)
173                .append(permissions, that.permissions)
174                .append(code, that.code)
175                .append(message, that.message)
176                .append(values, that.values)
177                .append(associate, that.associate)
178                .append(businessUnit, that.businessUnit)
179                .append(associateOnBehalf, that.associateOnBehalf)
180                .append(permissions, that.permissions)
181                .isEquals();
182    }
183
184    @Override
185    public int hashCode() {
186        return new HashCodeBuilder(17, 37).append(code)
187                .append(message)
188                .append(values)
189                .append(associate)
190                .append(businessUnit)
191                .append(associateOnBehalf)
192                .append(permissions)
193                .toHashCode();
194    }
195
196}