=begin #Lists #CRUD operations to manage lists and list memberships The version of the OpenAPI document: v3 Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.2.1 =end require 'cgi' module Hubspot module Crm module Lists class MembershipsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add Records to a List # Add the records provided to the list. Records that do not exist or that are already members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param request_body [Array] The IDs of the records to add to the list. # @param [Hash] opts the optional parameters # @return [MembershipsUpdateResponse] def add(list_id, request_body, opts = {}) data, _status_code, _headers = add_with_http_info(list_id, request_body, opts) data end # Add Records to a List # Add the records provided to the list. Records that do not exist or that are already members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param request_body [Array] The IDs of the records to add to the list. # @param [Hash] opts the optional parameters # @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers def add_with_http_info(list_id, request_body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.add ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add" end # verify the required parameter 'request_body' is set if @api_client.config.client_side_validation && request_body.nil? fail ArgumentError, "Missing the required parameter 'request_body' when calling MembershipsApi.add" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships/add'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(request_body) # return_type return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.add", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#add\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Add All Records from a Source List to a Destination List # Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.). This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to. # @param source_list_id [Integer] The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*. # @param [Hash] opts the optional parameters # @return [nil] def add_all_from_list(list_id, source_list_id, opts = {}) add_all_from_list_with_http_info(list_id, source_list_id, opts) nil end # Add All Records from a Source List to a Destination List # Add all of the records from a *source list* (specified by the `sourceListId`) to a *destination list* (specified by the `listId`). Records that are already members of the *destination list* will be ignored. The *destination* and *source list* IDs must be different. The *destination* and *source lists* must contain records of the same type (e.g. contacts, companies, etc.). This endpoint only works for *destination lists* that have a `processingType` of `MANUAL` or `SNAPSHOT`. The *source list* can have any `processingType`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` *destination list*, which the *source list* records are added to. # @param source_list_id [Integer] The **ILS ID** of the *source list* to grab the records from, which are then added to the *destination list*. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def add_all_from_list_with_http_info(list_id, source_list_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.add_all_from_list ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add_all_from_list" end # verify the required parameter 'source_list_id' is set if @api_client.config.client_side_validation && source_list_id.nil? fail ArgumentError, "Missing the required parameter 'source_list_id' when calling MembershipsApi.add_all_from_list" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships/add-from/{sourceListId}'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)).sub('{' + 'sourceListId' + '}', CGI.escape(source_list_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.add_all_from_list", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#add_all_from_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Add and/or Remove Records from a List # Add and/or remove records that have already been created in the system to and/or from a list. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param membership_change_request [MembershipChangeRequest] The IDs of the records to add and/or remove from the list. # @param [Hash] opts the optional parameters # @return [MembershipsUpdateResponse] def add_remove(list_id, membership_change_request, opts = {}) data, _status_code, _headers = add_remove_with_http_info(list_id, membership_change_request, opts) data end # Add and/or Remove Records from a List # Add and/or remove records that have already been created in the system to and/or from a list. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param membership_change_request [MembershipChangeRequest] The IDs of the records to add and/or remove from the list. # @param [Hash] opts the optional parameters # @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers def add_remove_with_http_info(list_id, membership_change_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.add_remove ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.add_remove" end # verify the required parameter 'membership_change_request' is set if @api_client.config.client_side_validation && membership_change_request.nil? fail ArgumentError, "Missing the required parameter 'membership_change_request' when calling MembershipsApi.add_remove" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships/add-and-remove'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(membership_change_request) # return_type return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.add_remove", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#add_remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Fetch List Memberships Ordered by ID # Fetch the memberships of a list in order sorted by the `recordId` of the records in the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided. # @param list_id [Integer] The **ILS ID** of the list. # @param [Hash] opts the optional parameters # @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset. # @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order. # @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100) # @return [CollectionResponseLong] def get_page(list_id, opts = {}) data, _status_code, _headers = get_page_with_http_info(list_id, opts) data end # Fetch List Memberships Ordered by ID # Fetch the memberships of a list in order sorted by the `recordId` of the records in the list. The `recordId`s are sorted in *ascending* order if an `after` offset or no offset is provided. If only a `before` offset is provided, then the records are sorted in *descending* order. The `after` offset parameter will take precedence over the `before` offset in a case where both are provided. # @param list_id [Integer] The **ILS ID** of the list. # @param [Hash] opts the optional parameters # @option opts [String] :after The paging offset token for the page that comes `after` the previously requested records. If provided, then the records in the response will be the records following the offset, sorted in *ascending* order. Takes precedence over the `before` offset. # @option opts [String] :before The paging offset token for the page that comes `before` the previously requested records. If provided, then the records in the response will be the records preceding the offset, sorted in *descending* order. # @option opts [Integer] :limit The number of records to return in the response. The maximum `limit` is 250. (default to 100) # @return [Array<(CollectionResponseLong, Integer, Hash)>] CollectionResponseLong data, response status code and response headers def get_page_with_http_info(list_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.get_page ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.get_page" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil? query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CollectionResponseLong' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.get_page", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#get_page\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Remove Records from a List # Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param request_body [Array] The IDs of the records to remove from the list. # @param [Hash] opts the optional parameters # @return [MembershipsUpdateResponse] def remove(list_id, request_body, opts = {}) data, _status_code, _headers = remove_with_http_info(list_id, request_body, opts) data end # Remove Records from a List # Remove the records provided from the list. Records that do not exist or that are not members of the list are ignored. This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param request_body [Array] The IDs of the records to remove from the list. # @param [Hash] opts the optional parameters # @return [Array<(MembershipsUpdateResponse, Integer, Hash)>] MembershipsUpdateResponse data, response status code and response headers def remove_with_http_info(list_id, request_body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.remove ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.remove" end # verify the required parameter 'request_body' is set if @api_client.config.client_side_validation && request_body.nil? fail ArgumentError, "Missing the required parameter 'request_body' when calling MembershipsApi.remove" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships/remove'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(request_body) # return_type return_type = opts[:debug_return_type] || 'MembershipsUpdateResponse' # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.remove", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete All Records from a List # Remove **all** of the records from a list. ***Note:*** *The list is not deleted.* This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param [Hash] opts the optional parameters # @return [nil] def remove_all(list_id, opts = {}) remove_all_with_http_info(list_id, opts) nil end # Delete All Records from a List # Remove **all** of the records from a list. ***Note:*** *The list is not deleted.* This endpoint only works for lists that have a `processingType` of `MANUAL` or `SNAPSHOT`. # @param list_id [Integer] The **ILS ID** of the `MANUAL` or `SNAPSHOT` list. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def remove_all_with_http_info(list_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MembershipsApi.remove_all ...' end # verify the required parameter 'list_id' is set if @api_client.config.client_side_validation && list_id.nil? fail ArgumentError, "Missing the required parameter 'list_id' when calling MembershipsApi.remove_all" end # resource path local_var_path = '/crm/v3/lists/{listId}/memberships'.sub('{' + 'listId' + '}', CGI.escape(list_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['oauth2'] new_options = opts.merge( :operation => :"MembershipsApi.remove_all", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MembershipsApi#remove_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end end end