Class: Payabli::Notification::Client
- Inherits:
-
Object
- Object
- Payabli::Notification::Client
- Defined in:
- lib/payabli/notification/client.rb
Instance Method Summary collapse
-
#add_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Create a new notification or autogenerated report.
-
#delete_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Deletes a single notification or autogenerated report.
-
#get_notification(request_options: {}, **params) ⇒ Payabli::Types::NotificationQueryRecord
Retrieves a single notification or autogenerated report's details.
-
#get_report_file(request_options: {}, **params) ⇒ Hash[String, Object]
Gets a copy of a generated report by ID.
- #initialize(client:) ⇒ void constructor
-
#update_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Update a notification or autogenerated report.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/notification/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Create a new notification or autogenerated report.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/payabli/notification/client.rb', line 37 def add_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Notification", headers: headers, body: Payabli::Types::AddNotificationRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Deletes a single notification or autogenerated report.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/payabli/notification/client.rb', line 170 def delete_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_notification(request_options: {}, **params) ⇒ Payabli::Types::NotificationQueryRecord
Retrieves a single notification or autogenerated report's details.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/payabli/notification/client.rb', line 77 def get_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::NotificationQueryRecord.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_report_file(request_options: {}, **params) ⇒ Hash[String, Object]
Gets a copy of a generated report by ID.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/payabli/notification/client.rb', line 209 def get_report_file(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Export/notificationReport/#{URI.encode_uri_component(params[:id].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::File.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_notification(request_options: {}, **params) ⇒ Payabli::Types::PayabliApiResponseNotifications
Update a notification or autogenerated report.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/payabli/notification/client.rb', line 127 def update_notification(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[n_id] body_params = params.except(*path_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Notification/#{URI.encode_uri_component(params[:n_id].to_s)}", headers: headers, body: Payabli::Types::UpdateNotificationRequest.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::PayabliApiResponseNotifications.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |