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

com.mastercard.api.mcon.User Maven / Gradle / Ivy

Go to download

Java Core SDK for use with SDKs available on MasterCard Developer Zone (https://developer.mastercard.com)

There is a newer version: 1.0.3
Show newest version
/*
 * Copyright 2016 MasterCard International.
 *
 * Redistribution and use in source and binary forms, with or without modification, are 
 * permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of 
 * conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * Neither the name of the MasterCard International Incorporated nor the names of its 
 * contributors may be used to endorse or promote products derived from this software 
 * without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
 * SUCH DAMAGE.
 *
 */

package com.mastercard.api.mcon;

import com.mastercard.api.core.exception.*;
import com.mastercard.api.core.model.*;
import com.mastercard.api.core.security.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class User extends BaseObject  {

    private static Map operationConfigs;

    static {
        operationConfigs = new HashMap();
        operationConfigs.put("93587463-9cd6-4103-a47c-e9755b566cf3", new OperationConfig("/bundle/profile/v1/users", Action.create, Arrays.asList(""), Arrays.asList("x-client-correlation-id")));
        operationConfigs.put("a474c3c6-3b4a-4bde-91ec-0afcf8a75779", new OperationConfig("/bundle/profile/v1/users/{userId}", Action.delete, Arrays.asList(""), Arrays.asList("x-client-correlation-id")));
        operationConfigs.put("51cf464e-3415-42c4-b2fe-786b0e5df398", new OperationConfig("/bundle/profile/v1/users/{userId}/patch", Action.create, Arrays.asList(""), Arrays.asList("x-client-correlation-id")));
        operationConfigs.put("3236783a-1023-4509-b082-89460a37b360", new OperationConfig("/bundle/profile/v1/users/{userId}", Action.read, Arrays.asList(""), Arrays.asList("x-client-correlation-id")));
        operationConfigs.put("bc2c5a8f-b43b-4103-a492-bb359901cb2f", new OperationConfig("/bundle/profile/v1/users/{userId}", Action.update, Arrays.asList(""), Arrays.asList("x-client-correlation-id")));
    }

    public User() {
    }

    public User(BaseObject o) {
        putAll(o);
    }

    public User(RequestMap requestMap) {
        putAll(requestMap);
    }

    @Override protected final OperationConfig getOperationConfig(String operationUUID) throws IllegalArgumentException{
        OperationConfig operationConfig = operationConfigs.get(operationUUID);

        if(operationConfig == null) {
            throw new IllegalArgumentException("Invalid operationUUID supplied: " + operationUUID);
        }

        return operationConfig;
    }

    @Override protected OperationMetadata getOperationMetadata() throws IllegalArgumentException {
        return new OperationMetadata(ResourceConfig.getInstance().getVersion(), ResourceConfig.getInstance().getHost(), ResourceConfig.getInstance().getContext(), ResourceConfig.getInstance().getJsonNative(), ResourceConfig.getInstance().getContentTypeOverride());
    }

  /**
   * Creates a User object
   *
   * @param map a map of parameters to create a User object
   *
   * @return a User object.
   *
   * @throws ApiException - which encapsulates the http status code and the error return by the server
   */
  public static User createUser(RequestMap map)
    throws ApiException {

    return createUser(null, map);
  }

  /**
   * Creates a User object
   *
   * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
   * @param map a map of parameters to create a User object
   *
   * @return a User object.
   *
   * @throws ApiException - which encapsulates the http status code and the error return by the server
   */
  public static User createUser(Authentication auth, RequestMap map)
    throws ApiException {

    return new User(BaseObject.executeOperation(auth, "93587463-9cd6-4103-a47c-e9755b566cf3", new User(map)));
  }









    /**
     * Deletes a User object.
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public User deleteUser()
        throws ApiException {

        BaseObject object = BaseObject.executeOperation(null, "a474c3c6-3b4a-4bde-91ec-0afcf8a75779", this);
        this.clear();
        this.putAll(object);
        return this;
    }

    /**
     * Deletes a User object.
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public User deleteUser(Authentication auth)
        throws ApiException {

        BaseObject object = BaseObject.executeOperation(auth, "a474c3c6-3b4a-4bde-91ec-0afcf8a75779", this);
        this.clear();
        this.putAll(object);
        return this;
    }

    /**
     * Deletes a User object.
     *
     * @param id the id of the object to delete
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User deleteUser(String id)
        throws ApiException {

        return deleteUser(null, id);
    }

    /**
     * Deletes a User object
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     * @param id  the id of the object to delete
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User deleteUser(Authentication auth, String id)
        throws ApiException {

        User object = new User(new RequestMap("id", id));
        return object.deleteUser(auth);
    }

    /**
     * Deletes a User object
     *
     * @param id the id of the object to delete
     * @param map a map of additional parameters
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User deleteUser(String id, RequestMap map)
        throws ApiException {

        return deleteUser(null, id, map);
    }

    /**
     * Deletes a User object
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     * @param id  the id of the object to delete
     * @param map a map of additional parameters
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User deleteUser(Authentication auth, String id, RequestMap map)
        throws ApiException {

        User object = new User(new RequestMap("id", id));
        if (map != null)  object.putAll(map);
        return object.deleteUser(auth);
    }



  /**
   * Creates a User object
   *
   * @param map a map of parameters to create a User object
   *
   * @return a User object.
   *
   * @throws ApiException - which encapsulates the http status code and the error return by the server
   */
  public static User patchUser(RequestMap map)
    throws ApiException {

    return patchUser(null, map);
  }

  /**
   * Creates a User object
   *
   * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
   * @param map a map of parameters to create a User object
   *
   * @return a User object.
   *
   * @throws ApiException - which encapsulates the http status code and the error return by the server
   */
  public static User patchUser(Authentication auth, RequestMap map)
    throws ApiException {

    return new User(BaseObject.executeOperation(auth, "51cf464e-3415-42c4-b2fe-786b0e5df398", new User(map)));
  }










    /**
     * Retrieve a User object
     *
     * @param id the id of the User object to retrieve
     *
     * @return a User object
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User readUser(String id)
        throws ApiException {

        return readUser(null, id, null);
    }

    /**
     * Retrieve a User object
     *
     * @param id the id of the User object to retrieve
     * @param map a map of additional parameters
     *
     * @return a User object
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User readUser(String id, RequestMap map)
        throws ApiException {

        return readUser(null, id, map);
    }

    /**
     * Retrieve a User object
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     * @param id the id of the User object to retrieve
     *
     * @return a User object
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User readUser(Authentication auth, String id)
        throws ApiException {

        return readUser(auth, id, null);
    }

    /**
     * Retrieve a User object
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     * @param id the id of the User object to retrieve
     * @param map a map of additional parameters
     *
     * @return a User object
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public static User readUser(Authentication auth, String id, RequestMap map)
        throws ApiException {

        User val = new User();
        if (id != null) val.put("id", id);
        if (map != null)  val.putAll(map);
        return new User(BaseObject.executeOperation(auth, "3236783a-1023-4509-b082-89460a37b360", val));
    }


    /**
     * Update a User object.
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public User updateUser()
        throws ApiException {

        BaseObject object = BaseObject.executeOperation(null, "bc2c5a8f-b43b-4103-a492-bb359901cb2f", this);
        this.putAll(object);
        return this;
    }

    /**
     * Update a User object.
     *
     * @param auth Authentication object overriding ApiConfig.setAuthentication(authentication)
     *
     * @return a User object.
     *
     * @throws ApiException - which encapsulates the http status code and the error return by the server
     */
    public User updateUser(Authentication auth)
        throws ApiException {

        BaseObject object = BaseObject.executeOperation(auth, "bc2c5a8f-b43b-4103-a492-bb359901cb2f", this);
        this.putAll(object);
        return this;
    }




}






© 2015 - 2025 Weber Informatics LLC | Privacy Policy