=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'uri' module SubskribeDevClient class NotificationsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add a notification target # Adds a notification target and events according to the specified parameters # @param body json representing the notification details # @param [Hash] opts the optional parameters # @return [NotificationTargetAndSubscriptions] def add_target_and_events_subscriptions(body, opts = {}) data, _status_code, _headers = add_target_and_events_subscriptions_with_http_info(body, opts) data end # Add a notification target # Adds a notification target and events according to the specified parameters # @param body json representing the notification details # @param [Hash] opts the optional parameters # @return [Array<(NotificationTargetAndSubscriptions, Fixnum, Hash)>] NotificationTargetAndSubscriptions data, response status code and response headers def add_target_and_events_subscriptions_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: NotificationsApi.add_target_and_events_subscriptions ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling NotificationsApi.add_target_and_events_subscriptions" end # resource path local_var_path = '/notifications' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'NotificationTargetAndSubscriptions') if @api_client.config.debugging @api_client.config.logger.debug "API called: NotificationsApi#add_target_and_events_subscriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all notifications # Returns all notification subscriptions for your tenant # @param [Hash] opts the optional parameters # @return [Array] def get_all_notification_subscriptions_for_tenant(opts = {}) data, _status_code, _headers = get_all_notification_subscriptions_for_tenant_with_http_info(opts) data end # Get all notifications # Returns all notification subscriptions for your tenant # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_all_notification_subscriptions_for_tenant_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: NotificationsApi.get_all_notification_subscriptions_for_tenant ...' end # resource path local_var_path = '/notifications' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: NotificationsApi#get_all_notification_subscriptions_for_tenant\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Attach an event to a notification # Attaches a notification event to the target specified by the notification id # @param notification_id id of the notification target # @param notification_event_type type of event # @param [Hash] opts the optional parameters # @return [nil] def subscribe_existing_notification_target_to_event(notification_id, notification_event_type, opts = {}) subscribe_existing_notification_target_to_event_with_http_info(notification_id, notification_event_type, opts) nil end # Attach an event to a notification # Attaches a notification event to the target specified by the notification id # @param notification_id id of the notification target # @param notification_event_type type of event # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def subscribe_existing_notification_target_to_event_with_http_info(notification_id, notification_event_type, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: NotificationsApi.subscribe_existing_notification_target_to_event ...' end # verify the required parameter 'notification_id' is set if @api_client.config.client_side_validation && notification_id.nil? fail ArgumentError, "Missing the required parameter 'notification_id' when calling NotificationsApi.subscribe_existing_notification_target_to_event" end # verify the required parameter 'notification_event_type' is set if @api_client.config.client_side_validation && notification_event_type.nil? fail ArgumentError, "Missing the required parameter 'notification_event_type' when calling NotificationsApi.subscribe_existing_notification_target_to_event" end # verify enum value if @api_client.config.client_side_validation && !['INVOICE_POSTED', 'SUBSCRIPTION_CREATED', 'ORDER_SUBMITTED', 'ORDER_EXECUTED'].include?(notification_event_type) fail ArgumentError, "invalid value for 'notification_event_type', must be one of INVOICE_POSTED, SUBSCRIPTION_CREATED, ORDER_SUBMITTED, ORDER_EXECUTED" end # resource path local_var_path = '/notifications/{notificationId}'.sub('{' + 'notificationId' + '}', notification_id.to_s) # query parameters query_params = {} query_params[:'notificationEventType'] = notification_event_type # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: NotificationsApi#subscribe_existing_notification_target_to_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Unsubscribe from an event # Unsubscribes the specified notification target from the specified event # @param notification_id id of the notification target # @param notification_event_type type of event # @param [Hash] opts the optional parameters # @return [nil] def unsubscribe_target_or_event(notification_id, notification_event_type, opts = {}) unsubscribe_target_or_event_with_http_info(notification_id, notification_event_type, opts) nil end # Unsubscribe from an event # Unsubscribes the specified notification target from the specified event # @param notification_id id of the notification target # @param notification_event_type type of event # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def unsubscribe_target_or_event_with_http_info(notification_id, notification_event_type, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: NotificationsApi.unsubscribe_target_or_event ...' end # verify the required parameter 'notification_id' is set if @api_client.config.client_side_validation && notification_id.nil? fail ArgumentError, "Missing the required parameter 'notification_id' when calling NotificationsApi.unsubscribe_target_or_event" end # verify the required parameter 'notification_event_type' is set if @api_client.config.client_side_validation && notification_event_type.nil? fail ArgumentError, "Missing the required parameter 'notification_event_type' when calling NotificationsApi.unsubscribe_target_or_event" end # verify enum value if @api_client.config.client_side_validation && !['INVOICE_POSTED', 'SUBSCRIPTION_CREATED', 'ORDER_SUBMITTED', 'ORDER_EXECUTED'].include?(notification_event_type) fail ArgumentError, "invalid value for 'notification_event_type', must be one of INVOICE_POSTED, SUBSCRIPTION_CREATED, ORDER_SUBMITTED, ORDER_EXECUTED" end # resource path local_var_path = '/notifications/unsubscribe/{notificationId}'.sub('{' + 'notificationId' + '}', notification_id.to_s) # query parameters query_params = {} query_params[:'notificationEventType'] = notification_event_type # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: NotificationsApi#unsubscribe_target_or_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end